homlab-gen 0.1.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.
- homlab_gen-0.1.1/.gitignore +218 -0
- homlab_gen-0.1.1/LICENSE +21 -0
- homlab_gen-0.1.1/PKG-INFO +105 -0
- homlab_gen-0.1.1/README.md +79 -0
- homlab_gen-0.1.1/docs/api.md +56 -0
- homlab_gen-0.1.1/docs/cli.md +42 -0
- homlab_gen-0.1.1/docs/packaging.md +47 -0
- homlab_gen-0.1.1/docs/project-json.md +55 -0
- homlab_gen-0.1.1/homlab_gen/__init__.py +9 -0
- homlab_gen-0.1.1/homlab_gen/__main__.py +7 -0
- homlab_gen-0.1.1/homlab_gen/cli.py +139 -0
- homlab_gen-0.1.1/homlab_gen/core.py +378 -0
- homlab_gen-0.1.1/homlab_gen/geometry.py +42 -0
- homlab_gen-0.1.1/homlab_gen/main.py +52 -0
- homlab_gen-0.1.1/pyproject.toml +56 -0
- homlab_gen-0.1.1/tests/__init__.py +1 -0
- homlab_gen-0.1.1/tests/test_core.py +81 -0
|
@@ -0,0 +1,218 @@
|
|
|
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
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
.vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
homlab_gen-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Homology Lab
|
|
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,105 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: homlab-gen
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Generate crossing-free subprojects for HomLab project JSON files.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Homology-Lab/homlab_gen
|
|
6
|
+
Project-URL: Documentation, https://github.com/Homology-Lab/homlab_gen/tree/main/docs
|
|
7
|
+
Project-URL: Issues, https://github.com/Homology-Lab/homlab_gen/issues
|
|
8
|
+
Author: HomLab.Gen contributors
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: diagram,generator,graph,homlab
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: filelock>=3.13
|
|
24
|
+
Requires-Dist: homlab-solver
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# HomLab.Gen
|
|
28
|
+
|
|
29
|
+
HomLab.Gen 用于读取 HomLab 项目 JSON,消除图中的交叉点,并生成所有可能的无交叉子图。
|
|
30
|
+
|
|
31
|
+
## 安装
|
|
32
|
+
|
|
33
|
+
开发安装:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
python -m pip install -e .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
构建发布包:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
python -m pip install build
|
|
43
|
+
python -m build
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
构建产物会输出到 `dist/`。
|
|
47
|
+
|
|
48
|
+
## 命令行使用
|
|
49
|
+
|
|
50
|
+
安装后可以使用 `homlab-gen`:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
homlab-gen path/to/project.json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
默认输出:
|
|
57
|
+
|
|
58
|
+
- `sub_diagram/`:所有生成的子项目 JSON。
|
|
59
|
+
- `erase.json`:删除原交叉边并插入角点后的中间文件。
|
|
60
|
+
- `progress.txt`:生成进度。
|
|
61
|
+
- `error.log`:错误日志。
|
|
62
|
+
|
|
63
|
+
也可以显式指定这些路径:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
homlab-gen path/to/project.json path/to/error.log --tmp path/to/erase.json --progress path/to/progress.txt
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
只清理旧的 `sub_diagram/` 目录:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
homlab-gen path/to/project.json --erase-only
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
兼容旧参数名:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
homlab-gen path/to/project.json --dryrun
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Python API
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from homlab_gen import generate_subprojects
|
|
85
|
+
|
|
86
|
+
exit_code = generate_subprojects("path/to/project.json")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`exit_code` 为 `0` 表示成功,为 `1` 表示失败。失败原因会写入错误日志。
|
|
90
|
+
|
|
91
|
+
## 文档
|
|
92
|
+
|
|
93
|
+
更多细节放在 `docs/`:
|
|
94
|
+
|
|
95
|
+
- [命令行接口](docs/cli.md)
|
|
96
|
+
- [Python API](docs/api.md)
|
|
97
|
+
- [项目 JSON 约定](docs/project-json.md)
|
|
98
|
+
- [打包与发布](docs/packaging.md)
|
|
99
|
+
|
|
100
|
+
## 开发检查
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
python -m unittest
|
|
104
|
+
python -m build
|
|
105
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# HomLab.Gen
|
|
2
|
+
|
|
3
|
+
HomLab.Gen 用于读取 HomLab 项目 JSON,消除图中的交叉点,并生成所有可能的无交叉子图。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
开发安装:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
python -m pip install -e .
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
构建发布包:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
python -m pip install build
|
|
17
|
+
python -m build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
构建产物会输出到 `dist/`。
|
|
21
|
+
|
|
22
|
+
## 命令行使用
|
|
23
|
+
|
|
24
|
+
安装后可以使用 `homlab-gen`:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
homlab-gen path/to/project.json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
默认输出:
|
|
31
|
+
|
|
32
|
+
- `sub_diagram/`:所有生成的子项目 JSON。
|
|
33
|
+
- `erase.json`:删除原交叉边并插入角点后的中间文件。
|
|
34
|
+
- `progress.txt`:生成进度。
|
|
35
|
+
- `error.log`:错误日志。
|
|
36
|
+
|
|
37
|
+
也可以显式指定这些路径:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
homlab-gen path/to/project.json path/to/error.log --tmp path/to/erase.json --progress path/to/progress.txt
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
只清理旧的 `sub_diagram/` 目录:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
homlab-gen path/to/project.json --erase-only
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
兼容旧参数名:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
homlab-gen path/to/project.json --dryrun
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Python API
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from homlab_gen import generate_subprojects
|
|
59
|
+
|
|
60
|
+
exit_code = generate_subprojects("path/to/project.json")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`exit_code` 为 `0` 表示成功,为 `1` 表示失败。失败原因会写入错误日志。
|
|
64
|
+
|
|
65
|
+
## 文档
|
|
66
|
+
|
|
67
|
+
更多细节放在 `docs/`:
|
|
68
|
+
|
|
69
|
+
- [命令行接口](docs/cli.md)
|
|
70
|
+
- [Python API](docs/api.md)
|
|
71
|
+
- [项目 JSON 约定](docs/project-json.md)
|
|
72
|
+
- [打包与发布](docs/packaging.md)
|
|
73
|
+
|
|
74
|
+
## 开发检查
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python -m unittest
|
|
78
|
+
python -m build
|
|
79
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Python API
|
|
2
|
+
|
|
3
|
+
推荐使用顶层导出的 `generate_subprojects`:
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from homlab_gen import generate_subprojects
|
|
7
|
+
|
|
8
|
+
code = generate_subprojects("project.json")
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## `generate_subprojects`
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
generate_subprojects(
|
|
15
|
+
filepath,
|
|
16
|
+
error_output_filepath=None,
|
|
17
|
+
tmp_filepath=None,
|
|
18
|
+
progress_filepath=None,
|
|
19
|
+
just_erase=False,
|
|
20
|
+
) -> int
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
参数:
|
|
24
|
+
|
|
25
|
+
- `filepath`:输入 HomLab 项目 JSON。
|
|
26
|
+
- `error_output_filepath`:错误日志路径。默认是输入文件同级目录下的 `error.log`。
|
|
27
|
+
- `tmp_filepath`:中间 JSON 路径。默认是输入文件同级目录下的 `erase.json`。
|
|
28
|
+
- `progress_filepath`:进度文件路径。默认是输入文件同级目录下的 `progress.txt`。
|
|
29
|
+
- `just_erase`:为 `True` 时只清理并重建 `sub_diagram/`。
|
|
30
|
+
|
|
31
|
+
返回值:
|
|
32
|
+
|
|
33
|
+
- `0`:成功。
|
|
34
|
+
- `1`:失败。
|
|
35
|
+
|
|
36
|
+
失败时会把详细 traceback 或业务错误写入错误日志。
|
|
37
|
+
|
|
38
|
+
## 兼容入口
|
|
39
|
+
|
|
40
|
+
历史上代码放在 `homlab_gen/main.py`。现在该文件仍然保留,可以继续:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
python -m homlab_gen.main project.json error.log
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
新代码建议使用:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m homlab_gen project.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
或安装后使用:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
homlab-gen project.json
|
|
56
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 命令行接口
|
|
2
|
+
|
|
3
|
+
安装项目后会得到 `homlab-gen` 命令。
|
|
4
|
+
|
|
5
|
+
## 基本命令
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
homlab-gen input.json
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
这个命令会在 `input.json` 同级目录下创建或覆盖:
|
|
12
|
+
|
|
13
|
+
- `sub_diagram/`
|
|
14
|
+
- `erase.json`
|
|
15
|
+
- `progress.txt`
|
|
16
|
+
- `error.log`
|
|
17
|
+
|
|
18
|
+
## 参数
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
homlab-gen [-h] [--tmp TMP] [--progress PROGRESS] [--erase-only] [--quiet] [--version] input [error_log]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- `input`:HomLab 项目 JSON。
|
|
25
|
+
- `error_log`:错误日志路径,默认是输入文件同级目录下的 `error.log`。
|
|
26
|
+
- `--tmp`:中间 JSON 路径,默认是输入文件同级目录下的 `erase.json`。
|
|
27
|
+
- `--progress`:进度文件路径,默认是输入文件同级目录下的 `progress.txt`。
|
|
28
|
+
- `--erase-only`:只删除并重建 `sub_diagram/`,不执行生成。
|
|
29
|
+
- `--dryrun`:`--erase-only` 的兼容别名。
|
|
30
|
+
- `--quiet`:不输出成功提示。
|
|
31
|
+
- `--version`:显示版本。
|
|
32
|
+
|
|
33
|
+
## 退出码
|
|
34
|
+
|
|
35
|
+
- `0`:执行成功。
|
|
36
|
+
- `1`:执行失败。具体原因查看错误日志。
|
|
37
|
+
|
|
38
|
+
## 注意事项
|
|
39
|
+
|
|
40
|
+
每条边最多只能包含一个交叉点。如果同一条边上检测到多个交叉点,程序会停止并写入错误日志。
|
|
41
|
+
|
|
42
|
+
当前为了避免生成数量爆炸,交叉点数量上限是 15。生成数量为 `2 ** 交叉点数量`。
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 打包与发布
|
|
2
|
+
|
|
3
|
+
项目使用标准 `pyproject.toml`,构建后会生成 wheel 和 sdist。
|
|
4
|
+
|
|
5
|
+
## 本地开发安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m pip install -e .
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 运行测试
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
python -m unittest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 构建
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
python -m pip install build
|
|
21
|
+
python -m build
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
构建产物:
|
|
25
|
+
|
|
26
|
+
- `dist/homlab_gen-*.whl`
|
|
27
|
+
- `dist/homlab_gen-*.tar.gz`
|
|
28
|
+
|
|
29
|
+
## 安装构建产物
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
python -m pip install dist/homlab_gen-*.whl
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 入口
|
|
36
|
+
|
|
37
|
+
包安装后会注册命令:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
homlab-gen --help
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
也可以使用模块入口:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python -m homlab_gen --help
|
|
47
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# 项目 JSON 约定
|
|
2
|
+
|
|
3
|
+
HomLab.Gen 期望输入文件包含 HomLab 项目结构。程序会读取以下字段:
|
|
4
|
+
|
|
5
|
+
- `type`
|
|
6
|
+
- `n`
|
|
7
|
+
- `sw`
|
|
8
|
+
- `cx`
|
|
9
|
+
- `cy`
|
|
10
|
+
- `sc`
|
|
11
|
+
- `r`
|
|
12
|
+
- `bw`
|
|
13
|
+
- `dpr`
|
|
14
|
+
- `cpr`
|
|
15
|
+
- `hs`
|
|
16
|
+
- `ns`
|
|
17
|
+
- `es`
|
|
18
|
+
|
|
19
|
+
## 节点
|
|
20
|
+
|
|
21
|
+
节点来自 `hs` 和 `ns`。每个非元数据键都需要包含:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"x": 0,
|
|
26
|
+
"y": 0
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
键名通常形如 `node_0000001`。以 `#` 开头的键会被视为元数据。
|
|
31
|
+
|
|
32
|
+
## 边
|
|
33
|
+
|
|
34
|
+
边来自 `es`。每条边需要包含:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"id_1": "node_0000001",
|
|
39
|
+
"id_2": "node_0000002"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
键名通常形如 `edge_0000001`。以 `#` 开头的键会被视为元数据。
|
|
44
|
+
|
|
45
|
+
## 生成过程
|
|
46
|
+
|
|
47
|
+
程序会:
|
|
48
|
+
|
|
49
|
+
1. 找出所有两两相交且不共享端点的边。
|
|
50
|
+
2. 删除相交的旧边。
|
|
51
|
+
3. 在每个交叉点周围创建四个新角点。
|
|
52
|
+
4. 枚举每个交叉点的两种连接方式。
|
|
53
|
+
5. 把每一种组合输出为 `sub_diagram/*.json`。
|
|
54
|
+
|
|
55
|
+
如果有 `n` 个交叉点,会生成 `2 ** n` 个子项目。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Generate crossing-free subprojects for HomLab project JSON files."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from .core import gen_all_dir_idx, generate_subprojects
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|
|
8
|
+
|
|
9
|
+
__all__ = ["__version__", "gen_all_dir_idx", "generate_subprojects"]
|