Skip to main content

Pycomfort - Python helper methods to make life easier

Project description

pycomfort

Utility methods for python code

It heavily uses functional approach and pyfunctional library to ease the work with file traversing and other routine tasks.

files.py

The most important methods are:

  • def children(p: Path) -> seq #lists files and subfolders as pyfunctional sequence
  • def dirs(p: Path) -> seq #lists subfolders as pyfunctional sequence
  • def files(p: Path) -> seq: #lists files as pyfunctional sequence
  • def with_ext(p: Path, ext: str) -> seq: # filters files by extension
  • def rename_files_with_dictionary(files_or_path: Union[seq, Path], dictionary: dict, test: bool = False): #renames files according to key value pairs mentioned in the dictionary
  • def rename_files(files_or_path: Union[seq, Path], has: str, what: str, to: str): rename files that contain a substring
  • def rename_not_files(files: seq, not_has: str, what: str, to: str) -> seq: #rename files that do NOT contain a substring
  • def replace_in_file(file: Path, what: str, to: str, output: Optional[Path] = None): #replaces string in a file
  • def replace_from_dict_in_file(file: Path, replacement: dict, output: Optional[Path] = None, verbose: bool = False) -> Path: # replaces the text in the file based on key-value pairs in the dictionary
  • def tprint(p: Path, max_depth: int = -1, prefix: str = "", debug: bool = False, depth: int = 0: #prints the file tree
  • def traverse(p: Path, fun: Callable[[Path], bool] = None, max_depth: int = -1, flatten: bool = True, depth: int = 0) -> list # traverses the file system searching for sample

executables

Executables are in comfort.py. At the moment it is the text replacement functions wrapped to CLI by click library:

  • def replace(file: str, what: str, to: str, output: Optional[str]):
  • def replace_dict(file: str, dictionary: str, output: Optional[str], verbose: bool = False):

publishing to pip

You can use publish.sh script

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

pycomfort-0.0.15.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

pycomfort-0.0.15-py2.py3-none-any.whl (10.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pycomfort-0.0.15.tar.gz.

File metadata

  • Download URL: pycomfort-0.0.15.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pycomfort-0.0.15.tar.gz
Algorithm Hash digest
SHA256 65ed4bd18b25674986a35d10ea66de615675f022e86927326c5343d8d20d14a0
MD5 fad0786d4a5ec4699eba5c371e1ff1f7
BLAKE2b-256 571232b0d5f1586143c9a271f74d46aac496fef9b0865bc1063b54aa8379cb0b

See more details on using hashes here.

File details

Details for the file pycomfort-0.0.15-py2.py3-none-any.whl.

File metadata

  • Download URL: pycomfort-0.0.15-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pycomfort-0.0.15-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 659a9e815099d3b7450b87a806864df2ee74656b20c7b40f028f264eb0909b7a
MD5 584fff82832dc35687b2c763c0814e48
BLAKE2b-256 12f0f92f7a821e3af10e8692752f4d60cc5a0174ced22fb49f7d9504b6966f30

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