path.local API [rev. unknown]

class LocalPath(FSPathBase, PosixMixin):

Local path implementation offering access/modification methods similar to os.path.

class attributes and properties:

basename: <property object (dynamically calculated value)>
ext: <property object (dynamically calculated value)>
purebasename: <property object (dynamically calculated value)>
sep: /

methods:

def atime(self):

return last access time of the path.

def chdir(self):

change directory to self and return old current directory

def check(self, **kw):

check a path for existence, or query its properties without arguments, this returns True if the path exists (on the filesystem), False if not with (keyword only) arguments, the object compares the value of the argument with the value of a property with the same name (if it has one, else it raises a TypeError) when for example the keyword argument 'ext' is '.py', this will return True if self.ext == '.py', False otherwise

def chmod(self, mode, rec=0):

change permissions to the given mode. If mode is an integer it directly encodes the os-specific modes. if rec is True perform recursively. (xxx if mode is a string then it specifies access rights in '/bin/chmod' style, e.g. a+r).

def chown(self, user, group, rec=0):

change ownership to the given user and group. user and group may be specified by a number or by a name. if rec is True change ownership recursively.

def common(self, other):

return the common part shared with the other path or None if there is no common part.

def computehash(self, hashtype='md5', chunksize=524288):

return hexdigest of hashvalue for this file.

def copy(self, target, archive=False):

copy path to target.

def dirpath(self, *args, **kwargs):

return the directory Path of the current Path joined with any given path arguments.

def dump(self, obj, bin=1):

pickle object into path location

def ensure(self, *args, **kwargs):

ensure that an args-joined path exists (by default as a file). if you specify a keyword argument 'dir=True' then the path is forced to be a directory path.

def get_temproot(cls):

return the system's temporary directory (where tempfiles are usually created in)

def group(self):

return group name of file.

def join(self, *args, **kwargs):

return a new path by appending all 'args' as path components. if abs=1 is used restart from root if any of the args is an absolute path.

def listdir(self, fil=None, sort=None):

list directory contents, possibly filter by the given fil func and possibly sorted.

def load(self):

return object unpickled from self.read()

def lstat(self):

Return an os.lstat() tuple.

def make_numbered_dir(cls, prefix='session-', rootdir=None, keep=3, lock_timeout=172800):

return unique directory with a number greater than the current maximum one. The number is assumed to start directly after prefix. if keep is true directories with a number less than (maxnum-keep) will be removed.

def mkdir(self, *args):

create & return the directory joined with args.

def mkdtemp(cls):

return a Path object pointing to a fresh new temporary directory (which we created ourself).

def mklinkto(self, oldname):

posix style hard link to another name.

def mksymlinkto(self, value, absolute=1):

create a symbolic link with the given value (pointing to another name).

def mode(self):

return permission mode of the path object

def move(self, target):

move this path to target.

def mtime(self):

def new(self, **kw):

create a modified version of this path. the following keyword arguments modify various path parts: a:/some/path/to/a/file.ext || drive |-------------| dirname |------| basename |--| purebasename |--| ext

def open(self, mode='r'):

return an opened file with the given mode.

def owner(self):

return owner name of file.

def parts(self, reverse=False):

return a root-first list of all ancestor directories plus the path itself.

def pyimport(self, modname=None, ensuresyspath=True):

return path as an imported python module. if modname is None, look for the containing package and construct an according module name. The module will be put/looked up in sys.modules.

def pypkgpath(self, pkgname=None):

return the path's package path by looking for the given pkgname. If pkgname is None then look for the last directory upwards which still contains an __init__.py. Return None if a pkgpath can not be determined.

def read(self, mode='rb'):

read and return a bytestring from reading the path.

def readlines(self, cr=1):

read and return a list of lines from the path. if cr is False, the newline will be removed from the end of each line.

def readlink(self):

def realpath(self):

return a new path which contains no symbolic links.

def relto(self, relpath):

return a string which is the relative part of the path to the given 'relpath'.

def remove(self, rec=1):

def rename(self, target):

rename this path to target.

def setmtime(self, mtime=None):

set modification time for the given path. if 'mtime' is None (the default) then the file's mtime is set to current time. Note that the resolution for 'mtime' is platform dependent.

def size(self):

return size of the underlying file object

def stat(self):

Return an os.stat() tuple.

def sysexec(self, *argv):

return stdout-put from executing a system child process, where the self path points to the binary (XXX or script) to be executed. Note that this process is directly invoked and not through a system shell.

def sysfind(cls, name, checker=None):

return a path object found by looking at the systems underlying PATH specification. If the checker is not None it will be invoked to filter matching paths. If a binary cannot be found, None is returned Note: This is probably not working on plain win32 systems but may work on cygwin.

def visit(self, fil=None, rec=None, ignore=<class py.__.path.common._dummyclass at 0x2adda0c0>):

yields all paths below the current one fil is a filter (glob pattern or callable), if not matching the path will not be yielded, defaulting to None (everything is returned) rec is a filter (glob pattern or callable) that controls whether a node is descended, defaulting to None ignore is an Exception class that is ignoredwhen calling dirlist() on any of the paths (by default, all exceptions are reported)

def write(self, content, mode='wb'):

write string content into path.

def __add__(self, other):

return new path object with 'other' added to the basename

def __cmp__(self, other):

return sort value (-1, 0, +1).

def __contains__(self, other):

*no docstring available*

def __div__(self, other):

def __eq__(self, other):

*no docstring available*

def __hash__(self):

*no docstring available*

def __iter__(self):

*no docstring available*

def __repr__(self):

*no docstring available*

def __str__(self):

return string representation of the Path.