1
0
mirror of https://github.com/gryf/fs-uae-wrapper.git synced 2025-12-19 04:20:23 +01:00

Added new function for creating archives

This commit is contained in:
2017-01-02 13:50:39 +01:00
parent 22d152bb64
commit 77dd4dfaf4
3 changed files with 90 additions and 13 deletions

View File

@@ -57,31 +57,51 @@ def get_config_options(conf):
for key, val in parser.items(section)}
def extract_archive(arch_name, title=''):
def operate_archive(arch_name, operation, text):
"""
Extract provided archive to current directory
Create archive from contents of current directory
"""
archiver = file_archive.get_archiver(arch_name)
if archiver is None:
sys.stderr.write("Unable find archive type for `%s' or executable "
"doesn't exists.\n" % arch_name)
return False
msg = message.Message("Extracting files for `%s'. Please be "
"patient" % title)
if title:
msg = message.Message(text)
if text:
msg.show()
res = archiver.extract(arch_name)
res = False
if operation == 'extract':
res = archiver.extract(arch_name)
if operation == 'create':
res = archiver.create(arch_name)
msg.close()
if not res:
sys.stderr.write("Error extracting `%s'.\n" % arch_name)
return False
return res
return True
def create_archive(arch_name, title=''):
"""
Create archive from contents of current directory
"""
msg = ''
if title:
msg = "Creating archive for `%s'. Please be patient" % title
return operate_archive(arch_name, 'create', msg)
def extract_archive(arch_name, title=''):
"""
Extract provided archive to current directory
"""
msg = ''
if title:
msg = "Extracting files for `%s'. Please be patient" % title
return operate_archive(arch_name, 'extract', msg)
def run_command(cmd):