Metadata-Version: 2.4
Name: invesyservertools
Version: 0.1.0
Summary: Tools for Python scripts or terminal
Author-email: Georg Pfolz <georg.pfolz@invesy.at>
License-Expression: MIT
Project-URL: Homepage, https://gitlab.com/Rastaf/invesyservertools
Project-URL: Bug Tracker, https://gitlab.com/Rastaf/invesyservertools/-/issues
Project-URL: Documentation, https://rastaf.gitlab.io/invesyservertools/
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: colorama
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# invesyservertools

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

Why "invesy"? Invesy (from German **In**halts**ve**rwaltungs**sy**stem == 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

```sh
pip install invesyservertools
```

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

## Quick example

```python
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
