[Python-ideas] Adding `pathlib.Path` method that would send file to recycle bin

Andrew Barnert abarnert at yahoo.com
Thu Jan 1 23:59:59 CET 2015


On Jan 1, 2015, at 17:00, Markus Unterwaditzer <markus at unterwaditzer.net> wrote:

> On Thu, Jan 01, 2015 at 04:37:52PM +0100, Andrew Barnert wrote:
>> On Jan 1, 2015, at 11:37, Ram Rachum <ram at rachum.com> wrote:
>> 
>>> Hi everyone,
>>> 
>>> I'm a complete ignoramus when it comes to Mac, so I can't say anything
>>> about that, but as I understand the discussion, there are problems with
>>> implementing this on Mac. Okay. So maybe this should be available only on
>>> Windows and Linux? (If it's not a problem to do on Linux.)
>> 
>> On Linux, it's not exactly like Mac, but it's similar. Linux has no notion of
>> trash at all; desktop environments like GNOME do. And if you want it to work
>> exactly like the way GNOME does, you call the API via GObject; otherwise you
>> have to implement a complicated approximation based on rename that won't be
>> fully functional.
> 
> Actually it seems that the trash location is standardized by the XDG Desktop
> Specification:
> 
> https://github.com/kevva/xdg-trash
> http://www.ramendik.ru/docs/trashspec.html

Yes, as I just said: Linux has no notion of trash; desktop environments do. The FreeDesktop standard is not Linux; it's a standard that at least two desktop environments (which also work on multiple non-Linux systems) support.

On most Linux systems, you will have Gtk libraries; on most Linux systems without Gtk libraries, you will not have a FreeDesktop-compliant trash. So, using GObject is a good 90% solution (like using NSFileManager is a good 90% solution on Mac).

Of course you _could_ implement that full spec yourself in Python, right? Well, read it. There are references to things "the implementation" may do, like providing a way for the administrator to disable sticky-bit checking for filesystems that don't support it. Do you know how to check whether the administrator has disabled sticky-bit checking on a filesystem? Or do you just want your code to say a file can't be trashed, or trash by moving it across the network to ~, even when the desktop and other apps have no problem trashing it properly? For that matter, do you know how every FreeDesktop-compatible system wants to report a problem to the administrator? You may meet the XDG Trash spec and still not satisfy user expectations. And it'll be a lot of work. 

In other words, "you have to implement a complicated approximation based on rename that won't be fully functional". Is that really a better solution than using GObject? If you're writing your own portability library like Qt or JUCE, probably; otherwise, I doubt it.



More information about the Python-ideas mailing list