MediaWikiServerTools 0.0.1__tar.gz
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.
- mediawikiservertools-0.0.1/.github/workflows/build.yml +37 -0
- mediawikiservertools-0.0.1/.github/workflows/upload-to-pypi.yml +27 -0
- mediawikiservertools-0.0.1/.gitignore +207 -0
- mediawikiservertools-0.0.1/.project +17 -0
- mediawikiservertools-0.0.1/.pydevproject +8 -0
- mediawikiservertools-0.0.1/AGENTS.md +234 -0
- mediawikiservertools-0.0.1/LICENSE +201 -0
- mediawikiservertools-0.0.1/PKG-INFO +41 -0
- mediawikiservertools-0.0.1/README.md +12 -0
- mediawikiservertools-0.0.1/backend/__init__.py +1 -0
- mediawikiservertools-0.0.1/backend/cron_backup.py +388 -0
- mediawikiservertools-0.0.1/backend/html_table.py +62 -0
- mediawikiservertools-0.0.1/backend/remote.py +851 -0
- mediawikiservertools-0.0.1/backend/server.py +447 -0
- mediawikiservertools-0.0.1/backend/site.py +448 -0
- mediawikiservertools-0.0.1/backend/sql_backup.py +413 -0
- mediawikiservertools-0.0.1/backend/tsite.py +1020 -0
- mediawikiservertools-0.0.1/backend/webscrape.py +49 -0
- mediawikiservertools-0.0.1/backend/wikibackup.py +114 -0
- mediawikiservertools-0.0.1/pyproject.toml +61 -0
- mediawikiservertools-0.0.1/scripts/blackisort +8 -0
- mediawikiservertools-0.0.1/scripts/doc +88 -0
- mediawikiservertools-0.0.1/scripts/install +18 -0
- mediawikiservertools-0.0.1/scripts/release +8 -0
- mediawikiservertools-0.0.1/scripts/test +132 -0
- mediawikiservertools-0.0.1/tests/__init__.py +0 -0
- mediawikiservertools-0.0.1/tests/smw_access.py +89 -0
- mediawikiservertools-0.0.1/tests/test_remote.py +137 -0
- mediawikiservertools-0.0.1/tests/test_server.py +74 -0
- mediawikiservertools-0.0.1/tests/test_site.py +72 -0
- mediawikiservertools-0.0.1/tests/test_sqlbackup.py +194 -0
- mediawikiservertools-0.0.1/tests/test_wikibackup.py +30 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Build
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ main ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ main ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
os: [ubuntu-latest]
|
|
19
|
+
python-version: ["3.10"]
|
|
20
|
+
#os: [ubuntu-latest, macos-latest, windows-latest]
|
|
21
|
+
#python-version: [ '3.10', '3.11', '3.12', '3.13' ]
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
26
|
+
uses: actions/setup-python@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: ${{ matrix.python-version }}
|
|
29
|
+
- name: Install pip
|
|
30
|
+
run: |
|
|
31
|
+
python -m pip install --upgrade pip
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
scripts/install
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: |
|
|
37
|
+
scripts/test
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Upload Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [created]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
deploy:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- name: Set up Python
|
|
16
|
+
uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: '3.x'
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip
|
|
22
|
+
pip install hatch
|
|
23
|
+
- name: Build and publish
|
|
24
|
+
run: |
|
|
25
|
+
hatch build
|
|
26
|
+
- name: Publish distribution to PyPI
|
|
27
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name>MediaWikiServerTools</name>
|
|
4
|
+
<comment></comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>org.python.pydev.PyDevBuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
</buildSpec>
|
|
14
|
+
<natures>
|
|
15
|
+
<nature>org.python.pydev.pythonNature</nature>
|
|
16
|
+
</natures>
|
|
17
|
+
</projectDescription>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<?eclipse-pydev version="1.0"?><pydev_project>
|
|
3
|
+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
|
4
|
+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
|
5
|
+
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
|
6
|
+
<path>/${PROJECT_DIR_NAME}</path>
|
|
7
|
+
</pydev_pathproperty>
|
|
8
|
+
</pydev_project>
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# AGENTS.md - Agent Coding Guidelines for MediaWikiServerTools
|
|
2
|
+
|
|
3
|
+
This file provides guidelines for agentic coding agents working on this repository.
|
|
4
|
+
|
|
5
|
+
## Important Rules
|
|
6
|
+
|
|
7
|
+
**CRITICAL: NEVER EVER DO ANY ACTION READING, MODIFYING OR RUNNING without explaing the plan
|
|
8
|
+
Each set of intended actions needs to be explained in the format:
|
|
9
|
+
I understood that <YOUR ANALYSIS> so that i plan to <GOALS YOU PURSUE> by <ACTIONS TO BE CONFIRMED> confirm with go!
|
|
10
|
+
YOU WILL NEVER PROCEED WITH OUT POSITIVE CONFIRMATION by go!
|
|
11
|
+
|
|
12
|
+
## Project Overview
|
|
13
|
+
|
|
14
|
+
MediaWikiServerTools is a Python-based MediaWiki Server Management System frontend. It allows local and
|
|
15
|
+
remote manipulation of servers with partial docker support
|
|
16
|
+
It consists of:
|
|
17
|
+
- `backend/` - Server and backup functionality
|
|
18
|
+
- `tests/` - Unit tests using unittest
|
|
19
|
+
|
|
20
|
+
Requires Python 3.10+.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Build, Lint, and Test Commands
|
|
25
|
+
|
|
26
|
+
### Installation
|
|
27
|
+
```bash
|
|
28
|
+
pip install -e .
|
|
29
|
+
# or: scripts/install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Running Tests
|
|
33
|
+
|
|
34
|
+
**Run all tests with unittest discover (default):**
|
|
35
|
+
```bash
|
|
36
|
+
python3 -m unittest discover
|
|
37
|
+
# or: scripts/test
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Run tests with green:**
|
|
41
|
+
```bash
|
|
42
|
+
scripts/test -g
|
|
43
|
+
# or: green tests -s 1
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Run tests module-by-module:**
|
|
47
|
+
```bash
|
|
48
|
+
scripts/test -m
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Run tests with tox:**
|
|
52
|
+
```bash
|
|
53
|
+
scripts/test -t
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Run a single test file:**
|
|
57
|
+
```bash
|
|
58
|
+
python -m unittest tests/test_wikicms.py
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Run a specific test method:**
|
|
62
|
+
```bash
|
|
63
|
+
python -m unittest tests.test_wikicms.TestWikiCMS.testWikiCMS
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Code Formatting
|
|
67
|
+
|
|
68
|
+
**Format and sort imports:**
|
|
69
|
+
```bash
|
|
70
|
+
scripts/blackisort
|
|
71
|
+
```
|
|
72
|
+
This runs `isort` then `black` on `tests/` and `backend/` directories.
|
|
73
|
+
|
|
74
|
+
### Running the Application
|
|
75
|
+
|
|
76
|
+
** CLI commands:**
|
|
77
|
+
```bash
|
|
78
|
+
tsite # backend/tsite:main
|
|
79
|
+
sqlbackup # backend/sql_backup:main
|
|
80
|
+
cronbackup # backend.cron_backup:main
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Code Style Guidelines
|
|
86
|
+
|
|
87
|
+
### Imports
|
|
88
|
+
|
|
89
|
+
Order imports as follows (enforced by isort):
|
|
90
|
+
1. Standard library
|
|
91
|
+
2. Third-party packages
|
|
92
|
+
3. Local application imports
|
|
93
|
+
|
|
94
|
+
Use relative imports within the project:
|
|
95
|
+
```python
|
|
96
|
+
from backend.site import FrontendSite
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Formatting
|
|
100
|
+
|
|
101
|
+
- **Line length**: Follow black's default (88 characters)
|
|
102
|
+
- **Strings**: Use f-strings for string interpolation
|
|
103
|
+
- **Indentation**: 4 spaces (no tabs)
|
|
104
|
+
|
|
105
|
+
### Type Hints
|
|
106
|
+
|
|
107
|
+
Use type hints for function signatures and variables:
|
|
108
|
+
```python
|
|
109
|
+
def getContent(self, pagePath: str) -> tuple[str, Optional[str], Optional[str]]:
|
|
110
|
+
# ...
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Common types used: `str`, `int`, `bool`, `List`, `Dict`, `Optional`, `Any`
|
|
114
|
+
|
|
115
|
+
### Naming Conventions
|
|
116
|
+
|
|
117
|
+
- **Classes**: `PascalCase` (e.g., `WikiFrontend`, `Site`)
|
|
118
|
+
- **Functions/methods**: `snake_case` (e.g., `get_content()`, `fix_images_and_videos()`)
|
|
119
|
+
- **Variables**: `snake_case` (e.g., `page_title`, `filter_keys`)
|
|
120
|
+
- **Constants**: `UPPER_SNAKE_CASE` (e.g., `DEFAULT_TIMEOUT`)
|
|
121
|
+
- **Private methods**: prefix with underscore (e.g., `_resolve_ip()`)
|
|
122
|
+
|
|
123
|
+
### Docstrings
|
|
124
|
+
|
|
125
|
+
Use docstrings for all public classes and functions:
|
|
126
|
+
```python
|
|
127
|
+
def extract_site_and_path(path: str):
|
|
128
|
+
"""
|
|
129
|
+
Splits the given path into the site component and the remaining path.
|
|
130
|
+
|
|
131
|
+
Parameters:
|
|
132
|
+
path (str): The complete path to split.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
tuple: A tuple where the first element is the site and the second
|
|
136
|
+
element is the subsequent path.
|
|
137
|
+
"""
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Error Handling
|
|
141
|
+
|
|
142
|
+
- Use try/except blocks with specific exception types when possible
|
|
143
|
+
- Include meaningful error messages
|
|
144
|
+
- Example pattern from codebase:
|
|
145
|
+
```python
|
|
146
|
+
try:
|
|
147
|
+
content = self.wiki.getHtml(pageTitle)
|
|
148
|
+
except Exception as e:
|
|
149
|
+
error = self.errMsg(e)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Logging
|
|
153
|
+
|
|
154
|
+
Use the logging module:
|
|
155
|
+
```python
|
|
156
|
+
import logging
|
|
157
|
+
self.logger = logging.getLogger(self.__class__.__name__)
|
|
158
|
+
self.logger.debug("message")
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Class Structure
|
|
162
|
+
|
|
163
|
+
- Classes should inherit from `object` or other base classes
|
|
164
|
+
- Use dataclasses for simple data containers:
|
|
165
|
+
```python
|
|
166
|
+
from dataclasses import dataclass, field
|
|
167
|
+
from typing import Optional
|
|
168
|
+
|
|
169
|
+
@dataclass
|
|
170
|
+
class Site:
|
|
171
|
+
name: str
|
|
172
|
+
container: Optional[str] = None
|
|
173
|
+
ip: str = field(default="?", init=False)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Constants and Configuration
|
|
177
|
+
|
|
178
|
+
- Store configuration in class attributes with type annotations
|
|
179
|
+
- Use `field(default=..., init=False)` for computed/non-init fields
|
|
180
|
+
|
|
181
|
+
### Testing
|
|
182
|
+
|
|
183
|
+
- Test classes inherit from `Basetest` (from basemkit)
|
|
184
|
+
- Test methods should start with `test_`
|
|
185
|
+
- Use assertions: `self.assertTrue()`, `self.assertEqual()`
|
|
186
|
+
- Debug output with `print()` using f-strings
|
|
187
|
+
|
|
188
|
+
### File Organization
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
MediaWikiServerTools/
|
|
192
|
+
├── backend/ # Server/backup code
|
|
193
|
+
│ ├── __init__.py
|
|
194
|
+
│ ├── site.py
|
|
195
|
+
│ ├── sql_backup.py
|
|
196
|
+
│ ├── cron_backup.py
|
|
197
|
+
│ ├── wikibackup.py
|
|
198
|
+
│ ├── remote.py
|
|
199
|
+
│ ├── tsite.py
|
|
200
|
+
│ └── server.py
|
|
201
|
+
├── tests/ # Unit tests
|
|
202
|
+
│ ├── test_wikicms.py
|
|
203
|
+
│ └── ...
|
|
204
|
+
├── scripts/ # Build/utility scripts
|
|
205
|
+
│ ├── blackisort
|
|
206
|
+
│ ├── test
|
|
207
|
+
│ └── install
|
|
208
|
+
└── pyproject.toml
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Dependencies
|
|
212
|
+
|
|
213
|
+
Key dependencies (see pyproject.toml):
|
|
214
|
+
- `pybasemkit` - Base utilities
|
|
215
|
+
- `py-3rdparty-mediawiki` - MediaWiki client
|
|
216
|
+
- `beautifulsoup4` - HTML parsing
|
|
217
|
+
- `lxml` - XML/HTML processing
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## CI/CD
|
|
222
|
+
|
|
223
|
+
GitHub Actions workflow: `.github/workflows/build.yml`
|
|
224
|
+
- Runs on Python 3.10
|
|
225
|
+
- Installs dependencies via `scripts/install`
|
|
226
|
+
- Runs tests via `scripts/test`
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Additional Notes
|
|
231
|
+
|
|
232
|
+
- Version is managed via hatchling in `backend/__init__.py`
|
|
233
|
+
- Package uses flit/hatchling build system
|
|
234
|
+
- Follow existing code patterns when extending functionality
|