steam-editor-tools 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,76 @@
1
+ # -*- coding: UTF-8 -*-
2
+ """
3
+ Steam Editor Tools
4
+ ======
5
+
6
+ Author
7
+ ------
8
+ Yuchen Jin (cainmagi)
9
+ cainmagi@gmail.com
10
+
11
+ License
12
+ -------
13
+ MIT License
14
+
15
+ Description
16
+ -----------
17
+ This package offers editor tools helping users write Steam guides and reviews.
18
+
19
+ This package support Steam information queries, image editing tools, and BBCode
20
+ text processing tools. Users can write their documents with Markdown, use this
21
+ package to process the images in the document, and convert the document to the
22
+ Steam BBCode format.
23
+ """
24
+
25
+ from pkgutil import extend_path
26
+
27
+ from . import version
28
+ from . import utils
29
+ from . import bbcode
30
+ from . import improc
31
+ from . import steaminfo
32
+
33
+ from .version import __version__
34
+ from .bbcode import DocumentParser, GuideParser, BBCodeRenderer, BBCodeConfig
35
+ from .improc import (
36
+ ImageFontAbsSize,
37
+ ImageFontSize,
38
+ ImageFormat,
39
+ ImageQuality,
40
+ ImageAnchor,
41
+ ImageSingle,
42
+ ImageText,
43
+ ImageTeX,
44
+ ImageMultiLayer,
45
+ )
46
+ from .steaminfo import query_app_by_name_simple, get_app_details
47
+
48
+ __all__ = (
49
+ "version",
50
+ "utils",
51
+ "bbcode",
52
+ "improc",
53
+ "steaminfo",
54
+ "__version__",
55
+ "DocumentParser",
56
+ "GuideParser",
57
+ "BBCodeRenderer",
58
+ "BBCodeConfig",
59
+ "ImageFontAbsSize",
60
+ "ImageFontSize",
61
+ "ImageFormat",
62
+ "ImageQuality",
63
+ "ImageAnchor",
64
+ "ImageSingle",
65
+ "ImageText",
66
+ "ImageTeX",
67
+ "ImageMultiLayer",
68
+ "query_app_by_name_simple",
69
+ "get_app_details",
70
+ )
71
+
72
+ # Set this local module as the prefered one
73
+ __path__ = extend_path(__path__, __name__)
74
+
75
+ # Delete private sub-modules and objects
76
+ del extend_path
@@ -0,0 +1,104 @@
1
+ # -*- coding: UTF-8 -*-
2
+ """
3
+ Utilities
4
+ =========
5
+ @ Steam Editor Tools
6
+
7
+ Author
8
+ ------
9
+ Yuchen Jin (cainmagi)
10
+ cainmagi@gmail.com
11
+
12
+ License
13
+ -------
14
+ MIT License
15
+
16
+ Description
17
+ -----------
18
+ The utilities of this package. The utilities in this module are designed for
19
+ general use.
20
+ """
21
+
22
+ import os
23
+ import contextlib
24
+ import tempfile
25
+ import shutil
26
+ import types
27
+
28
+ from typing import TypeVar
29
+
30
+
31
+ _BaseException = TypeVar("_BaseException", bound=BaseException)
32
+ __all__ = ("NamedTempFolder",)
33
+
34
+
35
+ class NamedTempFolder(contextlib.AbstractContextManager):
36
+ """Named temporary folder.
37
+
38
+ Similar to `tempfile.NamedTemporaryFile`. This context maintain a temporary
39
+ folder that can be accessed by the path. When exiting from the context, the
40
+ temporary folder will be automatically deleted.
41
+ """
42
+
43
+ __slots__ = ("folder_path", "__current_path")
44
+
45
+ def __init__(self, folder_path: "str | os.PathLike[str] | None" = None) -> None:
46
+ """Initialization.
47
+
48
+ Arguments
49
+ ---------
50
+ folder_path: `str | PathLike[str] | None`
51
+ The path to the temporary folder. If not specified, will use
52
+ `tempfile.mkdtemp()` to create the folder.
53
+
54
+ Note that if the specified folder path exists, will automatically add
55
+ postfix to the given path until a new folder can be maintained.
56
+ """
57
+ if folder_path:
58
+ folder_path = str(folder_path)
59
+ base_path = folder_path
60
+ num = 0
61
+ while os.path.exists(folder_path):
62
+ folder_path = os.path.join(base_path, "temp{0:03d}".format(num))
63
+ num = num + 1
64
+ else:
65
+ folder_path = None
66
+ self.folder_path: str | None = folder_path
67
+ self.__current_path: str | None = None
68
+
69
+ @property
70
+ def current_path(self) -> str | None:
71
+ """Property: Get the current temporary folder path. If not in the context,
72
+ this value will be `None`."""
73
+ return self.__current_path
74
+
75
+ def close(self) -> None:
76
+ """Close the temporary folder. Will delete the folder and reset the status
77
+ to the status that is not in the context.
78
+
79
+ This method will be automatically called when exiting from this context.
80
+ """
81
+ if isinstance(self.__current_path, str) and self.__current_path:
82
+ shutil.rmtree(self.__current_path, ignore_errors=True)
83
+ self.__current_path = None
84
+
85
+ def __enter__(self) -> str:
86
+ """Enter the context."""
87
+ self.close()
88
+ if self.folder_path is None:
89
+ current_path = tempfile.mkdtemp(suffix=None, prefix=None, dir=None)
90
+ else:
91
+ current_path = self.folder_path
92
+ os.makedirs(current_path, exist_ok=True)
93
+ self.__current_path = current_path
94
+ return current_path
95
+
96
+ def __exit__(
97
+ self,
98
+ exc_type: type[_BaseException] | None,
99
+ exc_value: _BaseException | None,
100
+ traceback: types.TracebackType | None,
101
+ ) -> bool | None:
102
+ """Raise any exception triggered within the runtime context."""
103
+ self.close()
104
+ return None
@@ -0,0 +1,23 @@
1
+ # -*- coding: UTF-8 -*-
2
+ """
3
+ Version
4
+ =======
5
+ @ Steam Editor Tools
6
+
7
+ Author
8
+ ------
9
+ Yuchen Jin (cainmagi)
10
+ cainmagi@gmail.com
11
+
12
+ License
13
+ -------
14
+ MIT License
15
+
16
+ Description
17
+ -----------
18
+ The version of this project.
19
+ """
20
+
21
+ __all__ = ("__version__",)
22
+
23
+ __version__ = "0.1.0"
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: steam-editor-tools
3
+ Version: 0.1.0
4
+ Summary: This package offers editor tools helping users write Steam guides and reviews. Support Steam information queries, image editing tools, and BBCode text processing tools.
5
+ Author-email: Yuchen Jin <cainmagi@gmail.com>
6
+ Maintainer-email: Yuchen Jin <cainmagi@gmail.com>
7
+ License: MIT License
8
+ Project-URL: Homepage, https://github.com/cainmagi/steam-editor-tools
9
+ Project-URL: Documentation, https://cainmagi.github.io/steam-editor-tools/
10
+ Project-URL: Repository, https://github.com/cainmagi/steam-editor-tools.git
11
+ Project-URL: Issues, https://github.com/cainmagi/steam-editor-tools/issues
12
+ Project-URL: Changelog, https://github.com/cainmagi/steam-editor-tools/blob/main/Changelog.md
13
+ Keywords: python,python3,python-library,image-processing,steam-api,steam-guide,steam-bbcode,steam-bbcode-converter,bbcode,markdown-to-bbcode,html-to-bbcode
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: License :: OSI Approved :: MIT License
25
+ Classifier: Operating System :: OS Independent
26
+ Classifier: Framework :: Pydantic
27
+ Classifier: Framework :: Pydantic :: 2
28
+ Classifier: Topic :: Text Processing :: Markup
29
+ Classifier: Topic :: Text Processing :: Markup :: HTML
30
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
31
+ Requires-Python: >=3.10
32
+ Description-Content-Type: text/markdown
33
+ License-File: LICENSE
34
+ Requires-Dist: typing-extensions>=4.1.0
35
+ Requires-Dist: pydantic>=2
36
+ Requires-Dist: markdown-it-py[linkify]
37
+ Requires-Dist: beautifulsoup4
38
+ Requires-Dist: pillow
39
+ Requires-Dist: httpx
40
+ Requires-Dist: rapidfuzz
41
+ Provides-Extra: dev
42
+ Requires-Dist: typing-extensions>=4.1.0; extra == "dev"
43
+ Requires-Dist: black; extra == "dev"
44
+ Requires-Dist: flake8; extra == "dev"
45
+ Requires-Dist: flake8-black; extra == "dev"
46
+ Requires-Dist: build; extra == "dev"
47
+ Requires-Dist: wheel; extra == "dev"
48
+ Provides-Extra: test
49
+ Requires-Dist: pytest; extra == "test"
50
+ Requires-Dist: pytest-base-url; extra == "test"
51
+ Requires-Dist: pytest-html; extra == "test"
52
+ Requires-Dist: pytest-metadata; extra == "test"
53
+ Requires-Dist: py; extra == "test"
54
+ Requires-Dist: pytest-variables; extra == "test"
55
+ Requires-Dist: pytest-xdist; extra == "test"
56
+ Requires-Dist: numpy; extra == "test"
57
+ Requires-Dist: scikit-image; extra == "test"
58
+ Dynamic: license-file
59
+
60
+ # Steam Editor Tools: Help You Write Guides and Reviews
61
+
62
+ <p><img alt="Banner" src="https://github.com/cainmagi/steam-editor-tools/blob/main/display/logo-banner.webp?raw=true"></p>
63
+
64
+ <p align="center">
65
+ <a href="https://github.com/cainmagi/steam-editor-tools/releases/latest"><img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/cainmagi/steam-editor-tools?logo=github&sort=semver&style=flat-square"></a>
66
+ <a href="https://github.com/cainmagi/steam-editor-tools/releases"><img alt="GitHub all releases" src="https://img.shields.io/github/downloads/cainmagi/steam-editor-tools/total?logo=github&style=flat-square"></a>
67
+ <a href="https://github.com/cainmagi/steam-editor-tools/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/cainmagi/steam-editor-tools?style=flat-square&logo=opensourceinitiative&logoColor=white"></a>
68
+ <a href="https://pypi.org/project/steam-editor-tools"><img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/steam-editor-tools?style=flat-square&logo=pypi&logoColor=white&label=pypi"/></a>
69
+ </p>
70
+ <p align="center">
71
+ <a href="https://github.com/cainmagi/steam-editor-tools/actions/workflows/python-package.yml"><img alt="GitHub Actions (Build)" src="https://img.shields.io/github/actions/workflow/status/cainmagi/steam-editor-tools/python-package.yml?style=flat-square&logo=githubactions&logoColor=white&label=build"></a>
72
+ <a href="https://github.com/cainmagi/steam-editor-tools/actions/workflows/python-publish.yml"><img alt="GitHub Actions (Release)" src="https://img.shields.io/github/actions/workflow/status/cainmagi/steam-editor-tools/python-publish.yml?style=flat-square&logo=githubactions&logoColor=white&label=release"></a>
73
+ </p>
74
+
75
+ This package offers editor tools helping users write Steam guides and reviews.
76
+
77
+ This package supports:
78
+
79
+ - Steam information queries
80
+ - Image editing tools
81
+ - BBCode text processing tools
82
+
83
+ Users can write their documents with Markdown, use this package to process the images in the document, and convert the document to the Steam BBCode format.
84
+
85
+ ## 1. Install
86
+
87
+ Intall the **latest released version** of this package by using the PyPI source:
88
+
89
+ ```sh
90
+ python -m pip install steam-editor-tools
91
+ ```
92
+
93
+ ## 2. Usage
94
+
95
+ The following minimal example shows a simple customization, where we convert a Markdown file into Steam BBCode, and print each header during the conversion.
96
+
97
+ ```python
98
+ import os
99
+ import steam_editor_tools as stet
100
+
101
+
102
+ class CustomizedRenderer(stet.BBCodeRenderer):
103
+ def render_heading(self, node: stet.bbcode.nodes.HeadingNode) -> str:
104
+ print(self.render_children(node.children))
105
+ super().render_heading(node)
106
+ return super().render_heading(node)
107
+
108
+
109
+ def convert(file_path: str) -> None:
110
+ out_file_path = os.path.splitext(file_path)[0].strip() + ".bbcode"
111
+ doc = stet.DocumentParser().parse_file(file_path)
112
+ with open(out_file_path, "w", encoding="utf-8") as fobj:
113
+ fobj.write(CustomizedRenderer().render(doc))
114
+
115
+
116
+ convert("example.md")
117
+ ```
118
+
119
+ Currently, we support the following features:
120
+
121
+ ### 2.1. Steam information query
122
+
123
+ | Functionality | Description |
124
+ | :-------------------- | :------------------------------------------------------------------------------------------------------------------------------ |
125
+ | Search app by name | Given the partial name of an app (game), search for its information, including the ID. Support fuzzy searching. |
126
+ | Get app details by ID | Given the app ID, fetch the full details, including the name, description, price, about page, and other information. |
127
+ | Download images | Use methods such as `get_header_image()` to get the header image, background image, and official screenshots on the store page. |
128
+
129
+ ### 2.2. Image editing tools
130
+
131
+ | Functionality | Description |
132
+ | :------------------ | :----------------------------------------------------------------------------------------------------------------------------------------- |
133
+ | Image stack | A code-based image editor, allowing users to stack multiple layers of images, texts, or LaTeX equations with styles. |
134
+ | Image anchor | Inspired by LaTeX's TikZ package, this package allows users to place images on the same canvas by using their relative positions. |
135
+ | Image optimization | Users only need to specify the quality and the saving format. The package can choose the best way to optimize the saved image size. |
136
+ | Image modifications | Basic image modification tools such as image resizing, cropping and blurring. |
137
+ | Thumbnail | Provide an option to create Steam-compatible thumbnails. This feature is useful when users need to upload screenshots by themselves. |
138
+ | Batch processing | Walk through a folder, apply a customized image processing function to each image, and save the results with thumbnails in another folder. |
139
+
140
+ Actually, the title banner of this Readme file is created by the image editing tools. See the examples.
141
+
142
+ > [!NOTE]
143
+ > You need to have a locally installed LaTeX released version like [TeXLive][link-texlive] to use the equation features.
144
+
145
+ ### 2.3. BBCode text processing tools
146
+
147
+ | Functionality | Description |
148
+ | :------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
149
+ | Structured data | All conversions are divided into two steps: Other formats -> `Document` stucture -> Steam BBCode. The intermediate `Document` strcture is supported by [pydantic][link-pydantic]. |
150
+ | HTML to BBCode | Recursively parse an HTML file, and convert it into `Document` or Steam BBCode. |
151
+ | Markdown to BBCode | Use [markdown-it][link-markdown-it] to convert a Markdown file to HTML, then convert the HTML to `Document` or BBCode. |
152
+ | Fetch a Steam guide | Given the URL of a Steam guide, convert it into `Document` or BBcode. |
153
+
154
+ ## 3. Why using this package
155
+
156
+ 1. Compared to other BBCode conversion packages such as [html2bbcode][link-html2bbcode] and [html2phpbbcode][link-html2phpbbcode], our package strictly follows the current Steam BBCode format. Different forums may have different BBCode standards.
157
+ 2. Compared to [ihroteka-converter][link-ihroteka-converter], we fully support every format provided by Steam. Unlike that regular-expression-based conversion, the BBCode reconstruction in this package is based on a recursive analysis of the HTML structure. Therefore, our package will not omit any text as long as it appears in the original document.
158
+ 3. We offer flexibility of customization. Users can inject any rendering step of this package by simply overriding the methods of `steam_editor_tools.bbcode.BBCodeRenderer`. For example, we can customize a `BBCodeRenderer` to create a title image for each header.
159
+ 4. We offer convenient approaches for integrating the store page information into the output data. For example, users can easily convert a store page to BBCode if needed.
160
+
161
+ ## 4. Examples
162
+
163
+ Currently, we offer the following examples in `./examples` folder:
164
+
165
+ | Example | Description |
166
+ | :--------------------------- | :-------------------------------------------------------------------------------------- |
167
+ | `markdown_to_bbcode` | A minimal example converting Markdown to BBCode. |
168
+ | `save_description_of_a_game` | Save the "about the game" section of a Steam app as an HTML file. |
169
+ | `download_screenshots` | Download all official screenshots of a game and create thumbnails of them. |
170
+ | `download_a_guide` | Fetch a Steam guide and save it as a BBCode file. |
171
+ | `create_a_title_figure` | Customize a figure-based title. Such title images can be inserted into the Steam guide. |
172
+ | `create_logo` | Render the title bar of this readme file. |
173
+
174
+ The following two guides are written with the help of this tool. Check them for viewing the details:
175
+
176
+ | Guide | Link |
177
+ | :------------------------------ | :-------------------------------------------------------------------------: |
178
+ | 此后,勇者学会了后验概率 | [:link:](https://steamcommunity.com/sharedfiles/filedetails/?id=3624295321) |
179
+ | 《海猫鸣泣之时·出题篇》解(伪) | [:link:](https://steamcommunity.com/sharedfiles/filedetails/?id=2881849336) |
180
+
181
+ ## 5. Documentation
182
+
183
+ > [!CAUTION]
184
+ > This documentation is a work in progress. It should be ready when the package is tested to be stable.
185
+
186
+ Check the documentation to find more details about the examples and APIs.
187
+
188
+ https://cainmagi.github.io/steam-editor-tools/
189
+
190
+ ## 6. Contributing
191
+
192
+ See [CONTRIBUTING.md :book:][link-contributing]
193
+
194
+ ## 7. Changelog
195
+
196
+ See [Changelog.md :book:][link-changelog]
197
+
198
+ ## 8. Future plan
199
+
200
+ - [x] HTML/Markdown to BBCode
201
+ - [x] Multi-layer image synthesis
202
+ - [x] Query Steam app ID by name
203
+ - [x] Get Steam app details by ID
204
+ - [x] Screenshot formatting
205
+ - [ ] System/User font file detection
206
+ - [ ] Image overlay with alpha channel
207
+ - [ ] Image layer properties
208
+ - [ ] Improved image anchor interfaces
209
+ - [ ] More Steam queries based on public APIs
210
+
211
+ [tool-git]: https://git-scm.com/downloads
212
+ [link-contributing]: https://github.com/cainmagi/steam-editor-tools/blob/main/CONTRIBUTING.md
213
+ [link-changelog]: https://github.com/cainmagi/steam-editor-tools/blob/main/Changelog.md
214
+ [link-pydantic]: https://docs.pydantic.dev/
215
+ [link-markdown-it]: https://markdown-it-py.readthedocs.io/
216
+ [link-html2bbcode]: https://github.com/tengattack/html2bbcode.js
217
+ [link-html2phpbbcode]: https://github.com/tdiam/html2phpbbcode
218
+ [link-ihroteka-converter]: https://github.com/pivoshenko/ihroteka-converter/tree/main
219
+ [link-texlive]: https://www.tug.org/texlive/
@@ -0,0 +1,9 @@
1
+ steam_editor_tools/__init__.py,sha256=PWqBDaKjv4EdUsiKcN4HNaocVxIz07cYvg6LwdIC4HY,1579
2
+ steam_editor_tools/utils.py,sha256=bjtNREoZFIg9G-6AVirOB1qfarWr5_TmnLxq65Nun_0,3091
3
+ steam_editor_tools/version.py,sha256=Mygnlo5R-Po6lRpkFV6wD8Zv4LaxHK7vlv8lJH9zkVY,259
4
+ steam_editor_tools-0.1.0.dist-info/licenses/LICENSE,sha256=XLlJBnXelwpHmOYpjZIh-t7Kfq_yY4R6cZypUKhbb1s,1067
5
+ steam_editor_tools-0.1.0.dist-info/METADATA,sha256=YRxjffvG9Eijkd_kfuJNv3mH_QR_ICAEXO_BMZcwRuA,13505
6
+ steam_editor_tools-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ steam_editor_tools-0.1.0.dist-info/top_level.txt,sha256=Os5Q0olMW8Id8dt2fsINOX91GPBzQca7AEST9k8bG-c,19
8
+ steam_editor_tools-0.1.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
+ steam_editor_tools-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yuchen Jin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ steam_editor_tools