예제 #1
0
def rename_output_file(filepaths):
    """Rename the output file by appending the options variable number (0-3).
    """
    print('\n' + ('-' * 60))
    # extract filename
    filepath = filepaths[0]
    filepath = filepath.replace('\\', '/')
    testdir = libastyle.get_test_directory()
    start = len(testdir) + 1
    end = filepath.find('/', start)
    if end == -1:
        libastyle.system_exit("Cannot find filename for rename: " + filepath)
    dirname = filepath[start:end]
    dirpath = testdir + '/' + dirname
    options_suffix = get_options_variable_name()[-1]
    newname = dirname + options_suffix
    newpath = dirpath + options_suffix
    # rename by adding the option number to the end
    if os.path.isdir(newpath):
        libextract.remove_test_directory(newname)
    print("rename {0} {1}".format(dirname, newname))
    try:
        shutil.move(dirpath, newpath)
    except WindowsError as err:
        time.sleep(2)
        try:
            shutil.move(dirpath, newpath)
        except WindowsError as err:
            print()
            print(err)
            libastyle.system_exit("Error in renaming output file: " + dirpath)
예제 #2
0
def rename_output_file(filepaths):
    """Rename the output file by appending the options variable number (0-3).
    """
    print('\n' + ('-' * 60))
    # extract filename
    filepath = filepaths[0]
    filepath = filepath.replace('\\', '/')
    testdir = libastyle.get_test_directory()
    start = len(testdir) + 1
    end = filepath.find('/', start)
    if end == -1:
        libastyle.system_exit("Cannot find filename for rename: " + filepath)
    dirname = filepath[start:end]
    dirpath = testdir + '/' + dirname
    options_suffix = get_options_variable_name()[-1]
    newname = dirname + options_suffix
    newpath = dirpath + options_suffix
    # rename by adding the option number to the end
    if os.path.isdir(newpath):
        libextract.remove_test_directory(newname)
    print("rename {0} {1}".format(dirname, newname))
    try:
        shutil.move(dirpath, newpath)
    except WindowsError as err:
        time.sleep(2)
        try:
            shutil.move(dirpath, newpath)
        except WindowsError as err:
            print()
            print(err)
            libastyle.system_exit("Error in renaming output file: " + dirpath)
예제 #3
0
def remove_test_files(index):
    """Remove test files for this run.
       If there is an active process using the file it cannot be removed.
       The active process will have to be killed to remove the file.
    """
    for i in range(index, len(__braces)):
        testfile = get_test_file_name(i)
        if os.path.exists(testfile):
            libextract.remove_test_directory(testfile)
예제 #4
0
def remove_test_files(index):
    """Remove test files for this run.
       If there is an active process using the file it cannot be removed.
       The active process will have to be killed to remove the file.
    """
    for i in range(index, len(__braces)):
        testfile = get_test_file_name(i)
        if os.path.exists(testfile):
            libextract.remove_test_directory(testfile)
예제 #5
0
def main():
    """Main processing function.
    """
    # initialization
    starttime = time.time()
    libastyle.set_text_color("yellow")
    print(libastyle.get_python_version())
    locale.setlocale(locale.LC_ALL, "")
    if os.name == "nt":
        process_windows_ramdrive()
    verify_options_x_variable()
    print_run_header()
    os.chdir(libastyle.get_file_py_directory())
    libastyle.build_astyle_executable(get_astyle_config())
    verify_astyle_executables(__astyleexe1, __astyleexe2)
    filepaths = libastyle.get_project_filepaths(__project)
    excludes = libastyle.get_project_excludes(__project)
    testfile = "test.txt"
    # run test 1
    if __formatOLD:
        print("\nTest 1 Extract")
        libextract.extract_project(__project, __all_files_option)
        print_test_header(1, __astyleexe1)
        astyle = set_astyle_args(filepaths, excludes, __astyleexe1)
        print_formatting_message(astyle, __project)
        call_artistic_style(astyle, testfile)
        print_astyle_totals(testfile)
        print("\nTest 1 Rename")
        libextract.remove_test_directory(__project + "OLD")
        libextract.rename_test_directory(__project, __project + "OLD")
    else:
        verify_test_directory(__project + "OLD")
        print("\nNo Test 1")

    # run test 2
    print("\nTest 2 Extract")
    libextract.extract_project(__project, __all_files_option)
    print_test_header(2, __astyleexe2)
    astyle = set_astyle_args(filepaths, excludes, __astyleexe2)
    print_formatting_message(astyle, __project)
    call_artistic_style(astyle, testfile)
    print_astyle_totals(testfile)

    # process formatted files
    diffs = compare_formatted_files(filepaths, len(excludes))
    print_run_total(starttime)
    libtest.diff_formatted_files(diffs, True)
