verysimpletree 1.2__tar.gz → 2.0.0__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.
- verysimpletree-2.0.0/PKG-INFO +98 -0
- verysimpletree-2.0.0/README.md +80 -0
- verysimpletree-2.0.0/pyproject.toml +65 -0
- verysimpletree-2.0.0/pyproject.toml.orig +54 -0
- verysimpletree-2.0.0/verysimpletree/test_tree.py +753 -0
- {verysimpletree-1.2 → verysimpletree-2.0.0}/verysimpletree/tree.py +178 -82
- {verysimpletree-1.2 → verysimpletree-2.0.0}/verysimpletree/util.py +1 -1
- verysimpletree-1.2/PKG-INFO +0 -21
- verysimpletree-1.2/README.md +0 -1
- verysimpletree-1.2/pyproject.toml +0 -28
- verysimpletree-1.2/verysimpletree/test_tree.py +0 -297
- {verysimpletree-1.2 → verysimpletree-2.0.0}/verysimpletree/.coverage +0 -0
- {verysimpletree-1.2 → verysimpletree-2.0.0}/verysimpletree/__init__.py +0 -0
- {verysimpletree-1.2 → verysimpletree-2.0.0}/verysimpletree/py.typed +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: verysimpletree
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: lightweight tree data structure
|
|
5
|
+
Author: Alex Gorji
|
|
6
|
+
Author-email: Alex Gorji <aligorji@hotmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Project-URL: Homepage, https://gitlab.com/alexgorji/verysimpletree.git
|
|
16
|
+
Project-URL: Repository, https://gitlab.com/alexgorji/verysimpletree.git
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
An abstract lightweight tree class for managing tree structures.
|
|
20
|
+
|
|
21
|
+
Requires Python 3.11 or newer.
|
|
22
|
+
|
|
23
|
+
## Development
|
|
24
|
+
|
|
25
|
+
Use a current uv release; development and package builds are verified with
|
|
26
|
+
uv 0.13.1. Older uv releases may fail to extract archives used by the current
|
|
27
|
+
build backend.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
uv sync --locked
|
|
31
|
+
uv run pytest
|
|
32
|
+
uv run mypy verysimpletree --strict
|
|
33
|
+
uv run ruff check .
|
|
34
|
+
uv run ruff format --check .
|
|
35
|
+
uv build
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## GitLab CI and releases
|
|
39
|
+
|
|
40
|
+
The root `.gitlab-ci.yml` runs lint and strict type checks, tests Python
|
|
41
|
+
3.11-3.14, and builds a wheel and source distribution. Merge requests, branch
|
|
42
|
+
pushes, and tags run validation; duplicate branch pipelines are skipped for
|
|
43
|
+
pushes with an open merge request. Jobs explicitly select their Python
|
|
44
|
+
interpreter rather than relying on the development `.python-version` pin.
|
|
45
|
+
JUnit test reports and built distributions are retained as job artifacts.
|
|
46
|
+
|
|
47
|
+
To enable publishing on GitLab:
|
|
48
|
+
|
|
49
|
+
1. Use a runner that supports the configured Python Docker images.
|
|
50
|
+
2. Protect release tags matching `v*` and restrict who can create them.
|
|
51
|
+
3. Add `UV_PUBLISH_TOKEN` as a masked, protected CI/CD variable containing a
|
|
52
|
+
PyPI API token scoped to the `verysimpletree` project.
|
|
53
|
+
4. Set the version in `pyproject.toml`, update `uv.lock`, and commit the changes.
|
|
54
|
+
5. Push a matching stable version tag, such as `v2.0.0`.
|
|
55
|
+
|
|
56
|
+
Publishing runs automatically only for protected stable version tags, after
|
|
57
|
+
checks, tests, and the build pass. The tag must match the package version.
|
|
58
|
+
The publish job uploads the build job's artifacts without rebuilding them.
|
|
59
|
+
Branch and merge request pipelines never publish.
|
|
60
|
+
|
|
61
|
+
## Structural mutations
|
|
62
|
+
|
|
63
|
+
- `parent.add_child(child)` appends a detached child and returns it.
|
|
64
|
+
- `parent.insert_child(index, child)` inserts a detached child and returns it.
|
|
65
|
+
Indices follow `list.insert()`: negative indices count from the end, and
|
|
66
|
+
out-of-range indices are clamped.
|
|
67
|
+
- `parent.remove(child)` detaches a direct child.
|
|
68
|
+
- `parent.replace_child(old, new, index=0)` replaces a direct child in place.
|
|
69
|
+
`old` can also be a predicate; `index` selects among matching children.
|
|
70
|
+
Replacing a child with itself is a no-op. The method returns `None`.
|
|
71
|
+
|
|
72
|
+
Children must have no parent before attachment. Self-insertion, ancestor
|
|
73
|
+
insertion, and attaching an already-parented child raise `ValueError`.
|
|
74
|
+
Subclass child-type checks still apply. Invalid attachments leave the tree
|
|
75
|
+
unchanged. To move a child, remove it from its old parent first:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
old_parent.remove(child)
|
|
79
|
+
new_parent.add_child(child)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Mutation methods update parent pointers, leaf status, and affected traversal,
|
|
83
|
+
leaf, and ancestor-path caches.
|
|
84
|
+
|
|
85
|
+
## Subclass contract
|
|
86
|
+
|
|
87
|
+
Implement `_check_child_to_be_added()` to validate allowed child types, raising
|
|
88
|
+
an exception for invalid children without mutating the tree. Structural checks
|
|
89
|
+
are shared by `add_child()`, `insert_child()`, and `replace_child()` through
|
|
90
|
+
`_validate_child_attachment()`.
|
|
91
|
+
|
|
92
|
+
Inherited structural operations use `_children` as their authoritative child
|
|
93
|
+
storage. Overriding `get_children()` alone does not provide alternative-storage
|
|
94
|
+
support. Subclasses using `_children` should reuse the mutation methods rather
|
|
95
|
+
than assign parent pointers or edit child lists directly.
|
|
96
|
+
|
|
97
|
+
`get_children()` still returns the mutable backing list for compatibility.
|
|
98
|
+
Direct edits bypass validation and cache invalidation.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
An abstract lightweight tree class for managing tree structures.
|
|
2
|
+
|
|
3
|
+
Requires Python 3.11 or newer.
|
|
4
|
+
|
|
5
|
+
## Development
|
|
6
|
+
|
|
7
|
+
Use a current uv release; development and package builds are verified with
|
|
8
|
+
uv 0.13.1. Older uv releases may fail to extract archives used by the current
|
|
9
|
+
build backend.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
uv sync --locked
|
|
13
|
+
uv run pytest
|
|
14
|
+
uv run mypy verysimpletree --strict
|
|
15
|
+
uv run ruff check .
|
|
16
|
+
uv run ruff format --check .
|
|
17
|
+
uv build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## GitLab CI and releases
|
|
21
|
+
|
|
22
|
+
The root `.gitlab-ci.yml` runs lint and strict type checks, tests Python
|
|
23
|
+
3.11-3.14, and builds a wheel and source distribution. Merge requests, branch
|
|
24
|
+
pushes, and tags run validation; duplicate branch pipelines are skipped for
|
|
25
|
+
pushes with an open merge request. Jobs explicitly select their Python
|
|
26
|
+
interpreter rather than relying on the development `.python-version` pin.
|
|
27
|
+
JUnit test reports and built distributions are retained as job artifacts.
|
|
28
|
+
|
|
29
|
+
To enable publishing on GitLab:
|
|
30
|
+
|
|
31
|
+
1. Use a runner that supports the configured Python Docker images.
|
|
32
|
+
2. Protect release tags matching `v*` and restrict who can create them.
|
|
33
|
+
3. Add `UV_PUBLISH_TOKEN` as a masked, protected CI/CD variable containing a
|
|
34
|
+
PyPI API token scoped to the `verysimpletree` project.
|
|
35
|
+
4. Set the version in `pyproject.toml`, update `uv.lock`, and commit the changes.
|
|
36
|
+
5. Push a matching stable version tag, such as `v2.0.0`.
|
|
37
|
+
|
|
38
|
+
Publishing runs automatically only for protected stable version tags, after
|
|
39
|
+
checks, tests, and the build pass. The tag must match the package version.
|
|
40
|
+
The publish job uploads the build job's artifacts without rebuilding them.
|
|
41
|
+
Branch and merge request pipelines never publish.
|
|
42
|
+
|
|
43
|
+
## Structural mutations
|
|
44
|
+
|
|
45
|
+
- `parent.add_child(child)` appends a detached child and returns it.
|
|
46
|
+
- `parent.insert_child(index, child)` inserts a detached child and returns it.
|
|
47
|
+
Indices follow `list.insert()`: negative indices count from the end, and
|
|
48
|
+
out-of-range indices are clamped.
|
|
49
|
+
- `parent.remove(child)` detaches a direct child.
|
|
50
|
+
- `parent.replace_child(old, new, index=0)` replaces a direct child in place.
|
|
51
|
+
`old` can also be a predicate; `index` selects among matching children.
|
|
52
|
+
Replacing a child with itself is a no-op. The method returns `None`.
|
|
53
|
+
|
|
54
|
+
Children must have no parent before attachment. Self-insertion, ancestor
|
|
55
|
+
insertion, and attaching an already-parented child raise `ValueError`.
|
|
56
|
+
Subclass child-type checks still apply. Invalid attachments leave the tree
|
|
57
|
+
unchanged. To move a child, remove it from its old parent first:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
old_parent.remove(child)
|
|
61
|
+
new_parent.add_child(child)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Mutation methods update parent pointers, leaf status, and affected traversal,
|
|
65
|
+
leaf, and ancestor-path caches.
|
|
66
|
+
|
|
67
|
+
## Subclass contract
|
|
68
|
+
|
|
69
|
+
Implement `_check_child_to_be_added()` to validate allowed child types, raising
|
|
70
|
+
an exception for invalid children without mutating the tree. Structural checks
|
|
71
|
+
are shared by `add_child()`, `insert_child()`, and `replace_child()` through
|
|
72
|
+
`_validate_child_attachment()`.
|
|
73
|
+
|
|
74
|
+
Inherited structural operations use `_children` as their authoritative child
|
|
75
|
+
storage. Overriding `get_children()` alone does not provide alternative-storage
|
|
76
|
+
support. Subclasses using `_children` should reuse the mutation methods rather
|
|
77
|
+
than assign parent pointers or edit child lists directly.
|
|
78
|
+
|
|
79
|
+
`get_children()` still returns the mutable backing list for compatibility.
|
|
80
|
+
Direct edits bypass validation and cache invalidation.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "verysimpletree"
|
|
3
|
+
version = "2.0.0"
|
|
4
|
+
description = "lightweight tree data structure"
|
|
5
|
+
requires-python = ">=3.11"
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Programming Language :: Python :: 3",
|
|
10
|
+
"Operating System :: OS Independent",
|
|
11
|
+
"Programming Language :: Python :: 3.11",
|
|
12
|
+
"Programming Language :: Python :: 3.12",
|
|
13
|
+
"Programming Language :: Python :: 3.13",
|
|
14
|
+
"Programming Language :: Python :: 3.14",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[[project.authors]]
|
|
18
|
+
name = "Alex Gorji"
|
|
19
|
+
email = "aligorji@hotmail.com"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://gitlab.com/alexgorji/verysimpletree.git"
|
|
23
|
+
Repository = "https://gitlab.com/alexgorji/verysimpletree.git"
|
|
24
|
+
|
|
25
|
+
[dependency-groups]
|
|
26
|
+
test = [
|
|
27
|
+
"mypy>=2.4.0,<3",
|
|
28
|
+
"pytest>=9.1.1,<10",
|
|
29
|
+
"pytest-xdist>=3.8.0,<4",
|
|
30
|
+
"pytest-cov>=7.1.0,<8",
|
|
31
|
+
]
|
|
32
|
+
dev = ["ruff>=0.17.1,<0.18"]
|
|
33
|
+
|
|
34
|
+
[tool.uv]
|
|
35
|
+
default-groups = "all"
|
|
36
|
+
|
|
37
|
+
[tool.uv.build-backend]
|
|
38
|
+
module-root = ""
|
|
39
|
+
source-include = ["verysimpletree/py.typed"]
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
addopts = "-s --doctest-modules"
|
|
43
|
+
markers = [
|
|
44
|
+
"nonci: marks non ci tests",
|
|
45
|
+
"wip: marks wip tests",
|
|
46
|
+
"only: focused tests",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.mypy]
|
|
50
|
+
python_version = "3.11"
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
target-version = "py311"
|
|
54
|
+
|
|
55
|
+
[tool.ruff.lint]
|
|
56
|
+
select = [
|
|
57
|
+
"E4",
|
|
58
|
+
"E7",
|
|
59
|
+
"E9",
|
|
60
|
+
"F",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[build-system]
|
|
64
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
65
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "verysimpletree"
|
|
3
|
+
version = "2.0.0"
|
|
4
|
+
description = "lightweight tree data structure"
|
|
5
|
+
authors = [{ name = "Alex Gorji", email = "aligorji@hotmail.com" }]
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
license = "MIT"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"Operating System :: OS Independent",
|
|
12
|
+
"Programming Language :: Python :: 3.11",
|
|
13
|
+
"Programming Language :: Python :: 3.12",
|
|
14
|
+
"Programming Language :: Python :: 3.13",
|
|
15
|
+
"Programming Language :: Python :: 3.14",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://gitlab.com/alexgorji/verysimpletree.git"
|
|
20
|
+
Repository = "https://gitlab.com/alexgorji/verysimpletree.git"
|
|
21
|
+
|
|
22
|
+
[dependency-groups]
|
|
23
|
+
test = [
|
|
24
|
+
"mypy>=2.4.0,<3",
|
|
25
|
+
"pytest>=9.1.1,<10",
|
|
26
|
+
"pytest-xdist>=3.8.0,<4",
|
|
27
|
+
"pytest-cov>=7.1.0,<8",
|
|
28
|
+
]
|
|
29
|
+
dev = ["ruff>=0.17.1,<0.18"]
|
|
30
|
+
|
|
31
|
+
[tool.uv]
|
|
32
|
+
default-groups = "all"
|
|
33
|
+
|
|
34
|
+
[tool.uv.build-backend]
|
|
35
|
+
module-root = ""
|
|
36
|
+
source-include = ["verysimpletree/py.typed"]
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
40
|
+
build-backend = "uv_build"
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
addopts = "-s --doctest-modules"
|
|
44
|
+
markers = ["nonci: marks non ci tests", "wip: marks wip tests", "only: focused tests"]
|
|
45
|
+
|
|
46
|
+
[tool.mypy]
|
|
47
|
+
python_version = "3.11"
|
|
48
|
+
|
|
49
|
+
[tool.ruff]
|
|
50
|
+
target-version = "py311"
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint]
|
|
53
|
+
# Preserve the lint policy used before Ruff's expanded defaults.
|
|
54
|
+
select = ["E4", "E7", "E9", "F"]
|