| @@ 488-506 (lines=19) @@ | ||
| 485 | raise SystemExit |
|
| 486 | ||
| 487 | ||
| 488 | def gpg_config_loader(homepath=None): |
|
| 489 | """ |
|
| 490 | Read a ConfigParser file to get PGP key, password (optional) |
|
| 491 | ||
| 492 | :param homepath: Folder containing ini file. Default is user directory. |
|
| 493 | :type homepath: str |
|
| 494 | """ |
|
| 495 | config = configparser.ConfigParser() |
|
| 496 | if homepath is None: |
|
| 497 | homepath = os.path.expanduser("~") |
|
| 498 | conffile = os.path.join(homepath, "bbarchivist.ini") |
|
| 499 | if not os.path.exists(conffile): |
|
| 500 | open(conffile, 'w').close() |
|
| 501 | config.read(conffile) |
|
| 502 | if not config.has_section('gpgrunner'): |
|
| 503 | config['gpgrunner'] = {} |
|
| 504 | gpgkey = config.get('gpgrunner', 'key', fallback=None) |
|
| 505 | gpgpass = config.get('gpgrunner', 'pass', fallback=None) |
|
| 506 | return gpgkey, gpgpass |
|
| 507 | ||
| 508 | ||
| 509 | def gpg_config_writer(key=None, password=None, homepath=None): |
|
| @@ 668-685 (lines=18) @@ | ||
| 665 | ||
| 666 | :param file: File to check. |
|
| 667 | :type file: str |
|
| 668 | ||
| 669 | :param pre: Prefix(es) to check. |
|
| 670 | :type pre: str or list or tuple |
|
| 671 | ||
| 672 | :param suf: Suffix(es) to check. |
|
| 673 | :type suf: str or list or tuple |
|
| 674 | """ |
|
| 675 | return file.startswith(pre) and file.endswith(suf) |
|
| 676 | ||
| 677 | ||
| 678 | def cappath_config_loader(homepath=None): |
|
| 679 | """ |
|
| 680 | Read a ConfigParser file to get cap preferences. |
|
| 681 | ||
| 682 | :param homepath: Folder containing ini file. Default is user directory. |
|
| 683 | :type homepath: str |
|
| 684 | """ |
|
| 685 | config = configparser.ConfigParser() |
|
| 686 | homepath = os.path.expanduser("~") if homepath is None else homepath |
|
| 687 | conffile = os.path.join(homepath, "bbarchivist.ini") |
|
| 688 | if not os.path.exists(conffile): |
|