Package Ganga :: Package Utility :: Module files
[hide private]
[frames] | no frames]

Module files

source code

Helper functions for operations on files.

Functions [hide private]
 
expandfilename(filename)
expand a path or filename in a standard way so that it may contain ~ and ${VAR} strings
source code
 
fullpath(path)
expandfilename() and additionally: strip leading and trailing whitespaces and expand symbolic links
source code
 
previous_dir(path, cnt)
returns the previous cnt-th directory
source code
 
chmod_executable(path)
make a file executable by the current user (u+x)
source code
 
is_executable(path)
check if the file is executable by the current user (u+x)
source code
 
real_basename(x)
a 'better' basename (removes the trailing / like on Unix)
source code
 
multi_glob(pats, exclude=None)
glob using a list of patterns and removing duplicate files, exclude name in the list for which the callback exclude(name) return true example: advanced_glob(['*.jpg','*.gif'],exclude=lambda n:len(n)>20) return a list of all JPG and GIF files which have names shorter then 20 characters
source code
 
recursive_copy(src, dest)
copy src file (or a directory tree if src specifies a directory) to dest directory.
source code
 
remove_prefix(fn, path_list)
Remove the common prefix of fn and the first matching element in the path_list.
source code
Variables [hide private]
  __package__ = 'Ganga.Utility'
Function Details [hide private]

recursive_copy(src, dest)

source code 

copy src file (or a directory tree if src specifies a directory) to dest directory. dest must be a directory and must exist. if src is a relative path, then the src directory structure is preserved in dest.

remove_prefix(fn, path_list)

source code 

Remove the common prefix of fn and the first matching element in the path_list.

Example: for fn='/a/b/c' and path=['d','/a','/a/b'] return 'b/c'

If no matching path is found, then fn is returned unchanged.

This function converts each element of the path_list using realpath.abspath.