Code Duplication    Length = 21-24 lines in 3 locations

bbarchivist/utilities.py 1 location

@@ 768-791 (lines=24) @@
765
        homepath = os.path.expanduser("~")
766
    conffile = os.path.join(homepath, "bbarchivist.ini")
767
    if not os.path.exists(conffile):
768
        open(conffile, 'w').close()
769
    config.read(conffile)
770
    if not config.has_section('cap'):
771
        config['cap'] = {}
772
    config['cap']['path'] = cappath
773
    with open(conffile, "w") as configfile:
774
        config.write(configfile)
775

bbarchivist/archiveutils.py 2 locations

@@ 416-439 (lines=24) @@
413
414
    :param szexe: Path to 7z executable, if needed.
415
    :type szexe: str
416
417
    :param selective: Only verify autoloaders. Default is false.
418
    :type selective: bool
419
    """
420
    method = filter_method(method, szexe)
421
    pathlist = [os.path.join(thepath, file) for file in os.listdir(thepath)]
422
    files = [file for file in pathlist if not os.path.isdir(file)]
423
    for file in files:
424
        filt = file.endswith(bbconstants.ARCS)
425
        if selective:
426
            filt = filt and file.startswith(bbconstants.PREFIXES)
427
        if filt:
428
            return decide_verifier(file, szexe)
429
430
431
def compress_suite(filepath, method="7z", szexe=None, selective=False):
432
    """
433
    Wrap compression and verification into one.
434
435
    :param filepath: Working directory. Required.
436
    :type filepath: str
437
438
    :param method: Compression type. Default is "7z". Defined in source.
439
    :type method: str
440
441
    :param szexe: Path to 7z executable, if needed.
442
    :type szexe: str
@@ 395-415 (lines=21) @@
392
    :type szexe: str
393
    """
394
    print("VERIFYING: {0}".format(file))
395
    if file.endswith(".7z") and szexe is not None:
396
        verif = sz_verify(os.path.abspath(file), szexe)
397
    else:
398
        verif = tarzip_verifier(file)
399
    if not verif:
400
        print("{0} IS BROKEN!".format((file)))
401
    return verif
402
403
404
def verify(thepath, method="7z", szexe=None, selective=False):
405
    """
406
    Verify specific archive files in a given folder.
407
408
    :param thepath: Working directory. Required.
409
    :type thepath: str
410
411
    :param method: Compression type. Default is "7z". Defined in source.
412
    :type method: str
413
414
    :param szexe: Path to 7z executable, if needed.
415
    :type szexe: str
416
417
    :param selective: Only verify autoloaders. Default is false.
418
    :type selective: bool