diff --git a/src/vfs/extfs/helpers/uc1541 b/src/vfs/extfs/helpers/uc1541 index dc15b4299b..05628a5491 100755 --- a/src/vfs/extfs/helpers/uc1541 +++ b/src/vfs/extfs/helpers/uc1541 @@ -32,23 +32,23 @@ else: Dummy logger object. Does nothing. """ @classmethod - def debug(*args, **kwargs): + def debug(cls, **kwargs): pass @classmethod - def info(*args, **kwargs): + def info(cls, **kwargs): pass @classmethod - def warning(*args, **kwargs): + def warning(cls, **kwargs): pass @classmethod - def error(*args, **kwargs): + def error(cls, **kwargs): pass @classmethod - def critical(*args, **kwargs): + def critical(cls, **kwargs): pass @@ -157,7 +157,7 @@ class Disk(object): characters with jokers. """ - filename = list() + filename = [] for chr_ in string: if _ord(chr_) == 160: # shift+space character; $a0 @@ -237,7 +237,7 @@ class Disk(object): Traverse through sectors and store entries in _dir_contents """ sector = self.current_sector_data - for dummy in range(8): + for _ in range(8): entry = sector[:32] ftype = _ord(entry[2]) @@ -247,13 +247,13 @@ class Disk(object): type_verbose = self._get_ftype(ftype) - protect = _ord(entry[2]) & 64 and "<" or " " + protect = "<" if _ord(entry[2]) & 64 else " " fname = entry[5:21] - if ftype == 'rel': - size = _ord(entry[23]) - else: - size = _ord(entry[30]) + _ord(entry[31]) * 226 - + size = ( + _ord(entry[23]) + if ftype == 'rel' + else _ord(entry[30]) + _ord(entry[31]) * 226 + ) self._dir_contents.append({'fname': self._map_filename(fname), 'ftype': type_verbose, 'size': size, @@ -431,10 +431,7 @@ class Uc1541(object): LOG.info("Removing file %s", dst) dst = self._get_masked_fname(dst) - if not self._call_command('delete', dst=dst): - return self._show_error() - - return 0 + return self._show_error() if not self._call_command('delete', dst=dst) else 0 def copyin(self, dst, src): """ @@ -551,7 +548,7 @@ class Uc1541(object): if ext == 'del': perms = "----------" else: - perms = "-r%s-r--r--" % (rw.strip() and "-" or "w") + perms = f'-r{rw.strip() and "-" or "w"}-r--r--' directory.append({'pattern_name': pattern_name, 'display_name': display_name, @@ -566,10 +563,7 @@ class Uc1541(object): """ Pass out error output from c1541 execution """ - if self._verbose: - return self.err - else: - return 1 + return self.err if self._verbose else 1 def _call_command(self, cmd, src=None, dst=None): """ @@ -579,20 +573,14 @@ class Uc1541(object): delete dir/list """ - command = ['c1541', '-attach', self.arch, '-%s' % cmd] + command = ['c1541', '-attach', self.arch, f'-{cmd}'] if src: command.append(src) if dst: command.append(dst) LOG.debug('executing command: %s', ' '.join(command)) - # For some reason using write and delete commands and reading output - # confuses Python3 beneath MC and as a consequence MC report an - # error...therefore for those commands let's not use - # universal_newlines... - universal_newlines = True - if cmd in ['delete', 'write']: - universal_newlines = False + universal_newlines = cmd not in ['delete', 'write'] self.out, self.err = Popen(command, universal_newlines=universal_newlines, stdout=PIPE, stderr=PIPE).communicate()