|
@@ 416-439 (lines=24) @@
|
| 413 |
|
if not utilities.new_enough(3) and method == "txz": |
| 414 |
|
method = "zip" # for 3.2 compatibility |
| 415 |
|
return method |
| 416 |
|
|
| 417 |
|
|
| 418 |
|
def compress_config_writer(method=None, homepath=None): |
| 419 |
|
""" |
| 420 |
|
Write a ConfigParser file to store compression preferences. |
| 421 |
|
|
| 422 |
|
:param method: Method to use. |
| 423 |
|
:type method: str |
| 424 |
|
|
| 425 |
|
:param homepath: Folder containing ini file. Default is user directory. |
| 426 |
|
:type homepath: str |
| 427 |
|
""" |
| 428 |
|
if method is None: |
| 429 |
|
method = compress_config_loader() |
| 430 |
|
config = configparser.ConfigParser() |
| 431 |
|
if homepath is None: |
| 432 |
|
homepath = os.path.expanduser("~") |
| 433 |
|
conffile = os.path.join(homepath, "bbarchivist.ini") |
| 434 |
|
if not os.path.exists(conffile): |
| 435 |
|
open(conffile, 'w').close() |
| 436 |
|
config.read(conffile) |
| 437 |
|
if not config.has_section('compression'): |
| 438 |
|
config['compression'] = {} |
| 439 |
|
config['compression']['method'] = method |
| 440 |
|
with open(conffile, "w") as configfile: |
| 441 |
|
config.write(configfile) |
| 442 |
|
|
|
@@ 395-415 (lines=21) @@
|
| 392 |
|
verify(filepath, method, szexe, selective) |
| 393 |
|
|
| 394 |
|
|
| 395 |
|
def compress_config_loader(homepath=None): |
| 396 |
|
""" |
| 397 |
|
Read a ConfigParser file to get compression preferences. |
| 398 |
|
|
| 399 |
|
:param homepath: Folder containing ini file. Default is user directory. |
| 400 |
|
:type homepath: str |
| 401 |
|
""" |
| 402 |
|
config = configparser.ConfigParser() |
| 403 |
|
if homepath is None: |
| 404 |
|
homepath = os.path.expanduser("~") |
| 405 |
|
conffile = os.path.join(homepath, "bbarchivist.ini") |
| 406 |
|
if not os.path.exists(conffile): |
| 407 |
|
open(conffile, 'w').close() |
| 408 |
|
config.read(conffile) |
| 409 |
|
if not config.has_section('compression'): |
| 410 |
|
config['compression'] = {} |
| 411 |
|
compini = config['compression'] |
| 412 |
|
method = compini.get('method', fallback="7z") |
| 413 |
|
if not utilities.new_enough(3) and method == "txz": |
| 414 |
|
method = "zip" # for 3.2 compatibility |
| 415 |
|
return method |
| 416 |
|
|
| 417 |
|
|
| 418 |
|
def compress_config_writer(method=None, homepath=None): |