1
0
mirror of https://github.com/gryf/uc1541.git synced 2026-01-15 23:14:10 +01:00

Drop Python2 support.

Starting from beginning of 2020 Python 2.7 is no longer supported[1],
hence the change of shebang for uc1541 script and removal of _ord
function.

[1] https://devguide.python.org/versions/
This commit is contained in:
2023-10-04 15:23:22 +02:00
parent 60dfd1f687
commit 6f359f7191
2 changed files with 13 additions and 24 deletions

View File

@@ -57,7 +57,7 @@ file.
Rquirements
===========
* Python 2.7 or Python 3.6 or higher
* Python 3.6 or higher (checked recently with 3.11)
* Vice installation (c1541 program in path)
Installation
@@ -87,6 +87,7 @@ script behaviour:
Changelog
=========
* **3.5** Drop Python2 support.
* **3.4** Code cleanup. Removed dummy logger class and sys.args based argument
parsing.
* **3.3** Added support for .d71 and .d81 disk images.

34
uc1541
View File

@@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
UC1541 Virtual filesystem
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
Date: 2020-06-28
Version: 3.4
Date: 2023-10-04
Version: 3.5
Licence: BSD
source: https://bitbucket.org/gryf/uc1541
mirror: https://github.com/gryf/uc1541
@@ -32,18 +32,6 @@ if os.getenv('UC1541_DEBUG'):
SECLEN = 256
def _ord(string_or_int):
"""
Return an int value for the (possible) string passed in argument. This
function is for compatibility between python2 and python3, where single
element in byte string array is a string or an int respectively.
"""
try:
return ord(string_or_int)
except TypeError:
return string_or_int
def _get_raw(dimage):
"""
Try to get contents of the D64 image either it's gzip compressed or not.
@@ -137,10 +125,10 @@ class Disk(object):
filename = list()
for chr_ in string:
if _ord(chr_) == 160: # shift+space character; $a0
if chr_ == 160: # shift+space character; $a0
break
character = D64.CHAR_MAP.get(_ord(chr_), '?')
character = D64.CHAR_MAP.get(chr_, '?')
filename.append(character)
# special cases
@@ -181,8 +169,8 @@ class Disk(object):
if not self.current_sector_data:
return False
self.next_track = _ord(self.current_sector_data[0])
self.next_sector = _ord(self.current_sector_data[1])
self.next_track = self.current_sector_data[0]
self.next_sector = self.current_sector_data[1]
if (self.next_track, self.next_sector) in self._already_done:
# Just a failsafe. Endless loop is not what is expected.
@@ -216,7 +204,7 @@ class Disk(object):
sector = self.current_sector_data
for dummy in range(8):
entry = sector[:32]
ftype = _ord(entry[2])
ftype = entry[2]
if ftype == 0: # deleted
sector = sector[32:]
@@ -224,12 +212,12 @@ class Disk(object):
type_verbose = self._get_ftype(ftype)
protect = _ord(entry[2]) & 64 and "<" or " "
protect = entry[2] & 64 and "<" or " "
fname = entry[5:21]
if ftype == 'rel':
size = _ord(entry[23])
size = entry[23]
else:
size = _ord(entry[30]) + _ord(entry[31]) * 226
size = entry[30] + entry[31] * 226
self._dir_contents.append({'fname': self._map_filename(fname),
'ftype': type_verbose,