Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.script.migration.migutil Namespace Reference

Functions

def fatalError
def error
def backup
def listdir
def makedir
def copy_dir
def copy_file
def move_file
def copy

Variables

 opj = os.path.join
 join = os.path.join

Function Documentation

def MoinMoin.script.migration.migutil.backup (   src,
  dst 
)
Create a backup of src directory in dst, create empty src

@param src: source
@param dst: destination

Definition at line 26 of file migutil.py.

00026 
00027 def backup(src, dst):
00028     """ Create a backup of src directory in dst, create empty src
00029 
00030     @param src: source
00031     @param dst: destination
00032     """
00033     print "Create backup of '%s' in '%s'" % (src, dst)
00034 
00035     if not os.path.isdir(src):
00036         fatalError("can't find '%s'. You must run this script from the directory where '%s' is located." % src)
00037 
00038     try:
00039         shutil.move(src, dst)
00040     except:
00041         fatalError("can't move '%s' to '%s'" % (src, dst))
00042 
00043     try:
00044         os.mkdir(src)
00045     except OSError:
00046         fatalError("can't create '%s'" % src)
00047 

Here is the call graph for this function:

def MoinMoin.script.migration.migutil.copy (   items,
  srcdir,
  dstdir 
)
copy items from src dir into dst dir

@param items: list of items to copy
@param srcdir: source directory to copy items from
@param dstdir: destination directory to copy into

Definition at line 91 of file migutil.py.

00091 
00092 def copy(items, srcdir, dstdir):
00093     """ copy items from src dir into dst dir
00094 
00095     @param items: list of items to copy
00096     @param srcdir: source directory to copy items from
00097     @param dstdir: destination directory to copy into
00098     """
00099     for item in items:
00100         src = join(srcdir, item)
00101         dst = join(dstdir, item)
00102 
00103         # Copy directories
00104         if os.path.isdir(src):
00105             copy_dir(src, dst)
00106         elif os.path.isfile(src):
00107             copy_file(src, dst)
00108         else:
00109             error("can't find '%s'" % src)
00110 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.script.migration.migutil.copy_dir (   dir_from,
  dir_to 
)
Copy a complete directory 

Definition at line 64 of file migutil.py.

00064 
00065 def copy_dir(dir_from, dir_to):
00066     """ Copy a complete directory """
00067     print "%s/ -> %s/" % (dir_from, dir_to)
00068     try:
00069         shutil.copytree(dir_from, dir_to)
00070     except Exception, err:
00071         error("can't copy '%s' to '%s' (%s)" % (dir_from, dir_to, str(err)))
00072 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.script.migration.migutil.copy_file (   fname_from,
  fname_to 
)
Copy a single file 

Definition at line 73 of file migutil.py.

00073 
00074 def copy_file(fname_from, fname_to):
00075     """ Copy a single file """
00076     print "%s -> %s" % (fname_from, fname_to)
00077     try:
00078         shutil.copy2(fname_from, fname_to) # copies file data, mode, atime, mtime
00079     except:
00080         error("can't copy '%s' to '%s'" % (fname_from, fname_to))
00081 

Here is the call graph for this function:

Here is the caller graph for this function:

Report minor error and continue 

Definition at line 21 of file migutil.py.

00021 
00022 def error(msg):
00023     """ Report minor error and continue """
00024     print "Error:", msg
00025 

Here is the caller graph for this function:

Exit with error message on fatal errors 

Definition at line 14 of file migutil.py.

00014 
00015 def fatalError(msg):
00016     """ Exit with error message on fatal errors """
00017     print "Fatal error:", msg
00018     print "Stoping"
00019     sys.exit(1)
00020 

Here is the caller graph for this function:

Return list of files in path, filtering certain files 

Definition at line 48 of file migutil.py.

00048 
00049 def listdir(path):
00050     """ Return list of files in path, filtering certain files """
00051     names = [name for name in os.listdir(path)
00052              if not name.startswith('.') and
00053              not name.endswith('.pickle') and
00054              name != 'CVS']
00055     return names
00056 

Here is the caller graph for this function:

Create a directory, if it doesn't exist 

Definition at line 57 of file migutil.py.

00057 
00058 def makedir(newdir):
00059     """ Create a directory, if it doesn't exist """
00060     try:
00061         os.mkdir(newdir)
00062     except OSError:
00063         pass

Here is the caller graph for this function:

def MoinMoin.script.migration.migutil.move_file (   fname_from,
  fname_to 
)
Move a single file 

Definition at line 82 of file migutil.py.

00082 
00083 def move_file(fname_from, fname_to):
00084     """ Move a single file """
00085     print "%s -> %s" % (fname_from, fname_to)
00086     try:
00087         shutil.move(fname_from, fname_to) # moves file (even to different filesystem, including mode and atime/mtime)
00088     except:
00089         error("can't move '%s' to '%s'" % (fname_from, fname_to))
00090 

Here is the call graph for this function:


Variable Documentation

Definition at line 11 of file migutil.py.

Definition at line 10 of file migutil.py.