DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Manipulate Files And Directory Easily With Path.py (on Pys60)

02.14.2006
| 4295 views |
  • submit to reddit
        I really like Jason Orendorff's <a href=http://www.jorendorff.com/articles/python/path>path.py</a>.
So, I modify it a bit to use with pys60.
- don't load fnmatch, glob, codecs
- remove some functionalities and some docstrings
- match wildcard with regexp simplisticly
#return fnmatch.fnmatch(self.name, pattern)

# poor man's fnmatch
pattern = pattern.replace('.', '\\.').replace('*','.*').replace('?','.')
return re.match(pattern, self.name)
But most of it works nicely. Please report bugs in comments.
Download it here <a href=http://larndham.net/service/pys60/path.py>path.py</a>.