Skip to main content

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

  1. Set Project Root Directory
  2. Create a Directory and Save to CSV
  3. Create a File and Save to CSV
  4. List All Paths in CSV
  5. Remove a Path from CSV
  6. Generate Paths Python File
  7. Add a Path to CSV
  8. 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 is None.

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 is None.

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 is None.

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 is None.
  • -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 is None.
  • --config_root_dir: Root directory where the config file is located. Default is None.

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 is None.

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 is None.

Key Changes Made:

  • Module Directory Argument: Added --module_dir_path as an argument for gpaths 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 of None.

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

path_chronicle-0.1.6.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

path_chronicle-0.1.6-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file path_chronicle-0.1.6.tar.gz.

File metadata

  • Download URL: path_chronicle-0.1.6.tar.gz
  • Upload date:
  • Size: 12.5 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

Hashes for path_chronicle-0.1.6.tar.gz
Algorithm Hash digest
SHA256 5eb7f17d54ca1cd61e3a8dd43483f80e9526a8e695cf9b11a2a52fb335259ade
MD5 5efc8cb37bff798a2e4d60e399af2c7b
BLAKE2b-256 fed16648b0dc9a021db927223873ed33d212184f809eb4e6c6dccaec6d807566

See more details on using hashes here.

File details

Details for the file path_chronicle-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: path_chronicle-0.1.6-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

Hashes for path_chronicle-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5e7c2b3df0707b8f90cd53488f6d1030f3aba3af9acf111ee48b775d6464facc
MD5 ec731c3ba6563910c0621fe7f78e18f0
BLAKE2b-256 9a7a39ed693a446d4c1a34d84b507578d00e3df70517f88e394d514bc3ea7f29

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page