예제 #6
0
def main():
    """Main processing function.
    """
    # initialization
    starttime = time.time()
    libastyle.set_text_color("yellow")
    print(libastyle.get_python_version())
    locale.setlocale(locale.LC_ALL, "")
    verify_options_x_variable()
    print_run_header()
    os.chdir(libastyle.get_file_py_directory())
    libastyle.build_astyle_executable(get_astyle_config())
    verify_astyle_executables(__astyleexe1, __astyleexe2)
    filepaths = libastyle.get_project_filepaths(__project)
    excludes = libastyle.get_project_excludes(__project)
    testfile = "test.txt"
    # run test 1
    if __formatOLD:
        print("\nTest 1 Extract")
        libextract.extract_project(__project, __all_files_option)
        print_test_header(1, __astyleexe1)
        astyle = set_astyle_args(filepaths, excludes, __astyleexe1)
        print_formatting_message(astyle, __project)
        call_artistic_style(astyle, testfile)
        print_astyle_totals(testfile)
        print("\nTest 1 Rename")
        libextract.remove_test_directory(__project + "OLD")
        libextract.rename_test_directory(__project, __project + "OLD")
    else:
        verify_test_directory(__project + "OLD")
        print("\nNo Test 1")

    # run test 2
    print("\nTest 2 Extract")
    libextract.extract_project(__project, __all_files_option)
    print_test_header(2, __astyleexe2)
    astyle = set_astyle_args(filepaths, excludes, __astyleexe2)
    print_formatting_message(astyle, __project)
    call_artistic_style(astyle, testfile)
    print_astyle_totals(testfile)

    # process formatted files
    diffs = compare_formatted_files(filepaths, len(excludes))
    print_run_total(starttime)
    libtest.diff_formatted_files(diffs, True)
def process_files():
    """Main processing function.
	"""
    # initialization
    starttime = time.time()
    libastyle.set_text_color()
    locale.setlocale(locale.LC_ALL, "")
    print_run_header()
    os.chdir(libastyle.get_file_py_directory())
    libastyle.build_astyle_executable(get_astyle_config())
    verify_astyle_executables(astyleexe1, astyleexe2)
    filepaths = get_file_paths()
    excludes = []
    testfile = "test.txt"
    # run test 1
    if formatOLD:
        print "\nExtracting Test 1"
        extract_project()
        print_test_header(1, astyleexe1)
        astyle = set_astyle_args(filepaths, excludes, astyleexe1)
        print_formatting_message(astyle, project)
        call_artistic_style(astyle, testfile)
        print_astyle_totals(testfile)
    else:
        verify_test_directory(project + "OLD")
        print "\nNo Test 1"

    # run test 2
    print "\nExtracting Test 2"
    if formatOLD:
        libextract.remove_test_directory(project + "OLD")
        libextract.rename_test_directory(project, project + "OLD")
    extract_project()
    print_test_header(2, astyleexe2)
    astyle = set_astyle_args(filepaths, excludes, astyleexe2)
    print_formatting_message(astyle, project)
    call_artistic_style(astyle, testfile)
    print_astyle_totals(testfile)

    # process formatted files
    diffs = compare_formatted_files(filepaths, len(excludes))
    print_run_total(starttime)
    libtest.diff_formatted_files(diffs, True)
예제 #8
0
def extract_test_zip(tarfile):
    """Extract zip files, including 7-zip, from archive to test directory.
	"""
    libextract.remove_test_directory(project)
    # libextract.extract_test_zip(archive, tarfile, source)
    libextract.extract_test_zip(archive, project, source)
예제 #9
0
def extract_test_tar(tarfile):
    """Extract tar files from archive to test directory.
	"""
    libextract.remove_test_directory(project)
    libextract.extract_test_tar(archive, tarfile, source)
예제 #10
0
def extract_test_zip(tarfile):
	"""Extract zip files, including 7-zip, from archive to test directory.
	"""
	libextract.remove_test_directory(project)
	# libextract.extract_test_zip(archive, tarfile, source)
	libextract.extract_test_zip(archive, project, source)
예제 #11
0
def extract_test_tar(tarfile):
	"""Extract tar files from archive to test directory.
	"""
	libextract.remove_test_directory(project)
	libextract.extract_test_tar(archive, tarfile, source)