Skip to main content

Reusable Python, Django and PostgreSql utilities.

Project description

Zut

Reusable Python, Django and PostgreSql utilities.

Installation

From PyPI, with all optional dependencies:

pip install zut[all]

From a Git branch or tag (using https or ssh):

pip install git+https://gitlab.com/ipamo/zut.git@main#egg=zut[all]
pip install git+ssh://git@gitlab.com/ipamo/zut.git@main#egg=zut[all]

Note: optionaly dependencies may also be chosen individually. For example, use zut[excel,pg] instead of zut[all].

Usage examples

Configure logging

from zut import configure_logging
configure_logging()

Flexible in/out - TODO

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:

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:

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):

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:

from zut import out_table, configure_smb_credentials

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

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

Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

zut-0.6.2-py3-none-any.whl (70.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page