2007年11月28日水曜日

writing in python

I'm trying to prototype a file archiver with python. Initially I started with bash and made a script that works for my limited type of tasks; taking a list of files, source directory, and destination directory and then copying to a temporary directory.
I simply call tar command to finish archiving.

Then I realized I wanted to add several features like being able to read a recipe for a particular archive from a file, to use substitutions and matching of key words in recipes, to handle remote files, ... Now it's getting hard for me to make the script simple, so I decided to rewrite it in python to make it easier for me and practiceusing python.

So far I needed to find basename, dirname, file testing, getting options, key inputs, ...

Key inputs are easy:
val = raw_input("type a value for val")

http://docs.python.org/lib/module-shutil.html

For getting options in commands, there are two choices afaik, and I gave it a try to optparse:
http://docs.python.org/lib/module-optparse.html

I liked the notations, so I am going to stick with it.

There are other features of python I need to learn, but that's all for today...

0 件のコメント: