Skip to content

Commit c313b2b

Browse files
authored
Merge branch 'ggtracker:upstream' into upstream
2 parents d5f6c5d + c314bfe commit c313b2b

29 files changed

+1684
-119
lines changed

.circleci/config.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,30 @@ version: 2.0
22

33
build_and_test: &build_and_test_steps
44
- checkout
5-
- run: sudo pip install --upgrade pip
6-
- run: sudo pip install pytest -r requirements.txt
7-
- run: pip install --user .
8-
- run: python --version ; pip --version ; pwd ; ls -l
5+
# Do not use `sudo pip`
6+
# pipx is already installed but `pipx list` is empty
7+
- run: python --version ; pip --version ; pipx --version ; pwd ; ls -l
8+
- run: pip install pytest -r requirements.txt
9+
- run: pip install --editable .
910
- run: pytest
1011

1112

1213
jobs:
1314
StyleCheck:
1415
docker:
15-
- image: circleci/python:3.10
16+
- image: cimg/python:3.11
1617
steps:
1718
- checkout
18-
- run: sudo pip install black codespell flake8
1919
- run: python --version ; pip --version ; pwd ; ls -l
20+
- run: pip install black codespell ruff
2021
- run: codespell -L queenland,uint
21-
# stop the build if there are Python syntax errors or undefined names
22-
- run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
23-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
24-
- run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
22+
- run: ruff .
2523
- run: black . --check
2624

2725

2826
Python3:
2927
docker:
30-
- image: circleci/python:3.10
28+
- image: cimg/python:3.11
3129
steps: *build_and_test_steps
3230

3331

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Support
22
=========
33

4-
For real-time support, please visit #sc2reader on the FreeNode.net IRC. For all other support please use the sc2reader@googlegroups.com mailing list or open an issue in the github tracker.
4+
As of Sept 2023, the best way to get support on sc2reader is on the GitHub project page. Preferably, it would be a new discussion https://github.com/ggtracker/sc2reader/discussions but can also be submitted as n issue
55

66
Issues
77
=========
@@ -14,15 +14,15 @@ If you can't share your code/replays publicly try to replicate with a smaller sc
1414
Patches
1515
=========
1616

17-
Please submit patches by pull request where possible. Patches should add a test to confirm their fix and should not break previously working tests. Circle CI automatically runs tests on each pull request so please check https://circleci.com/gh/ggtracker/sc2reader to see the results of those tests.
17+
Please submit patches by pull request where possible. Patches should add a test to confirm their fix and should not break previously working tests. Circle CI automatically runs tests on each pull request so please check https://circleci.com/gh/ggtracker/sc2reader to see the results of those tests.
1818

1919
If you are having trouble running/add/fixing tests for your patch let me know and I'll see if I can help.
2020

2121

2222
Coding Style
2323
==============
2424

