def migrate_results_trees(self, expected_results, confirmed_results): cwd = os.getcwd() expected_results = moresh.relative_path(expected_results, cwd) confirmed_results = moresh.relative_path(confirmed_results, cwd) # Files are listed in 'topdown' order. logging.debug("Migrating %s to %s"%(confirmed_results,expected_results)) common_files, unique_to_expected, unique_to_confirmed =\ moresh.compare_trees(expected_results, confirmed_results, ["\.svn"]) # Overwritten results for expected_filepath, confirmed_filepath in common_files: mv_cmd = 'mv -f %s %s'%(confirmed_filepath, expected_filepath) logging.debug(mv_cmd) os.system(mv_cmd) # Old expected results to be removed for expected_filepath in unique_to_expected: logging.debug("recursive_remove %s --force"%expected_filepath) version_control.recursive_remove(expected_filepath, '--force') # New expected results to be added for confirmed_filepath in unique_to_confirmed: expected_filepath = confirmed_filepath.replace('.confirmed', '') assert not os.path.exists(expected_filepath) if os.path.isdir(confirmed_filepath) \ and moresh.is_recursively_empty(confirmed_filepath): continue # Do not add empty directory to version control. rename_cmd = 'os.rename("%s", "%s")'%(confirmed_filepath, expected_filepath) logging.debug(rename_cmd) eval(rename_cmd) version_control.recursive_add(expected_filepath)
def pldiff(former, later, precision=1e-06, plearn_exec=__DUMMY__VALUE__, ignored_files_re=[]): """Compare to PLearn-compliant files or directory. TODO: 1) .dmat directory should be managed intelligently """ default_plearn_exec = _plearn_exec if plearn_exec != __DUMMY__VALUE__: set_plearn_exec(plearn_exec) report = [] common_files = [] # Compare two directories if os.path.isdir(former): assert os.path.isdir(later) common_files, unique_to_former, unique_to_later =\ moresh.compare_trees(former, later, ignored_files_re=ignored_files_re+["\.svn", ".\.metadata"]) report.extend(report_unique_paths(unique_to_former, later, '--- ')) report.extend(report_unique_paths(unique_to_later, former, '+++ ')) # Arguments are only files else: assert not os.path.islink(former) assert not os.path.islink(later) common_files = [(former, later)] for former_file,later_file in common_files: diff_report = [] if former_file.endswith('metainfos.txt'): continue # Skipping metainfos files elif former_file.endswith('.psave'): if plearn_exec is None: diff_report.append("Warning: %s encountered while plearn-exec is None\n"%former_file) else: diff_report.extend(psavediff(former_file, later_file, precision)) elif toolkit.isvmat(former_file): if plearn_exec is None: diff_report.append("Warning: %s encountered while plearn-exec is None\n"%former_file) else: diff_report = vmatdiff(former_file, later_file, precision) else: diff = toldiff(former_file, later_file, precision) if diff: diff_report = ["--- %s and %s\n %s"%(former_file, later_file, diff)] if diff_report and \ not (len(diff_report)==1 and diff_report[0]==''): report.extend(diff_report) set_plearn_exec(default_plearn_exec) return report
def migrate_results_trees(self, expected_results, confirmed_results): cwd = os.getcwd() expected_results = moresh.relative_path(expected_results, cwd) confirmed_results = moresh.relative_path(confirmed_results, cwd) # Files are listed in 'topdown' order. logging.debug("Migrating %s to %s" % (confirmed_results, expected_results)) common_files, unique_to_expected, unique_to_confirmed =\ moresh.compare_trees(expected_results, confirmed_results, ["\.svn"]) # Overwritten results for expected_filepath, confirmed_filepath in common_files: mv_cmd = 'mv -f %s %s' % (confirmed_filepath, expected_filepath) logging.debug(mv_cmd) os.system(mv_cmd) # Old expected results to be removed for expected_filepath in unique_to_expected: logging.debug("recursive_remove %s --force" % expected_filepath) version_control.recursive_remove(expected_filepath, '--force') # New expected results to be added for confirmed_filepath in unique_to_confirmed: expected_filepath = confirmed_filepath.replace('.confirmed', '') assert not os.path.exists(expected_filepath) if os.path.isdir(confirmed_filepath) \ and moresh.is_recursively_empty(confirmed_filepath): continue # Do not add empty directory to version control. rename_cmd = 'os.rename("%s", "%s")' % (confirmed_filepath, expected_filepath) logging.debug(rename_cmd) eval(rename_cmd) version_control.recursive_add(expected_filepath)