Skip to content

Commit ca8c50e

Browse files
committed
Autoformatting source
Most of the groundwork to make linter happy: - tabs -> 4 spaces - 2 lines separation on module-level statements - non-compliant indentation - etc
1 parent 3adf9aa commit ca8c50e

9 files changed

+5315
-5225
lines changed

gui.py

+887-880
Large diffs are not rendered by default.

guires.py

+183-183
Large diffs are not rendered by default.

lzari.py

+727-711
Large diffs are not rendered by default.

mymc.py

+751-724
Large diffs are not rendered by default.

ps2mc.py

+1,941-1,928
Large diffs are not rendered by default.

ps2mc_dir.py

+104-97
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,42 @@
77

88
"""Functions for working with PS2 memory card directory entries."""
99

10+
import os
11+
import calendar
12+
import time
13+
import struct
1014
_SCCS_ID = "@(#) mymc ps2mc_dir.py 1.5 23/07/06 06:30:13\n"
1115

12-
import struct
13-
import time
14-
import calendar
15-
import os
1616

1717
PS2MC_DIRENT_LENGTH = 512
1818

19-
DF_READ = 0x0001
20-
DF_WRITE = 0x0002
21-
DF_EXECUTE = 0x0004
22-
DF_RWX = DF_READ | DF_WRITE | DF_EXECUTE
23-
DF_PROTECTED = 0x0008
24-
DF_FILE = 0x0010
25-
DF_DIR = 0x0020
26-
DF_O_DCREAT = 0x0040
27-
DF_0080 = 0x0080
28-
DF_0100 = 0x0100
29-
DF_O_CREAT = 0x0200
30-
DF_0400 = 0x0400
31-
DF_POCKETSTN = 0x0800
32-
DF_PSX = 0x1000
33-
DF_HIDDEN = 0x2000
34-
DF_4000 = 0x4000
35-
DF_EXISTS = 0x8000
19+
DF_READ = 0x0001
20+
DF_WRITE = 0x0002
21+
DF_EXECUTE = 0x0004
22+
DF_RWX = DF_READ | DF_WRITE | DF_EXECUTE
23+
DF_PROTECTED = 0x0008
24+
DF_FILE = 0x0010
25+
DF_DIR = 0x0020
26+
DF_O_DCREAT = 0x0040
27+
DF_0080 = 0x0080
28+
DF_0100 = 0x0100
29+
DF_O_CREAT = 0x0200
30+
DF_0400 = 0x0400
31+
DF_POCKETSTN = 0x0800
32+
DF_PSX = 0x1000
33+
DF_HIDDEN = 0x2000
34+
DF_4000 = 0x4000
35+
DF_EXISTS = 0x8000
36+
3637

3738
def zero_terminate(s):
38-
"""Truncate a string at the first NUL ('\0') character, if any."""
39-
40-
i = s.find(b'\0')
41-
if i == -1:
42-
return s
43-
return s[:i]
39+
"""Truncate a string at the first NUL ('\0') character, if any."""
40+
41+
i = s.find(b'\0')
42+
if i == -1:
43+
return s
44+
return s[:i]
45+
4446

4547
# mode, ???, length, created,
4648
# fat_cluster, parent_entry, modified, attr,
@@ -52,86 +54,91 @@ def zero_terminate(s):
5254

