Linux
Cleaning pyc and py~ files in a directory
18th Şub 2011 | Sınıfı: Linux 1

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 could’ve been better if I did this by right clicking on an empty space.  But there’s no service menu provided on the empty space of a directory. So I have to settle for this.

Etiketler: , , ,
One Comment
  1. alp
    9.11 on Mayıs 18th, 2011

    kuzen biraz okudumda ilginç ve güzel geldi ee tabi sen yazarsında çirkin olabilirmi öyle bi şansı yok

Leave a Reply

IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

What is 6 + 3 ?
Please leave these two fields as-is: