Vincent Lam’s Weblog

On Open Source

Our 0.2

 I think I have a pretty good idea on what we want to build/code for this project: 
our 0.1 is to makes a change to file(s) “color to colour”
our 0.2 is a directory walk that “walk” all directory and file in a folder.
our 0.3 will be to support multiple translations, instead of just “color to colour” and if we have time we will fix the “key changing problem” 

It seems like the research and practice on python has pay off decently.  Yesterday, Armen and Rueen went to my house to work on our 0.2.  Armen arrived at 10:11am and Rueen arrived at 10:42am.  We want to have it done eary because we know that we are going to be extremely busy deeper into the semister.  Reading week is our chance to get “something” done again. 

And yes, at the end of the day, we done it again.  We have “something”. our 0.1 make changes to all file in the current directory. now, our 0.2 make changes to not only the current directory but all the child and sub directory files. At first, i wanted to do it recursively just as what I did before in another course.  We had a few options:

1. reuse the code from Axel, because the code seems to have a directory walk function called zipwalk.  that would take us a few hours to understand and modify/reuse
2. use my recursive testing code in python that has not been tested. that would take a few hours to fix and modify..
3. do a search a find a simple & working directory walk code online.

Since directory walk is such a common task, I just know that they already exist somewhere.  So? why waste our time to recode the exact same thing.  Moreover, Dave encourages us to reuse existing code? Didn’t he?  ^^” It took me less than a minute to find one.  And yes, it works perfectly.  It did walk every file and folder.  But we want it to do more than just that.  We want the code to use our translation function and apply change to all DTD and Propertise file.  We made a few adjustment.  We completely rewrite some of our code, did a lot of copy and paste. 

Fixing the indentation is not fun.  Python rely on indentation so much that if the indentation is wrong the program wouldn’t work at all.  No a problem.  I just has to do a lot of copy and paste of the indentation.  Moving things around.  I know the code will work… just that the identation is a little messy. 

Now comes to think of it? There should probably be “an Automatic Indentation Fixing Tool/Function for Python” out there we could use.  If they don’t? Here come another open source project which will be greatly welcomed by all python developer 🙂

Advertisements

October 24, 2007 - Posted by | open source

2 Comments »

  1. Vince, the indentation problem can be fixed by running a regular expression substitution.
    For instance, if we open the same file with VIm editor we can type this:
    %s/\t\ /
    That is subsitute every tab for 3 blanks spaces.
    Be aware that the command might be totally correct (I’m not sure about the slashes)

    Comment by armenzg | October 25, 2007 | Reply

  2. About “key changing problem”
    I think that the problem can be solved like this for DTD files:

    re.sub(r'(“.*)([Cc])olor’, r’\1\2olour’, instring)

    This changes just the value of an entity not the key.
    It worked for me, since we just want to change the string in between ” and “. This statement actually means to make a change after the first ” that you encounter

    Tell Rueen to see if this is what he meant

    Comment by armenzg | October 25, 2007 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: