Re: small code smell
Tim Hemel <[email protected]>
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Aug 31, 2003 at 09:46:32PM +0200, Tim Hemel wrote: > > I'll give it a shot and report back the result. I think most of the os > dependent code can be refactored out into nice functions. I see a lot of > long routines in Util.py which work on filenames, I'll have a look at those > as well. It seems that a lot of the operations in Util.py would fit nicely > into an OperatingSystem class by themselves. Here's one that can perhaps be made a lot simpler, by borrowing someone else's code: shorten_name in Util.py A similar function is described in the Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/208993 periperi(116):~/programs> python relpath.py from /a/b/c/d to /a/b/c1/d1 -> ../../c1/d1 from /foo/bdir/foo.o to /foo/test -> ../../test from /foo/test to /foo/bdir/foo.o -> ../bdir/foo.o The functions do not work with . and .. in the filenames, but that can be solved by always normalizing the pathnames. Tim -- Zen Microsystems: we're the om in .commmmmmmmm... ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf