Hi!<br><br>I am a MSc of Computer Engineering student from Sweden. A frequent reader of python-3000, and an occasional reader of python-dev for about a year now. I have wanted to get involved in the development of python for a while but haven't found the time before. Now, when I'm in the process of trying to figure out what project to do for my thesis, I have actually found myself having more time than before. Therefore I thought that now is a better time than never to get involved. After that compulsory first-post-introduction of myself, lets get to the reason I choose to send the post at all.
<br><br>I noticed that you wanted Mac OS tests, here are the test results from my Mac OS X (10.4), running on an Intel Core Duo MacBook, using python 2.5:<br><br>FF...F....................................................<br>
======================================================================<br>FAIL: test_absolute (__main__.TestCalculatingPaths)<br>----------------------------------------------------------------------<br>Traceback (most recent call last):
<br> File "./test.py", line 235, in test_absolute<br> eq(p1, p2)<br>AssertionError: FSPath('/private/tmp/tmpH9fppC/images') != FSPath('/tmp/tmpH9fppC/images')<br><br>======================================================================
<br>FAIL: test_chdir_absolute_relative (__main__.TestCalculatingPaths)<br>----------------------------------------------------------------------<br>Traceback (most recent call last):<br> File "./test.py", line 220, in test_chdir_absolute_relative
<br> eq(FSPath.cwd(), self.d)<br>AssertionError: FSPath('/private/tmp/tmpRJzqbt') != FSPath('/tmp/tmpRJzqbt')<br><br>======================================================================<br>FAIL: test_relative (__main__.TestCalculatingPaths)
<br>----------------------------------------------------------------------<br>Traceback (most recent call last):<br> File "./test.py", line 240, in test_relative<br> eq(p, "images")<br>AssertionError: FSPath('../../../tmp/tmpdw9juF/images') != 'images'
<br><br>----------------------------------------------------------------------<br>Ran 58 tests in 1.587s<br><br><br>Please let me know if there are any further tests or improvements I could help you with.<br><br>/Tobias<br>
<br><div><span class="gmail_quote">On 1/28/07, <b class="gmail_sendername">Mike Orr</b> <<a href="mailto:sluggoster@gmail.com">sluggoster@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I finally finished my path package (Unipath) and put it in the Cheeseshop.<br><a href="http://sluggo.scrapping.cc/python/unipath/">http://sluggo.scrapping.cc/python/unipath/</a><br><br>There's a Path class for pathname calculations, and a FSPath subclass
<br>for filesystem calls. I'm hoping Path -- or something resembling it<br>-- will find its way into os.path in Python 2.6 or 3.0. FSPath is<br>full of convenience methods so it may not be everybody's cup of tea,
<br>but perhaps something similar can go into Python in the farther future<br><br>Unipath is an early alpha release so the API may change as it gets<br>more real-world use. There's an extensive unittest suite, which<br>
passes on Python 2.5 and 2.4.4 on Linux. Windows and Macintosh<br>testers are needed.<br><br>Following are highlights from the python-3000 discussion and deviations from it:<br><br>- Path subclasses unicode, or str if the platform can't handle
<br>Unicode pathnames.<br><br>- FSPath subclasses Path. This allows you to do "from unipath import<br>FSPath as Path" and pretend there's only one class. I find this much<br>more convenient in applications, so you don't have to cast objects
<br>back and forth between the classes. Also, it just became infeasable<br>not to let them inherit, because so many methods call other methods.<br><br>- Nevertheless, you can use Path alone and rest assured it will never
<br>touch the filesystem. You can even use Path objects with os.*<br>functions if you are so heretically inclined. If Path is accepted<br>into the stdlib, FSPath will inherit it from there.<br><br>- I tried splitting FSPath into several mixins according to type of
<br>operation, but the need for methods to call other methods in a<br>different category sabotaged that too. So FSPath proudly has about<br>fifty methods. (Path has 10 public methods and 4 properties.)<br><br>- The dirname property is called .parent. The basename property is
<br>.name. The extension property is .ext. The name without extension is<br>.stem.<br><br>- .components() returns a list of directory components. The first<br>component is "/", a Windows drive root, a UNC share, or "" for a
<br>relative path. .split_root() returns the root and the rest.<br><br>- PosixPath, NTPath, and MacPath are Path subclasses using a specific<br>path library. This allows you to express non-native paths and convert<br>paths. Passing a relative foreign path to a *Path constructor
<br>converts it to the destination type. Passing an absolute foreign path<br>is an error, because there's no sane way to interpret "C:\\" on Posix<br>or "/" on Windows. I'm skeptical whether this non-native support is
<br>really worth it, because .norm() and .norm_case() already convert<br>slashes to backslashes (which is what Talin really wanted to do --<br>have Posix paths in a config file and automatically convert them to<br>the native format). And if Python is going to drop Mac OS 9 soon then
<br>MacPath is obsolete. So maybe this non-native path code will prove<br>less than useful and will be deleted. On the other hand, if someone<br>is burning to write a zippath or ftppath library, you can use it with<br>this.
<br><br>- Setting Path.auto_norm to true will automatically normalize all<br>paths on construction. I'm not sure if this should be the default,<br>because normalizing may produce the wrong path (e.g., if it contains a
<br>symlink). You can always pass norm=True or norm=False to the<br>constructor to enable/disable it.<br><br>- p.child("subdir", "grandkid") is Glyph's favorite "safe join" method<br>that prevents creating a path pointing above 'p'. You can use it as a
<br>.joinpath if you don't mind this restriction. The constructor allows<br>multiple positional arguments, which are joined using os.path.join().<br><br>- Listing is p.listdir(pattern=None, filter=None, names_only=False).
<br>This returns a non-recursive list of paths. If 'names_only' is true<br>it returns the same as os.listdir(). p.walk(pattern=None,<br>filter=None, top_down=True) is the recursive counterpart, yielding<br>paths. In both cases 'pattern' is a glob pattern, and 'filter' is one
<br>of the constants (FILES, DIRS, LINKS, FILES_NO_LINKS, DIRS_NO_LINKS,<br>DEAD_LINKS) or a custom boolean function. I spent a lot of time going<br>back and forth between Orendorff's six listing methods and Raphael's
<br>one, and finally decided on this, partly because I'm not satisfied<br>with how either Orendorff's class or Raphael's or os.walk() handle<br>symlinks -- sometimes you want to ignore the links and then iterate
<br>them separately.<br><br>- .read_file(mode) and .write_file(content, mode) are a compromise<br>between Orendorff's seven methods and purists' desire for zero<br>methods.<br><br>- .mkdir(), .rmdir(), .rmtree(), .copy(), .copy_stat(), .copy_tree(),
<br>and .move() are more fancy than their stdlib/Orendorff counterparts.<br>They silently succeed if the operation is already done, and have<br>arguments to smartly create/delete intermediate directories, etc.<br><br>- Two extra functions are in '
unipath.tools'. 'dict2dir' creates a<br>directory hierarchy modeled after a dict. 'dump_path' displays an<br>ASCII tree of a directory hierarchy, with file sizes and symlink<br>targets showing.<br><br>
Enjoy! and please provide feedback.<br><br>--Mike Orr <<a href="mailto:sluggoster@gmail.com">sluggoster@gmail.com</a>><br>_______________________________________________<br>Python-Dev mailing list<br><a href="mailto:Python-Dev@python.org">
Python-Dev@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/python-dev">http://mail.python.org/mailman/listinfo/python-dev</a><br>Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/thobes%40gmail.com">
http://mail.python.org/mailman/options/python-dev/thobes%40gmail.com</a><br></blockquote></div><br>