zut


Namezut JSON
Version 0.9.4 PyPI version JSON
download
home_pageNone
SummaryReusable Python utilities.
upload_time2024-05-28 15:25:34
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7.3
licenseNone
keywords reusable util utils common commons base flexout csv excel tabulate smb samba share out_table out_file db dbadapter
VCS
bugtrack_url
requirements typing-extensions colorlog tabulate tzlocal pytz tzdata openpyxl defusedxml sqlparse mysqlclient pyodbc sqlparams psycopg psycopg2-binary
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Zut
===

Reusable Python utilities.


## Installation

Zut package is published [on PyPI](https://pypi.org/project/zut/):

```sh
pip install zut
```


## 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 text or 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 text to stdout or to a file:

```py
import sys
from zut import out_file

with out_file(filename or sys.stdout) as f:
    f.write("Content")
```
    
Export tabular data to stdout or to a file:

```py
import sys
from zut import out_table

with out_table(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 out_table

with out_table(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 `out_table`.
Example:

```py
from zut import out_table, configure_smb_credentials

configure_smb_credentials(user=..., password=...)

with out_table(r"\\server\share\path\to\file") as o:
    ...
```


## Legal

This project is licensed under the terms of the [MIT license](https://raw.githubusercontent.com/ipamo/zut/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, out_table, out_file, db, DbAdapter",
    "author": null,
    "author_email": "S\u00e9bastien Hocquet <dev@ipamo.net>",
    "download_url": null,
    "platform": null,
    "description": "Zut\r\n===\r\n\r\nReusable Python utilities.\r\n\r\n\r\n## Installation\r\n\r\nZut package is published [on PyPI](https://pypi.org/project/zut/):\r\n\r\n```sh\r\npip install zut\r\n```\r\n\r\n\r\n## Usage examples\r\n\r\nSee also [full documentation](https://ipamo.net/zut) (including [API reference](https://ipamo.net/zut/latest/api-reference.html)).\r\n\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 text or 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 text to stdout or to a file:\r\n\r\n```py\r\nimport sys\r\nfrom zut import out_file\r\n\r\nwith out_file(filename or sys.stdout) as f:\r\n    f.write(\"Content\")\r\n```\r\n    \r\nExport tabular data to stdout or to a file:\r\n\r\n```py\r\nimport sys\r\nfrom zut import out_table\r\n\r\nwith out_table(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 out_table\r\n\r\nwith out_table(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 `out_table`.\r\nExample:\r\n\r\n```py\r\nfrom zut import out_table, configure_smb_credentials\r\n\r\nconfigure_smb_credentials(user=..., password=...)\r\n\r\nwith out_table(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://raw.githubusercontent.com/ipamo/zut/main/LICENSE.txt).\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Reusable Python utilities.",
    "version": "0.9.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/ipamo/zut/issues",
        "Homepage": "https://github.com/ipamo/zut"
    },
    "split_keywords": [
        "reusable",
        " util",
        " utils",
        " common",
        " commons",
        " base",
        " flexout",
        " csv",
        " excel",
        " tabulate",
        " smb",
        " samba",
        " share",
        " out_table",
        " out_file",
        " db",
        " dbadapter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "edeef6b62d208be9d7839206c0e043f6e37f77f447ead33d011ea78703270862",
                "md5": "2fc79d91239ec6021c2e1c4ebf07f4fc",
                "sha256": "e4488728c60b99f38a5acbe7a8f61df252e205c69667f9104633802174e2e546"
            },
            "downloads": -1,
            "filename": "zut-0.9.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2fc79d91239ec6021c2e1c4ebf07f4fc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.3",
            "size": 49089,
            "upload_time": "2024-05-28T15:25:34",
            "upload_time_iso_8601": "2024-05-28T15:25:34.579064Z",
            "url": "https://files.pythonhosted.org/packages/ed/ee/f6b62d208be9d7839206c0e043f6e37f77f447ead33d011ea78703270862/zut-0.9.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-28 15:25:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ipamo",
    "github_project": "zut",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "typing-extensions",
            "specs": []
        },
        {
            "name": "colorlog",
            "specs": []
        },
        {
            "name": "tabulate",
            "specs": []
        },
        {
            "name": "tzlocal",
            "specs": []
        },
        {
            "name": "pytz",
            "specs": []
        },
        {
            "name": "tzdata",
            "specs": []
        },
        {
            "name": "openpyxl",
            "specs": []
        },
        {
            "name": "defusedxml",
            "specs": []
        },
        {
            "name": "sqlparse",
            "specs": []
        },
        {
            "name": "mysqlclient",
            "specs": []
        },
        {
            "name": "pyodbc",
            "specs": []
        },
        {
            "name": "sqlparams",
            "specs": []
        },
        {
            "name": "psycopg",
            "specs": []
        },
        {
            "name": "psycopg2-binary",
            "specs": []
        }
    ],
    "lcname": "zut"
}
        
Elapsed time: 0.25893s