[py-dev] background/future plans
holger krekel
hpk at trillke.net
Fri Oct 1 21:01:40 CEST 2004
[Ian Bicking Fri, Oct 01, 2004 at 01:09:51PM -0500]
> holger krekel wrote:
> > .path.local the local filesystem class providing an
> > object oriented OO API for filesystem accesses
> >
> > .path.svnurl the remote subversion URL class providing
> > listdir(), update(), remove(), ...
> > methods for accesses to the transactional
> > subversion filesystem
> >
> > .path.svnwc a local working copy API offering most of what
> > path.local offers plus commit(), revert(), add()
> > etc.pp.
>
> Do you have thoughts on the path module
> (http://www.jorendorff.com/articles/python/path/). I've used it before
> some (mostly I forget to use it), and it's pretty complete. My only
> criticism might be that there's a few too many methods to keep track of.
> Anyway, it's close but not identical to path.local, and it's been used
> and had feedback from a fair number of people.
while path.local is only used by a few projects it is well tested and
shares many methods with the other path.svnurl and path.svnwc
implementations. I don't think there are e.g. subversion or other
implementations of the ohrendorff-interface.
Also, i think it's a questionable idea to subclass Path objects
from string or unicode which introduces lots of names, some of which
are superflous or even confusing in a filesystem context.
The visit/listdir methods of py.path.* objects are rather advanced, e.g.
for x in pathobj.visit(fil=py.path.checker(file=1, link=0, fnmatch='*.py'),
rec=py.path.checker(dotfile=0)):
# x will iterate over all .py files which are not
# links and will not recurse into "." directories
and this, of course, works on all path implementations. And, of course,
you can pass full-blown functions as filter and recursion parameters.
py.path.checker is just there to cover some common ground.
Another feature, especially nice with py.path.local objects,
is that exceptions are transformed so you'll write e.g.:
try:
localpathobj.somemethod()
except py.path.NotFound:
...
except py.path.Denied:
...
except py.path.IsDirectory:
...
to handle certain problems while accessing filesystems.
Note that this is _not_ generic yet, i.e. it doesn't work
the same way with subversion paths.
Other than that, some things are similar, e.g. recently py.path.* objects
grew basename, ext and purebasename read-only properties.
In general, i believe that interacting with remote or local Filesystem
Objects is something which a higher-level library should support very
well and consistently. The Ohrendorff seems to only go part of the way.
cheers,
holger
More information about the Pytest-dev
mailing list