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
666
def prep_logfile():
667
    """
668
    Prepare log file, labeling it with current date. Select folder based on frozen status.
669
    """
670
    logfile = "{0}.txt".format(time.strftime("%Y_%m_%d_%H%M%S"))
671
    root = os.getcwd() if getattr(sys, 'frozen', False) else os.path.expanduser("~")
672
    basefolder = os.path.join(root, "lookuplogs")
673
    os.makedirs(basefolder, exist_ok=True)
674
    record = os.path.join(basefolder, logfile)
675
    open(record, "w").close()
676
    return record
677
678
679
def prepends(file, pre, suf):
680
    """
681
    Check if filename starts with/ends with stuff.
682
683
    :param file: File to check.
684
    :type file: str
685
686
    :param pre: Prefix(es) to check.
687
    :type pre: str or list or tuple
688