def build_tests(args, directory, dirlist): options, ignored_directories = args if ignore.is_ignored(directory, dirlist): toolkit.exempt_list_of(dirlist, copy.copy(dirlist)) ignored_directories.append(directory) return toolkit.exempt_list_of(dirlist, ppath.special_directories) os.chdir(directory) config = config_file_path() try: if config in dirlist: execfile(config) except Exception, e: logging.critical("+++ In %s" % os.path.join(directory, config)) if options.traceback: raise else: logging.critical("%s: %s" % (e.__class__.__name__, e))
def build_tests(args, directory, dirlist): options, ignored_directories = args if ignore.is_ignored(directory, dirlist): toolkit.exempt_list_of( dirlist, copy.copy(dirlist) ) ignored_directories.append( directory ) return toolkit.exempt_list_of( dirlist, ppath.special_directories ) os.chdir(directory) config = config_file_path() try: if config in dirlist: execfile(config) except Exception, e: logging.critical("+++ In %s" % os.path.join(directory, config)) if options.traceback: raise else: logging.critical("%s: %s" % (e.__class__.__name__,e))
def compare_trees(former, later, ignored_files_re=["\.svn", ".\.metadata"]): """Compare the directory tree starting at \I{former} to the one starting at I{later}. Returns tree lists containing 1) (former_file, later_file) pairs of paths of common files 2) paths of directories or files unique to former 3) paths of directories or files unique to later Paths in the lists will be relative or absolute following the form in which I{former} and I{later} are. Files are listed in 'topdown' order. """ assert os.path.isdir(former) assert os.path.isdir(later) common_files = [] unique_to_former = [] unique_to_later = [] for former_dirpath, former_subdirs, former_files in os.walk(former): later_dirpath = former_dirpath.replace(former, later, 1) later_subdirs, later_files = split_listdir(later_dirpath) # Filters the subdirs given the 'ignored_files_re' argument re_filter_list(former_subdirs, ignored_files_re) re_filter_list(later_subdirs, ignored_files_re) # Filters the files given the 'ignored_files_re' argument re_filter_list(former_files, ignored_files_re) re_filter_list(later_files, ignored_files_re) ###### Directories ######################################################### uniquedirs = [] for subdir in former_subdirs: if subdir in later_subdirs: # can be modified without effects, unlike former_subdirs later_subdirs.remove(subdir) else: uniquedirs.append(subdir) unique_to_former.append(os.path.join(former_dirpath, subdir)) # Avoiding recursion in 'uniquedirs' exempt_list_of(former_subdirs, uniquedirs) # later_subdirs should now contain only dirs that were not in former_subdirs for subdir in later_subdirs: unique_to_later.append(os.path.join(later_dirpath, subdir)) ###### Files ############################################################### for fname in former_files: if fname in later_files: later_files.remove(fname) common_files.append( (os.path.join(former_dirpath, fname), os.path.join(later_dirpath, fname))) else: # if not os.path.islink(fname): unique_to_former.append(os.path.join(former_dirpath, fname)) # later_files should now contain only files that were not in former_files for fname in later_files: unique_to_later.append(os.path.join(later_dirpath, fname)) return common_files, unique_to_former, unique_to_later
def compare_trees(former, later, ignored_files_re=["\.svn", ".\.metadata"]): """Compare the directory tree starting at \I{former} to the one starting at I{later}. Returns tree lists containing 1) (former_file, later_file) pairs of paths of common files 2) paths of directories or files unique to former 3) paths of directories or files unique to later Paths in the lists will be relative or absolute following the form in which I{former} and I{later} are. Files are listed in 'topdown' order. """ assert os.path.isdir(former) assert os.path.isdir(later) common_files = [] unique_to_former = [] unique_to_later = [] for former_dirpath, former_subdirs, former_files in os.walk(former): later_dirpath = former_dirpath.replace(former, later, 1) later_subdirs, later_files = split_listdir(later_dirpath) # Filters the subdirs given the 'ignored_files_re' argument re_filter_list(former_subdirs, ignored_files_re) re_filter_list(later_subdirs, ignored_files_re) # Filters the files given the 'ignored_files_re' argument re_filter_list(former_files, ignored_files_re) re_filter_list(later_files, ignored_files_re) ###### Directories ######################################################### uniquedirs = [] for subdir in former_subdirs: if subdir in later_subdirs: # can be modified without effects, unlike former_subdirs later_subdirs.remove(subdir) else: uniquedirs.append(subdir) unique_to_former.append(os.path.join(former_dirpath, subdir)) # Avoiding recursion in 'uniquedirs' exempt_list_of(former_subdirs, uniquedirs) # later_subdirs should now contain only dirs that were not in former_subdirs for subdir in later_subdirs: unique_to_later.append(os.path.join(later_dirpath, subdir)) ###### Files ############################################################### for fname in former_files: if fname in later_files: later_files.remove(fname) common_files.append(( os.path.join(former_dirpath,fname), os.path.join(later_dirpath,fname) )) else: # if not os.path.islink(fname): unique_to_former.append(os.path.join(former_dirpath, fname)) # later_files should now contain only files that were not in former_files for fname in later_files: unique_to_later.append(os.path.join(later_dirpath, fname)) return common_files, unique_to_former, unique_to_later