No project description provided
Project description
path-chronicle
This library is for efficiently managing paths in a project. This README describes the standard usage of this library and the commands that can be used.
Standard Usage
1. Install
pip install path-chronicle
2. Set project root directory
※Please run it first after installation
# Set the root directory path of that project
pcsetpjroot .
3. Create a directory
pcmkdir test_dir
id,name,path,description
1,test_dir,test_dir,
4. Create a file
pctouch test_dir/test.txt
id,name,path,description
1,test_dir,test_dir,
2,test.txt,test_dir/test.txt,
5. Create a PathArchives
gpaths
from pathlib import Path
class PathArchives:
"""
This class provides paths for various project directories and files.
"""
test_dir = Path('/Users/{your dirctory}/Desktop/myprojects/package_test/ptest_3/test_dir')
test_txt = Path('/Users/{your dirctory}/Desktop/myprojects/package_test/ptest_3/test_dir/test.txt')
@staticmethod
def get_path(name: str) -> Path:
"""
Returns the Path object for the given name.
Available paths:
- test_dir: /Users/{your dirctory}/Desktop/myprojects/package_test/ptest_3/test_dir
- test_txt: /Users/{your dirctory}/Desktop/myprojects/package_test/ptest_3/test_dir/test.txt
"""
return getattr(PathArchives, name, None) or Path("")
6. Import PathArchives
from path_chronicle.path_archives.path_archives import PathArchives
def main():
print(PathArchives.get_path("test_dir"))
print(PathArchives.get_path("test_txt"))
if __name__ == "__main__":
main()
/Users/{your directory}/Desktop/myprojects/package_test/ptest_3/test_dir
/Users/{your directory}/Desktop/myprojects/package_test/ptest_3/test_dir/test.txt
The path saved to csv is relative to the project root, but the path is absolute when output.
Commands
- Set Project Root Directory
- Create a Directory and Save to CSV
- Create a File and Save to CSV
- List All Paths in CSV
- Remove a Path from CSV
- Generate Paths Python File
- Add a Path to CSV
- Remove a Path from CSV by Criteria
Set Project Root Directory
Sets the project root directory in the config file.
Example Usage
pcsetpjroot ./
pcsetpjroot /path/to/project
Create a Directory and Save to CSV
Creates a directory and optionally saves the path info to the CSV file.
Example Usage
pcmkdir ./my_temp_directory --description "Temporary directory for storage"
Common Arguments
path
: The path to the directory to create.--description
: A description for the directory. Default is an empty string.--csv_name
: Name of the CSV file for storing paths. Default is"paths.csv"
.--csv_dir_name
: Name of the directory containing the CSV file. Default is"path_archives"
.--no-save
: Do not save the path to the CSV file. If specified, the path will not be saved.--config_root_dir
: Root directory where the config file is located. Default isNone
.
Create a File and Save to CSV
Creates a file and optionally saves the path info to the CSV file.
Example Usage
pctouch ./my_temp_directory/another_file.txt --description "Another file for testing"
Common Arguments
path
: The path to the file to create.--description
: A description for the file. Default is an empty string.--csv_name
: Name of the CSV file for storing paths. Default is"paths.csv"
.--csv_dir_name
: Name of the directory containing the CSV file. Default is"path_archives"
.--no-save
: Do not save the path to the CSV file. If specified, the path will not be saved.--config_root_dir
: Root directory where the config file is located. Default isNone
.
List All Paths in CSV
Lists all paths stored in the CSV file.
Example Usage
pcpathslist
Common Arguments
--csv_name
: Name of the CSV file for storing paths. Default is"paths.csv"
.--csv_dir_name
: Name of the directory containing the CSV file. Default is"path_archives"
.--config_root_dir
: Root directory where the config file is located. Default isNone
.
Remove a Path from CSV
Removes a path based on ID, name, or path, and also removes it from the CSV file.
Example Usage
pcrmpath --id 1
pcrmpath --name example_name
pcrmpath --path /example/path/to/delete
pcrmpath --id 1 --force-remove
Common Arguments
--id
: The ID of the path to remove.--name
: The name of the path to remove.--path
: The path to remove.--csv_name
: Name of the CSV file for storing paths. Default is"paths.csv"
.--csv_dir_name
: Name of the directory containing the CSV file. Default is"path_archives"
.--config_root_dir
: Root directory where the config file is located. Default isNone
.-f
,--force_remove
: Force removal of directories even if they contain files.
Generate Paths Python File
Generates a Python file with paths for project directories and files.
Example Usage
gpaths
gpaths --csv_name paths.csv --path_archives_dir_name path_archives --module_name paths.py --module_dir_path ./path_module
Common Arguments
--path_archives_dir_name
: Name of the directory containing the CSV file. Default is"path_archives"
.--csv_name
: Name of the CSV file containing paths. Default is"paths.csv"
.--module_name
: Name of the output Python file. Default is"path_archives.py"
.--module_dir_path
: Directory where the module file should be created. Default isNone
.--config_root_dir
: Root directory where the config file is located. Default isNone
.
Add a Path to CSV
Adds a path to the CSV file.
Example Usage
pcaddtocsv ./my_temp_directory --description "Temporary directory for storage"
Common Arguments
path
: The path to add.--description
: A description for the path. Default is an empty string.--csv_name
: Name of the CSV file for storing paths. Default is"paths.csv"
.--csv_dir_name
: Name of the directory containing the CSV file. Default is"path_archives"
.--config_root_dir
: Root directory where the config file is located. Default isNone
.
Remove a Path from CSV by Criteria
Removes a path from the CSV file based on ID, name, or path.
Example Usage
pcrmtocsv --id 1
pcrmtocsv --name example_name
pcrmtocsv --path /example/path/to/delete
Common Arguments
--id
: The ID of the path to remove.--name
: The name of the path to remove.--path
: The path to remove.--csv_name
: Name of the CSV file for storing paths. Default is"paths.csv"
.--csv_dir_name
: Name of the directory containing the CSV file. Default is"path_archives"
.--config_root_dir
: Root directory where the config file is located. Default isNone
.
Key Changes Made:
- Module Directory Argument: Added
--module_dir_path
as an argument forgpaths
in the "Generate Paths Python File" section. - Force Removal: Added the
--force_remove
option to the "Remove a Path from CSV" section. - Config Root Directory: Clarified that the
--config_root_dir
argument is optional with a default ofNone
.
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 path_chronicle-0.1.7.tar.gz
.
File metadata
- Download URL: path_chronicle-0.1.7.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e356b21a7c0c28dbd99542b610cbb424948c67b2bce76b98d5281fa8df44d2d |
|
MD5 | 37b57b3b4ccf7f851cd30c35b3429bc7 |
|
BLAKE2b-256 | c50962376094e82f6a411dd8df4910f4a224af4d79f26ce8adb8f18b51babff7 |
File details
Details for the file path_chronicle-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: path_chronicle-0.1.7-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76f92bb33c6ff10930196f4b9017a5c1284d4127301e3693ed5efc9356ad487a |
|
MD5 | ba716d8c4c64b3e4735c1af66f4d6fb0 |
|
BLAKE2b-256 | 275f7851415a00c64638d8f9e21e189820a2ded3c36c321ad6c1ed54ec9c750a |