Skip to content

Commit 13236ec

Browse files
authored
Merge pull request #330 from bmos/patchright
Direct uploading of builds via API
2 parents 2f06513 + 48ef544 commit 13236ec

28 files changed

+1038
-916
lines changed

README.md

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,43 +40,41 @@ source .venv/bin/activate # Linux or macOS
4040
```
4141

4242
```shell
43-
uv pip install -e .
43+
uv pip install .
4444
```
4545

4646
## Usage
4747

48-
1. Create a `.env` file in the project folder containing the following (but with your information):
49-
50-
> [!NOTE]
51-
> You can add these values directly to your environment variables.
52-
53-
```env
54-
# your FG forum username
55-
FG_USER_NAME=**********
56-
# your FG forum password
57-
FG_USER_PASS=**********
58-
# the item ID of the FG Forge item you want to modify
59-
FG_ITEM_ID=33
60-
# the name(s) of the (supported -- ext, pak, mod, etc) file(s) you want to upload (can be comma-separated list)
61-
FG_UL_FILE=path/to/file.ext
62-
63-
# [OPTIONAL] set this to FALSE to skip build uploading
64-
FG_UPLOAD_BUILD=TRUE
65-
# [OPTIONAL] set this to "TEST" or "NONE" if you would rather target those channels
66-
FG_RELEASE_CHANNEL=LIVE
67-
68-
# [OPTIONAL] set this to TRUE to prevent replacing the description with the contents of README.md
69-
FG_README_UPDATE=FALSE
70-
# [OPTIONAL] set this to TRUE to remove images instead of creating links
71-
FG_README_NO_IMAGES=FALSE
72-
73-
# [OPTIONAL] set this to TRUE to generate a "cumulative-sales.png" image
74-
FG_GRAPH_SALES=FALSE
75-
```
48+
1. Put the ext file to upload into the project folder.
49+
50+
2. [OPTIONAL] Create a `.env` file in the project folder containing the following (but with your information):
51+
52+
> [!NOTE]
53+
> You can add these values directly to your environment variables.
54+
55+
```env
56+
# your FG forum username
57+
FG_USER_NAME=**********
58+
# your FG forum password
59+
FG_USER_PASS=**********
60+
# the item ID of the FG Forge item you want to modify
61+
FG_ITEM_ID=33
62+
# the name(s) of the (supported -- ext, pak, mod, etc) file(s) you want to upload (can be comma-separated list)
63+
FG_UL_FILE=path/to/file.ext
64+
65+
# [OPTIONAL] set this to FALSE to skip build uploading
66+
FG_UPLOAD_BUILD=TRUE
67+
# [OPTIONAL] set this to "TEST" or "NONE" if you would rather target those channels
68+
FG_RELEASE_CHANNEL=LIVE
69+
70+
# [OPTIONAL] set this to TRUE to prevent replacing the description with the contents of README.md
71+
FG_README_UPDATE=FALSE
72+
# [OPTIONAL] set this to TRUE to remove images instead of creating links
73+
FG_README_NO_IMAGES=FALSE
74+
```
7675
77-
2. Put an ext file to upload into the project folder.
7876
3. Run the following command from inside the project folder:
7977
8078
```shell
81-
python -m src.main
79+
fg-forge-uploader
8280
```

pyproject.toml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fg-forge-updater"
3-
version = "1.4.0"
3+
version = "2.0.0"
44
readme = "README.md"
55
requires-python = ">=3.11"
66
license = { file = "LICENSE" }
@@ -9,23 +9,18 @@ urls = { Repository = "https://github.com/bmos/fg_forge_updater" }
99
dependencies = [
1010
"beautifulsoup4==4.14.3",
1111
"markdown==3.10",
12-
"matplotlib==3.10.7",
1312
"mdformat-footnote==0.1.2",
1413
"mdformat-frontmatter==2.0.8",
1514
"mdformat-gfm==1.0.0",
16-
"pandas==2.3.3",
15+
"patchright>=1.56.0",
1716
"python-dotenv==1.2.1",
18-
"requestium @ git+https://github.com/tryolabs/requestium.git@38f5b174727795d6d3ee3f6f4508a152ff5fd0ff", # 0.5.0 (unreleased)
19-
"seaborn==0.13.2",
20-
"selenium==4.38.0",
17+
"requests>=2.32.5",
2118
]
2219

2320
[project.optional-dependencies]
2421
dev = [
2522
"bandit[sarif]==1.9.2",
2623
"mypy==1.19.0",
27-
"pandas-stubs==2.3.3.251201",
28-
"polyfactory==3.1.0",
2924
"pre-commit==4.5.0",
3025
"pytest-cov==7.0.0",
3126
"pytest-xdist==3.8.0",
@@ -35,11 +30,21 @@ dev = [
3530
"types-Markdown==3.10.0.20251106",
3631
"types-beautifulsoup4==4.12.0.20250516",
3732
"types-requests==2.32.4.20250913",
38-
"types-seaborn==0.13.2.20251214",
3933
]
4034

35+
[project.scripts]
36+
fg-forge-updater = "src.main:main"
37+
38+
[build-system]
39+
requires = ["setuptools>=80.0"]
40+
build-backend = "setuptools.build_meta"
41+
4142
[tool]
4243

44+
[tool.setuptools.packages.find]
45+
where = ["."]
46+
include = ["src*"]
47+
4348
[tool.ruff]
4449
line-length = 160
4550
include = [
@@ -107,14 +112,13 @@ ignore = [
107112

108113
[tool.ruff.lint.per-file-ignores]
109114
"**/{tests,docs}/*" = [
115+
"FBT001", # boolean-type-hint-positional-argument (FBT001)
110116
"SLF001", # private-member-access (SLF001)
111117
"PLR2004", # magic-value-comparison (PLR2004)
112118
]
113119

114120
[tool.pytest]
115121
addopts = ["-n", "auto", "--cov=src", "--no-cov-on-fail"]
116-
asyncio_mode = "auto"
117-
asyncio_default_fixture_loop_scope = "module"
118122
testpaths = [
119123
"tests",
120124
]

src/build_processing.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,15 @@ def readme_html(markdown_text: str, *, no_images: bool = False) -> str:
4444

4545

4646
def get_readme(new_files: list[Path], *, no_images: bool = False, readme_name: str = "README.md") -> str:
47-
"""Read the first README.md found in the new zip files and call readme_html() returning the result."""
48-
return next(
49-
(readme_html(ZipFile(file).read(readme_name).decode("UTF-8"), no_images=no_images) for file in new_files if readme_name in ZipFile(file).namelist()), ""
50-
)
47+
"""Extract and convert README file from the first zip file containing one."""
48+
for file in new_files:
49+
with ZipFile(file) as zf:
50+
if readme_name in zf.namelist():
51+
markdown_text = zf.read(readme_name).decode("UTF-8")
52+
return readme_html(markdown_text, no_images=no_images)
53+
54+
error_msg = "No README file found."
55+
raise FileNotFoundError(error_msg)
5156

5257

5358
def get_build(file_path: PurePath, env_file: str) -> Path:

src/dropzone.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)