Skip to main content

Package grouping functions that I'm using in multiple places

Project description

vbrpytools

vbrpytools is a Python library of general functions that I use in all my other packages.

Install Package

pip install vbrpytools

Use Package

Functions are grouped in the following modules:

misctools

Support library to ease development

  • verbose management
  • progress bar display
  • open with file preservation
  • input argument management
  • command line execution
  • Handling stdout encoding to match PYTHONIOENCODING envvar (needed when bundling python script in a exe)
from vbrpytools import misctools

# decorator to manage verbose & display execution information
@misctools.with_verbose

# decorator to execute a function through run_and_display_progress (see below)
@misctools.with_waiting_message

# Call in a loop to create terminal progress bar or revolving character
misctools.iterate_and_display_progress(iterable)

# Call a function in a separate thread and display a progress message while executing
misctools.run_and_display_progress(func)

# Rename a file by adding a timestamp to its name
misctools.timestamp_filename(filename)

# Make a copy of an existing file before opening it in write mode + enforce encoding to UTF-8 by default
misctools.open_preserve(filename)

# all-in-one argument definition, parse & read
misctools.get_args(arg_defs)

# Yields successive chunks from a list until all is parsed
misctools.divide_list(list, size)

# Put the input string in the clipboard
misctools.copy_to_clipboard(string)

# colorize a string if output in a terminal supporting ANSI escape characters
misctools.colorize(string)
misctools.Colors()  # List of supported colors

# If program is running in piping mode enforce stdout encoding to PYTHONIOENCODING.
misctools.force_stdout_encoding()

# Execute a command line in a separate subprocess and return the STD OUT
misctools.execute_cmd(cmd)

# Ask a yes/no question via and return answer.
misctools.query_yes_no(question)

# Transform a string into a date, trying to decode it.
misctools.parse_str_date(string)

dicjsontools

Support library to ease dict & JSON management:

  • dictionary manipulation (extraction, merge, ...)
  • json file load, save, update
from vbrpytools import dicjsontools

# Retrieve a subdict of a given dic "master" key
dicjsontools.sub_dict(dic, key, subkeys)

# merges 2 dictionaries, dict_b into dict_a
dicjsontools.merge_dict(dic_a, dic_b, options)

# Creates a dic from a list of key by nesting them
dicjsontools.create_nested_dict(keys, last_key_val)

# transform all relevant dictionary keys from string to integer
dicjsontools.dict_keys_to_int(dic)

# Load a json file into a dictionary with key conversion
dicjsontools.load_json_file(filename)

# Append a json dictionary to an existing json file
dicjsontools.append_json_file(filename, dic)

# Dump a dictionary in a json file
dicjsontools.save_json_file(dic, filename)

exceltojson

Open an excel file table and save it as a json file Available as executable script.

exceltojson *args*
python -m exceltojson *args*

License

ref: LICENSE vbrpytools is distributed under the terms of MIT.

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

vbrpytools-3.9.0.tar.gz (429.0 kB view details)

Uploaded Source

Built Distribution

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

vbrpytools-3.9.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file vbrpytools-3.9.0.tar.gz.

File metadata

  • Download URL: vbrpytools-3.9.0.tar.gz
  • Upload date:
  • Size: 429.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for vbrpytools-3.9.0.tar.gz
Algorithm Hash digest
SHA256 f0b577a11b140f3a68e4545ee9d5675e7c35981d59e9a5ed7a2a299e7e04a8ef
MD5 ec1b562ed3b94b79736e6f9b8314f0aa
BLAKE2b-256 1c4e9e390d4b252ec69559df9b9efd1b22cd26efa53e61ff8a6da2353841ac01

See more details on using hashes here.

File details

Details for the file vbrpytools-3.9.0-py3-none-any.whl.

File metadata

  • Download URL: vbrpytools-3.9.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for vbrpytools-3.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 492a5b97f0b2b6a16ff9ff3246c727f3b71be926793e06fd07c23d5cfc596dfc
MD5 a679a8d573cc5047da54a00e14c2e278
BLAKE2b-256 0307d5138650172dd01d44870209abf26c7e3b1b8476f51034db2fb932b39d60

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