dol 0.4.2__tar.gz → 0.4.3__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.
- {dol-0.4.2 → dol-0.4.3}/.claude/skills/dol-dev-portability/SKILL.md +1 -0
- {dol-0.4.2 → dol-0.4.3}/PKG-INFO +1 -1
- {dol-0.4.2 → dol-0.4.3}/dol/filesys.py +91 -23
- dol-0.4.3/dol/tests/test_files_walk.py +123 -0
- {dol-0.4.2 → dol-0.4.3}/pyproject.toml +1 -1
- {dol-0.4.2 → dol-0.4.3}/.claude/commands/add-codec.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/.claude/commands/explain-store.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/.claude/commands/new-store.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/.claude/rules/dol-conventions.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/.claude/skills/dol-dev-wrap-kvs/SKILL.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/.claude/skills/dol-facade-authoring/SKILL.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/.claude/skills/dol-facade-authoring/references/skeleton.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/.claude/skills/dol-store-building/SKILL.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/.gitattributes +0 -0
- {dol-0.4.2 → dol-0.4.3}/.github/workflows/ci.yml +0 -0
- {dol-0.4.2 → dol-0.4.3}/.gitignore +0 -0
- {dol-0.4.2 → dol-0.4.3}/CLAUDE.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/LICENSE +0 -0
- {dol-0.4.2 → dol-0.4.3}/README.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/__init__.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/_codecs_core.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/_interface_wrap.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/_paths_core.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/_relocated.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/appendable.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/atomic.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/base.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/cache_keys.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/caching.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/content.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/dig.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/errors.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/explicit.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/gitignore.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/kv_codecs.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/misc.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/mixins.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/naming.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/paths.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/py.typed +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/recipes.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/records.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/scrap/__init__.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/scrap/new_store_wrap.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/scrap/store_factories.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/sig_builtins.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/sig_compare.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/sig_recipes.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/signatures.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/sources.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/store_addons.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/store_caching.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/__init__.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/base_test.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/pickability_test.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/scrap.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_app_folder.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_appendable.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_atomic.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_caching.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_confirm_overwrite.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_content.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_dig.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_dol_tools.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_edge_cases.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_errors.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_fanout_stores.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_file_lock.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_filesys.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_fsspec_recipe.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_gitignore.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_interface_wrap.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_kv_codecs.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_mk_dirs_if_missing.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_on_overwrite.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_packaging_hygiene.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_path_writethrough.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_paths.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_records.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_relocated.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_split_back_compat.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_trans.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_update_json.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_walk_permissions.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_wrapped_class_attrs.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/test_x_of_y_deprecation.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tests/utils_for_tests.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/tools.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/trans.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/trash.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/util.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/dol/zipfiledol.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/llms-full.txt +0 -0
- {dol-0.4.2 → dol-0.4.3}/llms.txt +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/TIPS.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/codemods/__init__.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/codemods/x_of_y_kwargs.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/CHANGELOG.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/README.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/code-quality-improvements.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_architecture_map.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_content_metadata_bifurcation.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_design.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_flat_model.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_issue10_design.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_issue16_design.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_issue18_design.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_issue83_design.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_issue86_design.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_issues_report.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/dol_roadmap.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/frontend_dol_ideas.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/general_design.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/generate_llms_txt_instruction.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/docs/issues_and_discussions.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/README.md +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/__init__.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/__main__.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/astscan.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/baseline.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/fleet.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/pins.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/report.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/scan.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/store.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/surface.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/tests/__init__.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/tests/test_astscan.py +0 -0
- {dol-0.4.2 → dol-0.4.3}/misc/fleet_ledger/tests/test_ledger.py +0 -0
|
@@ -97,3 +97,4 @@ path template — landmines 1 & 2) → **file IO**. When a Windows-only `KeyErro
|
|
|
97
97
|
- [ ] No POSIX-only `os` call without a guard/`getpass` replacement.
|
|
98
98
|
- [ ] Tests/doctests assert behavior or `os.path.join`, not literal separators.
|
|
99
99
|
- [ ] Windows CI job is green (not just Linux/macOS).
|
|
100
|
+
- [ ] A directory walk on `os.scandir` keeps `listdir` + `isdir` semantics: `DirEntry.is_dir()`/`is_file()` raise on a symlink loop, a link through a file or into an unreadable folder (wrap them, as `dol.filesys._entry_is_dir` does), and `scandir` reads lazily, so snapshot each listing before yielding (#219).
|
{dol-0.4.2 → dol-0.4.3}/PKG-INFO
RENAMED
|
@@ -55,24 +55,69 @@ def ensure_slash_suffix(path: str):
|
|
|
55
55
|
return path
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
def
|
|
59
|
-
|
|
58
|
+
def _is_hidden(name: str) -> bool:
|
|
59
|
+
# TODO: is dot a platform independent marker for hidden file?
|
|
60
|
+
return name.startswith(".")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _dir_entries(dirpath, include_hidden=False) -> list:
|
|
64
|
+
"""The ``os.DirEntry`` objects of ``dirpath``, skipping hidden ones unless
|
|
65
|
+
``include_hidden``; empty for a directory that vanished, is not a directory, or
|
|
66
|
+
is not readable.
|
|
67
|
+
|
|
68
|
+
``os.scandir`` gets each entry's type from the directory listing itself, so
|
|
69
|
+
:func:`_entry_is_dir` / :func:`_entry_is_file` cost no ``stat`` call on most
|
|
70
|
+
platforms (i2mint/dol#219). The listing is read in full before anything is
|
|
71
|
+
yielded, as ``os.listdir`` did: a caller that writes into the folder while
|
|
72
|
+
iterating does not see its own new files, and no directory handle stays open
|
|
73
|
+
while the caller works.
|
|
74
|
+
"""
|
|
60
75
|
try:
|
|
61
|
-
|
|
62
|
-
if include_hidden or not name
|
|
63
|
-
"."
|
|
64
|
-
): # TODO: is dot a platform independent marker for hidden file?
|
|
65
|
-
filepath = os.path.join(rootdir, name)
|
|
66
|
-
if os.path.isdir(filepath):
|
|
67
|
-
yield ensure_slash_suffix(filepath)
|
|
68
|
-
else:
|
|
69
|
-
yield filepath
|
|
76
|
+
with os.scandir(dirpath) as entries:
|
|
77
|
+
return [e for e in entries if include_hidden or not _is_hidden(e.name)]
|
|
70
78
|
except (FileNotFoundError, NotADirectoryError, PermissionError):
|
|
71
79
|
# Skip directories that vanished, aren't directories, or aren't readable rather
|
|
72
80
|
# than crashing the (recursive) walk. Notably, OS-protected directories such as
|
|
73
81
|
# macOS's ``.../com.apple.*/TemporaryItems/`` under the temp dir raise
|
|
74
|
-
# PermissionError
|
|
75
|
-
|
|
82
|
+
# PermissionError when listed (Issue #3).
|
|
83
|
+
return []
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _entry_is_dir(entry) -> bool:
|
|
87
|
+
"""``os.path.isdir(entry.path)``, mostly without a ``stat`` call.
|
|
88
|
+
|
|
89
|
+
Like ``os.path.isdir``, it follows symlinks and answers ``False`` for any entry
|
|
90
|
+
it cannot resolve (a symlink loop, a link through a file or into an unreadable
|
|
91
|
+
folder), where ``DirEntry.is_dir`` raises. On Windows a junction's type comes
|
|
92
|
+
from the listing even when its target is gone, so it is checked for real.
|
|
93
|
+
"""
|
|
94
|
+
try:
|
|
95
|
+
if not entry.is_dir():
|
|
96
|
+
return False
|
|
97
|
+
is_junction = getattr(entry, "is_junction", None) # Python 3.12+
|
|
98
|
+
if is_junction is not None and is_junction():
|
|
99
|
+
return os.path.isdir(entry.path)
|
|
100
|
+
return True
|
|
101
|
+
except OSError:
|
|
102
|
+
return False
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _entry_is_file(entry) -> bool:
|
|
106
|
+
"""``os.path.isfile(entry.path)``, mostly without a ``stat`` call (see
|
|
107
|
+
:func:`_entry_is_dir`)."""
|
|
108
|
+
try:
|
|
109
|
+
return entry.is_file()
|
|
110
|
+
except OSError:
|
|
111
|
+
return False
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def paths_in_dir(rootdir, include_hidden=False):
|
|
115
|
+
"""Yield the paths of the entries of ``rootdir`` (directories with a trailing separator), skipping hidden ones unless ``include_hidden``."""
|
|
116
|
+
for entry in _dir_entries(rootdir, include_hidden):
|
|
117
|
+
if _entry_is_dir(entry):
|
|
118
|
+
yield ensure_slash_suffix(entry.path)
|
|
119
|
+
else:
|
|
120
|
+
yield entry.path
|
|
76
121
|
|
|
77
122
|
|
|
78
123
|
def iter_filepaths_in_folder_recursively(
|
|
@@ -81,15 +126,17 @@ def iter_filepaths_in_folder_recursively(
|
|
|
81
126
|
"""Recursively generates filepaths of folder (and subfolders, etc.) up to a given level"""
|
|
82
127
|
if max_levels is None:
|
|
83
128
|
max_levels = inf
|
|
84
|
-
for
|
|
85
|
-
if
|
|
129
|
+
for entry in _dir_entries(root_folder, include_hidden):
|
|
130
|
+
if _entry_is_dir(entry):
|
|
86
131
|
if _current_level < max_levels:
|
|
87
132
|
yield from iter_filepaths_in_folder_recursively(
|
|
88
|
-
|
|
133
|
+
ensure_slash_suffix(entry.path),
|
|
134
|
+
max_levels,
|
|
135
|
+
_current_level + 1,
|
|
136
|
+
include_hidden,
|
|
89
137
|
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
yield full_path
|
|
138
|
+
elif _entry_is_file(entry):
|
|
139
|
+
yield entry.path
|
|
93
140
|
|
|
94
141
|
|
|
95
142
|
def iter_dirpaths_in_folder_recursively(
|
|
@@ -98,8 +145,9 @@ def iter_dirpaths_in_folder_recursively(
|
|
|
98
145
|
"""Recursively generates dirpaths of folder (and subfolders, etc.) up to a given level"""
|
|
99
146
|
if max_levels is None:
|
|
100
147
|
max_levels = inf
|
|
101
|
-
for
|
|
102
|
-
if
|
|
148
|
+
for entry in _dir_entries(root_folder, include_hidden):
|
|
149
|
+
if _entry_is_dir(entry):
|
|
150
|
+
full_path = ensure_slash_suffix(entry.path)
|
|
103
151
|
yield full_path
|
|
104
152
|
if _current_level < max_levels:
|
|
105
153
|
yield from iter_dirpaths_in_folder_recursively(
|
|
@@ -574,6 +622,26 @@ class FileSysCollection(Collection):
|
|
|
574
622
|
)
|
|
575
623
|
)
|
|
576
624
|
|
|
625
|
+
def _walked_key_filter(self):
|
|
626
|
+
"""The predicate that keeps the keys of this collection's own walk.
|
|
627
|
+
|
|
628
|
+
A walked path starts with ``rootdir`` and has no ``..`` segment, so it is in
|
|
629
|
+
the root by construction and only the key pattern needs checking; the
|
|
630
|
+
containment test, about 40% of a walk, is for keys a caller supplies
|
|
631
|
+
(i2mint/dol#219). A subclass that overrides ``is_valid_key`` or
|
|
632
|
+
``is_in_root`` (on the class or the instance) keeps its own check on every
|
|
633
|
+
walked key.
|
|
634
|
+
"""
|
|
635
|
+
cls = type(self)
|
|
636
|
+
if (
|
|
637
|
+
cls.is_valid_key is FileSysCollection.is_valid_key
|
|
638
|
+
and cls.is_in_root is FileSysCollection.is_in_root
|
|
639
|
+
and "is_valid_key" not in vars(self)
|
|
640
|
+
and "is_in_root" not in vars(self)
|
|
641
|
+
):
|
|
642
|
+
return self._key_pattern.match
|
|
643
|
+
return self.is_valid_key
|
|
644
|
+
|
|
577
645
|
def validate_in_root(self, k):
|
|
578
646
|
"""Raise ``KeyValidationError`` if ``k`` leaves ``rootdir`` (i2mint/dol#107).
|
|
579
647
|
|
|
@@ -607,7 +675,7 @@ class DirCollection(FileSysCollection):
|
|
|
607
675
|
|
|
608
676
|
def __iter__(self):
|
|
609
677
|
yield from filter(
|
|
610
|
-
self.
|
|
678
|
+
self._walked_key_filter(),
|
|
611
679
|
iter_dirpaths_in_folder_recursively(
|
|
612
680
|
self.rootdir,
|
|
613
681
|
max_levels=self._max_levels,
|
|
@@ -636,7 +704,7 @@ class FileCollection(FileSysCollection):
|
|
|
636
704
|
True
|
|
637
705
|
"""
|
|
638
706
|
yield from filter(
|
|
639
|
-
self.
|
|
707
|
+
self._walked_key_filter(),
|
|
640
708
|
iter_filepaths_in_folder_recursively(
|
|
641
709
|
self.rootdir,
|
|
642
710
|
max_levels=self._max_levels,
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""The ``Files`` walk (i2mint/dol#219): ``os.scandir`` entries, and walked keys that
|
|
2
|
+
skip the containment check unless a subclass customises validation."""
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from dol.filesys import DirCollection, FileCollection
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
def tree(tmp_path):
|
|
13
|
+
(tmp_path / "a" / "b").mkdir(parents=True)
|
|
14
|
+
(tmp_path / "a" / "b" / "x.txt").write_text("1")
|
|
15
|
+
(tmp_path / "y.json").write_text("2")
|
|
16
|
+
(tmp_path / ".hidden").mkdir()
|
|
17
|
+
(tmp_path / ".hidden" / "h.txt").write_text("3")
|
|
18
|
+
return tmp_path
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _rel(store, root):
|
|
22
|
+
return sorted(os.path.relpath(k, root).replace(os.sep, "/") for k in store)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_files_and_dirs_are_walked_recursively(tree):
|
|
26
|
+
assert _rel(FileCollection(str(tree)), tree) == ["a/b/x.txt", "y.json"]
|
|
27
|
+
assert _rel(DirCollection(str(tree)), tree) == ["a", "a/b"]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_dirs_keep_their_trailing_separator(tree):
|
|
31
|
+
assert all(k.endswith(os.sep) for k in DirCollection(str(tree)))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_hidden_entries_only_on_request(tree):
|
|
35
|
+
assert _rel(FileCollection(str(tree), include_hidden=True), tree) == [
|
|
36
|
+
".hidden/h.txt",
|
|
37
|
+
"a/b/x.txt",
|
|
38
|
+
"y.json",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_max_levels_bounds_the_walk(tree):
|
|
43
|
+
assert _rel(FileCollection(str(tree), max_levels=0), tree) == ["y.json"]
|
|
44
|
+
assert _rel(DirCollection(str(tree), max_levels=0), tree) == ["a"]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@pytest.mark.skipif(os.name == "nt", reason="symlinks need privileges on Windows")
|
|
48
|
+
def test_symlinks_are_followed_and_broken_ones_skipped(tree, tmp_path_factory):
|
|
49
|
+
target = tmp_path_factory.mktemp("target")
|
|
50
|
+
(target / "t.txt").write_text("5")
|
|
51
|
+
os.symlink(target, tree / "linkdir")
|
|
52
|
+
os.symlink(tree / "missing", tree / "broken")
|
|
53
|
+
assert _rel(FileCollection(str(tree)), tree) == [
|
|
54
|
+
"a/b/x.txt",
|
|
55
|
+
"linkdir/t.txt",
|
|
56
|
+
"y.json",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_the_key_pattern_still_filters_walked_keys(tree):
|
|
61
|
+
s = FileCollection(str(tree), subpath=os.path.join("a", "{rest}"))
|
|
62
|
+
assert _rel(s, tree) == ["a/b/x.txt"]
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_a_subclass_validation_applies_to_walked_keys(tree):
|
|
66
|
+
class OnlyJson(FileCollection):
|
|
67
|
+
def is_valid_key(self, k):
|
|
68
|
+
return super().is_valid_key(k) and k.endswith(".json")
|
|
69
|
+
|
|
70
|
+
assert _rel(OnlyJson(str(tree)), tree) == ["y.json"]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_a_subclass_containment_applies_to_walked_keys(tree):
|
|
74
|
+
class NotUnderA(FileCollection):
|
|
75
|
+
def is_in_root(self, k):
|
|
76
|
+
return super().is_in_root(k) and os.sep + "a" + os.sep not in k
|
|
77
|
+
|
|
78
|
+
assert _rel(NotUnderA(str(tree)), tree) == ["y.json"]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_files_lists_relative_keys(tree):
|
|
82
|
+
from dol import Files
|
|
83
|
+
|
|
84
|
+
assert sorted(Files(str(tree))) == ["a/b/x.txt".replace("/", os.sep), "y.json"]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@pytest.mark.skipif(os.name == "nt", reason="symlinks need privileges on Windows")
|
|
88
|
+
@pytest.mark.parametrize(
|
|
89
|
+
"make_link",
|
|
90
|
+
[
|
|
91
|
+
pytest.param(lambda root: os.symlink(root / "loop", root / "loop"), id="self-loop"),
|
|
92
|
+
pytest.param(lambda root: os.symlink(root / "y.json" / "x", root / "through_file"), id="enotdir"),
|
|
93
|
+
],
|
|
94
|
+
)
|
|
95
|
+
def test_unresolvable_symlinks_are_skipped(tree, make_link):
|
|
96
|
+
make_link(tree)
|
|
97
|
+
assert _rel(FileCollection(str(tree)), tree) == ["a/b/x.txt", "y.json"]
|
|
98
|
+
assert _rel(DirCollection(str(tree)), tree) == ["a", "a/b"]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@pytest.mark.skipif(os.name == "nt", reason="symlinks need privileges on Windows")
|
|
102
|
+
def test_a_directory_cycle_ends(tree):
|
|
103
|
+
os.symlink(tree, tree / "a" / "back")
|
|
104
|
+
keys = list(FileCollection(str(tree))) # ends once the OS refuses the depth
|
|
105
|
+
assert len(keys) > 2
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_files_written_during_iteration_are_not_yielded(tmp_path):
|
|
109
|
+
n = 3000 # large enough that a lazy directory read would see new entries
|
|
110
|
+
for i in range(n):
|
|
111
|
+
(tmp_path / f"f{i}").write_text("")
|
|
112
|
+
seen = 0
|
|
113
|
+
for k in FileCollection(str(tmp_path)):
|
|
114
|
+
seen += 1
|
|
115
|
+
with open(k + ".bak", "w"):
|
|
116
|
+
pass
|
|
117
|
+
assert seen == n
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def test_an_instance_level_validator_applies_to_walked_keys(tree):
|
|
121
|
+
s = FileCollection(str(tree))
|
|
122
|
+
s.is_valid_key = lambda k: k.endswith(".json")
|
|
123
|
+
assert _rel(s, tree) == ["y.json"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dol-0.4.2 → dol-0.4.3}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dol-0.4.2 → dol-0.4.3}/llms.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|