12
12
import ps2mc
13
13
import wx
14
14
from functools import partial
15
- import time
16
15
from io import BytesIO
17
16
import struct
18
17
import sys
19
18
import os
19
+
20
20
_SCCS_ID = "@(#) mymc gui.py 1.9 23/07/06 19:35:21\n "
21
21
22
22
26
26
27
27
28
28
try :
29
- import ctypes
29
+ import ctypes # noqa: F401
30
30
import mymcicon
31
31
D3DXVECTOR3 = mymcicon .D3DXVECTOR3
32
32
D3DXVECTOR4 = mymcicon .D3DXVECTOR4
33
33
D3DXVECTOR4_ARRAY3 = mymcicon .D3DXVECTOR4_ARRAY3
34
34
35
- def mkvec4arr3 (l ):
35
+ def mkvec4arr3 (length ):
36
36
return D3DXVECTOR4_ARRAY3 (* [D3DXVECTOR4 (* vec )
37
- for vec in l ])
37
+ for vec in length ])
38
38
except ImportError :
39
39
mymcicon = None
40
40
@@ -172,7 +172,7 @@ def _update_dirtable(self, mc, dir):
172
172
continue
173
173
dirname = "/" + ent [8 ]
174
174
s = mc .get_icon_sys (dirname )
175
- if s == None :
175
+ if s is None :
176
176
continue
177
177
a = ps2save .unpack_icon_sys (s )
178
178
size = mc .dir_size (dirname )
@@ -181,7 +181,7 @@ def _update_dirtable(self, mc, dir):
181
181
182
182
def update_dirtable (self , mc ):
183
183
self .dirtable = []
184
- if mc == None :
184
+ if mc is None :
185
185
return
186
186
dir = mc .dir_open ("/" )
187
187
try :
@@ -346,7 +346,7 @@ def append_menu_options(self, win, menu):
346
346
def __init__ (self , parent , focus ):
347
347
self .failed = False
348
348
wx .Window .__init__ (self , parent )
349
- if mymcicon == None :
349
+ if mymcicon is None :
350
350
self .failed = True
351
351
return
352
352
r = mymcicon .init_icon_renderer (focus .GetHandle (),
@@ -367,7 +367,7 @@ def __init__(self, parent, focus):
367
367
self .Bind (wx .EVT_CONTEXT_MENU , self .evt_context_menu )
368
368
369
369
def __del__ (self ):
370
- if mymcicon != None :
370
+ if mymcicon is not None :
371
371
mymcicon .delete_icon_renderer ()
372
372
373
373
def update_menu (self , menu ):
@@ -383,7 +383,7 @@ def load_icon(self, icon_sys, icon):
383
383
if self .failed :
384
384
return
385
385
386
- if icon_sys == None or icon == None :
386
+ if icon_sys is None or icon is None :
387
387
r = mymcicon .load_icon (None , 0 , None , 0 )
388
388
else :
389
389
r = mymcicon .load_icon (icon_sys , len (icon_sys ),
@@ -498,15 +498,15 @@ def error_box(self, msg):
498
498
def mc_error (self , value , filename = None ):
499
499
"""Display a message box for EnvironmentError exeception."""
500
500
501
- if filename == None :
501
+ if filename is None :
502
502
filename = getattr (value , "filename" )
503
- if filename == None :
503
+ if filename is None :
504
504
filename = self .mcname
505
- if filename == None :
505
+ if filename is None :
506
506
filename = "???"
507
507
508
508
strerror = getattr (value , "strerror" , None )
509
- if strerror == None :
509
+ if strerror is None :
510
510
strerror = "unknown error"
511
511
512
512
return self .error_box (filename + ": " + strerror )
@@ -518,7 +518,7 @@ def __init__(self, parent, title, mcname=None):
518
518
self .icon_win = None
519
519
520
520
size = (750 , 350 )
521
- if mymcicon == None :
521
+ if mymcicon is None :
522
522
size = (500 , 350 )
523
523
wx .Frame .__init__ (self , parent , wx .ID_ANY , title , size = size )
524
524
@@ -580,7 +580,7 @@ def __init__(self, parent, title, mcname=None):
580
580
self .evt_dirlist_item_focused ,
581
581
self .evt_dirlist_select ,
582
582
self .config )
583
- if mcname != None :
583
+ if mcname is not None :
584
584
self .open_mc (mcname )
585
585
else :
586
586
self .refresh ()
@@ -590,14 +590,14 @@ def __init__(self, parent, title, mcname=None):
590
590
sizer .AddSpacer (5 )
591
591
592
592
icon_win = None
593
- if mymcicon != None :
593
+ if mymcicon is not None :
594
594
icon_win = icon_window (panel , self )
595
595
if icon_win .failed :
596
596
icon_win .Destroy ()
597
597
icon_win = None
598
598
self .icon_win = icon_win
599
599
600
- if icon_win == None :
600
+ if icon_win is None :
601
601
self .info1 = None
602
602
self .info2 = None
603
603
else :
@@ -633,17 +633,17 @@ def __init__(self, parent, title, mcname=None):
633
633
634
634
self .Show (True )
635
635
636
- if self .mc == None :
636
+ if self .mc is None :
637
637
self .evt_cmd_open ()
638
638
639
639
def _close_mc (self ):
640
- if self .mc != None :
640
+ if self .mc is not None :
641
641
try :
642
642
self .mc .close ()
643
643
except EnvironmentError as e :
644
644
self .mc_error (e )
645
645
self .mc = None
646
- if self .f != None :
646
+ if self .f is not None :
647
647
try :
648
648
self .f .close ()
649
649
except EnvironmentError as e :
@@ -661,10 +661,10 @@ def refresh(self):
661
661
662
662
mc = self .mc
663
663
664
- self .toolbar .EnableTool (self .ID_CMD_IMPORT , mc != None )
664
+ self .toolbar .EnableTool (self .ID_CMD_IMPORT , mc is not None )
665
665
self .toolbar .EnableTool (self .ID_CMD_EXPORT , False )
666
666
667
- if mc == None :
667
+ if mc is None :
668
668
status = "No memory card image"
669
669
else :
670
670
free = mc .get_free_space () / 1024
@@ -675,15 +675,15 @@ def refresh(self):
675
675
def open_mc (self , filename ):
676
676
self ._close_mc ()
677
677
self .statusbar .SetStatusText ("" , 1 )
678
- if self .icon_win != None :
678
+ if self .icon_win is not None :
679
679
self .icon_win .load_icon (None , None )
680
680
681
681
f = None
682
682
try :
683
683
f = open (filename , "r+b" )
684
684
mc = ps2mc .ps2mc (f )
685
685
except EnvironmentError as e :
686
- if f != None :
686
+ if f is not None :
687
687
f .close ()
688
688
self .mc_error (e , filename )
689
689
self .SetTitle (self .title )
@@ -697,16 +697,16 @@ def open_mc(self, filename):
697
697
self .refresh ()
698
698
699
699
def evt_menu_open (self , event ):
700
- self .import_menu_item .Enable (self .mc != None )
701
- selected = self .mc != None and len (self .dirlist .selected ) > 0
700
+ self .import_menu_item .Enable (self .mc is not None )
701
+ selected = self .mc is not None and len (self .dirlist .selected ) > 0
702
702
self .export_menu_item .Enable (selected )
703
703
self .delete_menu_item .Enable (selected )
704
704
self .ascii_menu_item .Check (self .config .get_ascii ())
705
- if self .icon_win != None :
705
+ if self .icon_win is not None :
706
706
self .icon_win .update_menu (self .icon_menu )
707
707
708
708
def evt_dirlist_item_focused (self , event ):
709
- if self .icon_win == None :
709
+ if self .icon_win is None :
710
710
return
711
711
712
712
mc = self .mc
@@ -732,7 +732,7 @@ def evt_dirlist_item_focused(self, event):
732
732
self .icon_win .load_icon (icon_sys , icon )
733
733
734
734
def evt_dirlist_select (self , event ):
735
- self .toolbar .EnableTool (self .ID_CMD_IMPORT , self .mc != None )
735
+ self .toolbar .EnableTool (self .ID_CMD_IMPORT , self .mc is not None )
736
736
self .toolbar .EnableTool (self .ID_CMD_EXPORT ,
737
737
len (self .dirlist .selected ) > 0 )
738
738
@@ -745,14 +745,14 @@ def evt_cmd_open(self, event=None):
745
745
if fn == "" :
746
746
return
747
747
self .open_mc (fn )
748
- if self .mc != None :
748
+ if self .mc is not None :
749
749
dirname = os .path .dirname (fn )
750
750
if os .path .isabs (dirname ):
751
751
self .config .set_memcard_dir (dirname )
752
752
753
753
def evt_cmd_export (self , event ):
754
754
mc = self .mc
755
- if mc == None :
755
+ if mc is None :
756
756
return
757
757
758
758
selected = self .dirlist .selected
@@ -851,7 +851,7 @@ def _do_import(self, fn):
851
851
self .error_box (fn + ": Save file already present." )
852
852
853
853
def evt_cmd_import (self , event ):
854
- if self .mc == None :
854
+ if self .mc is None :
855
855
return
856
856
857
857
dir = self .config .get_savefile_dir ("" )
@@ -862,7 +862,7 @@ def evt_cmd_import(self, event):
862
862
"|All files|*.*" ),
863
863
style = (wx .FD_OPEN | wx .FD_MULTIPLE
864
864
| wx .FD_FILE_MUST_EXIST ))
865
- if fd == None :
865
+ if fd is None :
866
866
return
867
867
r = fd .ShowModal ()
868
868
if r == wx .ID_CANCEL :
@@ -876,15 +876,15 @@ def evt_cmd_import(self, event):
876
876
except EnvironmentError as e :
877
877
self .mc_error (e , fn )
878
878
879
- if success != None :
879
+ if success is not None :
880
880
dir = os .path .dirname (success )
881
881
if os .path .isabs (dir ):
882
882
self .config .set_savefile_dir (dir )
883
883
self .refresh ()
884
884
885
885
def evt_cmd_delete (self , event ):
886
886
mc = self .mc
887
- if mc == None :
887
+ if mc is None :
888
888
return
889
889
890
890
selected = self .dirlist .selected
@@ -931,7 +931,6 @@ def run(filename=None):
931
931
"""Display a GUI for working with memory card images."""
932
932
933
933
wx_app = wx .App ()
934
- frame = gui_frame (None , "mymc" , filename )
935
934
return wx_app .MainLoop ()
936
935
937
936
@@ -954,7 +953,7 @@ def run(filename=None):
954
953
# for o in gc.garbage:
955
954
# if type(o) == ps2mc.ps2mc_file:
956
955
# for m in dir(o):
957
- # if getattr(o, m) == None:
956
+ # if getattr(o, m) is None:
958
957
# continue
959
958
# if (m == "__del__"
960
959
# or m == "__class__"
0 commit comments