5355
#
5456
# Use the new Struct object if available
55-
#
57+
#
5658
if hasattr(struct, "Struct"):
57-
_dirent_struct = struct.Struct(_dirent_fmt)
58-
_tod_struct = struct.Struct(_tod_fmt)
59-
60-
def unpack_tod(s):
61-
return _tod_struct.unpack(s)
62-
63-
def pack_tod(tod):
64-
return _tod_struct.pack(tod)
65-
66-
def unpack_dirent(s):
67-
ent = _dirent_struct.unpack(s)
68-
ent = list(ent)
69-
ent[3] = _tod_struct.unpack(ent[3])
70-
ent[6] = _tod_struct.unpack(ent[6])
71-
ent[8] = zero_terminate(ent[8]).decode("ascii")
72-
return ent
73-
74-
def pack_dirent(ent):
75-
ent = list(ent)
76-
ent[3] = _tod_struct.pack(*ent[3])
77-
ent[6] = _tod_struct.pack(*ent[6])
78-
ent[8] = ent[8].encode("ascii")
79-
return _dirent_struct.pack(*ent)
59+
_dirent_struct = struct.Struct(_dirent_fmt)
60+
_tod_struct = struct.Struct(_tod_fmt)
61+
62+
def unpack_tod(s):
63+
return _tod_struct.unpack(s)
64+
65+
def pack_tod(tod):
66+
return _tod_struct.pack(tod)
67+
68+
def unpack_dirent(s):
69+
ent = _dirent_struct.unpack(s)
70+
ent = list(ent)
71+
ent[3] = _tod_struct.unpack(ent[3])
72+
ent[6] = _tod_struct.unpack(ent[6])
73+
ent[8] = zero_terminate(ent[8]).decode("ascii")
74+
return ent
75+
76+
def pack_dirent(ent):
77+
ent = list(ent)
78+
ent[3] = _tod_struct.pack(*ent[3])
79+
ent[6] = _tod_struct.pack(*ent[6])
80+
ent[8] = ent[8].encode("ascii")
81+
return _dirent_struct.pack(*ent)
8082
else:
81-
def unpack_tod(s):
82-
return struct.unpack(_tod_fmt, s)
83-
84-
def pack_tod(tod):
85-
return struct.pack(_tod_fmt, tod)
86-
87-
def unpack_dirent(s):
88-
# mode, ???, length, created,
89-
# fat_cluster, parent_entry, modified, attr,
90-
# name
91-
ent = struct.unpack(_dirent_fmt, s)
92-
ent = list(ent)
93-
ent[3] = struct.unpack(_tod_fmt, ent[3])
94-
ent[6] = struct.unpack(_tod_fmt, ent[6])
95-
ent[8] = zero_terminate(ent[8])
96-
return ent
97-
98-
def pack_dirent(ent):
99-
ent = list(ent)
100-
ent[3] = struct.pack(_tod_fmt, *ent[3])
101-
ent[6] = struct.pack(_tod_fmt, *ent[6])
102-
ent[8] = ent[8].encode("ascii")
103-
return struct.pack(_dirent_fmt, *ent)
83+
def unpack_tod(s):
84+
return struct.unpack(_tod_fmt, s)
85+
86+
def pack_tod(tod):
87+
return struct.pack(_tod_fmt, tod)
88+
89+
def unpack_dirent(s):
90+
# mode, ???, length, created,
91+
# fat_cluster, parent_entry, modified, attr,
92+
# name
93+
ent = struct.unpack(_dirent_fmt, s)
94+
ent = list(ent)
95+
ent[3] = struct.unpack(_tod_fmt, ent[3])
96+
ent[6] = struct.unpack(_tod_fmt, ent[6])
97+
ent[8] = zero_terminate(ent[8])
98+
return ent
99+
100+
def pack_dirent(ent):
101+
ent = list(ent)
102+
ent[3] = struct.pack(_tod_fmt, *ent[3])
103+
ent[6] = struct.pack(_tod_fmt, *ent[6])
104+
ent[8] = ent[8].encode("ascii")
105+
return struct.pack(_dirent_fmt, *ent)
106+
104107

105108
def time_to_tod(when):
106-
"""Convert a Python time value to a ToD tuple"""
107-
108-
tm = time.gmtime(when + 9 * 3600)
109-
return (tm.tm_sec, tm.tm_min, tm.tm_hour,
110-
tm.tm_mday, tm.tm_mon, tm.tm_year)
109+
"""Convert a Python time value to a ToD tuple"""
110+
111+
tm = time.gmtime(when + 9 * 3600)
112+
return (tm.tm_sec, tm.tm_min, tm.tm_hour,
113+
tm.tm_mday, tm.tm_mon, tm.tm_year)
114+
111115

112116
def tod_to_time(tod):
113-
"""Convert a ToD tuple to a Python time value."""
114-
115-
try:
116-
month = tod[4]
117-
if month == 0:
118-
month = 1
119-
return calendar.timegm((tod[5], month, tod[3],
120-
tod[2], tod[1], tod[0],
121-
None, None, 0)) - 9 * 3600
122-
except ValueError:
123-
return 0
124-
117+
"""Convert a ToD tuple to a Python time value."""
118+
119+
try:
120+
month = tod[4]
121+
if month == 0:
122+
month = 1
123+
return calendar.timegm((tod[5], month, tod[3],
124+
tod[2], tod[1], tod[0],
125+
None, None, 0)) - 9 * 3600
126+
except ValueError:
127+
return 0
128+
129+
125130
def tod_now():
126-
"""Get the current time as a ToD tuple."""
127-
return time_to_tod(time.time())
131+
"""Get the current time as a ToD tuple."""
132+
return time_to_tod(time.time())
133+
128134

129135
def tod_from_file(filename):
130-
return time_to_tod(os.stat(filename).st_mtime)
136+
return time_to_tod(os.stat(filename).st_mtime)
137+
131138

132139
def mode_is_file(mode):
133-
return (mode & (DF_FILE | DF_DIR | DF_EXISTS)) == (DF_FILE | DF_EXISTS)
140+
return (mode & (DF_FILE | DF_DIR | DF_EXISTS)) == (DF_FILE | DF_EXISTS)
134141

135-
def mode_is_dir(mode):
136-
return (mode & (DF_FILE | DF_DIR | DF_EXISTS)) == (DF_DIR | DF_EXISTS)
137142

143+
def mode_is_dir(mode):
144+
return (mode & (DF_FILE | DF_DIR | DF_EXISTS)) == (DF_DIR | DF_EXISTS)

0 commit comments

Comments
 (0)