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 at all is 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 at all is 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.0.0",
"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": "dfed31f3df633389283fa3b931f503b60b6a67406b78644c6394d124138c84b5",
"md5": "48126f3f221ac66894ad4cdaea0ce417",
"sha256": "a4eb76a0f77436bc55595078db1afbb706490a063808600e695e733eae387dea"
},
"downloads": -1,
"filename": "zut-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "48126f3f221ac66894ad4cdaea0ce417",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.3",
"size": 72905,
"upload_time": "2024-11-19T12:15:43",
"upload_time_iso_8601": "2024-11-19T12:15:43.767594Z",
"url": "https://files.pythonhosted.org/packages/df/ed/31f3df633389283fa3b931f503b60b6a67406b78644c6394d124138c84b5/zut-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-19 12:15:43",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "ipamo",
"gitlab_project": "zut",
"lcname": "zut"
}