zut


Namezut JSON
Version 1.2.1 PyPI version JSON
download
home_pageNone
SummaryReusable Python utilities.
upload_time2025-02-22 23:02:10
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7.3
licenseNone
keywords reusable util utils common commons base flexout csv excel tabulate smb samba share dump dump_object tabular_dumper db
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Zut
===

Reusable Python utilities.

:warning: **This project is now in a read-only state and won't receive further updates.**


## 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

### 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
from zut.files import 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",
    "author": null,
    "author_email": "S\u00e9bastien Hocquet <seb@ipamo.net>",
    "download_url": null,
    "platform": null,
    "description": "Zut\r\n===\r\n\r\nReusable Python utilities.\r\n\r\n:warning: **This project is now in a read-only state and won't receive further updates.**\r\n\r\n\r\n## Installation\r\n\r\nZut package is published [on PyPI](https://pypi.org/project/zut/). Install with default, minimal dependencies:\r\n\r\n```sh\r\npip install zut[default]\r\n```\r\n\r\nOther possible dependency specifications:\r\n\r\n- `pip install zut` : no dependency installed\r\n- `pip install zut[excel]` : dependencies to manage Excel files (including [openpyxl](https://pypi.org/project/openpyxl))\r\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\r\n- `pip install zut[sqlite]` : dependencies to connect with a SQLite database ([sqlparse](https://pypi.org/project/sqlparse))\r\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))\r\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))\r\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))\r\n\r\n\r\n## Usage examples\r\n\r\n### Configure logging\r\n\r\n```py\r\nfrom zut import configure_logging\r\nconfigure_logging()\r\n```\r\n\r\n### Flexible output\r\n\r\nWrite tabular data to a flexible, easily configurable output: CSV or Excel file, or tabulated stdout/stderr.\r\n\r\nThe output file may be on the local file system or on a Windows/Samba share (including when the library is used on Linux).\r\n    \r\nExport tabular data to stdout or to a file:\r\n\r\n```py\r\nimport sys\r\nfrom zut import tabular_dumper\r\n\r\nwith tabular_dumper(filename or sys.stdout, headers=[\"Id\", \"Word\"]) as t:\r\n    t.append([1, \"Hello\"])\r\n    t.append([2, \"World\"])\r\n```\r\n\r\nTabular data can also be exported using dictionnaries (in this case, headers will be detected automatically by the library):\r\n\r\n```py\r\nimport sys\r\nfrom zut import tabular_dumper\r\n\r\nwith tabular_dumper(filename or sys.stdout) as t:\r\n    t.append({'id': 1, 'name': \"Hello\"})\r\n    t.append({'id': 2, 'col3': True})\r\n```\r\n\r\nIf `filename` has extension with `.xlsx`, output will be in Excel 2010 format.\r\nOtherwise it will be in CSV format.\r\n\r\nIf `filename` starts with `\\\\`, output will be done on the corresponding Windows/Samba share.\r\nTo indicate Samba credentials, call `configure_smb_credentials` before using function `tabular_dumper`.\r\nExample:\r\n\r\n```py\r\nfrom zut import tabular_dumper\r\nfrom zut.files import configure_smb_credentials\r\n\r\nconfigure_smb_credentials(user=..., password=...)\r\n\r\nwith tabular_dumper(r\"\\\\server\\share\\path\\to\\file\") as o:\r\n    ...\r\n```\r\n\r\n\r\n## Legal\r\n\r\nThis project is licensed under the terms of the [MIT license](https://gitlab.com/ipamo/zut/-/raw/main/LICENSE.txt).\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Reusable Python utilities.",
    "version": "1.2.1",
    "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"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0046afa26678c0b08719eda233172536fef69e88dcf6f6f3879a53511e94a8e5",
                "md5": "e8ef571e67841feeba0cfff7e3a799df",
                "sha256": "e4108d2fd7668f22915b6f45c634cf68daa43de4c8c31245912cbbaf6c6c57d2"
            },
            "downloads": -1,
            "filename": "zut-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8ef571e67841feeba0cfff7e3a799df",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.3",
            "size": 88878,
            "upload_time": "2025-02-22T23:02:10",
            "upload_time_iso_8601": "2025-02-22T23:02:10.376932Z",
            "url": "https://files.pythonhosted.org/packages/00/46/afa26678c0b08719eda233172536fef69e88dcf6f6f3879a53511e94a8e5/zut-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-22 23:02:10",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "ipamo",
    "gitlab_project": "zut",
    "lcname": "zut"
}
        
Elapsed time: 8.14552s