Code Duplication    Length = 18-19 lines in 2 locations

bbarchivist/hashutils.py 1 location

@@ 488-506 (lines=19) @@
485
                            xec.submit(gpgfile, thepath, gpg, keyid, pword)
486
                        except Exception as exc:
487
                            print("SOMETHING WENT WRONG")
488
                            print(str(exc))
489
                            raise SystemExit
490
491
492
def gpg_config_loader(homepath=None):
493
    """
494
    Read a ConfigParser file to get PGP key, password (optional)
495
496
    :param homepath: Folder containing ini file. Default is user directory.
497
    :type homepath: str
498
    """
499
    config = configparser.ConfigParser()
500
    if homepath is None:
501
        homepath = os.path.expanduser("~")
502
    conffile = os.path.join(homepath, "bbarchivist.ini")
503
    if not os.path.exists(conffile):
504
        open(conffile, 'w').close()
505
    config.read(conffile)
506
    if not config.has_section('gpgrunner'):
507
        config['gpgrunner'] = {}
508
    gpgkey = config.get('gpgrunner', 'key', fallback=None)
509
    gpgpass = config.get('gpgrunner', 'pass', fallback=None)

bbarchivist/utilities.py 1 location

@@ 668-685 (lines=18) @@
665
    if not is_windows():
666
        pass
667
    else:
668
        files = [file for file in os.listdir(a_dir) if not os.path.isdir(file)]
669
        brokens = []
670
        for file in files:
671
            if file.endswith(".exe") and file.startswith(bbconstants.PREFIXES):
672
                print("TESTING: {0}".format((file)))
673
                if not verify_loader_integrity(file):
674
                    brokens.append(file)
675
        return brokens
676
677
678
def workers(input_data):
679
    """
680
    Count number of CPU workers, smaller of number of threads and length of data.
681
682
    :param input_data: Input data, some iterable.
683
    :type input_data: list
684
    """
685
    runners = len(input_data) if len(input_data) < compat.enum_cpus() else compat.enum_cpus()
686
    return runners
687
688