25-
We'd like our code to follow PEP8 coding style in this project.
25+
We would like our code to follow [Ruff](https://docs.astral.sh/ruff/) coding style in this project.
2626
We use [python/black](https://github.com/python/black) in order to make our lives easier.
2727
We propose you do the same within this project, otherwise you might be asked to
2828
reformat your pull requests.

STYLE_GUIDE.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
STYLE GUIDE
22
==============
33

4-
As a rough style guide, please lint your code with black, codespell, and flake8::
4+
As a rough style guide, please lint your code with black, codespell, and ruff::
55

6-
pip install black codespell flake8
6+
pip install black codespell ruff
77
codespell -L queenland,uint
8-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
9-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
8+
ruff .
109
black . --check
1110

1211
More up-to-date checks may be detailed in `.circleci/config.yml`.

docs/source/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
# All configuration values have a default; values that are commented out
1111
# serve to show the default.
1212

13-
import sys, os
13+
import os
14+
import sys
15+
1416
import sc2reader
1517

1618
autodoc_member_order = "bysource"

examples/sc2autosave.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ def run(args):
184184

185185
# We break out of this loop in batch mode and on KeyboardInterrupt
186186
while True:
187-
188187
# The file scan uses the arguments and the state to filter down to
189188
# only new (since the last sync time) files.
190189
for path in scan(args, state):
@@ -193,8 +192,9 @@ def run(args):
193192
replay = sc2reader.load_replay(path, load_level=2)
194193
except KeyboardInterrupt:
195194
raise
196-
except:
195+
except Exception as e:
197196
# Failure to parse
197+
args.log.write(f"{e!r}")
198198
file_name = os.path.basename(path)
199199
directory = make_directory(args, ("parse_error",))
200200
new_path = os.path.join(directory, file_name)

examples/sc2store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
from pprint import PrettyPrinter
1313

14-
pprint = PrettyPrinter(indent=2).pprint
15-
1614
from sqlalchemy import create_engine
1715
from sqlalchemy import Column, ForeignKey, distinct, Table
1816
from sqlalchemy import Integer, String, Sequence, DateTime
@@ -23,6 +21,8 @@
2321
from sqlalchemy.ext.declarative import declarative_base
2422
from sqlalchemy.ext.associationproxy import association_proxy
2523

24+
pprint = PrettyPrinter(indent=2).pprint
25+
2626
Base = declarative_base()
2727

2828
party_member = Table(

pyproject.toml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools>=61.2",
5+
]
6+
7+
[project]
8+
name = "sc2reader"
9+
description = "Utility for parsing Starcraft II replay files"
10+
keywords = [
11+
"parser",
12+
"replay",
13+
"sc2",
14+
"starcraft 2",
15+
]
16+
license = {text = "MIT"}
17+
authors = [{name = "Kevin Leung", email = "[email protected]"}]
18+
requires-python = ">=3.7"
19+
classifiers = [
20+
"Development Status :: 5 - Production/Stable",
21+
"Environment :: Console",
22+
"Intended Audience :: Developers",
23+
"License :: OSI Approved :: MIT License",
24+
"Natural Language :: English",
25+
"Operating System :: OS Independent",
26+
"Programming Language :: Python",
27+
"Programming Language :: Python :: 3 :: Only",
28+
"Programming Language :: Python :: 3.7",
29+
"Programming Language :: Python :: 3.8",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
33+
"Programming Language :: Python :: Implementation :: CPython",
34+
"Programming Language :: Python :: Implementation :: PyPy",
35+
"Topic :: Games/Entertainment",
36+
"Topic :: Games/Entertainment :: Real Time Strategy",
37+
"Topic :: Software Development",
38+
"Topic :: Software Development :: Libraries",
39+
"Topic :: Utilities",
40+
]
41+
dynamic = [
42+
"readme",
43+
"version",
44+
]
45+
dependencies = [
46+
"mpyq",
47+
"pillow",
48+
]
49+
[project.optional-dependencies]
50+
testing = [
51+
"pytest",
52+
]
53+
[project.urls]
54+
Homepage = "https://github.com/ggtracker/sc2reader"
55+
[project.scripts]
56+
sc2attributes = "sc2reader.scripts.sc2attributes:main"
57+
sc2json = "sc2reader.scripts.sc2json:main"
58+
sc2parse = "sc2reader.scripts.sc2parse:main"
59+
sc2printer = "sc2reader.scripts.sc2printer:main"
60+
sc2replayer = "sc2reader.scripts.sc2replayer:main"
61+
62+
[tool.setuptools]
63+
include-package-data = true
64+
zip-safe = true
65+
platforms = ["any"]
66+
67+
[tool.setuptools.dynamic]
68+
readme = {file = ["README.rst", "CHANGELOG.rst"]}
69+
version = {attr = "sc2reader.__version__"}
70+
71+
[tool.setuptools.packages]
72+
find = {namespaces = false}

ruff.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ignore = [
2+
"F401", # module imported but unused; consider using `importlib.util.find_spec` to test for availability
3+
"F403", # Run `removestar` on this codebase
4+
"F405", # Run `removestar` on this codebase
5+
"F841", # Run `ruff --select=F841 --fix .`
6+
]
7+
line-length=129

sc2reader/constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import json
2+
import pkgutil
3+
14
# These are found in Repack-MPQ/fileset.{locale}#Mods#Core.SC2Mod#{locale}.SC2Data/LocalizedData/Editor/EditorCategoryStrings.txt
25
# EDSTR_CATEGORY_Race
36
# EDSTR_PLAYERPROPS_RACE
@@ -101,9 +104,6 @@
101104
}
102105

103106

104-
import json
105-
import pkgutil
106-
107107
attributes_json = pkgutil.get_data("sc2reader.data", "attributes.json").decode("utf8")
108108
attributes_dict = json.loads(attributes_json)
109109
LOBBY_PROPERTIES = dict()

0 commit comments

Comments
 (0)