Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 18 additions & 30 deletions src/vfs/extfs/helpers/uc1541
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ else:
Dummy logger object. Does nothing.
"""
@classmethod
def debug(*args, **kwargs):
def debug(cls, **kwargs):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LOG.debug refactored with the following changes:

pass

@classmethod
def info(*args, **kwargs):
def info(cls, **kwargs):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LOG.info refactored with the following changes:

pass

@classmethod
def warning(*args, **kwargs):
def warning(cls, **kwargs):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LOG.warning refactored with the following changes:

pass

@classmethod
def error(*args, **kwargs):
def error(cls, **kwargs):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LOG.error refactored with the following changes:

pass

@classmethod
def critical(*args, **kwargs):
def critical(cls, **kwargs):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LOG.critical refactored with the following changes:

pass


Expand Down Expand Up @@ -157,7 +157,7 @@ class Disk(object):
characters with jokers.
"""

filename = list()
filename = []

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Disk._map_filename refactored with the following changes:


for chr_ in string:
if _ord(chr_) == 160: # shift+space character; $a0
Expand Down Expand Up @@ -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):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Disk._harvest_entries refactored with the following changes:

entry = sector[:32]
ftype = _ord(entry[2])

Expand All @@ -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,
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Uc1541.rm refactored with the following changes:


def copyin(self, dst, src):
"""
Expand Down Expand Up @@ -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--'
Comment on lines -554 to +551

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Uc1541._get_dir refactored with the following changes:


directory.append({'pattern_name': pattern_name,
'display_name': display_name,
Expand All @@ -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
Comment on lines -569 to +566

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Uc1541._show_error refactored with the following changes:


def _call_command(self, cmd, src=None, dst=None):
"""
Expand All @@ -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']
Comment on lines -582 to +583

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Uc1541._call_command refactored with the following changes:

This removes the following comments ( why? ):

# universal_newlines...
# error...therefore for those commands let's not use
# confuses Python3 beneath MC and as a consequence MC report an
# For some reason using write and delete commands and reading output

self.out, self.err = Popen(command,
universal_newlines=universal_newlines,
stdout=PIPE, stderr=PIPE).communicate()
Expand Down