Skip to content

Commit 2a49356

Browse files
committed
Drop support for legacy Python
1 parent 12634e1 commit 2a49356

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+334
-469
lines changed

.circleci/config.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ jobs:
2525
- run: black . --check
2626

2727

28-
Python2:
29-
docker:
30-
- image: circleci/python:2.7.18
31-
steps: *build_and_test_steps
32-
3328
Python3:
3429
docker:
3530
- image: circleci/python:3.10
@@ -41,5 +36,4 @@ workflows:
4136
build:
4237
jobs:
4338
- StyleCheck
44-
- Python2
4539
- Python3

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# sc2reader documentation build configuration file, created by
43
# sphinx-quickstart on Sun May 01 12:39:48 2011.

examples/sc2autosave.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
"""sc2autosave is a utility for reorganizing and renaming Starcraft II files.
43
54
Overview
@@ -78,16 +77,16 @@
7877
keeps the script from looking into the 'Saved' subdirectory.
7978
8079
sc2autosave \
81-
--source ~/My\ Documents/Starcraft\ II/Accounts/.../Mutliplayer \
82-
--dest ~/My\ Documents/Starcraft\ II/Accounts/.../Multiplater/Saved \
80+
--source ~/My\\ Documents/Starcraft\\ II/Accounts/.../Mutliplayer \
81+
--dest ~/My\\ Documents/Starcraft\\ II/Accounts/.../Multiplater/Saved \
8382
--period 10 \
8483
--depth 0
8584
8685
This next configuration runs in batch mode using the default renaming format.
8786
8887
sc2autosave \
89-
--source ~/My\ Documents/Starcraft\ II/Accounts/.../Mutliplayer \
90-
--dest ~/My\ Documents/Starcraft\ II/Accounts/.../Multiplater/Saved \
88+
--source ~/My\\ Documents/Starcraft\\ II/Accounts/.../Mutliplayer \
89+
--dest ~/My\\ Documents/Starcraft\\ II/Accounts/.../Multiplater/Saved \
9190
--rename
9291
9392
(ZvP) Lost Temple: ShadesofGray(Z) vs Trisfall(P).SC2Replay
@@ -97,8 +96,8 @@
9796
by replay format and favors ShadesofGray in the player and team orderings.
9897
9998
sc2autosave \
100-
--source ~/My\ Documents/Starcraft\ II/Accounts/.../Mutliplayer \
101-
--dest ~/My\ Documents/Starcraft\ II/Accounts/.../Multiplater/Saved \
99+
--source ~/My\\ Documents/Starcraft\\ II/Accounts/.../Mutliplayer \
100+
--dest ~/My\\ Documents/Starcraft\\ II/Accounts/.../Multiplater/Saved \
102101
--rename "{:format}/{:matchup} on {:map}: {:teams}" \
103102
--player-format "{:name}({:play_race})" \
104103
--team-order-by number \
@@ -113,8 +112,8 @@
113112
length to show both minutes and seconds.
114113
115114
sc2autosave \
116-
--source ~/My\ Documents/Starcraft\ II/Accounts/.../Mutliplayer \
117-
--dest ~/My\ Documents/Starcraft\ II/Accounts/.../Multiplater/Saved \
115+
--source ~/My\\ Documents/Starcraft\\ II/Accounts/.../Mutliplayer \
116+
--dest ~/My\\ Documents/Starcraft\\ II/Accounts/.../Multiplater/Saved \
118117
--rename "{:matchup}/({:length}) {:map}: {:teams}" \
119118
--player-format "{:name}({:play_race})" \
120119
--team-order-by number \
@@ -200,7 +199,7 @@ def run(args):
200199
directory = make_directory(args, ("parse_error",))
201200
new_path = os.path.join(directory, file_name)
202201
source_path = path[len(args.source) :]
203-
args.log.write("Error parsing replay: {0}".format(source_path))
202+
args.log.write(f"Error parsing replay: {source_path}")
204203
if not args.dryrun:
205204
args.action.run(path, new_path)
206205

@@ -250,7 +249,7 @@ def run(args):
250249

251250

252251
def filter_out_replay(args, replay):
253-
player_names = set([player.name for player in replay.players])
252+
player_names = {player.name for player in replay.players}
254253
filter_out_player = not set(args.filter_player) & player_names
255254

256255
if args.filter_rule == "ALLOW":
@@ -262,7 +261,7 @@ def filter_out_replay(args, replay):
262261
# We need to create these compare functions at runtime because the ordering
263262
# hinges on the --favored PLAYER options passed in from the command line.
264263
def create_compare_funcs(args):
265-
favored_set = set(name.lower() for name in args.favored)
264+
favored_set = {name.lower() for name in args.favored}
266265

267266
def player_compare(player1, player2):
268267
# Normalize the player names and generate our key metrics
@@ -290,8 +289,8 @@ def player_compare(player1, player2):
290289

291290
def team_compare(team1, team2):
292291
# Normalize the team name lists and generate our key metrics
293-
team1_names = set(p.name.lower() for p in team1.players)
294-
team2_names = set(p.name.lower() for p in team2.players)
292+
team1_names = {p.name.lower() for p in team1.players}
293+
team2_names = {p.name.lower() for p in team2.players}
295294
team1_favored = team1_names & favored_set
296295
team2_favored = team2_names & favored_set
297296

@@ -341,7 +340,7 @@ def make_directory(args, path_parts):
341340
for part in path_parts:
342341
directory = os.path.join(directory, part)
343342
if not os.path.exists(directory):
344-
args.log.write("Creating subfolder: {0}\n".format(directory))
343+
args.log.write(f"Creating subfolder: {directory}\n")
345344
if not args.dryrun:
346345
os.mkdir(directory)
347346
elif not os.path.isdir(directory):
@@ -351,7 +350,7 @@ def make_directory(args, path_parts):
351350

352351

353352
def scan(args, state):
354-
args.log.write("SCANNING: {0}\n".format(args.source))
353+
args.log.write(f"SCANNING: {args.source}\n")
355354
files = sc2reader.utils.get_files(
356355
path=args.source,
357356
regex=args.exclude_files,
@@ -374,13 +373,13 @@ def reset(args):
374373
exit("Cannot reset, destination must be directory: {0}", args.dest)
375374

376375
print(
377-
"About to reset directory: {0}\nAll files and subdirectories will be removed.".format(
376+
"About to reset directory: {}\nAll files and subdirectories will be removed.".format(
378377
args.dest
379378
)
380379
)
381380
choice = raw_input("Proceed anyway? (y/n) ")
382381
if choice.lower() == "y":
383-
args.log.write("Removing old directory: {0}\n".format(args.dest))
382+
args.log.write(f"Removing old directory: {args.dest}\n")
384383
if not args.dryrun:
385384
print(args.dest)
386385
shutil.rmtree(args.dest)
@@ -404,13 +403,13 @@ def setup(args):
404403
if not args.dryrun:
405404
os.mkdir(args.dest)
406405
else:
407-
args.log.write("Creating destination: {0}\n".format(args.dest))
406+
args.log.write(f"Creating destination: {args.dest}\n")
408407
elif not os.path.isdir(args.dest):
409408
sys.exit("Destination must be a directory.\n\nScript Aborted")
410409

411410
data_file = os.path.join(args.dest, "sc2autosave.dat")
412411

413-
args.log.write("Loading state from file: {0}\n".format(data_file))
412+
args.log.write(f"Loading state from file: {data_file}\n")
414413
if os.path.isfile(data_file) and not args.reset:
415414
with open(data_file) as file:
416415
return cPickle.load(file)
@@ -425,7 +424,7 @@ def save_state(state, args):
425424
with open(data_file, "w") as file:
426425
cPickle.dump(state, file)
427426
else:
428-
args.log.write("Writing state to file: {0}\n".format(data_file))
427+
args.log.write(f"Writing state to file: {data_file}\n")
429428

430429

431430
def main():

examples/sc2store.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43
import cPickle
54
import os
@@ -196,7 +195,7 @@ def main():
196195

197196
for path in args.paths:
198197
for file_name in sc2reader.utils.get_files(path, depth=0):
199-
print("CREATING: {0}".format(file_name))
198+
print(f"CREATING: {file_name}")
200199
db.add(Game(sc2reader.read_file(file_name), db))
201200

202201
db.commit()

generate_build_data.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def generate_build_data(balance_data_path):
5858
elif unit_id == "Drone":
5959
build_ability_name = "ZergBuild"
6060
else:
61-
build_ability_name = "{}Build".format(unit_id)
61+
build_ability_name = f"{unit_id}Build"
6262

6363
if build_ability_index:
6464
abilities[build_ability_index] = build_ability_name
@@ -77,7 +77,7 @@ def generate_build_data(balance_data_path):
7777
while len(ability_lookup[build_ability_name]) <= command_index:
7878
ability_lookup[build_ability_name].append("")
7979

80-
build_command_name = "Build{}".format(built_unit_id)
80+
build_command_name = f"Build{built_unit_id}"
8181
ability_lookup[build_ability_name][
8282
command_index
8383
] = build_command_name
@@ -87,7 +87,7 @@ def generate_build_data(balance_data_path):
8787
train_ability_index = train_unit_elements[0].get("ability")
8888

8989
if train_ability_index:
90-
train_ability_name = "{}Train".format(unit_id)
90+
train_ability_name = f"{unit_id}Train"
9191
abilities[train_ability_index] = train_ability_name
9292

9393
if train_ability_name not in ability_lookup:
@@ -137,15 +137,15 @@ def generate_build_data(balance_data_path):
137137
):
138138
ability_lookup[train_ability_name].append("")
139139

140-
train_command_name = "Train{}".format(trained_unit_name)
140+
train_command_name = f"Train{trained_unit_name}"
141141
ability_lookup[train_ability_name][
142142
command_index
143143
] = train_command_name
144144

145145
research_upgrade_elements = root.findall("./researches/upgrade")
146146
if research_upgrade_elements:
147147
research_ability_index = research_upgrade_elements[0].get("ability")
148-
research_ability_name = "{}Research".format(unit_id)
148+
research_ability_name = f"{unit_id}Research"
149149

150150
abilities[research_ability_index] = research_ability_name
151151

@@ -163,7 +163,7 @@ def generate_build_data(balance_data_path):
163163
while len(ability_lookup[research_ability_name]) <= command_index:
164164
ability_lookup[research_ability_name].append("")
165165

166-
research_command_name = "Research{}".format(researched_upgrade_id)
166+
research_command_name = f"Research{researched_upgrade_id}"
167167
ability_lookup[research_ability_name][
168168
command_index
169169
] = research_command_name
@@ -175,7 +175,7 @@ def generate_build_data(balance_data_path):
175175
sorted(abilities.items(), key=lambda x: int(x[0]))
176176
)
177177

178-
unit_lookup = dict((unit_name, unit_name) for _, unit_name in sorted_units.items())
178+
unit_lookup = {unit_name: unit_name for _, unit_name in sorted_units.items()}
179179

180180
return sorted_units, sorted_abilities, unit_lookup, ability_lookup
181181

@@ -258,7 +258,7 @@ def main():
258258
unit_lookup_path = os.path.join(
259259
args.project_path, "sc2reader", "data", "unit_lookup.csv"
260260
)
261-
with open(unit_lookup_path, "r") as file:
261+
with open(unit_lookup_path) as file:
262262
csv_reader = csv.reader(file, delimiter=",", lineterminator=os.linesep)
263263
old_unit_lookup = collections.OrderedDict(
264264
[(row[0], row[1]) for row in csv_reader if len(row) > 1]
@@ -267,7 +267,7 @@ def main():
267267
ability_lookup_path = os.path.join(
268268
args.project_path, "sc2reader", "data", "ability_lookup.csv"
269269
)
270-
with open(ability_lookup_path, "r") as file:
270+
with open(ability_lookup_path) as file:
271271
csv_reader = csv.reader(file, delimiter=",", lineterminator=os.linesep)
272272
old_ability_lookup = collections.OrderedDict(
273273
[(row[0], row[1:]) for row in csv_reader if len(row) > 0]
@@ -290,7 +290,7 @@ def main():
290290
"sc2reader",
291291
"data",
292292
args.expansion,
293-
"{}_units.csv".format(args.build_version),
293+
f"{args.build_version}_units.csv",
294294
)
295295
with open(units_file_path, "w") as file:
296296
csv_writer = csv.writer(file, delimiter=",", lineterminator=os.linesep)
@@ -302,7 +302,7 @@ def main():
302302
"sc2reader",
303303
"data",
304304
args.expansion,
305-
"{}_abilities.csv".format(args.build_version),
305+
f"{args.build_version}_abilities.csv",
306306
)
307307
with open(abilities_file_path, "w") as file:
308308
csv_writer = csv.writer(file, delimiter=",", lineterminator=os.linesep)

new_units.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
str_id, title = entry.strip().split(",")
1616
UNIT_LOOKUP[str_id] = title
1717

18-
with open(sys.argv[1], "r") as new_units:
18+
with open(sys.argv[1]) as new_units:
1919
for line in new_units:
2020
new_unit_name = line.strip().split(",")[1]
2121
if new_unit_name not in UNIT_LOOKUP:
22-
print("{0},{1}".format(new_unit_name, new_unit_name))
22+
print(f"{new_unit_name},{new_unit_name}")
2323

2424
print("")
2525
print("")
@@ -31,8 +31,8 @@
3131
str_id, abilities = entry.split(",", 1)
3232
ABIL_LOOKUP[str_id] = abilities.split(",")
3333

34-
with open(sys.argv[2], "r") as new_abilities:
34+
with open(sys.argv[2]) as new_abilities:
3535
for line in new_abilities:
3636
new_ability_name = line.strip().split(",")[1]
3737
if new_ability_name not in ABIL_LOOKUP:
38-
print("{0},{1}".format(new_ability_name, new_ability_name))
38+
print(f"{new_ability_name},{new_ability_name}")

sc2reader/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
sc2reader
43
~~~~~~~~~~~
@@ -18,7 +17,6 @@
1817
:copyright: (c) 2011 by Graylin Kim.
1918
:license: MIT, see LICENSE for more details.
2019
"""
21-
from __future__ import absolute_import, print_function, unicode_literals, division
2220

2321
__version__ = "1.8.0"
2422

sc2reader/constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, print_function, unicode_literals, division
3-
41
# These are found in Repack-MPQ/fileset.{locale}#Mods#Core.SC2Mod#{locale}.SC2Data/LocalizedData/Editor/EditorCategoryStrings.txt
52
# EDSTR_CATEGORY_Race
63
# EDSTR_PLAYERPROPS_RACE

0 commit comments

Comments
 (0)