Re: OperatingSystem.py

Bram Moolenaar <[email protected]>
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
Tim Hemel wrote:

> > > Prepare for more...
> > 
> > We at least need the diffs for the places that use the new class!
> 
> Ok, I only wrote this as a suggestion, not an actual implementation. Now 
> that I know how to test the program (the code is well covered with unit tests
> I hope?) I can actually implement it. What I did was make a function and in
> the comments list the lines where it was used.

I'm afraid we do not have enough tests.  There are a few high-level
tests that should catch the most common mistakes, but hardly any tests
for specific situations.  I would really appreciate it when you add
tests for the code that you change, so that you can verify it still
works as before (or better!).  The writing of tests itself often helps
locating things that are wrong.

> > > # for dir_contents, use os.listdir instead of glob
> > 
> > Is there a specific reason to use os.listdir() instead of glob()?
> 
> os.listdir is more portable, and you do not have to do a glob('.*')
> if os.name == 'posix'. That makes the code less iffy.

Ah, the issue with "hidden files".

> > >     def getFullFname(self,name):
> > 
> > Please use a space after a comma, that makes it much easier to read.
> 
> Ok. Is there a page with a-a-p coding conventions?

No, you can see in the code what style I use.  The only real rule is
that it should be easy to read and understand the code!

> > >     def systemAsync(self,cmd):
> > >         if not os.fork():
> > >             n = os.system(cmd)
> > >             os._exit(n)
> > 
> > This is quite inefficient, forking the whole Python interpreter and not
> > doing an "exec" right away...  Can't be solved easely, trying to avoid
> > using it is probably the best solution.
> 
> I just copied it from the original...

Yeah, as I said before, putting these things together points out parts
of the code that need to be improved.

-- 
       When danger reared its ugly head,
       He bravely turned his tail and fled
       Yes, Brave Sir Robin turned about
       And gallantly he chickened out
       Bravely taking to his feet
       He beat a very brave retreat
       Bravest of the brave Sir Robin
       Petrified of being dead
       Soiled his pants then brave Sir Robin
       Turned away and fled.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.