Trees | Index | Help |
|
---|
Package logilab :: Package common :: Module fileutils |
|
Some file / file path manipulation utilities.
Version:
$Revision: 1.2 $
Author:
Logilab
Contact:
http://www.logilab.fr/ -- mailto:python-projects@logilab.org
Copyright:
2003-2005 LOGILAB S.A. (Paris, FRANCE)
Classes | |
---|---|
ProtectedFile |
a special file-object class that automatically that automatically does a 'chmod +w' when needed |
Exceptions | |
---|---|
UnresolvableError |
exception raised by relative path when it's unable to compute relative path between two paths |
Function Summary | |
---|---|
check that the given file has the given mode(s) set, else try to set it | |
deprecated, use files_by_ext instead | |
path manipulation | |
str |
return the first level directory of a path |
str |
try to get a relative path from from from_file to to_file
(path will be absolute if to_file is an absolute file). |
bool |
return true if filename may be a binary file, according to it's extension |
list |
return a list of files in a directory matching (or not) some extensions: you should either give the include_exts argument (and
only files ending with one of the listed extensions will be
considered) or the exclude_exts argument (and only files not
ending by one of the listed extensions will be considered). |
list |
return a list of files in a directory matching some extensions |
list |
return a list of files in a directory not matching some extensions |
deprecated, use files_by_ext instead | |
file manipulation | |
str |
return the content of the file with normalized line feeds |
file or StringIO |
return a stream for a file with content with normalized line feeds |
list |
return a list of non empty lines in the file located at path |
list |
return a list of non empty lines in the given stream |
str |
return the write mode that should used to open file |
check that the given file has the given mode(s) set, else try to set it | |
make a mirror of from_dir in to_dir , omitting directories and
files listed in the black list or ending with one of the given
extensions |
Variable Summary | |
---|---|
str |
__revision__ = '$Id: fileutils.py,v 1.25 2005/02/25 10:0...
|
tuple |
BASE_BLACKLIST : list files or directories ignored by default by the export function |
tuple |
IGNORED_EXTENSIONS : list file extensions ignored by default by the export function |
bool |
_HAS_UNIV_OPEN = True
|
Function Details |
---|
first_level_directory(path)return the first level directory of a path >>> first_level_directory('home/syt/work') 'home' >>> first_level_directory('/home/syt/work') '/' >>> first_level_directory('work') 'work' >>>
|
relative_path(from_file, to_file)try to get a relative path from from If both files are relative, they're expected to be relative to the same directory. >>> relative_path( from_file='toto/index.html', to_file='index.html') '../index.html' >>> relative_path( from_file='index.html', to_file='toto/index.html') 'toto/index.html' >>> relative_path( from_file='tutu/index.html', to_file='toto/index.html') '../toto/index.html' >>> relative_path( from_file='toto/index.html', to_file='/index.html') '/index.html' >>> relative_path( from_file='/toto/index.html', to_file='/index.html') '../index.html' >>> relative_path( from_file='/toto/index.html', to_file='/toto/summary.html') 'summary.html' >>> relative_path( from_file='index.html', to_file='index.html') '' >>> relative_path( from_file='/index.html', to_file='toto/index.html') Traceback (most recent call last): File "<string>", line 1, in ? File "<stdin>", line 37, in relative_path UnresolvableError >>> relative_path( from_file='/index.html', to_file='/index.html') '' >>> |
is_binary(filename)return true if filename may be a binary file, according to it's extension
|
files_by_ext(directory, include_exts=None, exclude_exts=None, exclude_dirs=('CVS', '.svn'))return a list of files in a directory matching (or not) some
extensions: you should either give the
|
include_files_by_ext(directory, include_exts, exclude_dirs=('CVS', '.svn'))return a list of files in a directory matching some extensions
|
exclude_files_by_ext(directory, exclude_exts, exclude_dirs=('CVS', '.svn'))return a list of files in a directory not matching some extensions
|
get_by_ext(*args, **kwargs)deprecated, use |
norm_read(path)return the content of the file with normalized line feeds
|
norm_open(path)return a stream for a file with content with normalized line feeds
|
lines(path, comments=None)return a list of non empty lines in the file located at
|
stream_lines(stream, comments=None)return a list of non empty lines in the given
|
write_open_mode(filename)return the write mode that should used to open file
|
ensure_fs_mode(filepath, desired_mode)check that the given file has the given mode(s) set, else try to set it
|
export(from_dir, to_dir, blacklist=('CVS', '.svn', 'debian', 'dist', 'build', '__buildlog'), ignore_ext=('.pyc', '.pyo', '.elc', '~'), verbose=0)make a mirror of
|
ensure_mode(filepath, desired_mode)check that the given file has the given mode(s) set, else try to set it
|
get_mode(*args, **kwargs)deprecated, use |
Variable Details |
---|
__revision__
|
BASE_BLACKLISTlist files or directories ignored by default by the
|
IGNORED_EXTENSIONSlist file extensions ignored by default by the
|
_HAS_UNIV_OPEN
|
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Thu Apr 14 11:37:32 2005 | http://epydoc.sf.net |