fstool
install using pip
python3 -m pip install fstool
Command line tool
python3 -m fstool -h
usage: __main__.py [-h] [-p PATH] [-c CONFIG] [-v] [-m] [-o] [-s START] [-e END]
{restructure}
format file directory files
positional arguments:
{restructure}
optional arguments:
-h, --help show this help message and exit
-p PATH, --path PATH home path
-c CONFIG, --config CONFIG
config file location. default is config.json
-v, --verbose increase output verbosity
-m, --move moves files instead of default copy
-o, --overwrite ovewrites the file if it exists
-s START, --start START
start depth of file search
-e END, --end END end depth of file search
Documentation
Exposes three functions to the public
- restructure
restructure(
home: str,
files: list,
config: dict,
*,
move: bool = True,
overwrite: bool = False,
verbose: bool = False,
):
config is a dictionary of instructions on how to restructure the files, an example of which would be
{
".+\\.txt":{
"dir":"aiml",
"file":".+\\.txt"
},
"(.+)\\.properties":{
"dir":"config",
"file":"\\1.txt"
}
}
This is inefficient to write so fstool comes with a built in parser (parse_config) so that the above json can be written as
{
"aiml": [
".+\\.txt"
],
"config": [{
"old": "(.+)\\.properties",
"new": "\\1.txt"
}],
}
where the key is the directory and maps to a list of regex patterns or if you want to rename the file an object with keys new and old
old - file to move
new - file to be moved to
- crawl
crawl(
path: str,
start_depth: int = 0,
end_depth: int = -1,
*,
skip_permission_error: bool = True) -> tuple:
iterates through directores starting with path
:return: (files, dirs) from start_depth(inclusive) to end_depth(exclusive)
default start_depth is 0
default end_depth is -1 (till all paths exhausted)
:param skip_permission_error: when true skips through all directores that requires elevated privilages
*note: if start_depth equals end_depth lists will be empty
To default parameters left to it would iterate through all the subdirectories
depth 0
start_depth - 0
start_depth - 1
depth 1
start_depth - 1
start_depth - 2
etc
- parse_config
parse_config(config: dict) -> dict:
Compiles input json to a more efficient version which can be used by the restructure function
Metadata
Release files for fstool 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fstool-0.1.8.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fstool-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.5 kB
Release files / fstool-0.1.8.tar.gz
| Download URL | fstool-0.1.8.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
761f2755643c0e0ecf91e478996e769fc458421b562edeb2a6d4a048fe13a1f9
|
|
BLAKE2b-256 checksum How to use checksums |
c36d8f691bfc5448324315c7ab8e5d5cfb9a8e1b308b1dd40445b37158745baf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Release files / fstool-0.1.8-py3-none-any.whl
| Download URL | fstool-0.1.8-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07ded01e50dbee924fff718493cfe0696f700434d3a3ebb6c9f1b126dfae5ac7
|
|
BLAKE2b-256 checksum How to use checksums |
6c773df6ff7efb8811cc3f3c7db6a5c94dbdcf7f06fac4e00fcccfec7c61d6f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|