Normalize imports

This commit is contained in:
2023-10-22 16:12:06 +02:00
parent b9fdd1d2a0
commit 0d529baa8b

26
ulha
View File

@@ -18,16 +18,16 @@ Version: 1.3
Licence: BSD
"""
import os
import sys
import re
import shutil
from subprocess import call, check_call, CalledProcessError
from tempfile import mkdtemp, mkstemp
import subprocess
import sys
import tempfile
from extfslib import Archive, parse_args
import extfslib
class ULha(Archive):
class ULha(extfslib.Archive):
"""Archive handle. Provides interface to MC's extfs subsystem"""
LINE_PAT = re.compile(b"^((?P<perms>[d-][rswx-]{9})|(\[generic\])|"
@@ -116,7 +116,7 @@ class ULha(Archive):
def run(self, dst):
"""Execute file out of archive"""
fdesc, tmp_file = mkstemp()
fdesc, tmp_file = tempfile.mkstemp()
os.close(fdesc)
result = 0
@@ -126,7 +126,7 @@ class ULha(Archive):
os.chmod(tmp_file, int("700", 8))
try:
result = call([tmp_file])
result = subprocess.call([tmp_file])
finally:
try:
os.unlink(tmp_file)
@@ -144,7 +144,7 @@ class ULha(Archive):
If src is empty, create empty directory with dst name."""
current_dir = os.path.abspath(os.curdir)
tmpdir = mkdtemp()
tmpdir = tempfile.mkdtemp()
arch_abspath = os.path.realpath(self._arch)
os.chdir(tmpdir)
if src:
@@ -154,10 +154,10 @@ class ULha(Archive):
os.makedirs(dst)
try:
result = check_call([self.ARCHIVER.decode('utf-8'),
result = subprocess.check_call([self.ARCHIVER.decode('utf-8'),
self.CMDS["write"].decode('utf-8'),
arch_abspath, dst])
except CalledProcessError:
except subprocess.CalledProcessError:
return 1
finally:
os.chdir(current_dir)
@@ -169,9 +169,9 @@ class ULha(Archive):
src = self._get_real_name(src)
fobj = open(dst, "wb")
try:
result = check_call([self.ARCHIVER, self.CMDS['read'], self._arch,
result = subprocess.check_call([self.ARCHIVER, self.CMDS['read'], self._arch,
src], stdout=fobj)
except CalledProcessError:
except subprocess.CalledProcessError:
return 1
finally:
fobj.close()
@@ -179,4 +179,4 @@ class ULha(Archive):
if __name__ == "__main__":
sys.exit(parse_args(ULha))
sys.exit(extfslib.parse_args(ULha))