lib-registry 3.1.7__tar.gz → 3.2.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.
- {lib_registry-3.1.7 → lib_registry-3.2.0}/CHANGELOG.md +53 -10
- {lib_registry-3.1.7 → lib_registry-3.2.0}/PKG-INFO +28 -18
- {lib_registry-3.1.7 → lib_registry-3.2.0}/README.md +19 -10
- {lib_registry-3.1.7 → lib_registry-3.2.0}/docs/systemdesign/module_reference.md +19 -1
- {lib_registry-3.1.7 → lib_registry-3.2.0}/pyproject.toml +17 -12
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/__init__.py +5 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/__init__conf__.py +1 -1
- lib_registry-3.2.0/src/lib_registry/_cli_helpers.py +373 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/_helpers.py +11 -10
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/_winreg_setup.py +7 -3
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/cli.py +26 -31
- lib_registry-3.2.0/src/lib_registry/records.py +74 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/registry.py +21 -16
- {lib_registry-3.1.7 → lib_registry-3.2.0}/tests/conftest.py +23 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/tests/test_cli.py +112 -35
- lib_registry-3.2.0/tests/test_walks.py +127 -0
- lib_registry-3.1.7/src/lib_registry/_cli_helpers.py +0 -205
- {lib_registry-3.1.7 → lib_registry-3.2.0}/.gitignore +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/LICENSE +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/__main__.py +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/exceptions.py +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/py.typed +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/src/lib_registry/typed_click.py +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/tests/test_metadata.py +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/tests/test_module_entry.py +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/tests/test_packaging.py +0 -0
- {lib_registry-3.1.7 → lib_registry-3.2.0}/tests/test_platform_markers.py +0 -0
|
@@ -5,7 +5,50 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
-
## [3.
|
|
8
|
+
## [3.2.0] - 2026-11-24
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Dependency floors raised to the current releases: `fake_winreg>=1.10.5` (runtime, non-Windows),
|
|
13
|
+
and in the dev extra `ruff>=0.17.5`, `click>=8.5.1` and `pydantic>=2.14.3`. `uv.lock` refreshed.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `KeyInfo`, `TypedValue`, `RegValue` and `ResolvedKey`, `NamedTuple` records exported from the
|
|
18
|
+
package. `key_info()` returns a `KeyInfo`, `get_value_ex()` a `TypedValue`, `values()` yields
|
|
19
|
+
`RegValue` records and `resolve_key()` returns a `ResolvedKey`. Each still unpacks, indexes and
|
|
20
|
+
compares like the plain tuple it replaces, so existing callers keep working; the fields can now
|
|
21
|
+
also be read by name (`info.number_of_subkeys`, `value.reg_type`). Their `repr` shows the record
|
|
22
|
+
name and field names.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- On Windows, a type checker saw every `winreg` type that `Registry` exposes (its handles, the
|
|
27
|
+
`REG_*` constants) as unknown, because `_winreg_setup` chose between `winreg` and `fake_winreg`
|
|
28
|
+
through a runtime flag and fake_winreg is not installed there. It now branches on
|
|
29
|
+
`sys.platform == "win32"`, which type checkers narrow. `is_platform_windows` keeps its value.
|
|
30
|
+
- `Registry.delete_key(..., delete_subkeys=True)` failed with `PermissionError: [WinError 5]
|
|
31
|
+
Access is denied` on a key with two or more children. It deleted the children while enumerating
|
|
32
|
+
them by index, and every delete shifted the remaining children down one slot, so it skipped
|
|
33
|
+
every other child and the final delete of the parent found it still had subkeys. It now lists the
|
|
34
|
+
children first. `lib_registry delete-key --recursive` had the same failure.
|
|
35
|
+
- `lib_registry diff` printed a value present in only one key as just the key path
|
|
36
|
+
(`- HKCU\Software\A (only in ...)`), so the output did not say which value it meant. It now
|
|
37
|
+
prints `- HKCU\Software\A / ValueName (only in ...)`, like the line for a value that differs.
|
|
38
|
+
The `--json` output is unchanged.
|
|
39
|
+
- The recursive CLI commands (`list --recursive`, `search`, `tree`, `diff`, `copy --recursive`) kept
|
|
40
|
+
one open registry handle for every key they visited until the command ended, because `Registry`
|
|
41
|
+
caches each handle it opens. Over a large subtree (all of `HKLM\SOFTWARE`) that is hundreds of
|
|
42
|
+
thousands of open handles. They now close a key's handles when they leave it, so a walk holds one
|
|
43
|
+
handle per level of depth. `search` and `diff` also yield their results one at a time and print
|
|
44
|
+
their JSON arrays as they go instead of collecting the whole result first; the bytes printed are
|
|
45
|
+
the same.
|
|
46
|
+
- `notebooks/Quickstart.ipynb` installs the checkout it runs in, so CI's "Execute notebooks" job
|
|
47
|
+
tests the commit under test. It used to install `git+https://github.com/...` every time, which is
|
|
48
|
+
the pushed default branch, so a pull request's notebook run tested the code already there.
|
|
49
|
+
Outside a checkout (a downloaded notebook) it still installs from GitHub.
|
|
50
|
+
|
|
51
|
+
## [3.1.7] - 2026-10-21
|
|
9
52
|
|
|
10
53
|
### Fixed
|
|
11
54
|
|
|
@@ -16,7 +59,7 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
16
59
|
or a `FileNotFoundError`. The tests now write under `tmp_path` and the doctests under a
|
|
17
60
|
`tempfile.TemporaryDirectory`, so every run gets its own file.
|
|
18
61
|
|
|
19
|
-
## [3.1.6] 2026-10-15
|
|
62
|
+
## [3.1.6] - 2026-10-15
|
|
20
63
|
|
|
21
64
|
### Fixed
|
|
22
65
|
|
|
@@ -37,7 +80,7 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
37
80
|
(`pytest_runtest_setup` in `tests/conftest.py`); registered in `pyproject.toml` alone they skipped
|
|
38
81
|
nothing, so a test trusting its marker ran everywhere. `tests/test_platform_markers.py` pins it.
|
|
39
82
|
|
|
40
|
-
## [3.1.5] 2026-10-13
|
|
83
|
+
## [3.1.5] - 2026-10-13
|
|
41
84
|
|
|
42
85
|
### Added
|
|
43
86
|
- Python 3.15 is a supported version: declared in the classifiers, so CI and `make test-all` run it.
|
|
@@ -50,7 +93,7 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
50
93
|
a plain `pip install` from PyPI does not.
|
|
51
94
|
- `rtoml` floor raised to 0.14.0, the first release with Python 3.15 wheels.
|
|
52
95
|
|
|
53
|
-
## [3.1.4] 2026-07-24
|
|
96
|
+
## [3.1.4] - 2026-07-24
|
|
54
97
|
|
|
55
98
|
### Changed
|
|
56
99
|
- Pinned the ruff lint policy with an explicit `[tool.ruff.lint].select` (the curated bitranox
|
|
@@ -78,19 +121,19 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
78
121
|
`noqa: PERF203`: `winreg.EnumKey`/`EnumValue` signal end-of-enumeration via `OSError`, so the
|
|
79
122
|
loop-local exception handling is the API's own contract, not an avoidable pattern.
|
|
80
123
|
|
|
81
|
-
## [3.1.3] 2026-06-14
|
|
124
|
+
## [3.1.3] - 2026-06-14
|
|
82
125
|
|
|
83
126
|
### Changed
|
|
84
127
|
- Added a `typed_click.py` facade wrapping rich-click's `option` / `argument` / `version_option` decorators behind explicit, fully-known signatures, keeping the CLI strict-clean under pyright 1.1.410 (`reportUnknownMemberType`) without disabling the rule (ignore isolated to the facade). `cli.py` remains in the pyright `exclude` list for non-click reasons (private-helper imports from excluded modules).
|
|
85
128
|
- Bumped `fake_winreg` floor to `>=1.9.1`.
|
|
86
129
|
|
|
87
|
-
## [3.1.2] 2026-04-02
|
|
130
|
+
## [3.1.2] - 2026-04-02
|
|
88
131
|
|
|
89
132
|
### Changed
|
|
90
133
|
- Comprehensive API Reference in README with full signatures, parameters, examples,
|
|
91
134
|
and type mapping table for every public method
|
|
92
135
|
|
|
93
|
-
## [3.1.1] 2026-04-02
|
|
136
|
+
## [3.1.1] - 2026-04-02
|
|
94
137
|
|
|
95
138
|
### Changed
|
|
96
139
|
- Split `registry.py` (1624 lines) into 4 modules: `_winreg_setup.py` (constants),
|
|
@@ -102,7 +145,7 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
102
145
|
`cli -> _cli_helpers -> registry -> _helpers -> exceptions|_winreg_setup`
|
|
103
146
|
- All public API imports unchanged (backward compatible)
|
|
104
147
|
|
|
105
|
-
## [3.1.0] 2026-04-02
|
|
148
|
+
## [3.1.0] - 2026-04-02
|
|
106
149
|
|
|
107
150
|
### Added
|
|
108
151
|
- `sid_from_username()` method: reverse lookup from username to SID (case-insensitive)
|
|
@@ -115,7 +158,7 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
115
158
|
`RegistryError` (fixes [#2](https://github.com/bitranox/lib_registry/issues/2))
|
|
116
159
|
- `sid_from_username('Default')` returns `".DEFAULT"` without iterating ProfileList
|
|
117
160
|
|
|
118
|
-
## [3.0.1] 2026-04-02
|
|
161
|
+
## [3.0.1] - 2026-04-02
|
|
119
162
|
|
|
120
163
|
### Changed
|
|
121
164
|
- Drop Python 3.9 support, require Python 3.10+
|
|
@@ -125,7 +168,7 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
125
168
|
- Simplify all conditional dependency constraints (no more 3.9 forks)
|
|
126
169
|
- Ruff target updated from `py39` to `py310`
|
|
127
170
|
|
|
128
|
-
## [3.0.0] 2026-04-02
|
|
171
|
+
## [3.0.0] - 2026-04-02
|
|
129
172
|
|
|
130
173
|
### Added
|
|
131
174
|
- `Registry` class wrapping `winreg` with connection caching, handle management,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: lib_registry
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: a more pythonic way to access the windows registry as winreg
|
|
5
5
|
Project-URL: Homepage, https://github.com/bitranox/lib_registry
|
|
6
6
|
Project-URL: Repository, https://github.com/bitranox/lib_registry.git
|
|
@@ -25,23 +25,24 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
25
25
|
Classifier: Topic :: System :: Systems Administration
|
|
26
26
|
Classifier: Typing :: Typed
|
|
27
27
|
Requires-Python: >=3.10
|
|
28
|
-
Requires-Dist: fake-winreg>=1.10.
|
|
28
|
+
Requires-Dist: fake-winreg>=1.10.5; sys_platform != 'win32'
|
|
29
29
|
Requires-Dist: rich-click>=1.9.9
|
|
30
30
|
Requires-Dist: rtoml>=0.14.0
|
|
31
31
|
Provides-Extra: dev
|
|
32
32
|
Requires-Dist: bandit>=1.9.4; extra == 'dev'
|
|
33
33
|
Requires-Dist: build>=1.6.1; extra == 'dev'
|
|
34
|
-
Requires-Dist: click>=8.5.
|
|
35
|
-
Requires-Dist: hatchling>=1.
|
|
34
|
+
Requires-Dist: click>=8.5.1; extra == 'dev'
|
|
35
|
+
Requires-Dist: hatchling>=1.33.0; extra == 'dev'
|
|
36
36
|
Requires-Dist: import-linter>=2.15; extra == 'dev'
|
|
37
37
|
Requires-Dist: pip-audit>=2.10.1; extra == 'dev'
|
|
38
|
-
Requires-Dist: pydantic>=2.14.
|
|
38
|
+
Requires-Dist: pydantic>=2.14.3; extra == 'dev'
|
|
39
39
|
Requires-Dist: pyright[nodejs]>=1.1.414; extra == 'dev'
|
|
40
40
|
Requires-Dist: pytest-cov>=7.1.0; extra == 'dev'
|
|
41
|
-
Requires-Dist: pytest>=
|
|
41
|
+
Requires-Dist: pytest-xdist>=3.8.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest>=9.2.0; extra == 'dev'
|
|
42
43
|
Requires-Dist: rtoml>=0.14.0; extra == 'dev'
|
|
43
|
-
Requires-Dist: ruff>=0.17.
|
|
44
|
-
Requires-Dist: setuptools>=84.2.
|
|
44
|
+
Requires-Dist: ruff>=0.17.5; extra == 'dev'
|
|
45
|
+
Requires-Dist: setuptools>=84.2.1; extra == 'dev'
|
|
45
46
|
Requires-Dist: textual>=8.2.8; extra == 'dev'
|
|
46
47
|
Requires-Dist: twine>=7.0.0; extra == 'dev'
|
|
47
48
|
Description-Content-Type: text/markdown
|
|
@@ -622,15 +623,20 @@ lib_registry diff HKCU/Software/MyApp HKCU/Software/MyAppBackup
|
|
|
622
623
|
lib_registry --json diff HKCU/Software/V1 HKCU/Software/V2
|
|
623
624
|
```
|
|
624
625
|
|
|
625
|
-
Output format:
|
|
626
|
+
Output format: `-` marks what only KEY_A has, `+` what only KEY_B has, `~` a value in both
|
|
627
|
+
with different data or type. Value lines name the key and the value.
|
|
626
628
|
```
|
|
627
|
-
- HKCU\Software\MyApp (only in KEY_A)
|
|
628
|
-
+ HKCU\Software\MyAppBackup (only in KEY_B)
|
|
629
629
|
~ HKCU\Software\MyApp / Setting
|
|
630
630
|
A: old_value
|
|
631
631
|
B: new_value
|
|
632
|
+
- HKCU\Software\MyApp / OldSetting (only in HKCU\Software\MyApp)
|
|
633
|
+
+ HKCU\Software\MyAppBackup / NewSetting (only in HKCU\Software\MyAppBackup)
|
|
634
|
+
- [KEY] HKCU\Software\MyApp\Plugins (only in HKCU\Software\MyApp)
|
|
632
635
|
```
|
|
633
636
|
|
|
637
|
+
With `--json`, each difference is an object whose `kind` is one of `value_differs`, `only_in_a`,
|
|
638
|
+
`only_in_b`, `subkey_only_in_a` or `subkey_only_in_b`.
|
|
639
|
+
|
|
634
640
|
---
|
|
635
641
|
|
|
636
642
|
### Access constants
|
|
@@ -712,11 +718,14 @@ if reg.key_exist("HKLM/SOFTWARE/Python"):
|
|
|
712
718
|
print("Python is installed")
|
|
713
719
|
```
|
|
714
720
|
|
|
715
|
-
#### `key_info(key, sub_key='') ->
|
|
721
|
+
#### `key_info(key, sub_key='') -> KeyInfo`
|
|
716
722
|
|
|
717
|
-
Returns `(number_of_subkeys, number_of_values, last_modified_win_timestamp)
|
|
723
|
+
Returns a `KeyInfo(number_of_subkeys, number_of_values, last_modified_win_timestamp)`, a
|
|
724
|
+
`NamedTuple`: read the fields by name or unpack it like a tuple.
|
|
718
725
|
|
|
719
726
|
```python
|
|
727
|
+
info = reg.key_info("HKLM/SOFTWARE")
|
|
728
|
+
print(info.number_of_subkeys)
|
|
720
729
|
subkeys, values, ts = reg.key_info("HKLM/SOFTWARE")
|
|
721
730
|
```
|
|
722
731
|
|
|
@@ -745,9 +754,9 @@ for name in reg.subkeys("HKEY_USERS"):
|
|
|
745
754
|
print(name)
|
|
746
755
|
```
|
|
747
756
|
|
|
748
|
-
#### `values(key, sub_key='') -> Iterator[
|
|
757
|
+
#### `values(key, sub_key='') -> Iterator[RegValue]`
|
|
749
758
|
|
|
750
|
-
Yields `(
|
|
759
|
+
Yields `RegValue(name, data, reg_type)` records, a `NamedTuple` that unpacks like a tuple.
|
|
751
760
|
|
|
752
761
|
```python
|
|
753
762
|
for name, data, reg_type in reg.values("HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion"):
|
|
@@ -766,9 +775,10 @@ Read a value's data. Pass `None` or `''` as `value_name` for the unnamed default
|
|
|
766
775
|
build = reg.get_value("HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion", "CurrentBuild")
|
|
767
776
|
```
|
|
768
777
|
|
|
769
|
-
#### `get_value_ex(key, value_name) ->
|
|
778
|
+
#### `get_value_ex(key, value_name) -> TypedValue`
|
|
770
779
|
|
|
771
|
-
Read data and registry type
|
|
780
|
+
Read data and registry type as a `TypedValue(data, reg_type)`, a `NamedTuple` that unpacks like a
|
|
781
|
+
tuple.
|
|
772
782
|
|
|
773
783
|
```python
|
|
774
784
|
data, reg_type = reg.get_value_ex("HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion", "CurrentBuild")
|
|
@@ -900,7 +910,7 @@ Registry.expand_environment_strings("%USERPROFILE%\\Documents")
|
|
|
900
910
|
```python
|
|
901
911
|
from lib_registry import resolve_key, get_key_as_string, normalize_separators
|
|
902
912
|
|
|
903
|
-
resolve_key("HKLM/SOFTWARE/Microsoft") # (HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft')
|
|
913
|
+
resolve_key("HKLM/SOFTWARE/Microsoft") # ResolvedKey(hive_key=HKEY_LOCAL_MACHINE, sub_key='SOFTWARE\\Microsoft')
|
|
904
914
|
get_key_as_string(winreg.HKEY_LOCAL_MACHINE) # 'HKEY_LOCAL_MACHINE'
|
|
905
915
|
normalize_separators("HKLM/SOFTWARE/test") # 'HKLM\\SOFTWARE\\test'
|
|
906
916
|
```
|
|
@@ -574,15 +574,20 @@ lib_registry diff HKCU/Software/MyApp HKCU/Software/MyAppBackup
|
|
|
574
574
|
lib_registry --json diff HKCU/Software/V1 HKCU/Software/V2
|
|
575
575
|
```
|
|
576
576
|
|
|
577
|
-
Output format:
|
|
577
|
+
Output format: `-` marks what only KEY_A has, `+` what only KEY_B has, `~` a value in both
|
|
578
|
+
with different data or type. Value lines name the key and the value.
|
|
578
579
|
```
|
|
579
|
-
- HKCU\Software\MyApp (only in KEY_A)
|
|
580
|
-
+ HKCU\Software\MyAppBackup (only in KEY_B)
|
|
581
580
|
~ HKCU\Software\MyApp / Setting
|
|
582
581
|
A: old_value
|
|
583
582
|
B: new_value
|
|
583
|
+
- HKCU\Software\MyApp / OldSetting (only in HKCU\Software\MyApp)
|
|
584
|
+
+ HKCU\Software\MyAppBackup / NewSetting (only in HKCU\Software\MyAppBackup)
|
|
585
|
+
- [KEY] HKCU\Software\MyApp\Plugins (only in HKCU\Software\MyApp)
|
|
584
586
|
```
|
|
585
587
|
|
|
588
|
+
With `--json`, each difference is an object whose `kind` is one of `value_differs`, `only_in_a`,
|
|
589
|
+
`only_in_b`, `subkey_only_in_a` or `subkey_only_in_b`.
|
|
590
|
+
|
|
586
591
|
---
|
|
587
592
|
|
|
588
593
|
### Access constants
|
|
@@ -664,11 +669,14 @@ if reg.key_exist("HKLM/SOFTWARE/Python"):
|
|
|
664
669
|
print("Python is installed")
|
|
665
670
|
```
|
|
666
671
|
|
|
667
|
-
#### `key_info(key, sub_key='') ->
|
|
672
|
+
#### `key_info(key, sub_key='') -> KeyInfo`
|
|
668
673
|
|
|
669
|
-
Returns `(number_of_subkeys, number_of_values, last_modified_win_timestamp)
|
|
674
|
+
Returns a `KeyInfo(number_of_subkeys, number_of_values, last_modified_win_timestamp)`, a
|
|
675
|
+
`NamedTuple`: read the fields by name or unpack it like a tuple.
|
|
670
676
|
|
|
671
677
|
```python
|
|
678
|
+
info = reg.key_info("HKLM/SOFTWARE")
|
|
679
|
+
print(info.number_of_subkeys)
|
|
672
680
|
subkeys, values, ts = reg.key_info("HKLM/SOFTWARE")
|
|
673
681
|
```
|
|
674
682
|
|
|
@@ -697,9 +705,9 @@ for name in reg.subkeys("HKEY_USERS"):
|
|
|
697
705
|
print(name)
|
|
698
706
|
```
|
|
699
707
|
|
|
700
|
-
#### `values(key, sub_key='') -> Iterator[
|
|
708
|
+
#### `values(key, sub_key='') -> Iterator[RegValue]`
|
|
701
709
|
|
|
702
|
-
Yields `(
|
|
710
|
+
Yields `RegValue(name, data, reg_type)` records, a `NamedTuple` that unpacks like a tuple.
|
|
703
711
|
|
|
704
712
|
```python
|
|
705
713
|
for name, data, reg_type in reg.values("HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion"):
|
|
@@ -718,9 +726,10 @@ Read a value's data. Pass `None` or `''` as `value_name` for the unnamed default
|
|
|
718
726
|
build = reg.get_value("HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion", "CurrentBuild")
|
|
719
727
|
```
|
|
720
728
|
|
|
721
|
-
#### `get_value_ex(key, value_name) ->
|
|
729
|
+
#### `get_value_ex(key, value_name) -> TypedValue`
|
|
722
730
|
|
|
723
|
-
Read data and registry type
|
|
731
|
+
Read data and registry type as a `TypedValue(data, reg_type)`, a `NamedTuple` that unpacks like a
|
|
732
|
+
tuple.
|
|
724
733
|
|
|
725
734
|
```python
|
|
726
735
|
data, reg_type = reg.get_value_ex("HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion", "CurrentBuild")
|
|
@@ -852,7 +861,7 @@ Registry.expand_environment_strings("%USERPROFILE%\\Documents")
|
|
|
852
861
|
```python
|
|
853
862
|
from lib_registry import resolve_key, get_key_as_string, normalize_separators
|
|
854
863
|
|
|
855
|
-
resolve_key("HKLM/SOFTWARE/Microsoft") # (HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft')
|
|
864
|
+
resolve_key("HKLM/SOFTWARE/Microsoft") # ResolvedKey(hive_key=HKEY_LOCAL_MACHINE, sub_key='SOFTWARE\\Microsoft')
|
|
856
865
|
get_key_as_string(winreg.HKEY_LOCAL_MACHINE) # 'HKEY_LOCAL_MACHINE'
|
|
857
866
|
normalize_separators("HKLM/SOFTWARE/test") # 'HKLM\\SOFTWARE\\test'
|
|
858
867
|
```
|
|
@@ -104,7 +104,7 @@ winreg / fake_winreg
|
|
|
104
104
|
### Helper Functions
|
|
105
105
|
|
|
106
106
|
* `normalize_separators()` - Convert `/` to `\` for cross-platform key paths
|
|
107
|
-
* `resolve_key()` - Parse key string/int into (hive_key, sub_key)
|
|
107
|
+
* `resolve_key()` - Parse key string/int into a `ResolvedKey(hive_key, sub_key)`
|
|
108
108
|
* `get_hkey_int()` - Extract HKEY constant from key name string
|
|
109
109
|
* `get_key_as_string()` - Format key as human-readable string
|
|
110
110
|
* `get_value_type_as_string()` - Format registry type as string
|
|
@@ -124,6 +124,16 @@ winreg / fake_winreg
|
|
|
124
124
|
* `RegData = None | bytes | int | str | list[str]` - Union of valid registry
|
|
125
125
|
value types.
|
|
126
126
|
|
|
127
|
+
### Records (records.py)
|
|
128
|
+
|
|
129
|
+
`NamedTuple` records returned in place of bare tuples; each still unpacks and
|
|
130
|
+
compares like the tuple `winreg` returns.
|
|
131
|
+
|
|
132
|
+
* `ResolvedKey(hive_key, sub_key)` - from `resolve_key()`
|
|
133
|
+
* `KeyInfo(number_of_subkeys, number_of_values, last_modified_win_timestamp)` - from `key_info()`
|
|
134
|
+
* `TypedValue(data, reg_type)` - from `get_value_ex()`
|
|
135
|
+
* `RegValue(name, data, reg_type)` - yielded by `values()`
|
|
136
|
+
|
|
127
137
|
### Exported Constants
|
|
128
138
|
|
|
129
139
|
* All `HKEY_*` hive constants (7 hives with short aliases)
|
|
@@ -206,6 +216,14 @@ overflow validation for REG_DWORD (0..4294967295).
|
|
|
206
216
|
* `__exit__` calls `close_all()` to close all cached handles and connections.
|
|
207
217
|
* `__call__` calls `close_all()` before re-initializing to prevent leaks.
|
|
208
218
|
* `delete_key_ex` iterates all cached access masks for the deleted key.
|
|
219
|
+
* `delete_key(..., delete_subkeys=True)` lists a key's children before deleting
|
|
220
|
+
them: `RegEnumKey` enumerates by index, so deleting while enumerating would
|
|
221
|
+
skip every other child.
|
|
222
|
+
* The CLI's recursive walkers (`list -r`, `search`, `tree`, `diff`, `copy -r`)
|
|
223
|
+
close the handles they open for a key once they leave it
|
|
224
|
+
(`_cli_helpers.released_handles`), so a walk holds one handle per level of
|
|
225
|
+
depth. `search` and `diff` yield results one at a time and print JSON arrays
|
|
226
|
+
as they go (`echo_json_array`).
|
|
209
227
|
|
|
210
228
|
---
|
|
211
229
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "lib_registry"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.2.0"
|
|
4
4
|
description = "a more pythonic way to access the windows registry as winreg"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"rich-click>=1.9.9",
|
|
9
9
|
"rtoml>=0.14.0",
|
|
10
|
-
"fake_winreg>=1.10.
|
|
10
|
+
"fake_winreg>=1.10.5; sys_platform!='win32'",
|
|
11
11
|
]
|
|
12
12
|
license = { text = "MIT" }
|
|
13
13
|
authors = [{ name = "bitranox", email = "bitranox@gmail.com" }]
|
|
@@ -46,15 +46,16 @@ Issues = "https://github.com/bitranox/lib_registry/issues"
|
|
|
46
46
|
|
|
47
47
|
[project.optional-dependencies]
|
|
48
48
|
dev = [
|
|
49
|
-
"pytest>=9.
|
|
49
|
+
"pytest>=9.2.0",
|
|
50
50
|
"pytest-cov>=7.1.0",
|
|
51
|
-
"
|
|
51
|
+
"pytest-xdist>=3.8.0",
|
|
52
|
+
"ruff>=0.17.5",
|
|
52
53
|
"pyright[nodejs]>=1.1.414",
|
|
53
54
|
"bandit>=1.9.4",
|
|
54
55
|
# 1.5.1 was yanked upstream (unintended breaking changes), so 1.5.0 is the newest usable
|
|
55
56
|
# release; a >=1.5.1 floor has ZERO candidates and makes this extra unresolvable.
|
|
56
57
|
"build>=1.6.1",
|
|
57
|
-
"hatchling>=1.
|
|
58
|
+
"hatchling>=1.33.0",
|
|
58
59
|
"twine>=7.0.0",
|
|
59
60
|
# codecov-cli is disabled, not dropped: it requires click<8.3.0, which drags click back to
|
|
60
61
|
# 8.2.1 - the version with CVE-2026-7246 (command injection in click.edit(), fixed in 8.3.3).
|
|
@@ -64,12 +65,12 @@ dev = [
|
|
|
64
65
|
# Re-enable once codecov-cli relaxes its click<8.3.0 pin.
|
|
65
66
|
# "codecov-cli>=11.2.8",
|
|
66
67
|
# Transitive CVE pins
|
|
67
|
-
"click>=8.5.
|
|
68
|
+
"click>=8.5.1", # CVE-2026-7246
|
|
68
69
|
"pip-audit>=2.10.1",
|
|
69
70
|
"textual>=8.2.8",
|
|
70
71
|
"import-linter>=2.15",
|
|
71
|
-
"pydantic>=2.14.
|
|
72
|
-
"setuptools>=84.2.
|
|
72
|
+
"pydantic>=2.14.3",
|
|
73
|
+
"setuptools>=84.2.1",
|
|
73
74
|
"rtoml>=0.14.0",
|
|
74
75
|
]
|
|
75
76
|
|
|
@@ -78,7 +79,7 @@ lib_registry = "lib_registry.cli:main"
|
|
|
78
79
|
|
|
79
80
|
[build-system]
|
|
80
81
|
requires = [
|
|
81
|
-
"hatchling>=1.
|
|
82
|
+
"hatchling>=1.33.0",
|
|
82
83
|
]
|
|
83
84
|
build-backend = "hatchling.build"
|
|
84
85
|
|
|
@@ -138,7 +139,10 @@ convention = "google"
|
|
|
138
139
|
|
|
139
140
|
[tool.ruff.lint.per-file-ignores]
|
|
140
141
|
# ignore the "unused import sys" in the jupyter notebook - which we need (it is a linter hickup)
|
|
141
|
-
|
|
142
|
+
# A `!cmd` never raises, so CI sees a failing shell command only through
|
|
143
|
+
# `assert _exit_code == N` after it: IPython injects `_exit_code` at run time (F821)
|
|
144
|
+
# and those asserts are the gate (S101).
|
|
145
|
+
"notebooks/*.ipynb" = ["F401", "F821", "S101"]
|
|
142
146
|
# Tests: assert is standard, test fixtures have passwords, magic values are clearer inline, temp paths are fine.
|
|
143
147
|
# PLC0415: local/deferred imports are a deliberate test idiom - several tests import inside the test
|
|
144
148
|
# body to exercise import-time and cache behaviour, so moving them to module top would defeat intent.
|
|
@@ -239,6 +243,7 @@ layers = [
|
|
|
239
243
|
"lib_registry._cli_helpers",
|
|
240
244
|
"lib_registry.registry",
|
|
241
245
|
"lib_registry._helpers",
|
|
246
|
+
"lib_registry.records",
|
|
242
247
|
"lib_registry.exceptions | lib_registry._winreg_setup",
|
|
243
248
|
]
|
|
244
249
|
|
|
@@ -256,5 +261,5 @@ max-line-length = 120
|
|
|
256
261
|
ignores = ["E003"]
|
|
257
262
|
|
|
258
263
|
[tool.uv]
|
|
259
|
-
exclude-newer = "
|
|
260
|
-
exclude-newer-package = {
|
|
264
|
+
exclude-newer = "7 days"
|
|
265
|
+
exclude-newer-package = {fake-winreg = false, lib-cli-exit-tools = false, lib-layered-config = false, lib-log-rich = false, lib-registry = false}
|
|
@@ -52,6 +52,7 @@ from .exceptions import (
|
|
|
52
52
|
RegistryValueNotFoundError,
|
|
53
53
|
RegistryValueWriteError,
|
|
54
54
|
)
|
|
55
|
+
from .records import KeyInfo, RegValue, ResolvedKey, TypedValue
|
|
55
56
|
from .registry import Registry
|
|
56
57
|
|
|
57
58
|
__all__ = [
|
|
@@ -69,7 +70,9 @@ __all__ = [
|
|
|
69
70
|
"KEY_WOW64_64KEY",
|
|
70
71
|
"KEY_WRITE",
|
|
71
72
|
# Registry API
|
|
73
|
+
"KeyInfo",
|
|
72
74
|
"RegData",
|
|
75
|
+
"RegValue",
|
|
73
76
|
"Registry",
|
|
74
77
|
"RegistryConnectionError",
|
|
75
78
|
"RegistryError",
|
|
@@ -85,6 +88,8 @@ __all__ = [
|
|
|
85
88
|
"RegistryValueError",
|
|
86
89
|
"RegistryValueNotFoundError",
|
|
87
90
|
"RegistryValueWriteError",
|
|
91
|
+
"ResolvedKey",
|
|
92
|
+
"TypedValue",
|
|
88
93
|
"get_first_part_of_the_key",
|
|
89
94
|
"get_hkey_int",
|
|
90
95
|
"get_key_as_string",
|
|
@@ -24,7 +24,7 @@ name = "lib_registry"
|
|
|
24
24
|
#: Human-readable summary shown in CLI help output.
|
|
25
25
|
title = "a more pythonic way to access the windows registry as winreg"
|
|
26
26
|
#: Current release version pulled from ``pyproject.toml`` by automation.
|
|
27
|
-
version = "3.
|
|
27
|
+
version = "3.2.0"
|
|
28
28
|
#: Repository homepage presented to users.
|
|
29
29
|
homepage = "https://github.com/bitranox/lib_registry"
|
|
30
30
|
#: Author attribution surfaced in CLI output.
|