Category: English

Date:

When you have lots of always changing python files in a directory or  these modules are imported by other modules, you encounter seeing lots of pyc and py~ files together with those files. This is irritating, at least for me. For that reason, I wish if I could remove these residue files with a right click in that directory. I came up with a solution:

I wrote a bash script at the location /usr/bin/cleanpydir

 #!/bin/sh
 
rm $1/*.pyc $1/*.py~

Then I gave executable rights for it and installed kservicemenueditor for Pardus 2011 (KDE):

sudo chmod +x /usr/bin/cleanpydir
sudo pisi bi http://svn.pardus.org.tr/pardus/playground/maidis/2011/desktop/kde/addon/kservicemenueditor/pspec.xml
sudo pisi it kservicemenueditor*

I run the KServiceMenuEditor program and inserted a new event called Cleanpy and addressed the executable as "cleanpydir %u". For the conditions part, I chose inode/directory and saved my preferences.

Now, I right click on a directory and from the Actions menu, I click on "Cleanpy" which results it cleaning all the pyc and py~ files for that particular directory. There should be lots of different alternatives for this but this is -good or not- a solution. It couldve been better if I did this by right clicking on an empty space.  But theres no service menu provided on the empty space of a directory. So I have to settle for this.


Share: FacebookGoogle+Email


comments powered by Disqus