From d4e5d0a016e9db949336d4329beb8de8daf00d4f Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Sun, 9 Jul 2023 20:41:14 +0200 Subject: [PATCH] Fixing all linter errors Using flake8 --- gui.py | 73 +++++----- guires.py | 366 +++++++++++++++++++++++++++------------------------ lzari.py | 74 +++++------ mymc.py | 92 +++++++------ ps2mc.py | 267 +++++++++++++++++++++---------------- ps2mc_ecc.py | 14 +- ps2save.py | 44 ++++--- sjistab.py | 1 + 8 files changed, 501 insertions(+), 430 deletions(-) diff --git a/gui.py b/gui.py index 276aca4..7b3d04e 100755 --- a/gui.py +++ b/gui.py @@ -12,11 +12,11 @@ import ps2mc import wx from functools import partial -import time from io import BytesIO import struct import sys import os + _SCCS_ID = "@(#) mymc gui.py 1.9 23/07/06 19:35:21\n" @@ -26,15 +26,15 @@ try: - import ctypes + import ctypes # noqa: F401 import mymcicon D3DXVECTOR3 = mymcicon.D3DXVECTOR3 D3DXVECTOR4 = mymcicon.D3DXVECTOR4 D3DXVECTOR4_ARRAY3 = mymcicon.D3DXVECTOR4_ARRAY3 - def mkvec4arr3(l): + def mkvec4arr3(length): return D3DXVECTOR4_ARRAY3(*[D3DXVECTOR4(*vec) - for vec in l]) + for vec in length]) except ImportError: mymcicon = None @@ -172,7 +172,7 @@ def _update_dirtable(self, mc, dir): continue dirname = "/" + ent[8] s = mc.get_icon_sys(dirname) - if s == None: + if s is None: continue a = ps2save.unpack_icon_sys(s) size = mc.dir_size(dirname) @@ -181,7 +181,7 @@ def _update_dirtable(self, mc, dir): def update_dirtable(self, mc): self.dirtable = [] - if mc == None: + if mc is None: return dir = mc.dir_open("/") try: @@ -346,7 +346,7 @@ def append_menu_options(self, win, menu): def __init__(self, parent, focus): self.failed = False wx.Window.__init__(self, parent) - if mymcicon == None: + if mymcicon is None: self.failed = True return r = mymcicon.init_icon_renderer(focus.GetHandle(), @@ -367,7 +367,7 @@ def __init__(self, parent, focus): self.Bind(wx.EVT_CONTEXT_MENU, self.evt_context_menu) def __del__(self): - if mymcicon != None: + if mymcicon is not None: mymcicon.delete_icon_renderer() def update_menu(self, menu): @@ -383,7 +383,7 @@ def load_icon(self, icon_sys, icon): if self.failed: return - if icon_sys == None or icon == None: + if icon_sys is None or icon is None: r = mymcicon.load_icon(None, 0, None, 0) else: r = mymcicon.load_icon(icon_sys, len(icon_sys), @@ -498,15 +498,15 @@ def error_box(self, msg): def mc_error(self, value, filename=None): """Display a message box for EnvironmentError exeception.""" - if filename == None: + if filename is None: filename = getattr(value, "filename") - if filename == None: + if filename is None: filename = self.mcname - if filename == None: + if filename is None: filename = "???" strerror = getattr(value, "strerror", None) - if strerror == None: + if strerror is None: strerror = "unknown error" return self.error_box(filename + ": " + strerror) @@ -518,7 +518,7 @@ def __init__(self, parent, title, mcname=None): self.icon_win = None size = (750, 350) - if mymcicon == None: + if mymcicon is None: size = (500, 350) wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=size) @@ -580,7 +580,7 @@ def __init__(self, parent, title, mcname=None): self.evt_dirlist_item_focused, self.evt_dirlist_select, self.config) - if mcname != None: + if mcname is not None: self.open_mc(mcname) else: self.refresh() @@ -590,14 +590,14 @@ def __init__(self, parent, title, mcname=None): sizer.AddSpacer(5) icon_win = None - if mymcicon != None: + if mymcicon is not None: icon_win = icon_window(panel, self) if icon_win.failed: icon_win.Destroy() icon_win = None self.icon_win = icon_win - if icon_win == None: + if icon_win is None: self.info1 = None self.info2 = None else: @@ -633,17 +633,17 @@ def __init__(self, parent, title, mcname=None): self.Show(True) - if self.mc == None: + if self.mc is None: self.evt_cmd_open() def _close_mc(self): - if self.mc != None: + if self.mc is not None: try: self.mc.close() except EnvironmentError as e: self.mc_error(e) self.mc = None - if self.f != None: + if self.f is not None: try: self.f.close() except EnvironmentError as e: @@ -661,10 +661,10 @@ def refresh(self): mc = self.mc - self.toolbar.EnableTool(self.ID_CMD_IMPORT, mc != None) + self.toolbar.EnableTool(self.ID_CMD_IMPORT, mc is not None) self.toolbar.EnableTool(self.ID_CMD_EXPORT, False) - if mc == None: + if mc is None: status = "No memory card image" else: free = mc.get_free_space() / 1024 @@ -675,7 +675,7 @@ def refresh(self): def open_mc(self, filename): self._close_mc() self.statusbar.SetStatusText("", 1) - if self.icon_win != None: + if self.icon_win is not None: self.icon_win.load_icon(None, None) f = None @@ -683,7 +683,7 @@ def open_mc(self, filename): f = open(filename, "r+b") mc = ps2mc.ps2mc(f) except EnvironmentError as e: - if f != None: + if f is not None: f.close() self.mc_error(e, filename) self.SetTitle(self.title) @@ -697,16 +697,16 @@ def open_mc(self, filename): self.refresh() def evt_menu_open(self, event): - self.import_menu_item.Enable(self.mc != None) - selected = self.mc != None and len(self.dirlist.selected) > 0 + self.import_menu_item.Enable(self.mc is not None) + selected = self.mc is not None and len(self.dirlist.selected) > 0 self.export_menu_item.Enable(selected) self.delete_menu_item.Enable(selected) self.ascii_menu_item.Check(self.config.get_ascii()) - if self.icon_win != None: + if self.icon_win is not None: self.icon_win.update_menu(self.icon_menu) def evt_dirlist_item_focused(self, event): - if self.icon_win == None: + if self.icon_win is None: return mc = self.mc @@ -732,7 +732,7 @@ def evt_dirlist_item_focused(self, event): self.icon_win.load_icon(icon_sys, icon) def evt_dirlist_select(self, event): - self.toolbar.EnableTool(self.ID_CMD_IMPORT, self.mc != None) + self.toolbar.EnableTool(self.ID_CMD_IMPORT, self.mc is not None) self.toolbar.EnableTool(self.ID_CMD_EXPORT, len(self.dirlist.selected) > 0) @@ -745,14 +745,14 @@ def evt_cmd_open(self, event=None): if fn == "": return self.open_mc(fn) - if self.mc != None: + if self.mc is not None: dirname = os.path.dirname(fn) if os.path.isabs(dirname): self.config.set_memcard_dir(dirname) def evt_cmd_export(self, event): mc = self.mc - if mc == None: + if mc is None: return selected = self.dirlist.selected @@ -851,7 +851,7 @@ def _do_import(self, fn): self.error_box(fn + ": Save file already present.") def evt_cmd_import(self, event): - if self.mc == None: + if self.mc is None: return dir = self.config.get_savefile_dir("") @@ -862,7 +862,7 @@ def evt_cmd_import(self, event): "|All files|*.*"), style=(wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_FILE_MUST_EXIST)) - if fd == None: + if fd is None: return r = fd.ShowModal() if r == wx.ID_CANCEL: @@ -876,7 +876,7 @@ def evt_cmd_import(self, event): except EnvironmentError as e: self.mc_error(e, fn) - if success != None: + if success is not None: dir = os.path.dirname(success) if os.path.isabs(dir): self.config.set_savefile_dir(dir) @@ -884,7 +884,7 @@ def evt_cmd_import(self, event): def evt_cmd_delete(self, event): mc = self.mc - if mc == None: + if mc is None: return selected = self.dirlist.selected @@ -931,7 +931,6 @@ def run(filename=None): """Display a GUI for working with memory card images.""" wx_app = wx.App() - frame = gui_frame(None, "mymc", filename) return wx_app.MainLoop() @@ -954,7 +953,7 @@ def run(filename=None): # for o in gc.garbage: # if type(o) == ps2mc.ps2mc_file: # for m in dir(o): -# if getattr(o, m) == None: +# if getattr(o, m) is None: # continue # if (m == "__del__" # or m == "__class__" diff --git a/guires.py b/guires.py index 3cf372e..e671871 100755 --- a/guires.py +++ b/guires.py @@ -2,186 +2,202 @@ resources = { "mc4.ico": base64.b64decode( - "AAABAAIAICAQAAAAAADoAgAAJgAAADAwAAEAAAAAqA4AAA4DAAAoAAAAIAAAAEAAAAABAAQAAAAA" - "AIACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAA" - "AAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - "AAAAAAAAAAcABwAAAAAAAAAAAAAAAABwAABwAAAAAAAAAAAAAAAHAAYAB3d3d3dwAAAAAAAAcABm" - "YAB3d3dwAAAAAAAABwAGZmYAB3d3AAAAAAAAAHAAZmZmYAB4iIiIiIiAAAcABmZmZgAAB/+P+q/4" - "gABwAGZmZmAAAABu7u7u6IAHAAZmZmYAAAAABu7u7u6AAABmZmZgBwcAAABu7u7ugAAG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AggABAIKAAQCDAAEAg" - "4ABAQAAAQEAgAEBAQABAQGAAQECAAEBAoABAQMAAQEDgAEBgAABAYCAAQGBAAEBgYABAYIAAQGCg" - "AEBgwABAYOAAQIAAAECAIABAgEAAQIBgAECAgABAgKAAQIDAAECA4ABAoAAAQKAgAECgQABAoGAA" - "QKCAAECgoABAoMAAQKDgAEDAAABAwCAAQMBAAEDAYABAwIAAQMCgAEDAwABAwOAAQOAAAEDgIABA" - "4EAAQOBgAEDggABA4KAAQODAAEDg4ACAAAAAgAAgAIAAQACAAGAAgACAAIAAoACAAMAAgADgAIAg" - "AACAICAAgCBAAIAgYACAIIAAgCCgAIAgwACAIOAAgEAAAIBAIACAQEAAgEBgAIBAgACAQKAAgEDA" - "AIBA4ACAYAAAgGAgAIBgQACAYGAAgGCAAIBgoACAYMAAgGDgAICAAACAgCAAgIBAAICAYACAgIAA" - "gICgAICAwACAgOAAgKAAAICgIACAoEAAgKBgAICggACAoKAAgKDAAICg4ACAwAAAgMAgAIDAQACA" - "wGAAgMCAAIDAoACAwMAAgMDgAIDgAACA4CAAgOBAAIDgYACA4IAAgOCgAIDgwACA4OAAwAAAAMAA" - "IADAAEAAwABgAMAAgADAAKAAwADAAMAA4ADAIAAAwCAgAMAgQADAIGAAwCCAAMAgoADAIMAAwCDg" - "AMBAAADAQCAAwEBAAMBAYADAQIAAwECgAMBAwADAQOAAwGAAAMBgIADAYEAAwGBgAMBggADAYKAA" - "wGDAAMBg4ADAgAAAwIAgAMCAQADAgGAAwICAAMCAoADAgMAAwIDgAMCgAADAoCAAwKBAAMCgYADA" - "oIAAwKCgAMCgwADAoOAAwMAAAMDAIADAwEAAwMBgAMDAgADAwKAA8Pv/AKSgoACAgIAAAAD/AAD/" - "AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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7oAAAAju5gAEzAAG7u7u7u6AAAAI7u5gAA" + "wAbu7u7u7ugAAACO7u5gAABu7u7u7u7oAAAAju7u5gAG7u7u7u7u6AAAAI7u7u5gbu7u7" + "u7u7ugAAACI7u7u7u7u7u7u7u6IAAAAiIiIiIiIiIiIiIiIiAAAAIiIiIiIiIiIiIiIiI" + "gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////g////wH///4AA" + "H/8AAH/+AAD//AAAAHgAAABwAAAAYAAAAGAAAABgAAAAYAAAAGAAAAB4AAAAfAAAAH4AA" + "AB+AAAAfgAAAH4AAAB+AAAAfgAAAH4AAAB+AAAAfgAAAH4AAAB+AAAAfgAAAH4AAAB///" + "///////8oAAAAMAAAAGAAAAABAAgAAAAAAIAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "gAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwADA3MAA8MqmAAAgQAAAIGAAACCAAAAgoAAAI" + "MAAACDgAABAAAAAQCAAAEBAAABAYAAAQIAAAECgAABAwAAAQOAAAGAAAABgIAAAYEAAAG" + "BgAABggAAAYKAAAGDAAABg4AAAgAAAAIAgAACAQAAAgGAAAICAAACAoAAAgMAAAIDgAAC" + "gAAAAoCAAAKBAAACgYAAAoIAAAKCgAACgwAAAoOAAAMAAAADAIAAAwEAAAMBgAADAgAAA" + "wKAAAMDAAADA4AAA4AAAAOAgAADgQAAA4GAAAOCAAADgoAAA4MAAAODgAEAAAABAACAAQ" + "ABAAEAAYABAAIAAQACgAEAAwABAAOAAQCAAAEAgIABAIEAAQCBgAEAggABAIKAAQCDAAE" + "Ag4ABAQAAAQEAgAEBAQABAQGAAQECAAEBAoABAQMAAQEDgAEBgAABAYCAAQGBAAEBgYAB" + "AYIAAQGCgAEBgwABAYOAAQIAAAECAIABAgEAAQIBgAECAgABAgKAAQIDAAECA4ABAoAAA" + "QKAgAECgQABAoGAAQKCAAECgoABAoMAAQKDgAEDAAABAwCAAQMBAAE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cAAAAAAAAAB/7+/v7+/v7+/v7+/v7+/v7+9/cAAA" + "AAAAAAAAD39/7+/v7+/v7+/v4HAAAAAAAH/v7+/v7+/v7+/v7+/v7+/v7+9/cAAAAAAAA" + "AAAD39/7+/v7+/v7+/v7+BwAAAAf+/v7+/v7+/v7+/v7+/v7+/v7+9/cAAAAAAAAAAAD3" + "9/7+/v7+/v7+/v7+/gcAB/7+/v7+/v7+/v7+/v7+/v7+/v7+9/cAAAAAAAAAAAD39/7+/" + "v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+9/cAAAAAAAAAAAD39/f+/v7+/v" + "7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v739/cAAAAAAAAAAAD3+/v79/f39/f39/f" + "39/f39/f39/f39/f39/f39/f39/f39/f39/cAAAAAAAAAAAD30NDQ9/f39/f39/f39/f3" + "9/f39/f39/f39/f39/f396SkpKSk9/cAAAAAAAAAAAD3+ff59/f39/f39/f39/f39/f39" + "/f39/f39/f39/f39/f39/f39/cAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAP///////wAA////////AAD//h////8AAP/8D////wAA//gP////AAD/8" + "Af///8AAP/gAAAP/wAA/8AAAD//AAD/gAAB//8AAP8AAAH//wAA/gAAAAADAAD8AAAAAA" + "MAAPgAAAAAAwAA8AAAAAADAADgAAAAAAMAAMAAAAAAAwAAgAAAAAADAACAAAAAAAMAAIA" + "AAAAAAwAAgAAAAAADAADAAAAAAAMAAPAAAAAAAwAA+AAAAAADAAD8AAAAAAMAAP4AAAAA" + "AwAA/gAAAAADAAD+AAAAAAMAAP4AAAAAAwAA/gAAAAADAAD+A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AAAAAAAAAAAAAAAAA" - "AAAAAAAAAAAAAAD///////////////////////8H///+B////AP///gB///QAH//wAA//8AAH/+A" - "AA+AAAAHgAAAA4AAAAGAAAAAgAAAAIAAAACAAAAAgAAAAP/AAAH/wAAD/8wAB//eAA///wAf//+A" - "P///wH///+D////x/////////////////w==" + "AAABAAEAICAQAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP" + "8AAAD//wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAA" + "AAAAAAAABwAAAAAAAAAAAAAAAAAAAHAAYAAAAAAAAAAAAAAAAAcABmYAAAAAAAAAAAAAA" + "KBwAGZmYABwAAAAAAAAAACqAAZmZmYABwAAAAAAAAAAqqBmZmZgAABwAAAAAAAAB6qqZm" + "ZmAAAABwAACqqqqqqiqqZmYAAAAABwAAqqqqqqoiqqZgBwcAAABwAKoiIiIiIiqqAHBwA" + "AAABwCqIiIiIiIiqqcHBwAAAABwqiIiIiIiIqqgcHBwAAAAAKoiIiIiIiqqBwcHAABAAA" + "CqqqqqqiKqoHB3cAAEAAAAqqqqqqoqqgAAB3AAwAAAcAAAAAAKqqAAAAAABAAABwAAAAA" + "ACqpwAAAAAMAHAHAAAAAAAAqgBwAAAAAAdwcAAAAAAAAKAABwAAxAAABwAAAAAAAAAAAA" + "BwAEzAAHAAAAAAAAAAAAAABwAAwAcAAAAAAAAAAAAAAABwAABwAAAAAAAAAAAAAAAABwA" + "HAAAAAAAAAAAAAAAAAABwcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAD///////////////////////8H///+B////AP///gB///QA" + "H//wAA//8AAH/+AAA+AAAAHgAAAA4AAAAGAAAAAgAAAAIAAAACAAAAAgAAAAP/AAAH/wA" + "AD/8wAB//eAA///wAf//+AP///wH///+D////x/////////////////w==" ), "mc2.ico": base64.b64decode( - "AAABAAEAMDAAAQAAAACoDgAAFgAAACgAAAAwAAAAYAAAAAEACAAAAAAAgAoAAAAAAAAAAAAAAAAA" - "AAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYAACBAAAAgYAAAIIAA" - "ACCgAAAgwAAAIOAAAEAAAABAIAAAQEAAAEBgAABAgAAAQKAAAEDAAABA4AAAYAAAAGAgAABgQAAA" - "YGAAAGCAAABgoAAAYMAAAGDgAACAAAAAgCAAAIBAAACAYAAAgIAAAICgAACAwAAAgOAAAKAAAACg" - "IAAAoEAAAKBgAACggAAAoKAAAKDAAACg4AAAwAAAAMAgAADAQAAAwGAAAMCAAADAoAAAwMAAAMDg" - "AADgAAAA4CAAAOBAAADgYAAA4IAAAOCgAADgwAAA4OAAQAAAAEAAIABAAEAAQABgAEAAgABAAKAA" - "QADAAEAA4ABAIAAAQCAgAEAgQABAIGAAQCCAAEAgoABAIMAAQCDgAEBAAABAQCAAQEBAAEBAYABA" - "QIAAQECgAEBAwABAQOAAQGAAAEBgIABAYEAAQGBgAEBggABAYKAAQGDAAEBg4ABAgAAAQIAgAECA" - "QABAgGAAQICAAECAoABAgMAAQIDgAECgAABAoCAAQKBAAECgYABAoIAAQKCgAECgwABAoOAAQMAA" - "AEDAIABAwEAAQMBgAEDAgABAwKAAQMDAAEDA4ABA4AAAQOAgAEDgQABA4GAAQOCAAEDgoABA4MAA" - "QODgAIAAAACAACAAgABAAIAAYACAAIAAgACgAIAAwACAAOAAgCAAAIAgIACAIEAAgCBgAIAggACA" - "IKAAgCDAAIAg4ACAQAAAgEAgAIBAQACAQGAAgECAAIBAoACAQMAAgEDgAIBgAACAYCAAgGBAAIBg" - "YACAYIA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AAAAAAD39/ekpKSkpPf396SkpKSkpKSkAAAAAAAAAAAAAKSkpKSkpKSk" - "9/f39/f39wAAAPf39/ekpKSkpPf396SkpKSkpKSkAAAAAAAAAAAAAKSkpKSkpKSk9/f39/f39/cA" - "9/f39/ekpKSkpPf396SkpKSkpKSkAAAAAAAAAAAAAKSkpKSkpKSk9/f39/f39/f39/f39/ekpKSk" - "pPf396SkpKSkpKSkAAAAAAAAAAAAAKSkpKSkpKSk9/f39/f39/f39/f39/ekpKSkpPf396SkpKSk" - "pKQAAAAAAAAAAAAAAKSkpKSkpKSk9/f39/f39/f39/f39/ekpKSkpPf396SkpKSkpAAA9gAAAAAA" - "AAAAAACkpKSkpKSk9/f39/f39/f39/f39/f39/f39/f396SkpKSkAAAAAAAAAAAAAAAAAAAAAAAA" - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////AAD///////8AAP///////wAA////////" - "AAD//w////8AAP8AAAAADwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcA" - "AP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAPwAAAAABwAA+AAAAAAHAADwAAAAAAcAAOAAAAAABwAA" - "wAAAAAAHAADAAAAAAAcAAMAAAAAABwAAwAAAAAAHAADgAAAAAAcAAPgAAAAABwAA/AAAAAAHAAD+" - "AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAP4A" - "AAAABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAA" - "AAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAA8AAP4AAAAAGwAA/wAAAAA/AAD/////" - "//sAAP///////wAA" + "AAABAAEAMDAAAQAAAACoDgAAFgAAACgAAAAwAAAAYAAAAAEACAAAAAAAgAoAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYAAC" + "BAAAAgYAAAIIAAACCgAAAgwAAAIOAAAEAAAABAIAAAQEAAAEBgAABAgAAAQKAAAEDAAAB" + "A4AAAYAAAAGAgAABgQAAAYGAAAGCAAABgoAAAYMAAAGDgAACAAAAAgCAAAIBAAACAYAAA" + "gIAAAICgAACAwAAAgOAAAKAAAACgIAAAoEAAAKBgAACggAAAoKAAAKDAAACg4AAAwAAAA" + "MAgAADAQAAAwGAAAMCAAADAoAAAwMAAAMDgAADgAAAA4CAAAOBAAADgYAAA4IAAAOCgAA" + "DgwAAA4OAAQAAAAEAAIABAAEAAQABgAEAAgABAAKAAQADAAEAA4ABAIAAAQCAgAEAgQAB" + "AIGAAQCCAAEAgoABAIMAAQCDgAEBAAABAQCAAQEBAAEBAYABAQIAAQECgAEBAwABAQOAA" + "QGAAAEBgIABAYEAAQGBgAEBggABAYKAAQGDAAEBg4ABAgAAAQIAgAECAQABAgGAAQICAA" + "ECAoABAgMAAQIDgAECgAABAoCAAQKBAAECgYABAoIAAQKCgAECgwABAoOAAQMAAAEDAIA" + "BAwEAAQMBgAEDAgABAwKAAQMDAAEDA4ABA4AAAQOAgAEDgQABA4GAAQOCAAEDgoABA4MA" + "AQODgAIAAAACAACAAgABAAIAAYACAAIAAgACgAIAAwACAAOAAgCAAAIAgIACAIEAAgCBg" + "AIAggACAIKAAgCDAAIAg4ACAQAAAgEAgAIBAQACAQGAAgECAAIBAoACAQMAAgEDgAIBgA" + "ACAYCAAgGBAAIBgYACAYIAAgGCgAIBgwACAYOAAgIAAAICAIACAgEAAgIBgAICAgACAgK" + "AAgIDAAICA4ACAoAAAgKAgAICgQACAoGAAgKCAAICgoACAoMAAgKDgAIDAAACAwCAAgMB" + "AAIDAYACAwIAAgMCgAIDAwACAwOAAgO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39/ekpKSkpPf396SkpKSkpKSkAAAAAAAA" + "AAAAAKSkpKSkpKSk9/f39/f39/f39/f39/ekpKSkpPf396SkpKSkpKSkAAAAAAAAAAAAA" + "KSkpKSkpKSk9/f39/f39/f39/f39/ekpKSkpPf396SkpKSkpKQAAAAAAAAAAAAAAKSkpK" + "SkpKSk9/f39/f39/f39/f39/ekpKSkpPf396SkpKSkpAAA9gAAAAAAAAAAAACkpKSkpKS" + "k9/f39/f39/f39/f39/f39/f39/f396SkpKSkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////AAD///////8AAP///////wAA//" + "//////AAD//w////8AAP8AAAAADwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAA" + "HAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAPwAAAAABwAA+AAAAAAHAADw" + "AAAAAAcAAOAAAAAABwAAwAAAAAAHAADAAAAAAAcAAMAAAAAABwAAwAAAAAAHAADgAAAAA" + "AcAAPgAAAAABwAA/AAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAP" + "4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAA" + "ABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA" + "/gAAAAAHAAD+AAAAAA8AAP4AAAAAGwAA/wAAAAA/AAD///////sAAP///////wAA" ), "mc6a.ico": base64.b64decode( - "AAABAAEAICAQAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAA" - "AAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA" - "/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAcABg" - "AAAAAAAAAAAAAAAABwAGZgAAAAAAAAAAAAAAAHAAZmZgAHAAAACgAAAAAAcABmZmZgAHAAAAqgAA" - "AABwAGZmZmAAAHAAAKqgAAAHAAZmZmYAAAAHAACqqgAAcABmZmZgAAqqqqqqoqqgAAAGZmZmAHB6" - "qqqqqqIqqgAAZmZmYAcHCqIiIiIiIqqgAAZmZgBwcHqiIiIiIiIqqnAAZmAHBwcKoiIiIiIiKqoA" - "AAYAAHBweqIiIiIiIqqgAAAAAAcHdwqqqqqqoiqqAAAAAAAAAHcKqqqqqqKqoAAAAHAAAAAAAEAA" - "AHCqqgAAAAAHAAAAAAwAcAcAqqAAAAAAAHAAAAAAB3BwAKoAAAAAAAAHAADEAAAHAACgAAAAAAAA" - "AHAATMAAcAAAAAAAAAAAAAAHAADABwAAAAAAAAAAAAAAAHAAAHAAAAAAAAAAAAAAAAAHAAcAAAAA" - "AAAAAAAAAAAAAHBwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - "AAAAAAAAAAAAAAD//////////////////////wf///4H///8A///+AH///AAf3/gAD8/wAAfH4AA" - "Dw8AAAAHAAAAAwAAAAEAAAAAAAAAAMAAAAHgAAAD8AAAB/AAAQ/4AAMf/AAHP/4AD3//AB///4A/" - "///Af///4P////H//////////////////w==" + "AAABAAEAICAQAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP" + "8AAAD//wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAA" + "AAAHAAAAAAAAAAAAAAAAAAAAcABgAAAAAAAAAAAAAAAABwAGZgAAAAAAAAAAAAAAAHAAZ" + "mZgAHAAAACgAAAAAAcABmZmZgAHAAAAqgAAAABwAGZmZmAAAHAAAKqgAAAHAAZmZmYAAA" + "AHAACqqgAAcABmZmZgAAqqqqqqoqqgAAAGZmZmAHB6qqqqqqIqqgAAZmZmYAcHCqIiIiI" + "iIqqgAAZmZgBwcHqiIiIiIiIqqnAAZmAHBwcKoiIiIiIiKqoAAAYAAHBweqIiIiIiIqqg" + "AAAAAAcHdwqqqqqqoiqqAAAAAAAAAHcKqqqqqqKqoAAAAHAAAAAAAEAAAHCqqgAAAAAHA" + "AAAAAwAcAcAqqAAAAAAAHAAAAAAB3BwAKoAAAAAAAAHAADEAAAHAACgAAAAAAAAAHAATM" + "AAcAAAAAAAAAAAAAAHAADABwAAAAAAAAAAAAAAAHAAAHAAAAAAAAAAAAAAAAAHAAcAAAA" + "AAAAAAAAAAAAAAHBwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAD//////////////////////wf///4H///8A///+AH///AAf" + "3/gAD8/wAAfH4AADw8AAAAHAAAAAwAAAAEAAAAAAAAAAMAAAAHgAAAD8AAAB/AAAQ/4AA" + "Mf/AAHP/4AD3//AB///4A////Af///4P////H//////////////////w==" ), } diff --git a/lzari.py b/lzari.py index 968c80f..3e919f1 100755 --- a/lzari.py +++ b/lzari.py @@ -14,7 +14,6 @@ from math import log from bisect import bisect_right import time -import string import binascii import array import sys @@ -117,12 +116,12 @@ def _match(src, pos, hpos, mlen, end): def _rehash_table2(src, chars, head, next, next2, hist_invalid): p = head table2 = {} - l = [] + lst = [] while p > hist_invalid: - l.append(p) + lst.append(p) p = next[p % HIST_LEN] - l.reverse() - for p in l: + lst.reverse() + for p in lst: p2 = p + MIN_MATCH_LEN key2 = src[p2: p2 + chars] head2 = table2.get(key2, hist_invalid) @@ -329,7 +328,7 @@ def add_suffix_2(self, pos, find): key = src[pos: pos2] a = suffix_table.get(key) - if a != None: + if a is not None: next = self.next_table next2 = self.next2_table @@ -343,7 +342,7 @@ def add_suffix_2(self, pos, find): maxmlen = max_match - min_match2 while p > hist_invalid and mlen != maxmlen: p3 = p + min_match2 - if mpos == None and p3 <= pos: + if mpos is None and p3 <= pos: mpos = p mlen = 0 if p3 >= pos: @@ -351,11 +350,11 @@ def add_suffix_2(self, pos, find): continue rlen = _match(src, pos3, p3, mlen, min(maxmlen, pos - p3)) - if rlen != None: + if rlen is not None: mpos = p mlen = rlen p = next2[p % HIST_LEN] - if mpos != None: + if mpos is not None: mlen += min_match2 elif find: p = head @@ -367,7 +366,7 @@ def add_suffix_2(self, pos, find): i += 1 p2 = p + MIN_MATCH_LEN l2 = pos - p2 - if mpos == None and l2 >= 0: + if mpos is None and l2 >= 0: mpos = p mlen = 0 if l2 <= 0: @@ -387,12 +386,12 @@ def add_suffix_2(self, pos, find): else: mlen = l2 # rlen = _match(src, pos2, p2, mlen, l2) - # if rlen != None: + # if rlen is not None: # mpos = p # mlen = rlen p = next[p % HIST_LEN] - if mpos != None: + if mpos is not None: mlen += MIN_MATCH_LEN count += 1 @@ -439,14 +438,14 @@ def add_suffix_2(self, pos, find): if table2[key2] == p: del table2[key2] a[0] = count - assert (mpos == None + assert (mpos is None or src[pos: pos + mlen] == src[mpos: mpos + mlen]) return (mpos, mlen) def _add_suffix(self, pos, find): r = self.add_suffix_2(pos, find) start_pos = self.start_pos - if find and r[0] != None: + if find and r[0] is not None: print("%4d %02x %4d %2d" % (pos - start_pos, ord(self.src[pos]), r[0] - start_pos, r[1])) @@ -642,7 +641,7 @@ def decode(self, src, out_length, progress=None): return out.tostring() -if mymcsup == None: +if mymcsup is None: def decode(src, out_length, progress=None): return lzari_codec().decode(src, out_length, progress) @@ -666,7 +665,7 @@ def encode(src, progress=None): # print(r, compressed.value, comp_len) if r == -1: raise MemoryError("out of memory during compression") - if compressed.value == None: + if compressed.value is None: return "" ret = ctypes.string_at(compressed.value, comp_len.value) mylzari_free_encoded(compressed) @@ -701,7 +700,7 @@ def _get_hotshot_lineinfo(filename): for what, loc, tdelta in log: if what == hotshot.log.LINE: a = timings.get(loc) - if a == None: + if a is None: timings[loc] = [1, tdelta] else: a[0] += 1 @@ -711,27 +710,26 @@ def _get_hotshot_lineinfo(filename): def _dump_hotshot_lineinfo(log): a = sorted(_get_hotshot_lineinfo(log)) - total_count = sum((time[0] - for (loc, time) in a)) - total_time = sum((time[1] - for (loc, time) in a)) - for (loc, [count, time]) in a: + total_count = sum((logtime[0] for (loc, logtime) in a)) + total_time = sum((logtime[1] for (loc, logtime) in a)) + for (loc, [count, logtime]) in a: print("%8d %6.3f%% %8d %6.3f%%" - % (time, time * 100.0 / total_time, + % (logtime, logtime * 100.0 / total_time, count, count * 100.0 / total_count)), print("%s:%d(%s)" % loc) def _dump_hotshot_lineinfo2(log): cur = None + f = None a = sorted(_get_hotshot_lineinfo(log)) - total_count = sum((time[0] - for (loc, time) in a)) - total_time = sum((time[1] - for (loc, time) in a)) - for ((filename, lineno, fn), [count, time]) in a: + total_count = sum((logtime[0] + for (loc, logtime) in a)) + total_time = sum((logtime[1] + for (loc, logtime) in a)) + for ((filename, lineno, fn), [count, logtime]) in a: if cur != filename: - if cur != None and f != None: + if cur is not None and f is not None: for line in f: print(line[:-1]) f.close() @@ -740,16 +738,16 @@ def _dump_hotshot_lineinfo2(log): except OSError: f = None cur = filename - l = 0 + current_line = 0 print("#", filename) - if f != None: - while l < lineno: + if f is not None: + while current_line < lineno: print(f.readline()[:-1]) - l += 1 + current_line += 1 print("# %8d %6.3f%% %8d %6.3f%%" - % (time, time * 100.0 / total_time, + % (logtime, logtime * 100.0 / total_time, count, count * 100.0 / total_count)) - if cur != None and f != None: + if cur is not None and f is not None: for line in f: print(line[:-1]) f.close() @@ -779,12 +777,12 @@ def main(args): warnings.filterwarnings("ignore") tmp = os.tempnam() try: - l = args[1].startswith("hl") - p = hotshot.Profile(tmp, l) + hlarg = args[1].startswith("hl") + p = hotshot.Profile(tmp, hlarg) ret = p.runcall(main2, args[1:]) p.close() p = None - if l: + if hlarg: if args[1] == "hl2": _dump_hotshot_lineinfo2(tmp) else: diff --git a/mymc.py b/mymc.py index c6d3736..9ba3c59 100755 --- a/mymc.py +++ b/mymc.py @@ -7,19 +7,32 @@ """A utility for manipulating PS2 memory card images.""" -import verbuild -from round import * -from ps2mc_dir import * -import ps2save -import ps2mc from errno import EEXIST, EIO -import string -import binascii -import textwrap import optparse -import time import os +import struct import sys +import textwrap +import time + +import verbuild +from ps2mc_dir import ( + DF_EXECUTE, + DF_EXISTS, + DF_HIDDEN, + DF_POCKETSTN, + DF_PROTECTED, + DF_PSX, + DF_READ, + DF_WRITE, + mode_is_file, + mode_is_dir, + tod_to_time, + zero_terminate, +) +import ps2save +import ps2mc + _SCCS_ID = "@(#) mymc mymc.py 1.14 23/07/06 15:51:52\n"[:-1] @@ -58,7 +71,7 @@ def __setattr__(self, name, value): for name in ["stdin", "stdout", "stderr"]: f = getattr(sys, name) cur = getattr(f, "encoding", None) - if cur == "ascii" or cur == None: + if cur == "ascii" or cur is None: f = file_wrap(f, "mbcs") else: try: @@ -136,7 +149,7 @@ def do_ls(cmd, mc, opts, args, opterr): def do_add(cmd, mc, opts, args, opterr): if len(args) < 1: opterr("Filename required.") - if opts.directory != None: + if opts.directory is not None: mc.chdir(opts.directory) for src in glob_args(args, glob): f = open(src, "rb") @@ -151,15 +164,14 @@ def do_extract(cmd, mc, opts, args, opterr): if len(args) < 1: opterr("Filename required.") - if opts.directory != None: + if opts.directory is not None: mc.chdir(opts.directory) close_out = False out = None - if opts.output != None: + if opts.output is not None: if opts.use_stdout: opterr("The -o and -p options are mutually exclusive.") - dont_close_out = True out = open(opts.output, "wb") elif opts.use_stdout: out = sys.stdout @@ -168,7 +180,7 @@ def do_extract(cmd, mc, opts, args, opterr): for filename in glob_args(args, mc.glob): f = mc.open(filename, "rb") try: - if out != None: + if out is not None: _copy(out, f) continue a = filename.split("/") @@ -205,7 +217,7 @@ def do_import(cmd, mc, opts, args, opterr): opterr("Filename required.") args = glob_args(args, glob) - if opts.directory != None and len(args) > 1: + if opts.directory is not None and len(args) > 1: opterr("The -d option can only be used with a" "single savefile.") @@ -233,7 +245,7 @@ def do_import(cmd, mc, opts, args, opterr): finally: f.close() dirname = opts.directory - if dirname == None: + if dirname is None: dirname = sf.get_directory()[8] print("Importing", filename, "to", dirname) if not mc.import_save_file(sf, opts.ignore_existing, @@ -252,14 +264,14 @@ def do_export(cmd, mc, opts, args, opterr): opterr("The -i and -f options are mutually exclusive.") args = glob_args(args, mc.glob) - if opts.output_file != None: + if opts.output_file is not None: if len(args) > 1: opterr("Only one directory can be exported" " when the -o option is used.") if opts.longnames: opterr("The -o and -l options are mutually exclusive.") - if opts.directory != None: + if opts.directory is not None: os.chdir(opts.directory) for dirname in args: @@ -268,7 +280,7 @@ def do_export(cmd, mc, opts, args, opterr): if opts.longnames: filename = (ps2save.make_longname(dirname, sf) + "." + opts.type) - if filename == None: + if filename is None: filename = dirname + "." + opts.type if not opts.overwrite_existing: @@ -312,7 +324,7 @@ def do_setmode(cmd, mc, opts, args, opterr): (opts.psx, DF_PSX), (opts.pocketstation, DF_POCKETSTN), (opts.hidden, DF_HIDDEN)]: - if opt != None: + if opt is not None: if opt: set_mask |= bit else: @@ -320,20 +332,20 @@ def do_setmode(cmd, mc, opts, args, opterr): value = opts.hex_value if set_mask == 0 and clear_mask == ~0: - if value == None: + if value is None: opterr("At least one option must be given.") if value.startswith("0x") or value.startswith("0X"): value = int(value[2:], 16) else: value = int(value, 16) else: - if value != None: + if value is not None: opterr("The -X option can't be combined with" " other options.") for arg in glob_args(args, mc.glob): ent = mc.get_dirent(arg) - if value == None: + if value is None: ent[0] = (ent[0] & clear_mask) | set_mask # print("new %04x" % ent[0]) else: @@ -349,7 +361,7 @@ def do_rename(cmd, mc, opts, args, opterr): def _get_ps2_title(mc, enc): s = mc.get_icon_sys(".") - if s == None: + if s is None: return None a = ps2save.unpack_icon_sys(s) return ps2save.icon_sys_title(a, enc) @@ -357,7 +369,7 @@ def _get_ps2_title(mc, enc): def _get_psx_title(mc, savename, enc): mode = mc.get_mode(savename) - if mode == None or not mode_is_file(mode): + if mode is None or not mode_is_file(mode): return None f = mc.open(savename) s = f.read(128) @@ -387,7 +399,7 @@ def do_dir(cmd, mc, opts, args, opterr): title = _get_psx_title(mc, ent[8], enc) else: title = _get_ps2_title(mc, enc) - if title == None: + if title is None: title = ["Corrupt", ""] protection = dirmode & (DF_PROTECTED | DF_WRITE) if protection == 0: @@ -404,7 +416,7 @@ def do_dir(cmd, mc, opts, args, opterr): type = "PlayStation" if dirmode & DF_POCKETSTN: type = "PocketStation" - if type != None: + if type is not None: protection = type print("%-32s %s" % (ent[8], title[0])) @@ -412,7 +424,7 @@ def do_dir(cmd, mc, opts, args, opterr): % (length / 1024, protection, title[1])) print() finally: - if f != None: + if f is not None: f.close() dir.close() @@ -447,7 +459,7 @@ def do_format(cmd, mcname, opts, args, opterr): if len(args) != 0: opterr("Incorrect number of arguments.") pages_per_card = ps2mc.PS2MC_STANDARD_PAGES_PER_CARD - if opts.clusters != None: + if opts.clusters is not None: pages_per_cluster = (ps2mc.PS2MC_CLUSTER_SIZE / ps2mc.PS2MC_STANDARD_PAGE_SIZE) pages_per_card = opts.clusters * pages_per_cluster @@ -703,7 +715,7 @@ def do_ecc_check(cmd, mc, opts, args, opterr): def write_error(filename, msg): - if filename == None: + if filename is None: sys.stderr.write(msg + "\n") else: sys.stderr.write(filename + ": " + msg + "\n") @@ -769,7 +781,7 @@ def main(): import gui except ImportError: gui = None - if gui != None: + if gui is not None: optparser.destroy() gui.run() sys.exit(0) @@ -787,7 +799,7 @@ def main(): usage = "%prog" if len(optlist) > 0: usage += " [options]" - if usage_args != None: + if usage_args is not None: usage += " " + usage_args subprog = prog + " memcard.ps2 " + cmd subopt_parser = suboption_parser(prog=subprog, usage=usage, @@ -803,7 +815,7 @@ def main(): try: (subopts, subargs) = subopt_parser.parse_args(args[2:]) try: - if mode == None: + if mode is None: ret = fn(cmd, mcname, subopts, subargs, subopt_parser.error) else: @@ -812,17 +824,17 @@ def main(): ret = fn(cmd, mc, subopts, subargs, subopt_parser.error) finally: - if mc != None: + if mc is not None: mc.close() - if f != None: + if f is not None: # print("f.close()") f.close() except EnvironmentError as e: - if getattr(e, "filename", None) != None: + if getattr(e, "filename", None) is not None: write_error(e.filename, e.strerror) ret = 1 - elif getattr(e, "strerror", None) != None: + elif getattr(e, "strerror", None) is not None: write_error(mcname, e.strerror) ret = 1 else: @@ -836,14 +848,14 @@ def main(): except (ps2mc.error, ps2save.error) as e: fn = getattr(e, "filename", None) - if fn == None: + if fn is None: fn = mcname write_error(fn, str(e)) if opts.debug: raise ret = 1 - if ret == None: + if ret is None: ret = 0 return ret diff --git a/ps2mc.py b/ps2mc.py index a509cf9..62671d7 100755 --- a/ps2mc.py +++ b/ps2mc.py @@ -7,17 +7,48 @@ """Manipulate PS2 memory card images.""" -import ps2save -from ps2mc_dir import * -from ps2mc_ecc import * -from round import * -import traceback +import array +from errno import ( + EACCES, + ENOENT, + EEXIST, + ENOTDIR, + EISDIR, + ENOTEMPTY, + ENOSPC, + EIO, + EBUSY, + EINVAL +) import fnmatch -from errno import EACCES, ENOENT, EEXIST, ENOTDIR, EISDIR, EROFS, ENOTEMPTY,\ - ENOSPC, EIO, EBUSY, EINVAL import struct -import array import sys +import traceback + +import ps2save +from ps2mc_dir import ( + DF_0400, + DF_DIR, + DF_EXECUTE, + DF_EXISTS, + DF_FILE, + DF_HIDDEN, + DF_RWX, + DF_WRITE, + PS2MC_DIRENT_LENGTH, + mode_is_file, + mode_is_dir, + pack_dirent, + tod_now, + unpack_dirent, +) +from ps2mc_ecc import ( + ECC_CHECK_FAILED, + ecc_calculate_page, + ecc_check_page, +) +from round import div_round_up, round_up, round_down + _SCCS_ID = "@(#) mymc ps2mc.py 1.12 23/07/06 19:48:03\n" @@ -44,9 +75,9 @@ def __init__(self, *args, **kwargs): IOError.__init__(self, *args, **kwargs) def __str__(self): - if getattr(self, "strerror", None) == None: + if getattr(self, "strerror", None) is None: return str(self.args) - if getattr(self, "filename", None) != None: + if getattr(self, "filename", None) is not None: return self.filename + ": " + self.strerror return self.strerror @@ -76,7 +107,7 @@ def __init__(self, filename, index): class corrupt(io_error): def __init__(self, msg, f=None): filename = None - if f != None: + if f is not None: filename = getattr(f, "name") io_error.__init__(self, EIO, msg, filename) @@ -181,7 +212,7 @@ def add(self, key, value): i = lru_list[-1][0] elt = lru_list[i] old_key = elt[1] - if old_key != None: + if old_key is not None: del index_map[old_key] ret = (old_key, elt[2]) index_map[key] = i @@ -193,7 +224,7 @@ def add(self, key, value): def get(self, key, default=None): i = self._index_map.get(key) - if i == None: + if i is None: # print("get miss", key) return default # print("get hit ", key, i) @@ -204,7 +235,7 @@ def get(self, key, default=None): def items(self): return [(elt[1], elt[2]) for elt in self._lru_list[1: -1] - if elt[2] != None] + if elt[2] is not None] class fat_chain(object): @@ -224,7 +255,7 @@ def __getitem__(self, i): # print("@@@ fat_chain[] cur:", i, self._cur) return self._cur elif i == offset - 1: - assert self._prev != None + assert self._prev is not None # print("@@@ fat_chain[] prev:", i, self._prev) return self._prev if i < offset: @@ -287,13 +318,13 @@ def __init__(self, mc, dirloc, first_cluster, length, mode, self.buffer = None self.buffer_cluster = None self.softspace = 0 - if name == None: + if name is None: self.name = "" else: self.name = name self.closed = False - if mode == None or len(mode) == 0: + if mode is None or len(mode) == 0: mode = "rb" self.mode = mode self._append = False @@ -304,7 +335,7 @@ def __init__(self, mc, dirloc, first_cluster, length, mode, self._write = True def _find_file_cluster(self, n): - if self.fat_chain == None: + if self.fat_chain is None: self.fat_chain = self.mc.fat_chain(self.first_cluster) return self.fat_chain[n] @@ -312,7 +343,9 @@ def read_file_cluster(self, n): if n == self.buffer_cluster: return self.buffer cluster = self._find_file_cluster(n) - # print("@@@ read_file_cluster", self.dirloc, n, cluster, repr(self.name)) + # print( + # "@@@ read_file_cluster", self.dirloc, n, cluster, repr(self.name) + # ) if cluster == PS2MC_FAT_CHAIN_END: return None self.buffer = self.mc.read_allocatable_cluster(cluster) @@ -323,7 +356,7 @@ def _extend_file(self, n): mc = self.mc cluster = mc.allocate_cluster() # print("@@@ extending file", n, cluster) - if cluster == None: + if cluster is None: return None if n == 0: self.first_cluster = cluster @@ -356,7 +389,7 @@ def write_file_cluster(self, n, buf): for i in range(file_cluster_end, n): cluster = self._extend_file(i) - if cluster == None: + if cluster is None: if i != file_cluster_end: self.length = (i - 1) * cluster_size mc.update_dirent(self.dirloc, self, @@ -367,7 +400,7 @@ def write_file_cluster(self, n, buf): [b"\0"] * cluster_size) cluster = self._extend_file(n) - if cluster == None: + if cluster is None: return False mc.write_allocatable_cluster(cluster, buf) @@ -389,25 +422,25 @@ def read(self, size=None, eol=None): pos = self._pos cluster_size = self.mc.cluster_size - if size == None: + if size is None: size = self.length size = max(min(self.length - pos, size), 0) ret = b"" while size > 0: off = int(pos % cluster_size) - l = min(cluster_size - off, size) + length = min(cluster_size - off, size) buf = self.read_file_cluster(int(pos / cluster_size)) - if buf == None: + if buf is None: break - if eol != None: - i = buf.find(eol, off, off + l) + if eol is not None: + i = buf.find(eol, off, off + length) if i != -1: - l = off - i + 1 - size = l - pos += l + length = off - i + 1 + size = length + pos += length self._pos = pos - ret += buf[off: off + l] - size -= l + ret += buf[off: off + length] + size -= length return ret def write(self, out, _set_modified=True): @@ -428,16 +461,16 @@ def write(self, out, _set_modified=True): while size > 0: cluster = int(pos / cluster_size) off = int(pos % cluster_size) - l = min(cluster_size - off, size) - s = out[i: i + l] - pos += l - if l == cluster_size: + length = min(cluster_size - off, size) + s = out[i: i + length] + pos += length + if length == cluster_size: buf = s else: buf = self.read_file_cluster(cluster) - if buf == None: + if buf is None: buf = b"\0" * cluster_size - buf = buf[:off] + s + buf[off + l:] + buf = buf[:off] + s + buf[off + length:] if not self.write_file_cluster(cluster, buf): raise io_error(ENOSPC, "out of space on image", @@ -450,12 +483,12 @@ def write(self, out, _set_modified=True): self.mc.update_dirent(self.dirloc, self, None, new_length, _set_modified) - i += l - size -= l + i += length + size -= length def close(self): # print("ps2mc_file.close", self.name, self) - if self.mc != None: + if self.mc is not None: self.mc.notify_closed(self.dirloc, self) self.mc = None self.fat_chain = None @@ -500,7 +533,7 @@ def __exit__(self, a, b, c): # def __del__(self): # # print("ps2mc_file.__del__", self) - # if self.mc != None: + # if self.mc is not None: # self.mc.notify_closed(self.dirloc, self) # self.mc = None # self.fat_chain = None @@ -562,12 +595,12 @@ def __setitem__(self, index, new_ent): mode = ent[0] if (mode & DF_EXISTS) == 0: return - if new_ent[0] != None: + if new_ent[0] is not None: mode = ((new_ent[0] & ~(DF_FILE | DF_DIR | DF_EXISTS)) | (mode & (DF_FILE | DF_DIR | DF_EXISTS))) ent[0] = mode for i in [1, 3, 6, 7, 8]: # ???, created, modifed, attr - if new_ent[i] != None: + if new_ent[i] is not None: ent[i] = new_ent[i] self.write_raw_ent(index, ent, False) @@ -578,7 +611,7 @@ def close(self): def __del__(self): # print("ps2mc_directory.__del__", self) - if self.f != None: + if self.f is not None: self.f.close() self.f = None @@ -635,7 +668,7 @@ def __init__(self, f, ignore_ecc=False, params=None): s = f.read(0x154) header = PS2MC_MAGIC.encode("utf-8") if len(s) != 0x154 or not s[0:len(header)] == header: - if (params == None): + if (params is None): raise corrupt("Not a PS2 memory card image", f) self.f = f self.format(params) @@ -895,14 +928,14 @@ def write_cluster(self, n, buf): def _add_fat_cluster_to_cache(self, n, fat, dirty): old = self.fat_cache.add(n, [fat, dirty]) - if old != None: + if old is not None: (n, [fat, dirty]) = old if dirty: self.write_cluster(n, pack_fat(fat)) def _read_fat_cluster(self, n): v = self.fat_cache.get(n) - if v != None: + if v is not None: # print("@@@ fat hit", n) return v[0] # print("@@@ fat miss", n) @@ -914,7 +947,7 @@ def _write_fat_cluster(self, n, fat): self._add_fat_cluster_to_cache(n, fat, True) def flush_fat_cache(self): - if self.fat_cache == None: + if self.fat_cache is None: return for (n, v) in self.fat_cache.items(): [fat, dirty] = v @@ -924,7 +957,7 @@ def flush_fat_cache(self): def _add_alloc_cluster_to_cache(self, n, buf, dirty): old = self.alloc_cluster_cache.add(n, [buf, dirty]) - if old != None: + if old is not None: (n, [buf, dirty]) = old if dirty: n += self.allocatable_cluster_offset @@ -932,7 +965,7 @@ def _add_alloc_cluster_to_cache(self, n, buf, dirty): def read_allocatable_cluster(self, n): a = self.alloc_cluster_cache.get(n) - if a != None: + if a is not None: # print("@@@ cache hit", n) return a[0] # print("@@@ cache miss", n) @@ -944,7 +977,7 @@ def write_allocatable_cluster(self, n, buf): self._add_alloc_cluster_to_cache(n, buf, True) def flush_alloc_cluster_cache(self): - if self.alloc_cluster_cache == None: + if self.alloc_cluster_cache is None: return for (n, a) in self.alloc_cluster_cache.items(): [buf, dirty] = a @@ -1011,7 +1044,7 @@ def file(self, dirloc, first_cluster, length, mode, name=None): """Create a new file-like object for a file.""" f = ps2mc_file(self, dirloc, first_cluster, length, mode, name) - if dirloc == None: + if dirloc is None: return open_files = self.open_files if dirloc not in open_files: @@ -1031,16 +1064,16 @@ def _directory(self, dirloc, first_cluster, length, if first_cluster != 0: return self.directory(dirloc, first_cluster, length, mode, name) - if dirloc == None: + if dirloc is None: dirloc = (0, 0) assert dirloc == (0, 0) - if self.rootdir != None: + if self.rootdir is not None: return self.rootdir dir = _root_directory(self, dirloc, 0, length, "r+b", "/") - l = dir[0][2] - if l != length: + length = dir[0][2] + if length != length: dir.real_close() - dir = _root_directory(self, dirloc, 0, l, "r+b", "/") + dir = _root_directory(self, dirloc, 0, length, "r+b", "/") self.rootdir = dir return dir @@ -1080,14 +1113,14 @@ def update_dirent_all(self, dirloc, thisf, new_ent): # print("@@@ update_dirent", dirloc) # print("@@@ new_ent", new_ent) opened = self.open_files.get(dirloc, None) - if opened == None: + if opened is None: files = [] dir = None else: dir, files = opened - if dir == None: + if dir is None: dir = self._opendir_parent_dirloc(dirloc, "r+b") - if opened != None: + if opened is not None: opened[0] = dir ent = dir[dirloc[1]] @@ -1095,7 +1128,7 @@ def update_dirent_all(self, dirloc, thisf, new_ent): is_dir = ent[0] & DF_DIR - if is_dir and thisf != None and new_ent[2] != None: + if is_dir and thisf is not None and new_ent[2] is not None: new_ent = list(new_ent) new_ent[2] = int(new_ent[2] / PS2MC_DIRENT_LENGTH) @@ -1104,7 +1137,7 @@ def update_dirent_all(self, dirloc, thisf, new_ent): modified = changed = notify = False for i in range(len(ent)): new = new_ent[i] - if new != None: + if new is not None: if new != ent[i]: ent[i] = new changed = True @@ -1125,7 +1158,7 @@ def update_dirent_all(self, dirloc, thisf, new_ent): for f in files: if f != thisf: f.update_notfiy(ent[4], ent[2]) - if opened == None: + if opened is None: dir.close() def update_dirent(self, dirloc, thisf, first_cluster, length, @@ -1133,7 +1166,7 @@ def update_dirent(self, dirloc, thisf, first_cluster, length, if modified: modified = tod_now() else: - if first_cluster == None and length == None: + if first_cluster is None and length is None: return modified = None self.update_dirent_all(dirloc, thisf, @@ -1142,17 +1175,17 @@ def update_dirent(self, dirloc, thisf, first_cluster, length, None)) def notify_closed(self, dirloc, thisf): - if self.open_files == None or dirloc == None: + if self.open_files is None or dirloc is None: return a = self.open_files.get(dirloc, None) - if a == None: + if a is None: return self.flush() dir, files = a files.discard(thisf) if len(files) == 0: # print("@@@ notify_closed", dir) - if dir != None: + if dir is not None: dir.close() del self.open_files[dirloc] @@ -1183,15 +1216,15 @@ def create_dir_entry(self, parent_dirloc, name, mode): dir_ent = self._dirloc_to_ent(parent_dirloc) dir = self._directory(parent_dirloc, dir_ent[4], dir_ent[2], "r+b") - l = len(dir) - # print("@@@ len", l) - assert l >= 2 - for i in range(l): + length = len(dir) + # print("@@@ len", length) + assert length >= 2 + for i in range(length): ent = dir[i] if (ent[0] & DF_EXISTS) == 0: break else: - i = l + i = length dirloc = (dir_ent[4], i) # print("@@@ dirloc", dirloc) @@ -1317,9 +1350,9 @@ def path_search(self, pathname): name=tmpname) for s in components: - # print("@@@", dirloc, repr(s), dir == None, ent) + # print("@@@", dirloc, repr(s), dir is None, ent) - if dir == None: + if dir is None: # tried to traverse a file or a # non-existent directory return (None, (0, 0, 0, 0, 0, 0, 0, 0, None), @@ -1341,7 +1374,7 @@ def path_search(self, pathname): dir.close() dir = None - if ent == None: + if ent is None: continue dirloc = (dir_cluster, i) @@ -1349,13 +1382,13 @@ def path_search(self, pathname): dir = _directory(dirloc, ent[4], ent[2], name=tmpname) - if dir != None: + if dir is not None: dir.close() is_dir = True - elif ent != None: + elif ent is not None: is_dir = False - if ent == None: + if ent is None: ent = (0, 0, 0, 0, 0, 0, 0, 0, components[-1]) return (dirloc, ent, is_dir) @@ -1365,7 +1398,7 @@ def open(self, filename, mode="r"): (dirloc, ent, is_dir) = self.path_search(filename) # print("@@@ open", (dirloc, ent)) - if dirloc == None: + if dirloc is None: raise path_not_found(filename) if is_dir: raise io_error(EISDIR, "not a regular file", @@ -1386,7 +1419,7 @@ def open(self, filename, mode="r"): def dir_open(self, filename, mode="rb"): (dirloc, ent, is_dir) = self.path_search(filename) - if dirloc == None: + if dirloc is None: raise path_not_found(filename) if ent[0] == 0: raise dir_not_found(filename) @@ -1396,7 +1429,7 @@ def dir_open(self, filename, mode="rb"): def mkdir(self, filename): (dirloc, ent, is_dir) = self.path_search(filename) - if dirloc == None: + if dirloc is None: raise path_not_found(filename) if ent[0] != 0: raise io_error(EEXIST, "directory exists", filename) @@ -1421,7 +1454,7 @@ def remove(self, filename): """Remove a file or empty directory.""" (dirloc, ent, is_dir) = self.path_search(filename) - if dirloc == None: + if dirloc is None: raise path_not_found(filename) if ent[0] == 0: raise file_not_found(filename) @@ -1439,7 +1472,7 @@ def remove(self, filename): def chdir(self, filename): (dirloc, ent, is_dir) = self.path_search(filename) - if dirloc == None: + if dirloc is None: raise path_not_found(filename) if ent[0] == 0: raise dir_not_found(filename) @@ -1462,7 +1495,7 @@ def get_dirent(self, filename): """Get the raw directory entry tuple for a file.""" (dirloc, ent, is_dir) = self.path_search(filename) - if dirloc == None: + if dirloc is None: raise path_not_found(filename) if ent[0] == 0: raise file_not_found(filename) @@ -1475,7 +1508,7 @@ def set_dirent(self, filename, new_ent): is set to None then is not changed.""" (dirloc, ent, is_dir) = self.path_search(filename) - if dirloc == None: + if dirloc is None: raise path_not_found(filename) if ent[0] == 0: raise file_not_found(filename) @@ -1499,7 +1532,7 @@ def is_ancestor(self, dirloc, olddirloc): def rename(self, oldpathname, newpathname): (olddirloc, oldent, is_dir) = self.path_search(oldpathname) - if olddirloc == None: + if olddirloc is None: raise path_not_found(oldpathname) if oldent[0] == 0: raise file_not_found(oldpathname) @@ -1510,10 +1543,10 @@ def rename(self, oldpathname, newpathname): oldpathname) if olddirloc in self.open_files: raise io_error(EBUSY, "cannot rename open file", - newname) + newpathname) (newparentdirloc, newent, x) = self.path_search(newpathname) - if newparentdirloc == None: + if newparentdirloc is None: raise path_not_found(newpathname) if newent[0] != 0: raise io_error(EEXIST, "file exists", newpathname) @@ -1551,12 +1584,12 @@ def rename(self, oldpathname, newpathname): oldent[0] &= ~DF_EXISTS self.update_dirent_all(olddirloc, None, oldent) - except: - if newent != None: + except Exception: + if newent is not None: self.delete_dirloc(newdirloc, False, newpathname) finally: - if newparentdir != None: + if newparentdir is not None: newparentdir.close() if not is_dir: @@ -1581,11 +1614,11 @@ def import_save_file(self, sf, ignore_existing, dirname=None): """ dir_ent = sf.get_directory() - if dirname == None: + if dirname is None: dirname = "/" + dir_ent[8] (root_dirloc, ent, is_dir) = self.path_search(dirname) - if root_dirloc == None: + if root_dirloc is None: raise path_not_found(dirname) if ent[0] != 0: if ignore_existing: @@ -1620,14 +1653,14 @@ def import_save_file(self, sf, ignore_existing, dirname=None): (ent, data) = sf.get_file(i) # print("@@@ remove", ent[8]) self.remove(dirname + ent[8]) - except EnvironmentError as e: + except EnvironmentError: # print("@@@ failed", e) pass try: # print("@@@ remove dir", dirname) self.remove(dirname) - except EnvironmentError as e: + except EnvironmentError: # print("@@@ failed", e) pass raise Exception(type, what, where) @@ -1656,7 +1689,7 @@ def import_save_file(self, sf, ignore_existing, dirname=None): def export_save_file(self, filename): (dir_dirloc, dirent, is_dir) = self.path_search(filename) - if dir_dirloc == None: + if dir_dirloc is None: raise path_not_found(filename) if dirent[0] == 0: raise dir_not_found(filename) @@ -1685,7 +1718,7 @@ def export_save_file(self, filename): assert len(data) == ent[2] files.append((ent, data)) finally: - if f != None: + if f is not None: f.close() dir.close() dirent[2] = len(files) @@ -1723,7 +1756,7 @@ def rmdir(self, dirname): """Recursively delete a directory.""" (dirloc, ent, is_dir) = self.path_search(dirname) - if dirloc == None: + if dirloc is None: raise path_not_found(dirname) if ent[0] == 0: raise dir_not_found(dirname) @@ -1777,7 +1810,7 @@ def _check_file(self, fat, first_cluster, length): def _check_dir(self, fat, dirloc, dirname, ent): why = self._check_file(fat, ent[4], ent[2] * PS2MC_DIRENT_LENGTH) - if why != None: + if why is not None: print("bad directory:", dirname + ":", why) return False ret = True @@ -1808,7 +1841,7 @@ def _check_dir(self, fat, dirloc, dirname, ent): ret = False else: why = self._check_file(fat, ent[4], ent[2]) - if why != None: + if why is not None: print("bad file:", (dirname + ent[8] + ":"), why) ret = False @@ -1852,15 +1885,15 @@ def _globdir(self, dirname, components, is_dir): dir = self.dir_open(".") else: dir = self.dir_open(dirname) - try: - return [dirname + ent[8] - for ent in dir - if ((ent[0] & DF_EXISTS) - and (not is_dir or (ent[8] & DF_DIR)) - and (ent[8] not in [".", ".."] - or ent[8] == pattern) - and fnmatch.fnmatchcase(ent[8], - pattern))] + try: + return [ + dirname + ent[8] for ent in dir if ( + (ent[0] & DF_EXISTS) + and (not is_dir or (ent[8] & DF_DIR)) + and (ent[8] not in [".", ".."] or ent[8] == pattern) + and fnmatch.fnmatchcase(ent[8], pattern) + ) + ] finally: dir.close() @@ -1917,7 +1950,7 @@ def get_icon_sys(self, dirname): icon_sys = dirname + "/icon.sys" mode = self.get_mode(icon_sys) - if mode == None or not mode_is_file(mode): + if mode is None or not mode_is_file(mode): return None f = self.open(icon_sys, "rb") s = f.read(964) @@ -1962,12 +1995,12 @@ def close(self): # print("ps2mc.close") try: f = self.f - if f == None or getattr(f, "closed", False): + if f is None or getattr(f, "closed", False): # print("closed") return open_files = self.open_files # print("open_files", open_files) - if open_files != None: + if open_files is not None: # this is complicated by the fact as # files are closed they will remove # themselves from the list of open files @@ -1977,11 +2010,11 @@ def close(self): while len(open_files) > 0: (k, v) = open_files.popitem() (dir, files) = v - if dir != None: + if dir is not None: dir.close() - if self.rootdir != None: + if self.rootdir is not None: self.rootdir.close() - if self.fat_cache != None: + if self.fat_cache is not None: self.flush() finally: self.open_files = None @@ -1993,6 +2026,6 @@ def __del__(self): # print("ps2mc.__del__") try: self.close() - except: + except Exception: sys.stderr.write("ps2mc.__del__: \n") traceback.print_exc() diff --git a/ps2mc_ecc.py b/ps2mc_ecc.py index 63aca59..7d9e60a 100755 --- a/ps2mc_ecc.py +++ b/ps2mc_ecc.py @@ -7,13 +7,12 @@ """ Routines for calculating the Hamming codes, a simple form of error -correcting codes (ECC), as used on PS2 memory cards. +correcting codes (ECC), as used on PS2 memory cards. """ -from round import div_round_up import array -_SCCS_ID = "@(#) mymc ps2mc_ecc.py 1.5 23/07/06 16:03:58\n" +from round import div_round_up try: import ctypes @@ -21,6 +20,8 @@ except ImportError: mymcsup = None +_SCCS_ID = "@(#) mymc ps2mc_ecc.py 1.5 23/07/06 16:03:58\n" + __ALL__ = ["ECC_CHECK_OK", "ECC_CHECK_CORRECTED", "ECC_CHECK_FAILED", "ecc_calculate", "ecc_check", "ecc_calculate_page", "ecc_check_page"] @@ -85,7 +86,7 @@ def _ecc_calculate(s): def _ecc_check(s, ecc): """Detect and correct any single bit errors. - The parameters "s" and "ecc", the data and expected Hamming code + The parameters "s" and "ecc", the data and expected Hamming code repectively, must be modifiable sequences of integers and are updated with the corrected values if necessary.""" @@ -137,9 +138,6 @@ def ecc_calculate_page(page): def ecc_check_page(page, spare): "Check and correct any single bit errors in a PS2 memory card page." - failed = False - corrected = False - # chunks = [(array.array('B', page[i * 128 : i * 128 + 128]), # map(ord, spare[i * 3 : i * 3 + 3])) # for i in range(div_round_up(len(page), 128))] @@ -166,7 +164,7 @@ def ecc_check_page(page, spare): return (ret, page, spare) -if mymcsup == None: +if mymcsup is None: ecc_calculate = _ecc_calculate ecc_check = _ecc_check else: diff --git a/ps2save.py b/ps2save.py index ec7c7e0..53ba392 100755 --- a/ps2save.py +++ b/ps2save.py @@ -7,16 +7,32 @@ # A simple interface for working with various PS2 save file formats. # -from sjistab import shift_jis_normalize_table -from ps2mc_dir import * -from round import div_round_up, round_up -import zlib import array import binascii -import struct -import string import os +import struct import sys +import zlib + +from sjistab import shift_jis_normalize_table +from ps2mc_dir import ( + DF_0400, + DF_DIR, + DF_EXISTS, + DF_FILE, + DF_RWX, + PS2MC_DIRENT_LENGTH, + mode_is_file, + mode_is_dir, + pack_dirent, + tod_to_time, + tod_now, + unpack_tod, + unpack_dirent, + zero_terminate, +) +from round import round_up + _SCCS_ID = "@(#) mymc ps2save.py 1.9 23/07/06 19:46:30\n" @@ -76,7 +92,7 @@ class corrupt(error): def __init__(self, msg, f=None): fn = None - if f != None: + if f is not None: fn = getattr(f, "name", None) self.filename = fn error.__init__(self, "Corrupt save file: " + msg) @@ -180,7 +196,7 @@ def shift_jis_conv(src, encoding=None): exactly representable in the desired encoding. """ - if encoding == None: + if encoding is None: encoding = sys.getdefaultencoding() if encoding == "shift_jis": return src @@ -369,7 +385,7 @@ def _load_max_drive_2(self): (length, s) = self._compressed self._compressed = None - if lzari == None: + if lzari is None: raise error("The lzari module is needed to " " decompress MAX Drive saves.") s = lzari.decode(s, length, @@ -410,7 +426,7 @@ def load_max_drive(self, f, timestamp=None): else: s = _read_fixed(f, clen - 4) dirname = zero_terminate(dirname) - if timestamp == None: + if timestamp is None: timestamp = tod_now() self.set_directory((DF_RWX | DF_DIR | DF_0400 | DF_EXISTS, 0, dirlen, timestamp, 0, 0, timestamp, 0, @@ -419,12 +435,12 @@ def load_max_drive(self, f, timestamp=None): self._compressed = (length, s) def save_max_drive(self, f): - if lzari == None: + if lzari is None: raise error("The lzari module is needed to " " decompress MAX Drive saves.") iconsysname = "" icon_sys = self.get_icon_sys() - if icon_sys != None: + if icon_sys is not None: title = icon_sys_title(icon_sys, "ascii") if len(title[0]) > 0 and title[0][-1] != ' ': iconsysname = title[0] + " " + title[1].strip() @@ -523,8 +539,6 @@ def load_sharkport(self, f): raise corrupt("Not a SharkPort/X-Port save file.", f) (savetype,) = struct.unpack("', u'\uff22': u'B', u'\uff26': u'F', u'\uff2a': u'J', u'\u222c': u'\u222b\u222b', u'\uff2e': u'N', u'\uff32': u'R', u'\uff36': u'V', u'\uff3a': u'Z', u'\uff3e': u'^', u'\uff42': u'b', u'\uff46': u'f', u'\uff4a': u'j', u'\uff4e': u'n', u'\uff52': u'r', u'\uff56': u'v', u'\uff5a': u'z', u'\uff62': u'\u300c', u'\uffe5': u'\xa5', u'\uff66': u'\u30f2', u'\uff6a': u'\u30a7', u'\uff6e': u'\u30e7', u'\uff72': u'\u30a4', u'\uff76': u'\u30ab', u'\uff7a': u'\u30b3', u'\uff7e': u'\u30bb', u'\uff01': u'!', u'\uff82': u'\u30c4', u'\uff05': u'%', u'\uff86': u'\u30cb', u'\uff09': u')', u'\uff8a': u'\u30cf', u'\uff8e': u'\u30db', u'\uff11': u'1', u'\uff92': u'\u30e1', u'\uff15': u'5', u'\uff96': u'\u30e8', u'\uff19': u'9', u'\uff9a': u'\u30ec', u'\uff1d': u'=', u'\u309c': u' \u309a', u'\uff9e': u'\u3099', u'\uff21': u'A', u'\uff25': u'E', u'\uff29': u'I', u'\xa8': u' \u0308', u'\uff2d': u'M', u'\uff31': u'Q', u'\u2033': u'\u2032\u2032', u'\uff35': u'U', u'\xb4': u' \u0301', u'\uff39': u'Y', u'\uff3d': u']', u'\uff41': u'a', u'\uff45': u'e', u'\uff49': u'i', u'\uff4d': u'm', u'\uff51': u'q', u'\uff55': u'u', u'\uff59': u'y', u'\uff5d': u'}', u'\uff61': u'\u3002', u'\uff65': u'\u30fb', u'\uff69': u'\u30a5', u'\uff6d': u'\u30e5', u'\uff71': u'\u30a2', u'\uff75': u'\u30aa', u'\uff79': u'\u30b1', u'\uff7d': u'\u30b9', u'\uff83': u'\u30c6', u'\uff04': u'$', u'\uff87': u'\u30cc', u'\uff08': u'(', u'\uff8b': u'\u30d2', u'\uff0c': u',', u'\uff8f': u'\u30de', u'\uff10': u'0', u'\uff93': u'\u30e2', u'\uff14': u'4', u'\uff97': u'\u30e9', u'\uff18': u'8', u'\uff9b': u'\u30ed', u'\uff1c': u'<', u'\uff9f': u'\u309a', u'\uff20': u'@', u'\uff24': u'D', u'\u2026': u'...', u'\uff28': u'H', u'\uff2c': u'L', u'\uff30': u'P', u'\uff34': u'T', u'\uff38': u'X', u'\uff3c': u'\\', u'\uff40': u'`', u'\uff44': u'd', u'\uff48': u'h', u'\uff4c': u'l', u'\uff50': u'p', u'\uff54': u't', u'\uff58': u'x', u'\uff5c': u'|', u'\uffe3': u' \u0304', u'\uff64': u'\u3001', u'\uff68': u'\u30a3', u'\uff6c': u'\u30e3', u'\uff70': u'\u30fc', u'\uff74': u'\u30a8', u'\uff78': u'\u30af', u'\uff7c': u'\u30b7', u'\uff80': u'\u30bf', u'\u2103': u'\xb0C', u'\uff84': u'\u30c8', u'\uff88': u'\u30cd', u'\uff0b': u'+', u'\uff8c': u'\u30d5', u'\uff0f': u'/', u'\uff90': u'\u30df', u'\uff13': u'3', u'\uff94': u'\u30e4', u'\uff17': u'7', u'\uff98': u'\u30ea', u'\uff1b': u';', u'\uff9c': u'\u30ef', u'\uff1f': u'?', u'\uff23': u'C', u'\u2025': u'..', u'\uff27': u'G', u'\u212b': u'\xc5', u'\uff2f': u'O', u'\uff33': u'S', u'\uff37': u'W', u'\uff3b': u'[', u'\uff3f': u'_', u'\uff43': u'c', u'\uff47': u'g', u'\uff4b': u'k', u'\uff4f': u'o', u'\uff53': u's', u'\uff57': u'w', u'\uff5b': u'{', u'\uff63': u'\u300d', u'\uff67': u'\u30a1', u'\uff6b': u'\u30a9', u'\uff6f': u'\u30c3', u'\uff73': u'\u30a6', u'\uff77': u'\u30ad', u'\uff7b': u'\u30b5', u'\uff2b': u'K', u'\uff7f': u'\u30bd'}