SourceForge.net Logo Home of http://sourceforge.net/projects/pyfmf
Contact: danperl@users.sourceforge.net
Downloads: http://sourceforge.net/project/showfiles.php?group_id=116235

pyfmf: a file management framework in python
Page Changed: 1/19/2005


http://www.python.org

Zago

Zago is the graphical platform that incorporates the framework and the zigo toolkit.  It has the same power as the toolkit but it is much easier to use (especially to create new configurations of handler stacks).  Requirements: you must have python (http://www.python.org) and wxPython installed (http://www.wxpython.orgZago is implemented with wxPython 2.5.2.8 and has not been tested with other versions).

Download It

You can download a public release containing the source from: http://sourceforge.net/project/showfiles.php?group_id=116235. Please also note that zigo is included in zago, the graphical platform based on the pyfmf framework.  If you download zago, you do not need to download also a release of zigo (the difference between the two releases is that zago also contains a directory gui).

If you enjoy living dangerously and you want the latest (even if it's un-stable and un-documented) source, you can use CVS to download the files.  Fortunately, that's easy.  First, log in:
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/pyfmf login
When prompted for a password for anonymous, simply press the Enter key.  Then check out the files:
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/pyfmf co zago

There, you have the source files now.  And good thing with Python, that's all you need (assuming that you already have Python installed, otherwise, see http://www.python.org).

You can just browse the code from http://cvs.sourceforge.net/viewcvs.py/pyfmf/danperl/zigzag.  See "Basic Introduction to CVS and SourceForge.net (SF.net) Project CVS Services" for more general info on using CVS with SourceForge.net.

Mini Tutorial

Let's work on an example that can be used to clean up '*.pyc' and '*.pyo' files.  Start zago by invoking zago.py (under zigzag/gui).  This will start the graphical tool in a 'Configuration' view (see screenshot below).  From the 'File' menu, select the 'Open' item.  A dialog will give you the choice between several configuration files under the zigzag/config directory (remember, configuration files are expected to be part of a config package).  Choose the cleanupPythonFiles.py file.  You have now opened a 'project'.

This configuration uses several handlers in the stack to filter files and directories, one viewer handler (viewFilesPlain) and one processor handler that performs the file removal (procRemoveFiles).  Click on a handler in the stack list and its configuration will show up on the right side of the tool.  Change the directories to be filtered out by modifying the configurations of the appropriate filter handlers.  Change the directory trees to be processed by modifying the list in the bottom left corner of the tool.  Then enable the viewing handler by checking the 'enabled' checkbox in its configuration.  Make sure that the file removing handler is disabled for now.

Now select the 'Run' item in the 'Run' menu.  Notice that soon enough the status bar on its right side indicates that the project is running.  While it is running, there are some commands that are ignored.  You cannot execute 'Run' again, you cannot create a new project and you cannot open another configuration for a project.  Depending on how many and how big are the trees that you are processing this run may take some time.  You can 'Pause', 'Resume' and 'Stop' the run from the 'Run' menu.  It's up to you to play with those commands.

You can see the results by selecting the 'Results' view from the 'Views' menu (see screenshot below).  Only the viewFilesPlain handler is "viewable".  If you click on any of the other handlers in the stack there will be no results shown.  But if you click on the viewFilesPlain handler, you will see a list of all the files that are passed into the procRemoveFiles handler to be removed.  Lines keep getting added to this view as the project is running.

Once the project has finished running, you can look at the list of files that are passed into the procRemoveFiles handler and you can decide to refine the filtering by changing the configurations of the filters in the stack.  You can repeat this process until you are satisfied with the list of files to be removed.  Once you are satisfied with the list, you are ready to remove them.  Switch back to the 'Configuration' view, enable the procRemoveFiles handler and run the project again.  The files will be removed.

You may get more sophisticated by writing a new handler that compares the modification times of the '*.pyc' and '*.pyo' files to the modification time of the corresponding '*.py' files and remove only the files that are older that their '*.py' files.  Of course, I do not recommend that you regularly remove all the compiled files, unless you are not concerned about the performance of loading the modules.

Once you have created a project that you want to use again in the future, you can save its configuration with the 'Save As' item in the 'File' menu.  For simplicity sake, I chose not to have a 'Save' item in the first release of zago.  'Save As' can be used also for the same purpose as 'Save', you only have to explicitly specify the file.

This briefly shows the usage of zago.  However, zago is especially useful if you write your own handlers besides the handlers that are already implemented.  For that, look at the design of the framework and the zigo toolkit.

Mini User Guide

Projects
A project represents a handler stack and a controller with a specific configuration.  A configuration is actually what identifies a project.  A project can be started by opening an existing configuration or by creating a new configuration.  Saving a project implies only saving its configuration.

Views
There are two views for a project: Configuration and Results.  See screenshots below.

The Configuration view is the default view when zago starts, containing an empty configuration.  Editing and viewing the configuration are done in the Configuration view.  The Configuration view contains:
  •  a widget for configuring the stack
  • a widget for configuring the list of trees to be traversed and processed
  • a widget for configuring the work directory
  • a widget for configuring individual handlers
Selecting a handler in the stack widget brings up its configuration in the handler widget.

Once the project starts running. results can be viewed in the Results view.  The Results view contains a widget for the stack of handlers and a pane for results.  Selecting a handler in the stack brings up its results in the results pane.  Only "viewer" handlers (that subclass from the ViewerMixin mixin class) can show results.  See the list of handlers to find which handlers are viewers.
Running a project
A project can be started to run from the Run menu.  With the same menu, once a project is running, it can be paused and then resumed, and it can be stopped.  Once a project is running, there are some operations that canot be performed.  You cannot execute 'Run' again, you cannot create a new project and you cannot open another configuration for a project.  The status bar indicates the status of the run, whether it is running, paused, or stopped.
Screenshots
A screenshot of a Configuration view:

Configuration view

A screenshot of a Results view:

Results view