Cleanups.

This commit is contained in:
2023-10-20 17:02:21 +02:00
parent cb5b03aa20
commit 1a6c6af759

11
uadf
View File

@@ -27,7 +27,7 @@ Changelog:
1.0 Initial release 1.0 Initial release
Author: Roman 'gryf' Dobosz <gryf73@gmail.com> Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
Date: 2023-10-16 Date: 2023-10-19
Version: 1.4 Version: 1.4
Licence: BSD Licence: BSD
""" """
@@ -49,7 +49,7 @@ BANNER_PAT = re.compile(r'unADF v\d.\d : a unzip like for .ADF files, '
class UAdf(extfslib.Archive): class UAdf(extfslib.Archive):
""" """
Class for interact with c1541 program and MC Class for interact with ADF/DMS images and MC
""" """
LINE_PAT = re.compile(r'\s*(?P<size>\d+)?' LINE_PAT = re.compile(r'\s*(?P<size>\d+)?'
r'\s{2}(?P<date>\d{4}/\d{2}/\d{2})' r'\s{2}(?P<date>\d{4}/\d{2}/\d{2})'
@@ -186,7 +186,7 @@ class UAdf(extfslib.Archive):
real_src = real_src[0].encode('latin-1') real_src = real_src[0].encode('latin-1')
if " " in real_src: if b" " in real_src:
sys.stderr.write("unadf is unable to operate on filepath with " sys.stderr.write("unadf is unable to operate on filepath with "
"space inside.\nUse affs to mount image and than" "space inside.\nUse affs to mount image and than"
" extract desired files.\n") " extract desired files.\n")
@@ -194,10 +194,9 @@ class UAdf(extfslib.Archive):
extract_dir = tempfile.mkdtemp() extract_dir = tempfile.mkdtemp()
cmd = [self.ARCHIVER, "-d", extract_dir, self._arch, real_src] cmd = [self.ARCHIVER, "-d", extract_dir, self._arch, real_src]
result = subprocess.run(cmd, stdout=open(os.devnull, 'wb'), result = subprocess.run(cmd, capture_output=True)
stderr=open(os.devnull, 'wb'))
error_msg = self._parse_banner(result.stderr) error_msg = self._parse_banner(result.stderr.decode('utf-8'))
if error_msg: if error_msg:
sys.stderr.write("unadf returned with error:\n") sys.stderr.write("unadf returned with error:\n")
sys.stderr.write(error_msg) sys.stderr.write(error_msg)