mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-12-28 15:29:33 +00:00
PEP8 whitespace fixes
This commit is contained in:
parent
6f29e6053a
commit
c897460df0
@ -45,6 +45,7 @@ def process(image, dirent, options):
|
||||
else:
|
||||
print dirent
|
||||
|
||||
|
||||
def find_diskimage(filename):
|
||||
try:
|
||||
with open(filename, "rb") as fh:
|
||||
@ -72,6 +73,7 @@ def find_diskimage(filename):
|
||||
parser.image.ext = ""
|
||||
return parser
|
||||
|
||||
|
||||
def extract_files(image, files):
|
||||
for name in files:
|
||||
try:
|
||||
@ -85,6 +87,7 @@ def extract_files(image, files):
|
||||
with open(dirent.filename, "wb") as fh:
|
||||
fh.write(data)
|
||||
|
||||
|
||||
def save_file(image, name, filetype, data):
|
||||
try:
|
||||
dirent = image.find_dirent(name)
|
||||
@ -114,6 +117,7 @@ def add_files(image, files):
|
||||
if changed:
|
||||
image.save()
|
||||
|
||||
|
||||
def remove_files(image, files):
|
||||
changed = False
|
||||
for name in files:
|
||||
@ -129,6 +133,7 @@ def remove_files(image, files):
|
||||
if changed:
|
||||
image.save()
|
||||
|
||||
|
||||
def list_files(image, files):
|
||||
files = set(files)
|
||||
for dirent in image.files:
|
||||
@ -137,6 +142,7 @@ def list_files(image, files):
|
||||
if options.metadata:
|
||||
print dirent.extra_metadata(image)
|
||||
|
||||
|
||||
def assemble(image, source_files, data_files):
|
||||
if source_files:
|
||||
try:
|
||||
@ -170,6 +176,7 @@ def assemble(image, source_files, data_files):
|
||||
if changed:
|
||||
image.save()
|
||||
|
||||
|
||||
def shred_image(image, value=0):
|
||||
print "shredding: free sectors from %s filled with %d" % (image, value)
|
||||
if not options.dry_run:
|
||||
|
@ -256,6 +256,7 @@ class AtariDosFile(object):
|
||||
|
||||
Ref: http://www.atarimax.com/jindroush.atari.org/afmtexe.html
|
||||
"""
|
||||
|
||||
def __init__(self, rawdata):
|
||||
self.rawdata = rawdata
|
||||
self.size = len(rawdata)
|
||||
@ -746,6 +747,7 @@ def get_xex(segments, runaddr=None):
|
||||
i += len(s)
|
||||
return bytes
|
||||
|
||||
|
||||
def add_atr_header(bytes):
|
||||
header = AtrHeader(create=True)
|
||||
header.check_size(len(bytes))
|
||||
|
@ -95,6 +95,7 @@ known_cart_types = [
|
||||
|
||||
known_cart_type_map = {c[0]:i for i, c in enumerate(known_cart_types)}
|
||||
|
||||
|
||||
def get_known_carts():
|
||||
grouped = defaultdict(list)
|
||||
for c in known_cart_types[1:]:
|
||||
@ -102,6 +103,7 @@ def get_known_carts():
|
||||
grouped[size].append(c)
|
||||
return grouped
|
||||
|
||||
|
||||
def get_cart(cart_type):
|
||||
try:
|
||||
return known_cart_types[known_cart_type_map[cart_type]]
|
||||
|
@ -605,10 +605,6 @@ class Dos33DiskImage(DiskImageBase):
|
||||
return image, 'B'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ProdosHeader(Dos33Header):
|
||||
file_format = "ProDOS"
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
class AtrError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidAtrHeader(AtrError):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidCartHeader(AtrError):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidDiskImage(AtrError):
|
||||
""" Disk image is not recognized by a parser.
|
||||
|
||||
@ -15,6 +18,7 @@ class InvalidDiskImage(AtrError):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class UnsupportedDiskImage(AtrError):
|
||||
""" Disk image is recognized by a parser but it isn't supported yet.
|
||||
|
||||
@ -22,32 +26,42 @@ class UnsupportedDiskImage(AtrError):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class InvalidDirent(AtrError):
|
||||
pass
|
||||
|
||||
|
||||
class LastDirent(AtrError):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidFile(AtrError):
|
||||
pass
|
||||
|
||||
|
||||
class FileNumberMismatchError164(InvalidFile):
|
||||
pass
|
||||
|
||||
|
||||
class ByteNotInFile166(InvalidFile):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidBinaryFile(InvalidFile):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidSegmentParser(AtrError):
|
||||
pass
|
||||
|
||||
|
||||
class NoSpaceInDirectory(AtrError):
|
||||
pass
|
||||
|
||||
|
||||
class NotEnoughSpaceOnDisk(AtrError):
|
||||
pass
|
||||
|
||||
|
||||
class FileNotFound(AtrError):
|
||||
pass
|
||||
|
@ -57,8 +57,10 @@ class KBootImage(AtariDosDiskImage):
|
||||
raw = self.rawdata[start:end]
|
||||
return XexSegment(raw, 0, 0, start, end, name="KBoot Executable")
|
||||
|
||||
|
||||
xexboot_header = '\x00\x03\x00\x07\r\x07L\r\x07\x1c[\x00\x00\xa0\x00\x8c\t\x03\x8c\x04\x03\x8cD\x02\x8c\xe2\x02\x8c\xe3\x02\xc8\x84\t\x8c\x01\x03\xce\x06\x03\xa91\x8d\x00\x03\xa9R\x8d\x02\x03\xa9\x80\x8d\x08\x03\xa9\x01\x8d\x05\x03\xa9\xe3\x8d0\x02\x8d\x02\xd4\xa9\x07\x8d1\x02\x8d\x03\xd4\xa9\x00\xaa\x8d\x0b\x03\xa9\x04\x8d\n\x03 \xbc\x07\xca \xa5\x07\x85C \xa5\x07\x85D%C\xc9\xff\xf0\xf0 \xa5\x07\x85E \xa5\x07\x85F \xa5\x07\x91C\xe6C\xd0\x02\xe6D\xa5E\xc5C\xa5F\xe5D\xb0\xeb\xad\xe2\x02\r\xe3\x02\xf0\xc9\x86\x19 \xa2\x07\xa6\x19\xa0\x00\x8c\xe2\x02\x8c\xe3\x02\xf0\xb8l\xe2\x02\xad\t\x07\xd0\x0b\xad\n\x07\xd0\x03l\xe0\x02\xce\n\x07\xce\t\x07\xe0\x80\x90"\xa9@\x8d\x03\x03 Y\xe4\x10\x06\xce\x01\x07\xd0\xf1\x00\xee\n\x03\xd0\x03\xee\x0b\x03\xad\n\x03\x8d\x19\xd0\xa0\x00\xa2\x00\xbd\x00\x01\xe8`pppppF\xf8\x07p\x07ppp\x06p\x06p\x06A\xe3\x07\x00\x00\x00\x00\x00,/!$).\'\x0e\x0e\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&2/-'
|
||||
|
||||
|
||||
def insert_string(data, offset, string, color):
|
||||
s = np.fromstring(string.upper(), dtype=np.uint8) - 32 # convert to internal
|
||||
s = s | color
|
||||
@ -66,6 +68,7 @@ def insert_string(data, offset, string, color):
|
||||
tx = offset + (20 - count)/ 2
|
||||
data[tx:tx+count] = s
|
||||
|
||||
|
||||
def add_xexboot_header(bytes, bootcode=None, title="DEMO", author="an atari user"):
|
||||
sec_size = 128
|
||||
xex_size = len(bytes)
|
||||
|
@ -122,6 +122,7 @@ def guess_parser_for_mime(mime, r, verbose=False):
|
||||
pass
|
||||
return found
|
||||
|
||||
|
||||
def guess_parser_for_system(mime_base, r):
|
||||
for mime in mime_parse_order:
|
||||
if mime.startswith(mime_base):
|
||||
@ -130,6 +131,7 @@ def guess_parser_for_system(mime_base, r):
|
||||
return mime, p
|
||||
return None, None
|
||||
|
||||
|
||||
def iter_parsers(r):
|
||||
for mime in mime_parse_order:
|
||||
p = guess_parser_for_mime(mime, r)
|
||||
@ -197,6 +199,7 @@ known_segment_parsers = [DefaultSegmentParser]
|
||||
for mime in mime_parse_order:
|
||||
known_segment_parsers.extend(mime_parsers[mime])
|
||||
|
||||
|
||||
def iter_known_segment_parsers():
|
||||
yield "application/octet-stream", "", [DefaultSegmentParser]
|
||||
for mime in mime_parse_order:
|
||||
|
@ -16,6 +16,7 @@ match_bit_mask = 0x20
|
||||
comment_bit_mask = 0x40
|
||||
selected_bit_mask = 0x80
|
||||
|
||||
|
||||
def get_style_bits(match=False, comment=False, selected=False, data=False, diff=False, user=0):
|
||||
""" Return an int value that contains the specified style bits set.
|
||||
|
||||
@ -41,6 +42,7 @@ def get_style_bits(match=False, comment=False, selected=False, data=False, diff=
|
||||
style_bits |= selected_bit_mask
|
||||
return style_bits
|
||||
|
||||
|
||||
def get_style_mask(**kwargs):
|
||||
"""Get the bit mask that, when anded with data, will turn off the
|
||||
selected bits
|
||||
@ -70,6 +72,7 @@ class OrderWrapper(object):
|
||||
intermediate layer is needed that defines the __setitem__ method that
|
||||
explicitly references the byte ordering in the data array.
|
||||
"""
|
||||
|
||||
def __init__(self, data, byte_order):
|
||||
self.np_data = data
|
||||
self.base = data.base # base array for numpy bounds determination
|
||||
@ -109,6 +112,7 @@ class OrderWrapper(object):
|
||||
def tostring(self):
|
||||
return self.np_data[self.order].tostring()
|
||||
|
||||
|
||||
class UserExtraData(object):
|
||||
def __init__(self):
|
||||
self.comments = dict()
|
||||
@ -492,7 +496,6 @@ class DefaultSegment(object):
|
||||
if slot in e:
|
||||
self.set_style_ranges(e[slot], user=i)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
if self.start_addr > 0:
|
||||
origin = " @ %04x" % (self.start_addr)
|
||||
@ -1055,6 +1058,7 @@ class RawTrackSectorSegment(RawSectorsSegment):
|
||||
return "t%02ds%02d:%02x" % (t, s, byte)
|
||||
return "t%02ds%02d:%02X" % (t, s, byte)
|
||||
|
||||
|
||||
def interleave_indexes(segments, num_bytes):
|
||||
num_segments = len(segments)
|
||||
size = len(segments[0])
|
||||
@ -1074,6 +1078,7 @@ def interleave_indexes(segments, num_bytes):
|
||||
start += 1
|
||||
return interleave
|
||||
|
||||
|
||||
def interleave_segments(segments, num_bytes):
|
||||
new_index = interleave_indexes(segments, num_bytes)
|
||||
data_base, style_base = segments[0].rawdata.get_bases()
|
||||
|
@ -137,6 +137,7 @@ class Dirent(object):
|
||||
"""Abstract base class for a directory entry
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, file_num=0):
|
||||
self.file_num = file_num
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user