Skip to content

Commit

Permalink
wvdutil.py tweaks
Browse files Browse the repository at this point in the history
Fixes after running with latest type checker.

Update version from 1.6 to 1.7.
  • Loading branch information
jtbattle committed Jan 4, 2020
1 parent 56343fa commit 9373ee2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/UiMyAboutDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ MyAboutDlg::MyAboutDlg(wxWindow *parent) :

MyStaticText *version = new MyStaticText(this, wxID_ANY,
"Wang 2200 Emulator\n"
"Version 3.0-pre; December 26, 2019");
"Version 3.0; January 4, 2020");
wxFont bold_font(*wxNORMAL_FONT);
bold_font.SetPointSize(bold_font.GetPointSize() + 2);
bold_font.SetWeight(wxFONTWEIGHT_BOLD);
Expand Down
11 changes: 5 additions & 6 deletions wvdutil/wvdHandler_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,11 @@ def prettyprint(origline, width=80, basic2=True):
if len(newline) <= width:
listing.append(newline)
break
listing.append(newline[0:width])
if width > 6:
newline = " " + newline[width:]
else:
listing.append(newline[0:width])
if width > 6:
newline = " " + newline[width:]
else:
newline = newline[width:]
newline = newline[width:]

line = line[stmt_end:] # remainder of line
if line != '':
Expand Down Expand Up @@ -594,7 +593,7 @@ def checkBodyRecord(self, sec, blk, terminator_byte):
state = seek_cr
continue

elif state == seek_cr:
if state == seek_cr:
# looking for the end of line
if blk[cp] != 0x0D:
cp = cp+1
Expand Down
2 changes: 1 addition & 1 deletion wvdutil/wvdHandler_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def checkBlocks(self, blocks, options):
if (blk[0] & 0xa0) == 0xa0:
state = 2
break
elif (blk[0] == 0x81) and (blk[1] == 0x01):
if (blk[0] == 0x81) and (blk[1] == 0x01):
# this is a single sector record
state = 0
elif (blk[0] == 0x82) and (blk[1] == 0x01):
Expand Down
19 changes: 10 additions & 9 deletions wvdutil/wvdHandler_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def nameLong():
# it returns a tuple (str, str), with the first str being the filename
# if found, otherwise empty. if the filename was found, the second string
# classifies it as 'type1' or 'type2'.
def getFilename(self, blk):
# type: bytearray -> bytearray
@staticmethod
def getFilename(blk):
# type: (bytearray) -> Tuple[str, str]
# the first string contains magic bytes, the filename, and date
line0 = blk[3+0*63:2+1*63]
type1 = (line0[0] == 0x02) and (line0[1] == 0x01) and \
Expand Down Expand Up @@ -118,10 +119,10 @@ def checkBlocks(self, blocks, options):
break

# first block should contain the filename
if (offset == 0):
if (blk[3:11] == '*FILE = '):
if offset == 0:
if blk[3:11] == '*FILE = ':
ftype = 'type2'
elif (blk[6:13] == 'FILE = '):
elif blk[6:13] == 'FILE = ':
ftype = 'type1'
else:
ftype = ''
Expand All @@ -136,8 +137,8 @@ def checkBlocks(self, blocks, options):

if offset == 0:
# the first string contains magic bytes, the filename, and date
(filename, ftype) = self.getFilename(blk)
if (ftype == 'none'):
(_, ftype) = self.getFilename(blk)
if ftype == 'none':
self.error(sec, "sector %d: first line didn't contain the filename" % sec)
break
# TODO: check the date format?
Expand Down Expand Up @@ -187,7 +188,7 @@ def listBlocks(self, blocks, options):
# that is what the EDIT program does.
(filename, ftype) = self.getFilename(secData)
if ftype == 'none':
self.error(sec, "sector %d: first line didn't contain the filename" % sec)
print("sector 0: first line didn't contain the filename")
break
if ftype == 'type1' and (line0[2] not in range(0x16,0x1b)):
print("relative sector 0: ",
Expand Down Expand Up @@ -236,7 +237,7 @@ def listBlocks(self, blocks, options):
curline += chr(byt)
else:
curline += "\\x%02x" % byt
if (ftype == 'type2'):
if ftype == 'type2':
listing.append(curline.rstrip())
curline = ''

Expand Down
2 changes: 1 addition & 1 deletion wvdutil/wvdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def read(self, filename):
if self.head_dat[0:5] != b'WANG\x00':
print('File is not a .wvd type')
raise IOError
self.sector = [] # type: List[bytearray]
self.sector = []
for i in range(self.numPlatters() * self.numSectors()):
self.sector.append(fdata[256*(i+1) : 256*(i+2)])
i = i+1
Expand Down
4 changes: 3 additions & 1 deletion wvdutil/wvdutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# fixed a number of crash scenarios, including using "| more" with py3
# significant code restructuring
# pylint cleanups
# Version: 1.7, 2020/01/04, JTB
# enhance 'edit' file handler to recognize a second format for such files

########################################################################
# there are any number of operations that could be provided by this
Expand Down Expand Up @@ -2134,7 +2136,7 @@ def mainloop():
command(wvd, commandStr)
return

print(basename + ', version 1.6, 2018/09/15')
print(basename + ', version 1.7, 2020/01/04')
print('Type "help" to see all commands')

# accept command lines from user interactively
Expand Down

0 comments on commit 9373ee2

Please sign in to comment.