aligncsv.py needs updating

Content and general development discussion, including maps, quests, and server code from the development team.
Post Reply
User avatar
o11c
Knight
Knight
Posts: 2262
Joined: Sun Feb 20, 2011 10:09 pm
Location: ^ ^

aligncsv.py needs updating

Post by o11c » Tue Aug 23, 2011 7:13 pm

  • The most severe problem is that this treats commas in {scripts} as if they were top-level commas.
  • The consensus has changed from tabs to spaces, both for the output of the script as well as the indentation of the script itself. Actually, even if the consensus had not changed, tabs should NEVER be used for alignment, only for indentation.
  • The destination file should not be required to exist.
  • Check whether the required arguments exist before doing anything else.
  • There should be a check for whether open(fname, "mode") succeeded, rather than just if the file exists.
  • Avoid the repeated calls to .strip()
  • General review by somebody who actually knows python. More comments would be helpful for those of us who don't (what's with all the [-1]).
When this is said and done, it can be made a policy to run this before committing CSVs. (TODO look at precommit hooks - IIRC it must be made a filter from stdin to stdout then).

Is it worth saving this or should it be rewritten from scratch?
Former programmer for the TMWA server.
User avatar
argul
Novice
Novice
Posts: 237
Joined: Sun Aug 08, 2010 7:43 pm

Re: aligncsv.py needs updating

Post by argul » Tue Aug 23, 2011 9:37 pm

o11c wrote:
  • General review by somebody who actually knows python. More comments would be helpful for those of us who don't (what's with all the [-1]).
When this is said and done, it can be made a policy to run this before committing CSVs. (TODO look at precommit hooks - IIRC it must be made a filter from stdin to stdout then).

Is it worth saving this or should it be rewritten from scratch?
Originally I wrote that script.
And yes it's a so-called 'hack', so I don't mind if anyone rewrites that script in any language you like to.
hooks as you said :-D nice ones:)

Iirc, the script supports both indentation with tabs and spaces, not sure if they are on my local disc or already in the git repos.

In python you can address arrays from either left to right (so index is 0,1,2,3) or from right to left (negative numbers, so -1,-2,-3 are indices seen from right)
---
User avatar
o11c
Knight
Knight
Posts: 2262
Joined: Sun Feb 20, 2011 10:09 pm
Location: ^ ^

Re: aligncsv.py needs updating

Post by o11c » Fri Sep 16, 2011 10:59 pm

Done, in C++, in commit ed81f91ac3c470e00df0d5c5cf9c274ce30f47b3
Former programmer for the TMWA server.
Post Reply