def extract_test_tar(pattern, tarpattern, fileext):
    """Extract a tarball given the search pattern.
       If necessary, the tarball will be extracted first.
       There must be one and only one matching file.
       arg 1- search pattern for the compressed file.
       arg 2- serach pattern for the tarball.
       arg 3- a list of search patterns for the source files.
    """
    arcdir = libastyle.get_archive_directory(True)
    testdir = libastyle.get_test_directory(True)
    # check for existing tarball
    files = glob.glob(arcdir + tarpattern)
    if len(files) == 1:
        call_7zip(files[0], testdir, fileext)
        return
    # extract the tarball
    files = glob.glob(arcdir + pattern)
    if len(files) == 0:
        libastyle.system_exit("No file to extract: " + pattern)
    if len(files) > 1:
        libastyle.system_exit(str(files) + "\nToo many files to extract")
    call_7zip(files[0], arcdir, [])
    # extract files from the tarball
    files = glob.glob(arcdir + tarpattern)
    if len(files) == 0:
        libastyle.system_exit("No tarball to extract: " + tarpattern)
    if len(files) > 1:
        libastyle.system_exit(str(files) + "\nToo many tarballs to extract")
    call_7zip(files[0], testdir, fileext)
def test_all_compressed():
    """Test extracts for all compressed files.
    """
    starttime = time.time()
    print("TEST COMPRESSED\n")
    arcdir = libastyle.get_archive_directory()
    files = glob.glob(arcdir + "/*.tar")
    for file_in in files:
        file_in = file_in.replace('\\', '/')
        prtfile = strip_directory_prefix(file_in)
        print("remove tar " + prtfile)
        os.remove(file_in)
    print()
    extract_project(libastyle.CODEBLOCKS, False)
    print()
    extract_project(libastyle.GWORKSPACE, False)
    print()
    extract_project(libastyle.JEDIT, False)
    #print()
    #extract_project(libastyle.KDEVELOP, False)
    #print()
    #extract_project(libastyle.MONODEVELOP, False)
    print()
    extract_project(libastyle.SCITE, False)
    print()
    extract_project(libastyle.SHARPDEVELOP, False)
    print()
    extract_project(libastyle.TESTPROJECT, False)
    print()
    stoptime = time.time()
    test_print_time(starttime, stoptime)
    print()
Exemple #3
0
def test_all_compressed():
	"""Test extracts for all compressed files.
	"""
	starttime = time.time()
	print("TEST COMPRESSED\n")
	arcdir = libastyle.get_archive_directory()
	files = glob.glob(arcdir  + "/*.tar")
	for file_in in files:
		file_in = file_in.replace('\\', '/')
		prtfile = strip_directory_prefix(file_in)
		print("remove tar " + prtfile)
		os.remove(file_in)
	print()
	#extract_project(libastyle.CODEBLOCKS, False)
	print()
	#extract_project(libastyle.DRJAVA, False)
	print()
	extract_project(libastyle.GWORKSPACE, False)
	print()
	#extract_project(libastyle.JEDIT, False)
	print()
	#extract_project(libastyle.KDEVELOP, False)
	print()
	#extract_project(libastyle.MONODEVELOP, False)
	print()
	#extract_project(libastyle.SCITE, False)
	print()
	#extract_project(libastyle.SHARPDEVELOP, False)
	print()
	extract_project(libastyle.TESTPROJECT, False)
	print()
	stoptime = time.time()
	test_print_time(starttime, stoptime)
	print()
Exemple #4
0
def extract_test_tar(pattern, tarpattern, fileext):
	"""Extract a tarball given the search pattern.
	   If necessary, the tarball will be extracted first.
	   There must be one and only one matching file.
	   arg 1- search pattern for the compressed file.
	   arg 2- serach pattern for the tarball.
	   arg 3- a list of search patterns for the source files.
	"""
	arcdir = libastyle.get_archive_directory(True)
	testdir = libastyle.get_test_directory(True)
	# check for existing tarball
	files = glob.glob(arcdir + tarpattern)
	if len(files) == 1:
		call_7zip(files[0], testdir, fileext)
		return
	# extract the tarball
	files = glob.glob(arcdir + pattern)
	if len(files) == 0:
		libastyle.system_exit("No file to extract: " + pattern)
	if len(files) > 1:
		libastyle.system_exit(str(files) + "\nToo many files to extract")
	call_7zip(files[0], arcdir, [])
	# extract files from the tarball
	files = glob.glob(arcdir + tarpattern)
	if len(files) == 0:
		libastyle.system_exit("No tarball to extract: " + tarpattern)
	if len(files) > 1:
		libastyle.system_exit(str(files) + "\nToo many tarballs to extract")
	call_7zip(files[0], testdir, fileext)
Exemple #5
0
def extract_project():
    """Extract files from archive to test directory.
	"""
    if not os.path.isfile(libastyle.get_archive_directory(True) + archive):
        libastyle.system_exit("Cannot find archive: " + archive)
    tarfile, ext = os.path.splitext(archive)
    print tarfile
    if ext == ".gz" or ext == ".bz2":
        extract_test_tar(tarfile)
    elif ext == ".zip" or ext == ".7z":
        extract_test_zip(tarfile)
    else:
        libastyle.system_exit("Cannot open archive: " + archive)
def extract_project():
	"""Extract files from archive to test directory.
	"""
	if not os.path.isfile(libastyle.get_archive_directory(True) + archive):
		 libastyle.system_exit("Cannot find archive: " + archive)
	tarfile, ext = os.path.splitext(archive)
	print (tarfile)
	if ext == ".gz" or ext == ".bz2":
		extract_test_tar(tarfile)
	elif ext == ".zip" or ext == ".7z":
		extract_test_zip(tarfile)
	else:
		libastyle.system_exit("Cannot open archive: " + archive)
def extract_test_zip(pattern, dirname, fileext):
    """Extract a compressed zip given the search pattern.
       There must be one and only one matching file.
       arg 1- search pattern for the compressed file.
       arg 2- name of the output top-level directory.
       arg 3- a list of search patterns for the source files.
    """
    arcdir = libastyle.get_archive_directory(True)
    testdir = libastyle.get_test_directory(True)
    # extract thezip
    files = glob.glob(arcdir + pattern)
    if len(files) == 0:
        libastyle.system_exit("No zip to extract")
    if len(files) > 1:
        libastyle.system_exit(str(files) + "\nToo many zips to extract")
    call_7zip(files[0], testdir + dirname.strip(), fileext)
Exemple #8
0
def extract_test_zip(pattern, dirname, fileext):
	"""Extract a compressed zip given the search pattern.
	   There must be one and only one matching file.
	   arg 1- search pattern for the compressed file.
	   arg 2- name of the output top-level directory.
	   arg 3- a list of search patterns for the source files.
	"""
	arcdir = libastyle.get_archive_directory(True)
	testdir = libastyle.get_test_directory(True)
	# extract thezip
	files = glob.glob(arcdir + pattern)
	if len(files) == 0:
		libastyle.system_exit("No zip to extract")
	if len(files) > 1:
		libastyle.system_exit(str(files) + "\nToo many zips to extract")
	call_7zip(files[0], testdir + dirname.strip(), fileext)