Code Duplication    Length = 21-24 lines in 3 locations

bbarchivist/utilities.py 1 location

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

bbarchivist/archiveutils.py 2 locations

@@ 416-439 (lines=24) @@
413
414
    :param filepath: Working directory. Required.
415
    :type filepath: str
416
417
    :param method: Compression type. Default is "7z". Defined in source.
418
    :type method: str
419
420
    :param szexe: Path to 7z executable, if needed.
421
    :type szexe: str
422
423
    :param selective: Only compress autoloaders. Default is false.
424
    :type selective: bool
425
    """
426
    compress(filepath, method, szexe, selective)
427
    verify(filepath, method, szexe, selective)
428
429
430
def compress_config_loader(homepath=None):
431
    """
432
    Read a ConfigParser file to get compression preferences.
433
434
    :param homepath: Folder containing ini file. Default is user directory.
435
    :type homepath: str
436
    """
437
    config = configparser.ConfigParser()
438
    if homepath is None:
439
        homepath = os.path.expanduser("~")
440
    conffile = os.path.join(homepath, "bbarchivist.ini")
441
    if not os.path.exists(conffile):
442
        open(conffile, 'w').close()
@@ 395-415 (lines=21) @@
392
            print("VERIFYING: {0}".format(file))
393
            if file.endswith(".7z") and szexe is not None:
394
                verif = sz_verify(os.path.abspath(file), szexe)
395
            elif file.endswith(".tar.gz"):
396
                verif = tgz_verify(file)
397
            elif file.endswith(".tar.xz"):
398
                verif = txz_verify(file)
399
            elif file.endswith(".tar.bz2"):
400
                verif = tbz_verify(file)
401
            elif file.endswith(".tar"):
402
                verif = tar_verify(file)
403
            elif file.endswith(".zip"):
404
                verif = zip_verify(file)
405
            if not verif:
406
                print("{0} IS BROKEN!".format((file)))
407
            return verif
408
409
410
def compress_suite(filepath, method="7z", szexe=None, selective=False):
411
    """
412
    Wrap compression and verification into one.
413
414
    :param filepath: Working directory. Required.
415
    :type filepath: str
416
417
    :param method: Compression type. Default is "7z". Defined in source.
418
    :type method: str