Path object VC index
Project description
Path object VC index
Index versioned .py files
Install
pip install lsfiles
Development
poetry install
Usage
The LSFiles instance is a list-like object instantiated with an empty index
>>> from lsfiles import LSFiles
>>> from pathlib import Path
>>>
>>> files = LSFiles()
>>> files
<LSFiles []>
The LSFiles index calls git ls-files and only versioned files are indexed
>>> files.populate()
>>> for path in sorted([p.relative_to(Path.cwd()) for p in files]):
... print(path)
docs/conf.py
lsfiles/__init__.py
lsfiles/_indexing.py
lsfiles/_objects.py
lsfiles/_version.py
tests/__init__.py
tests/_environ.py
tests/_test.py
tests/conftest.py
whitelist.py
The LSFiles instance is an index of unique file paths
It’s implementation of extend prevents duplicates
>>> p1 = Path.cwd() / "f1"
>>> p2 = Path.cwd() / "f1"
>>>
>>> files = LSFiles()
>>> files.extend([p1, p2])
>>> sorted([p.relative_to(Path.cwd()) for p in files.reduce()])
[PosixPath('f1')]
Reduce minimizes index to directories and individual files relative to the current working dir
The list value is returned, leaving the instance unaltered
>>> p1 = Path.cwd() / "f1"
>>>
>>> d = Path.cwd() / "dir"
>>> p2 = d / "f2"
>>> p3 = d / "f3"
>>>
>>> files = LSFiles()
>>> files.extend([p1, p2, p3])
>>> sorted(p.relative_to(Path.cwd()) for p in files.reduce())
[PosixPath('dir'), PosixPath('f1')]
Exclusions can be added on instantiation
Exclusions are evaluated by their basename, and does not have to be an absolute path
>>> p1 = Path.cwd() / "docs" / "conf.py"
>>> p2 = Path.cwd() / "lsfiles" / "__init__.py"
>>>
>>> files = LSFiles()
>>> files.populate(f".*\/{p1.name}")
>>>
>>> ps = [str(p) for p in files]
>>>
>>> assert not str(p1) in ps
>>> assert str(p2) in ps
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lsfiles-0.5.1.tar.gz
.
File metadata
- Download URL: lsfiles-0.5.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.13 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 860bb1fc8b9f029c42066eb6aabc68236249dfcfe22f7968c3cc88335387f893 |
|
MD5 | cd896906a4a8251db837efe0eb361a70 |
|
BLAKE2b-256 | 55320121510fceac32087d1ff4ccc1a9857f2108dcaf0fd5185498e8fc84c414 |
File details
Details for the file lsfiles-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: lsfiles-0.5.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.13 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ac6fec5593ee5472f1b49e228e51ed29d76ffa3fd153ce86d555188c8c79531 |
|
MD5 | fdccc732f657e482038d575e3ed0bcf5 |
|
BLAKE2b-256 | 274e74af94a09d3597fe1457678cdd7acbf607723c6682a05858500cdf55882f |