Skip to main content

General Python tools

Project description

https://travis-ci.org/visaplan/visaplan.tools.svg?branch=master https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336:target:https://pycqa.github.io/isort/

visaplan.tools

This is a collection of utility modules for Python projects.

Features

  • buildout module, for buildout-built projects:

    Function checkPathForPackage to check a given package against a versions whitelist. Useful if you like to constrain the versions of that package without actually requiring it.

  • coding module:

    Factory functions to create safe_encode resp. safe_decode functions as needed

  • classes module:

    Several simple but useful classes derived from Python dicts, e.g. Mirror and Proxy

  • dates module:

    • parse dates, supporting multiple formats

  • debug module:

    • trace_this decorator

  • dicts module:

    • several tools to work with standard dictionaries

  • files module:

    • functions related to files; for now make_mtime_checker

  • html module:

    • HtmlEntityProxy - a dict which returns unicode characters when given a named HTML entity

  • http module:

    • extract_hostname (using url.split and raising ValueError)

  • lands0 module:

    • several tools to work with lists and strings

  • minifuncs module:

    • very small functions, for some cases where functions are used as arguments

  • profile module:

    • a StopWatch context manager and @profile decorator

  • sequences module:

    • tools for sequences, e.g. inject_indexes

  • sql module:

    • functions for the generation of SQL statements, including insert, update, delete and select.

      The visaplan.zope.reldb package has a copy of this module which uses the SQLAlchemy placeholders convention (:name).

  • times module:

    • functions related to date and/or time calculations

Documentation

The modules are documented by doctests. Apart from this, we don’t have real user documentation yet (sorry).

Installation

Simply install visaplan.tools by using pip:

pip install visaplan.tools

or by adding it to your buildout:

[buildout]
...
eggs =
    visaplan.tools

and then running bin/buildout

Contribute

Support

If you are having issues, please let us know; please use the issue tracker mentioned above.

License

The project is licensed under the GNU General Public License v2 (GPLv2).

Contributors

Changelog

2.0.0 (unreleased)

  • Breaking changes:

    • Signature change (e.g. name of first argument: form –> dic) for dicts.update_dict.

1.3.1 (unreleased)

Improvements:

  • .sequences.nonempty_lines now takes a function argument, default: string.strip

New Features:

  • new module sql which helps generating SQL statements; it doesn’t try, however, to provide any kind of object relational mapping.

    The following function return a statement string with placeholders and a values dictionary:

    • insert

    • update

    • delete

    • select

    (a modified copy of the utils module from visaplan.plone.sqlwrapper v1.0.2), with the following unfinished functions removed:

    • make_grouping_wrapper (including the helper _groupable_spectup)

    • make_join (in [v1_3_x]@34490)

    Instead, we have new functions:

    • subdict_ne - create a subdict of non-empty values. This is a replacement for the extract_dict function which (sadly) expects - other than the .dicts.subdict function - the fields argument first.

      It is generated by the .sql.make_dict_extractor factory function which allows for a few keyword options, e.g. to specify the values considered empty.

  • new function lands0.make_default_prefixer

[tobiasherp]

1.3.0 (2020-06-12)

New Features:

  • new module batches, containing a batch_tuples function which generates (sublist, txt) tuples

  • new class classes.StackOfDicts

  • new function minifuncs.check_kwargs

  • new function debug.has_strings

  • new function debug.make_debugfile_writer (not yet sufficiently generalized)

Requirements:

  • six module, for Python 3 compatibility

[tobiasherp]

1.2.6 (2020-01-08)

Improvements:

  • Travis CI integration added.

  • Test discovery configuration for nose2 (used on Travis) and nose.

Bugfixes:

  • Fixed doctests for

    • .dicts.update_dict

    • .dicts.make_key_injector

  • Removed now-obsolete …tests/test_doctests.py file which caused nosetests to fail.

New Features:

  • .times.make_defaulttime_calculator: new keyword-only option utc=False, to make the doctests work with Travis.

[tobiasherp]

1.2.5 (2019-10-16)

  • New class classes.AliasDict

  • Added some doctests.

[tobiasherp]

1.2.4 (2019-05-09)

  • New function dicts.update_dict (from v1.2.3) “published” in __all__ list. We are not happy with the signature of this function, though, so it will likely change in a future release.

  • New function classes.connected_dicts which creates two connected dictionaries with dic1[key] = val <–> dict2[val] = key

  • log_or_trace will print a useful info, containing the trace_key, before calling set_trace()

[tobiasherp]

1.2.3 (2019-01-30)

  • new function update_dict in dicts module (which takes a deletions list argument)

  • buildout.extract_package_and_version supports egg specs with subpaths as well (child of an /eggs/ directory)

  • buildout.checkPathForPackage logs the invalid package entries if the package in question could not be found

  • lands0.groupstring supports cumulate option (default: False) [tobiasherp]

1.2.2 (2018-11-08)

  • new module buildout for use in buildout-built projects: use the checkPathForPackage function to check an installed package against a versions whitelist [tobiasherp]

1.2.1 (2018-09-17)

  • new module dates:

    • make_date_parser factory to create a parse_date function which understands multiple date formats

    • make_date_formatter factory to create a function which formats date, given as a datetime object or a tuple of int

  • new module profile:

    • StopWatch context manager and @profile decorator

  • new module mock:

    • a few small classes for use in doctests

    • the same module as visaplan.plone.tools.mock

  • module debug:

    • new decorators trace_this, log_result

    • new function print_indented

    • new factory function make_sleeper

  • module dicts:

    • new function make_key_injector

  • module minifuncs:

    • new function translate_dummy

  • module sequences:

    • new function nocomment_split

    • new function columns [tobiasherp]

  • module lands0:

    • new function join_stripped

  • License changed to GPLv2

1.2 (2018-07-11)

  • breaking changes:

    • classes: Proxy is now a factory rather than a class

  • modules debug, dicts, lands0, minifuncs [tobiasherp]

1.1 (2018-06-12)

  • modules sequences, times, files

  • Minor Bugfixes [tobiasherp]

1.0 (2018-06-11)

  • Initial release, including modules classes, html, http and coding [tobiasherp]

Project details


Download files

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

Source Distribution

visaplan.tools-1.3.1.dev6.tar.gz (87.2 kB view details)

Uploaded Source

File details

Details for the file visaplan.tools-1.3.1.dev6.tar.gz.

File metadata

  • Download URL: visaplan.tools-1.3.1.dev6.tar.gz
  • Upload date:
  • Size: 87.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.5

File hashes

Hashes for visaplan.tools-1.3.1.dev6.tar.gz
Algorithm Hash digest
SHA256 5ea3c8ce7f995114aeca845a62f34f901a61655c6fca6eb4758fc197eea00ac4
MD5 2c46aa1c35514a9b04db8b7c00ad1a5d
BLAKE2b-256 e423048bc772ad6d88d25c2c2ac43ac8cd1eb700928d10923bc69f9b3f13aa2f

See more details on using hashes here.

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