Back to index

python3.2  3.2.2
Functions | Variables
Extras Namespace Reference

Functions

def isclean
def copycleandir
def main

Variables

int verbose = 1
int debug = 0

Detailed Description

Recursively copy a directory but skip undesired files and
directories (CVS, backup files, pyc files, etc)

Function Documentation

def Extras.copycleandir (   src,
  dst 
)

Definition at line 23 of file Extras.install.py.

00023 
00024 def copycleandir(src, dst):
00025     for cursrc, dirs, files in os.walk(src):
00026         assert cursrc.startswith(src)
00027         curdst = dst + cursrc[len(src):]
00028         if verbose:
00029             print("mkdir", curdst)
00030         if not debug:
00031             if not os.path.exists(curdst):
00032                 os.makedirs(curdst)
00033         for fn in files:
00034             if isclean(fn):
00035                 if verbose:
00036                     print("copy", os.path.join(cursrc, fn), os.path.join(curdst, fn))
00037                 if not debug:
00038                     shutil.copy2(os.path.join(cursrc, fn), os.path.join(curdst, fn))
00039             else:
00040                 if verbose:
00041                     print("skipfile", os.path.join(cursrc, fn))
00042         for i in range(len(dirs)-1, -1, -1):
00043             if not isclean(dirs[i]):
00044                 if verbose:
00045                     print("skipdir", os.path.join(cursrc, dirs[i]))
00046                 del dirs[i]

Here is the call graph for this function:

Here is the caller graph for this function:

def Extras.isclean (   name)

Definition at line 11 of file Extras.install.py.

00011 
00012 def isclean(name):
00013     if name == 'CVS': return 0
00014     if name == '.cvsignore': return 0
00015     if name == '.DS_store': return 0
00016     if name == '.svn': return 0
00017     if name.endswith('~'): return 0
00018     if name.endswith('.BAK'): return 0
00019     if name.endswith('.pyc'): return 0
00020     if name.endswith('.pyo'): return 0
00021     if name.endswith('.orig'): return 0
00022     return 1

Here is the caller graph for this function:

def Extras.main ( void  )

Definition at line 47 of file Extras.install.py.

00047 
00048 def main():
00049     if len(sys.argv) != 3:
00050         sys.stderr.write("Usage: %s srcdir dstdir\n" % sys.argv[0])
00051         sys.exit(1)
00052     copycleandir(sys.argv[1], sys.argv[2])

Here is the call graph for this function:


Variable Documentation

Definition at line 9 of file Extras.install.py.

Definition at line 8 of file Extras.install.py.