Skip to main content

The "path2success" library, is a multi-OS compatible python library, that includes advanced path-related functions.

Project description

The path2success library, is a multi-OS compatible python library, that includes advanced path-related functions.

The "is_safely_quoted()" Function:

Description:

1.) Checks if the supplied path, is OS-appropriately quoted and has no unneccessary quotes
2.) Returns "True", if the supplied path is appropriately quoted (Or appropriately not), otherwise, returns "False"

Example Usage:

import path2success

try:
    PATH = input('Enter a path: ')
    print(f'Is safely quoted?: {path2success.is_safely_quoted(PATH)}')
except Exception as ERROR:
    print(ERROR)
input('Press Enter: ')

The "filter_path()" Function:

Description:

1.) Uses path2success' "appropriate_quotes()" function, to remove any prepended quotes, at the beginning of the supplied path, and any matching quotes, at the end of the supplied path, as well as, replace any OS-inappropriate quotes, in the supplied path, with OS-appropriate quotes
2.) The "appropriate_quotes()" function, checks if the supplied path contains a space, if it does, the OS-appropriate quotes are added, to the beginning and end of the path, and the OS-appropriately quoted path, is returned to the "filter_path()" function
3.) Uses path2success' "unquote_path()" function, to remove the beginning and end quotes, added by the "appropriate_quotes()" function (if the supplied path contained a space), then returns the unquoted path, to the "filter_path()" function
4.) Converts any OS-specific environment variables, in the supplied path, using the "os" module
5.) Converts any dot-sequences, in the supplied path, and replaces OS-inappropriate slashes, with OS-appropriate slashes, using the "pathlib" module
6.) Returns a filtered and converted path

Example Usage:

import path2success

try:
    PATH = input('Enter a path: ')
    FILTERED = path2success.filter_path(PATH)
    print(f'Filtered path: {FILTERED}')
except Exception as ERROR:
    print(ERROR)
input('Press Enter: ')

The "appropriate_quotes()" Function:

Description:

1.) Removes any prepended quotes, from the beginning of the supplied path, as well as any matching quotes, at the end of the supplied path
2.) Replaces any OS-inappropriate quotes, in the supplied path, with OS-appropriate quotes
3.) Checks if the supplied path contains a space, if it does, the OS-appropriate quotes are added to the beginning and end, of the supplied path
4.) Returns an appropriately quoted path

Example Usage:

import path2success

try:
    PATH = input('Enter a path: ')
if path2success.is_safely_quoted(PATH):
    print(f'Correct: {path2success.appropriate_quotes(PATH)}')
else:
    print(f'Incorrectly quoted path: {PATH}')
    print(f'Changed to: {path2success.appropriate_quotes(PATH)}')
except Exception as ERROR:
    print(ERROR)
input('Press Enter: ')

The "unquote_path()" Function:

Description:

1.) If the first and last characters, in the supplied path, are matching quotes, they are removed
2.) Returns an unquoted path

Example Usage:

import path2success

try:
    PATH = input('Enter a path: ')
    print(f'Unquoted path: {path2success.unquote_path(PATH)}')
except Exception as ERROR:
    print(ERROR)
input('Press Enter: ')

The "recursive_files_and_bytes_total()" Function:

Description:

1.) Uses path2success' "filter_path()" function, to filter the supplied path
2.) Recursively scans, for the total number of files and bytes, of data, with the help of the "os" module
3.) Returns the total number of files and bytes, of data
Note: path2success' "convert_bytes()" function, can convert the total bytes return value, of the "recursive_files_and_bytes_total()" function, to kilobytes, megabytes, gigabytes, or even terabytes

Example Usage:

import path2success

try:
    PATH = input('Enter a path: ')
    FILES_TOTAL, BYTES_TOTAL = path2success.recursive_files_and_bytes_total(PATH)
    print(f'Total files: {FILES_TOTAL}')
    print(f'Total amount of data: {path2success.convert_bytes(BYTES_TOTAL)}')
except Exception as ERROR:
    print(ERROR)
input('Press Enter: ')

The "convert_bytes()" Function:

Description:

1.) Accepts a number of bytes
2.) Returns the converted bytes, kilobytes, megabytes, gigabytes, or even terabytes

Example Usage:

import path2success

try:
    BYTES = input('Enter a number, of bytes: ')
    print(f'Converted: {path2success.convert_bytes(BYTES)}')
except Exception as ERROR:
    print(ERROR)
input('Press Enter: ')

The "recursive_copy_with_progress()" Function:

Description:

1.) Uses path2success' "filter_path()" function, to filter the supplied source and destination paths
2.) Calculates and displays the total number of files and bytes, of data, to be copied from the source path, using path2success' "recursive_files_and_bytes_total()" function, and it's "convert_bytes()" function, along with the help of the "os" module
3.) Creates a new directory, in the destination path, matching the source path's folder name, using the "os" module, if the folder does not already exist in the destination path, however, if the folder does already exist in the destination path, a new directory with a new name is created, in the destination path
4.) Recursively copies all files and folders, within the supplied source path, to the supplied destination path, while displaying a live progress bar and ETA until finished, with the help of the "sys" and "time" modules

Example Usage:

import path2success

try:
    SOURCE_PATH = input('Enter a source path: ')
    DESTINATION_PATH = input('Enter a destination path: ')
    path2success.recursive_copy_with_progress(SOURCE_PATH, DESTINATION_PATH)
except Exception as ERROR:
    print(ERROR)
input('Press Enter: ')

The "recursive_copy_with_progress()" function, CLI Usage:

python -m path2success recursive_copy_with_progress SOURCE_PATH DESTINATION_PATH

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

path2success-5.1.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

path2success-5.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file path2success-5.1.tar.gz.

File metadata

  • Download URL: path2success-5.1.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for path2success-5.1.tar.gz
Algorithm Hash digest
SHA256 2c122d66eb8514f42f5870ccbcb218f7830f6ff34d258375e6ee3ecaadfa9726
MD5 afd30fabaab8754519f42fbae34719ae
BLAKE2b-256 64a2b25bdf4c90518a7f331b637db3839d64a5f154e8c626ee80060c8abb3ab5

See more details on using hashes here.

File details

Details for the file path2success-5.1-py3-none-any.whl.

File metadata

  • Download URL: path2success-5.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for path2success-5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 35c6311b42ab9f1ec1398eba9e764ba176ec2f5e403383905720b0716138e1df
MD5 ffcabfa6895e7a740ece78a12c417d7c
BLAKE2b-256 a66e5497adaba84ced15d87ba2d37a7f32dd4413512756582496ccd1211c25ba

See more details on using hashes here.

Supported by

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