No project description provided
Project description
dumpwd
Overview:
dumpwd
is a Python package that allows the user to dump the contents of a directory tree in a variety of formats. It can be used both as a CLI tool and as an API.
Installation:
You can install dumpwd using pip:
pip install dumpwd
CLI Usage:
The CLI accepts three commands:
get_inodes
: This command retrieves the inodes of the directory tree rooted at the given path.
Example:
$ python -m dumpwd get_inodes --exclude "**/venv/**" --read --depth 2 /path/to/dir
This command will retrieve the inodes of the directory tree rooted at /path/to/dir
, excluding all directories containing venv
, and reading the contents of all files. It will traverse the directory tree to a maximum depth of 2.
get_tree
: This command retrieves the directory tree rooted at the given path.
Example:
$ python -m dumpwd get_tree --exclude "**/venv/**" --read --depth 2 --compressed /path/to/dir
This command will retrieve the directory tree rooted at /path/to/dir
, excluding all directories containing venv
, and reading the contents of all files. It will traverse the directory tree to a maximum depth of 2. The output will be compressed.
get_contents
: This command retrieves the contents of the directory tree rooted at the given path.
Example:
$ python -m dumpwd get_contents --exclude "**/venv/**" --read --depth 2 /path/to/dir
This command will retrieve the contents of the directory tree rooted at /path/to/dir
, excluding all directories containing venv
, and reading the contents of all files. It will traverse the directory tree to a maximum depth of 2.
API Usage:
The dumpwd
API provides three functions that correspond to the three CLI commands: get_inodes()
, get_tree()
, and get_contents()
.
get_inodes(path: str, exclude: Union[str, List[str]] = IGNORE_PREFIXES, read: bool = True, depth: Optional[int] = None) -> List[Tuple[str, Union[str, List[Tuple[str, Union[str, List]]]]]]
: This function retrieves the inodes of the directory tree rooted at the given path.
Example:
from dumpwd.api import get_inodes
inodes = get_inodes("/path/to/dir", exclude=["**/venv/**"], read=True, depth=2)
This command will retrieve the inodes of the directory tree rooted at /path/to/dir
, excluding all directories containing venv
, and reading the contents of all files. It will traverse the directory tree to a maximum depth of 2.
get_tree(inodes: List[Tuple[str, Union[str, List[Tuple[str, Union[str, List]]]]]], prefix: str = '', depth: Optional[int] = None, current_depth: int = 0, compressed: bool = False) -> str
: This function retrieves the directory tree rooted at the given path.
Example:
from dumpwd.api import get_inodes, get_tree
inodes = get_inodes("/path/to/dir", exclude=["**/venv/**"], read=True, depth=2)
tree = get_tree(inodes, prefix="", depth=None, compressed=False)
This command will retrieve the directory tree rooted at /path/to/dir
, excluding all directories containing venv
, and reading the contents of all files. It will traverse the directory tree to a maximum depth of 2. The output will not be compressed.
get_contents(inodes: List[Tuple[str, Union[str, List[Tuple[str, bytes]]]], exclude: Union[str, List[str]] = IGNORE_PREFIXES, read: bool = True) -> List[Tuple[str, bytes]]
: This function retrieves the contents of the directory tree rooted at the given path.
Example:
from dumpwd.api import get_inodes, get_contents
inodes = get_inodes("/path/to/dir", exclude=["**/venv/**"], read=True, depth=2)
contents = get_contents(inodes, exclude=["**/*.txt"], read=True)
This command will retrieve the contents of the directory tree rooted at /path/to/dir
, excluding all directories containing venv
, and reading the contents of all files. It will exclude all .txt
files from the contents.
Contributing
Contributions to this project are welcome and appreciated. To contribute, please follow these steps:
- Fork the project repository.
- Create a new branch for your feature or bug fix.
- Make your changes, and ensure that they work properly.
- Test your changes thoroughly.
- Submit a pull request.
Please ensure that your code adheres to the coding standards of the project, and that you have added tests for any new features or changes.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Project details
Release history Release notifications | RSS feed
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 dumpwd-0.2.0.tar.gz
.
File metadata
- Download URL: dumpwd-0.2.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26a9608ae81a73a6bd7f1fad92ed9ae175ccc4ea1d6a758d89a4d2f397c539be |
|
MD5 | 5ea5e0b92c76c7b7c2332e4d1a093a9d |
|
BLAKE2b-256 | 56c2489d5d2019405e62014035731036b9e021de69546aa57a60da2cb3f11d33 |
File details
Details for the file dumpwd-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: dumpwd-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bebd0bf5b6251b2e181596786d2dd6fcd00d8caf4c76b86d7aed9bddd09edc19 |
|
MD5 | 267e570d114c039fc6293570d6efc7be |
|
BLAKE2b-256 | 51c13cffd3cd609e3e4b06c28d079c05dbb292b48ddb6ba3b3b29d39e5381a8d |