tree_file_compare Namespace Reference

Functions

def output
def build_file_index_for
def build_name_index_for
def display_content_duplicates
def display_name_duplicates
def compare_content_trees
def compare_name_trees
def check_content_completeness
def check_mirror_completeness
def check_name_completeness
def detect_common_content
def detect_common_name
def write_hashes

Variables

string __doc__
 log_file = None
tuple base_write_path = os.path.expanduser("~")
tuple file_base_name = time.strftime( "%Y%m%d-tree-file-compare.log", time.gmtime() )
tuple log_filename = os.path.join( base_write_path, file_base_name )
list help_options = [ '-h', '--help' ]
list verbose_options = [ '-v', '--verbose' ]
list by_name_options = [ '--by-name-only' ]
list reverse_options = [ '-r', '--reverse' ]
 options = help_options+verbose_options+by_name_options+reverse_options
 verbose = False
 compare_by_content = True
 reverse_compare = False
list saved_args = sys.argv[1:]
int item_count = 0
 reference_path = None
 mirror_path = None
tuple item = sys.argv.pop(0)
 item_understood = False
tuple ref_name_index = build_name_index_for( reference_path )
tuple mirror_name_index = build_name_index_for( mirror_path )

Function Documentation

def tree_file_compare::build_file_index_for (   path  ) 
Creates two (dictionary-based) file index for specified path.

Definition at line 59 of file tree_file_compare.py.

def tree_file_compare::build_name_index_for (   path  ) 
Creates one (dictionary-based) name index for specified path.

Definition at line 97 of file tree_file_compare.py.

def tree_file_compare::check_content_completeness (   ref_content_index,
  mirror_content_index 
)
Checks that all content of mirror tree is in reference tree, preferably with the same filenames.

Definition at line 181 of file tree_file_compare.py.

def tree_file_compare::check_mirror_completeness (   ref_content_index,
  mirror_content_index 
)
Checks that all content of reference tree is in mirror tree, preferably with the same filenames.

Definition at line 192 of file tree_file_compare.py.

def tree_file_compare::check_name_completeness (   ref_name_index,
  mirror_name_index 
)
Checks that all name of mirror tree is in reference tree, preferably with the same filenames.

Definition at line 203 of file tree_file_compare.py.

def tree_file_compare::compare_content_trees (   ref_content_index,
  mirror_content_index 
)
Compares the reference and mirror trees, based on the file content. Useful to know whether a mirror is complete.

Definition at line 148 of file tree_file_compare.py.

def tree_file_compare::compare_name_trees (   ref_name_index,
  mirror_name_index 
)
Compares the reference and mirror trees, based on the file name. Useful to know whether a mirror is complete.

Definition at line 164 of file tree_file_compare.py.

def tree_file_compare::detect_common_content (   ref_content_index,
  mirror_content_index 
)
Useful in the cases where one wants to check two trees partition indeed a set of files (we do not want the same content to appear more than once).
Common files are detected in terms of content.

Definition at line 214 of file tree_file_compare.py.

def tree_file_compare::detect_common_name (   ref_name_index,
  mirror_name_index 
)
Useful in the cases where one wants to check two trees partition indeed a set of files (we do not want the same content to appear more than once).
Common files are detected in terms of name.

Definition at line 231 of file tree_file_compare.py.

def tree_file_compare::display_content_duplicates (   root_path,
  content_index 
)
Displays the duplicates in specified content file index.

Definition at line 124 of file tree_file_compare.py.

def tree_file_compare::display_name_duplicates (   root_path,
  name_index 
)
Displays the duplicates in specified name file index.

Definition at line 136 of file tree_file_compare.py.

def tree_file_compare::output (   message  ) 

Definition at line 53 of file tree_file_compare.py.

def tree_file_compare::write_hashes (   log_file,
  content_index 
)
Writes specified content index in specified log file.

Definition at line 248 of file tree_file_compare.py.


Variable Documentation

Initial value:
"""
Usage: tree-file-compare.py [ -h | --help ] [ -v | --verbose ] [ -r | --reverse] [ --by-name-only ] --reference APath [--mirror AnotherPath] 
Will scan first specified tree, in search of duplicated files (same content, different path). The resulting associations will be stored in ~/*-tree-file-compare.log files. If a second tree is specified (--mirror option), then will look for files whose content is in second tree but not in the first one, to ensure the reference tree is complete.

This script is useful to ensure a reference tree does not lack any content from a mirror and to know whether the mirror is up-to-date.
The script can be used for example for snapshots or archives.

Options:
    -v or --verbose: set verbose mode
    --by-name-only: comparison is done based on names only; no MD5 checksum performed (useful when the names refer clearly to the content, as an archive filename, as opposed to snapshots) 
    --mirror A_PATH: specifies a second tree to compare with
    --reverse: reverse-compare, i.e. search for files that are common to both trees rather than lacking in one (useful to ensure there is no duplicate between trees)
"""

Definition at line 7 of file tree_file_compare.py.

tuple tree_file_compare::base_write_path = os.path.expanduser("~")

Definition at line 45 of file tree_file_compare.py.

list tree_file_compare::by_name_options = [ '--by-name-only' ]

Definition at line 262 of file tree_file_compare.py.

Definition at line 269 of file tree_file_compare.py.

tuple tree_file_compare::file_base_name = time.strftime( "%Y%m%d-tree-file-compare.log", time.gmtime() )

Definition at line 47 of file tree_file_compare.py.

list tree_file_compare::help_options = [ '-h', '--help' ]

Definition at line 260 of file tree_file_compare.py.

tuple tree_file_compare::item = sys.argv.pop(0)

Definition at line 286 of file tree_file_compare.py.

Definition at line 279 of file tree_file_compare.py.

Definition at line 287 of file tree_file_compare.py.

Definition at line 42 of file tree_file_compare.py.

Definition at line 49 of file tree_file_compare.py.

tuple tree_file_compare::mirror_name_index = build_name_index_for( mirror_path )

Definition at line 389 of file tree_file_compare.py.

Definition at line 282 of file tree_file_compare.py.

Definition at line 265 of file tree_file_compare.py.

tuple tree_file_compare::ref_name_index = build_name_index_for( reference_path )

Definition at line 372 of file tree_file_compare.py.

Definition at line 281 of file tree_file_compare.py.

Definition at line 270 of file tree_file_compare.py.

list tree_file_compare::reverse_options = [ '-r', '--reverse' ]

Definition at line 263 of file tree_file_compare.py.

list tree_file_compare::saved_args = sys.argv[1:]

Definition at line 274 of file tree_file_compare.py.

Definition at line 268 of file tree_file_compare.py.

Definition at line 261 of file tree_file_compare.py.

Generated on Mon Nov 29 13:43:29 2010 for Ceylan by  doxygen 1.6.3