Skip to main content

Tools for Python scripts or terminal

Project description

invesyservertools

A small set of useful tools on a server, especially for terminal scripts.

Why "invesy"? Invesy (from German Inhaltsverwaltungssystem == content management system) is a closed source cms I created with Thomas Macher. It's only used in-house, that's why we didn't bother making it open source.

Installation

pip install invesyservertools

Requires Python >= 3.9 on a POSIX platform (Linux, *BSD, macOS — uses the Unix-only modules termios and pwd).

Quick example

from invesyservertools import print_, format_filesize, wait_for_key

print_('Hello', 'World', color={1: 'green'}, sep=' ')
print(format_filesize(234567890))  # '223.7 MiB'
wait_for_key()

What's in the box?

interactive_tools

  • wait_for_key: Wait for a pressed key to continue.

print_tools

  • and_list: human-readable list like a, 1, 2 and something
  • indent: get an indentation string
  • print_: Enhanced print function, specially enhanced for printing in the terminal and into log files.
  • format_filesize: return a human-readable filesize, like 31.9 GiB.

system_tools

  • get_username: get the username in the operating system
  • get_home_dir: get the home directory
  • find_file_path: provide a filename and a start path to begin searching recursively, get the complete path including the filename

Documentation

Full API docs: https://rastaf.gitlab.io/invesyservertools/

License

MIT

History

0.1.0

  • Packaging modernized: built from pyproject.toml, tests run under pytest
  • Breaking: requires Python >= 3.9 (was 3.7)
  • Breaking: find_file_path() returns None when nothing is found (was a message string); the not_found argument was removed
  • Targets POSIX (Linux, *BSD, macOS) but now imports cleanly everywhere — the POSIX-only wait_for_key and get_username raise a clear error on non-POSIX instead of breaking import invesyservertools
  • and_list: keeps the conjunction for multi-word or punctuated final elements
  • print_: several correctness fixes (terminal-size detection, end/separator handling, colour indexing and wrapped-line indentation, style= off a tty)
  • format_filesize: correct SI (decimal) thresholds and large-value handling; clear error on an invalid prefix_type
  • wait_for_key: robust on non-tty stdin (no crash; returns None at EOF)

0.0.10 (2023-07-13)

  • bumped version to 0.0.10
  • replaced dynamic package imports using exec() and sys.path mutation with importlib

0.0.9 (2023-06-10)

  • fixed IndexError in print_ (for line ending in last string)
  • print_ checks for terminal (-> no colors, no wrapper)

0.0.5 (2022-12-09)

  • fixed import of submodules

0.0.4 (2022-12-09)

  • wait_for_key gets a "indent" argument
  • Sphinx documentation

0.0.3 (2022-06-16)

Added support for line breaks in print_:

  • can be added as singletons or as part of strings
  • line break singletons are not counted in the color argument

0.0.2 (2022-06-13)

  • splitted modules (now: interactive_tools, print_tools, system_tools)
  • added new functions:
    • system_tools
      • get_username
      • get_home_dir
      • find_file_path
    • print_tools
      • and_list
      • format_filesize

0.0.1 (2022-06-10)

  • first version

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

invesyservertools-0.1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

invesyservertools-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file invesyservertools-0.1.0.tar.gz.

File metadata

  • Download URL: invesyservertools-0.1.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for invesyservertools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8152e392a5b2e68fa652253936a851a79975ffb1670600fda85c5c4238fb32dc
MD5 0c56c4d1c7d803dd9415016affc7715c
BLAKE2b-256 6f35be0514b339ab77c866c0faf299c1a4e5ce72ab3b611b5914538d8e3b4fa8

See more details on using hashes here.

File details

Details for the file invesyservertools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for invesyservertools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5645654313f0891c9607e89c52583b317e38e4db2ee7860605051abcb116b1b
MD5 45ec72b1ca345ad637c80736e8f1906b
BLAKE2b-256 22696b78d6679aa572a34e50fc9a91c8d5d8ab0f333463035f3bfcfe42ca7aba

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