Zut
===
Reusable Python utilities.
## Installation
Zut package is published [on PyPI](https://pypi.org/project/zut/). Install with default, minimal dependencies:
```sh
pip install zut[default]
```
Other possible dependency specifications:
- `pip install zut` : no dependency installed
- `pip install zut[excel]` : dependencies to manage Excel files (including [openpyxl](https://pypi.org/project/openpyxl))
- `pip install zut[smb]` : dependencies to access files on Samba shares from Linux, or on Windows with non-standard security context (including [smbprotocol](https://pypi.org/project/smbprotocol)) - Not required to access Samba shares from Windows using default credentials
- `pip install zut[sqlite]` : dependencies to connect with a SQLite database ([sqlparse](https://pypi.org/project/sqlparse))
- `pip install zut[postgresql]` (or `[pg]`) : dependencies to connect with a PostgreSQL database ([psycopg](https://pypi.org/project/psycopg) and [sqlparse](https://pypi.org/project/sqlparse))
- `pip install zut[mariadb]` (or `[mysql]`) : dependencies to connect with a MariaDB or MySQL database ([mysqlclient](https://pypi.org/project/mysqlclient) and [sqlparse](https://pypi.org/project/sqlparse))
- `pip install zut[sqlserver]` : dependencies to connect with a Microsoft SQL Server database (including [pyodbc](https://pypi.org/project/pyodbc) and [sqlparse](https://pypi.org/project/sqlparse))
## Usage examples
See also [full documentation](https://ipamo.net/zut) (including [API reference](https://ipamo.net/zut/latest/api-reference.html)).
### Configure logging
```py
from zut import configure_logging
configure_logging()
```
### Flexible output
Write tabular data to a flexible, easily configurable output: CSV or Excel file, or tabulated stdout/stderr.
The output file may be on the local file system or on a Windows/Samba share (including when the library is used on Linux).
Export tabular data to stdout or to a file:
```py
import sys
from zut import tabular_dumper
with tabular_dumper(filename or sys.stdout, headers=["Id", "Word"]) as t:
t.append([1, "Hello"])
t.append([2, "World"])
```
Tabular data can also be exported using dictionnaries (in this case, headers will be detected automatically by the library):
```py
import sys
from zut import tabular_dumper
with tabular_dumper(filename or sys.stdout) as t:
t.append({'id': 1, 'name': "Hello"})
t.append({'id': 2, 'col3': True})
```
If `filename` has extension with `.xlsx`, output will be in Excel 2010 format.
Otherwise it will be in CSV format.
If `filename` starts with `\\`, output will be done on the corresponding Windows/Samba share.
To indicate Samba credentials, call `configure_smb_credentials` before using function `tabular_dumper`.
Example:
```py
from zut import tabular_dumper, configure_smb_credentials
configure_smb_credentials(user=..., password=...)
with tabular_dumper(r"\\server\share\path\to\file") as o:
...
```
## Legal
This project is licensed under the terms of the [MIT license](https://gitlab.com/ipamo/zut/-/raw/main/LICENSE.txt).
Raw data
{
"_id": null,
"home_page": null,
"name": "zut",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7.3",
"maintainer_email": null,
"keywords": "reusable, util, utils, common, commons, base, flexout, csv, excel, tabulate, smb, samba, share, dump, dump_object, tabular_dumper, db, DbAdapter",
"author": null,
"author_email": "S\u00e9bastien Hocquet <dev@ipamo.net>",
"download_url": null,
"platform": null,
"description": "Zut\n===\n\nReusable Python utilities.\n\n\n## Installation\n\nZut package is published [on PyPI](https://pypi.org/project/zut/). Install with default, minimal dependencies:\n\n```sh\npip install zut[default]\n```\n\nOther possible dependency specifications:\n\n- `pip install zut` : no dependency installed\n- `pip install zut[excel]` : dependencies to manage Excel files (including [openpyxl](https://pypi.org/project/openpyxl))\n- `pip install zut[smb]` : dependencies to access files on Samba shares from Linux, or on Windows with non-standard security context (including [smbprotocol](https://pypi.org/project/smbprotocol)) - Not required to access Samba shares from Windows using default credentials\n- `pip install zut[sqlite]` : dependencies to connect with a SQLite database ([sqlparse](https://pypi.org/project/sqlparse))\n- `pip install zut[postgresql]` (or `[pg]`) : dependencies to connect with a PostgreSQL database ([psycopg](https://pypi.org/project/psycopg) and [sqlparse](https://pypi.org/project/sqlparse))\n- `pip install zut[mariadb]` (or `[mysql]`) : dependencies to connect with a MariaDB or MySQL database ([mysqlclient](https://pypi.org/project/mysqlclient) and [sqlparse](https://pypi.org/project/sqlparse))\n- `pip install zut[sqlserver]` : dependencies to connect with a Microsoft SQL Server database (including [pyodbc](https://pypi.org/project/pyodbc) and [sqlparse](https://pypi.org/project/sqlparse))\n\n\n## Usage examples\n\nSee also [full documentation](https://ipamo.net/zut) (including [API reference](https://ipamo.net/zut/latest/api-reference.html)).\n\n\n### Configure logging\n\n```py\nfrom zut import configure_logging\nconfigure_logging()\n```\n\n### Flexible output\n\nWrite tabular data to a flexible, easily configurable output: CSV or Excel file, or tabulated stdout/stderr.\n\nThe output file may be on the local file system or on a Windows/Samba share (including when the library is used on Linux).\n \nExport tabular data to stdout or to a file:\n\n```py\nimport sys\nfrom zut import tabular_dumper\n\nwith tabular_dumper(filename or sys.stdout, headers=[\"Id\", \"Word\"]) as t:\n t.append([1, \"Hello\"])\n t.append([2, \"World\"])\n```\n\nTabular data can also be exported using dictionnaries (in this case, headers will be detected automatically by the library):\n\n```py\nimport sys\nfrom zut import tabular_dumper\n\nwith tabular_dumper(filename or sys.stdout) as t:\n t.append({'id': 1, 'name': \"Hello\"})\n t.append({'id': 2, 'col3': True})\n```\n\nIf `filename` has extension with `.xlsx`, output will be in Excel 2010 format.\nOtherwise it will be in CSV format.\n\nIf `filename` starts with `\\\\`, output will be done on the corresponding Windows/Samba share.\nTo indicate Samba credentials, call `configure_smb_credentials` before using function `tabular_dumper`.\nExample:\n\n```py\nfrom zut import tabular_dumper, configure_smb_credentials\n\nconfigure_smb_credentials(user=..., password=...)\n\nwith tabular_dumper(r\"\\\\server\\share\\path\\to\\file\") as o:\n ...\n```\n\n\n## Legal\n\nThis project is licensed under the terms of the [MIT license](https://gitlab.com/ipamo/zut/-/raw/main/LICENSE.txt).\n",
"bugtrack_url": null,
"license": null,
"summary": "Reusable Python utilities.",
"version": "1.1.5",
"project_urls": {
"Bug Tracker": "https://gitlab.com/ipamo/zut/issues",
"Homepage": "https://gitlab.com/ipamo/zut"
},
"split_keywords": [
"reusable",
" util",
" utils",
" common",
" commons",
" base",
" flexout",
" csv",
" excel",
" tabulate",
" smb",
" samba",
" share",
" dump",
" dump_object",
" tabular_dumper",
" db",
" dbadapter"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ef1eb7c9f3c4b0636b73d32c49cbcae95a556717d8c81a8d7020bfa2a8012d32",
"md5": "490e598a477c58bc13401932e06c5ddb",
"sha256": "b0f562155a2aaa1cd6a7a76b28f9abaf04bf164b6880cd533fd48b7bc5363cef"
},
"downloads": -1,
"filename": "zut-1.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "490e598a477c58bc13401932e06c5ddb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.3",
"size": 76410,
"upload_time": "2024-12-19T19:23:02",
"upload_time_iso_8601": "2024-12-19T19:23:02.487849Z",
"url": "https://files.pythonhosted.org/packages/ef/1e/b7c9f3c4b0636b73d32c49cbcae95a556717d8c81a8d7020bfa2a8012d32/zut-1.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 19:23:02",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "ipamo",
"gitlab_project": "zut",
"lcname": "zut"
}