예제 #1
0
def diff_formatted_files(filepaths, diff_old=False):
    """Call the diff program for formatted files.
	   diff_old=True will diff files from the "OLD" directory.
	   Otherwise diff ".orig" files from the current directory.
	   This function requires keyboard input.
	   It cannot be run from an editor.
	"""
    if not libastyle.is_executed_from_console():
        if diff_old:
            diffprog = "diff2-print.py"
        else:
            diffprog = "diff1-print.py"
        msg = "Run {0} from the console to view the diffs"
        print(msg.format(diffprog))
        return
    print("Press m or n to skip, q to quit")
    numin = 0
    processed = 0
    for filepath in filepaths:
        numin += 1
        filepath = filepath.replace('\\', '/')
        stripfile = strip_test_directory_prefix(filepath)
        print("{0} of {1} {2}".format(numin, len(filepaths), stripfile))
        ch_in = libastyle.getch()
        if ch_in == 'n' or ch_in == 'N' or ch_in == 'm' or ch_in == 'M':
            continue
        if ch_in == 'q' or ch_in == 'Q':
            break
        processed += 1
        if diff_old:
            oldpath = get_old_filepath(filepath)
            call_diff_program(filepath, oldpath)
        else:
            call_diff_program(filepath, filepath + ".orig")
    print("{0} of {1} diffs processed".format(processed, len(filepaths)))
예제 #2
0
파일: libtest.py 프로젝트: a-w/astyle
def diff_formatted_files(filepaths, diff_old=False):
    """Call the diff program for formatted files.
       diff_old=True will diff files from the "OLD" directory.
       Otherwise diff ".orig" files from the current directory.
       This function requires keyboard input.
       It cannot be run from an editor.
    """
    if not libastyle.is_executed_from_console():
        if diff_old:
            diffprog = "diff2-print.py"
        else:
            diffprog = "diff1-print.py"
        msg = "Run {0} from the console to view the diffs"
        print(msg.format(diffprog))
        return
    print("Press m or n to skip, q to quit")
    numin = 0
    processed = 0
    for filepath in filepaths:
        numin += 1
        filepath = filepath.replace('\\', '/')
        stripfile = strip_test_directory_prefix(filepath)
        print("{0} of {1} {2}".format(numin, len(filepaths), stripfile))
        ch_in = libastyle.get_ch()
        if ch_in == 'n' or ch_in == 'N' or ch_in == 'm' or ch_in == 'M':
            continue
        if ch_in == 'q' or ch_in == 'Q':
            break
        processed += 1
        if diff_old:
            oldpath = get_old_filepath(filepath)
            call_diff_program(filepath, oldpath)
        else:
            call_diff_program(filepath, filepath + ".orig")
    print("{0} of {1} diffs processed".format(processed, len(filepaths)))
예제 #3
0
def run_cppcheck():
	"""Run the cppcheck program.
	   NOTE: The window stays open only if run from the console.
	   --enable=all       Enable all checks
	   -f, --force        Force checking if "too many" #ifdefs.
	   -h, --help         Print the help information.
	   -j <jobs>          Start [jobs] threads.
	   -q, --quiet        Only print error messages.
	   --report-progress  Report progress while checking a file.
	   --suppress=<spec>  Suppress a specific warning.
	   --suppressions-list=<file> Suppress warnings listed in the file.
	   -v, --verbose      More detailed error reports.
	   --version          Print the version number.
	   --xml              Write results in xml to error stream.
	"""
	if os.name == "nt":
		exepath = "C:/Program Files (x86)/Cppcheck/cppcheck.exe"
	else:
		exepath = "cppcheck"
	if not os.path.exists(exepath):
		libastyle.system_exit("Cannot find executable: " + exepath)
	verify_cppcheck_version(exepath)
	cppcheck = [exepath]
	cppcheck.append("--enable=all")
	cppcheck.append("--force")
	cppcheck.append("--verbose")
	cppcheck.append("--xml")
	cppcheck.append("--suppressions-list=" +  __suppression_path)
	cppcheck.append(__src_dir)
	# shell=True keeps the console window open, but will not display if run from an editor
	# subprocess.check_output() doesn't work from an editor
	try:
		if libastyle.is_executed_from_console():
			subprocess.check_call(cppcheck, shell=True)
		else:
			subprocess.check_call(cppcheck)
	except subprocess.CalledProcessError as err:
		libastyle.system_exit("Bad cppcheck return: " + str(err.returncode))
	except OSError:
		libastyle.system_exit("Cannot find executable: " + cppcheck[0])
예제 #4
0
def run_cppcheck():
    """Run the cppcheck program.
	   NOTE: The window stays open only if run from the console.
	   --enable=all       Enable all checks
	   -f, --force        Force checking if "too many" #ifdefs.
	   -h, --help         Print the help information.
	   -j <jobs>          Start [jobs] threads.
	   -q, --quiet        Only print error messages.
	   --report-progress  Report progress while checking a file.
	   --suppress=<spec>  Suppress a specific warning.
	   --suppressions-list=<file> Suppress warnings listed in the file.
	   -v, --verbose      More detailed error reports.
	   --version          Print the version number.
	   --xml              Write results in xml to error stream.
	"""
    if os.name == "nt":
        exepath = "C:/Program Files/Cppcheck/cppcheck.exe"
    else:
        exepath = "cppcheck"
    verify_cppcheck_version(exepath)
    cppcheck = [exepath]
    cppcheck.append("--enable=all")
    cppcheck.append("--force")
    cppcheck.append("--verbose")
    cppcheck.append("--xml")
    cppcheck.append("--suppressions-list=" + __suppression_path)
    cppcheck.append(__src_dir)
    # shell=True keeps the console window open, but will not display if run from an editor
    # subprocess.check_output() doesn't work from an editor
    try:
        if libastyle.is_executed_from_console():
            subprocess.check_call(cppcheck, shell=True)
        else:
            subprocess.check_call(cppcheck)
    except subprocess.CalledProcessError as err:
        libastyle.system_exit("Bad cppcheck return: " + str(err.returncode))
    except OSError:
        libastyle.system_exit("Cannot find executable: " + cppcheck[0])