Skip to main content

Utility functions and classes

Project description

Some utility functions and classes I use in many projects.

https://img.shields.io/pypi/v/flotils.svg https://img.shields.io/pypi/l/flotils.svg https://img.shields.io/pypi/dm/flotils.svg

Note: This package does not follow the UNIX philosophy. (It does more than one thing). Though some modules might get moved to their own packages in the future, this is currently not planned.

Documentation at GitHub

logable

Module to ease logging efforts

Supports

  • Using logging calls directly on instance

  • Module logger

  • Optional instance id

  • Add method information to log

  • Default logging config

In class Demo(Logable) you are able to use the logging calls directly (eg. self.debug(), self.warning(), self.exception(),..) to produce structured logging output like

DEBUG:Demo:working on something
INFO:Demo:Finished working
DEBUG:root:Inbetween
WARNING:Demo:Something might go wrong
ERROR:Demo:Something went wrong
WARNING:Demo:Told you!

The Logable class allows you to specify an id for an instance Demo({'id': "demo2"}) resulting in

DEBUG:Demo.demo2:working on something
INFO:Demo.demo2:Finished working
DEBUG:root:Inbetween
WARNING:Demo.demo2:Something might go wrong
ERROR:Demo.demo2:Something went wrong
WARNING:Demo.demo2:Told you!

Also supports method information:

2015-12-27 20:30:48 DEBUG   [Demo.demo2.work_on_something] working on something
2015-12-27 20:30:48 INFO    [Demo.demo2.work_on_something] Finished working
2015-12-27 20:30:48 DEBUG   [root] Inbetween
2015-12-27 20:30:48 WARNING [Demo.demo2.work_on_something_else] Something might go wrong
2015-12-27 20:30:48 ERROR   [Demo.demo2.work_on_something_else] Something went wrong
2015-12-27 20:30:48 WARNING [Demo.demo2.work_on_something_else] Told you!

For information on how to enable this, please have a look at logable.default_logging_config

loadable

Module to ease json(file) efforts

Supports

  • loading/writing json both as string and file

  • date, time and datetime types supported (saved and loaded as utc)

  • class to load/save settings from/to file

Loadable is a child class of Logable, thus inheriting all logging capabilities.

To tell class Demo(Loadable) to create an instance from a settings file, just write Demo({'settings_file': "path/to/settings.json"}).

Settings provided in __init__() overwrite the ones set in the file.

runable

Module to ease starting/stoping of classes

Supports

  • Startable (Class can be started start())

  • Stopable (Class can be stopped stop())

  • StartStopable (Startable() + Stopable())

  • SignalStopWrapper (Listens for SIGTERM and SIGINT signals and stops the class)

History

0.5.0 (2019-03-26)

  • Fix typos

  • Flake8 not version bound

  • Update pyyaml

  • Remove deprecated code

  • Fix open() calls (use io.open(), no byte open, utf8 encoding)

  • StartStopable.is_running

  • DateTimeEn/Decode free of time zone (always utc)

  • Drop “python-dateutil” dependency

  • Basic loadable test file

0.4.2 (2018-01-27)

  • missing merge

0.4.1 (2018-01-27)

  • small __init__ changes

0.4.0 (2018-01-27)

  • add convenience module (PrintableBase, FromToDictBase)

  • add save_file/load_file to Loadable

  • remove deprecated logException, warn from Logable

  • __future__ imports in runable

0.3.5a0 (2017-03-06)

  • Deprecated camel-case methods in loadable, new save/load methods

0.3.4a0 (2017-03-06)

  • Add yaml loading/saving code

0.3.3a0 (2017-03-06)

  • Add get_logger function

0.3.2b0 (2016-11-25)

  • Fix relative import in loadable

0.3.2a0 (2016-08-14)

  • Add datetime.timedelta to JSONEncoder/Decoder

0.3.1a0 (2016-03-31)

  • Catch interrupt in Stopable.stop() when sleeping

0.3.0a0 (2016-03-08)

  • Move webscraper to own package

0.2.14b0 (2016-03-02)

  • Fix missing calls to parent init method

0.2.13a0 (2016-01-28)

  • Runable (Startable, Stopable, StartStopable, SignalStopWrapper)

0.2.12a0 (2016-01-07)

  • WebScraper

0.2.11a0 (2015-12-31)

  • Loadable

  • Changed documentation

0.2.10a0 (2015-12-27)

  • First release on PyPI.

  • Logable

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

flotils-0.5.0.win-amd64.zip (27.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

flotils-0.5.0-py3.7.egg (24.8 kB view details)

Uploaded Egg

flotils-0.5.0-py2.py3-none-any.whl (12.8 kB view details)

Uploaded Python 2Python 3

flotils-0.5.0-py2.7.egg (24.7 kB view details)

Uploaded Egg

File details

Details for the file flotils-0.5.0.win-amd64.zip.

File metadata

  • Download URL: flotils-0.5.0.win-amd64.zip
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for flotils-0.5.0.win-amd64.zip
Algorithm Hash digest
SHA256 e79d46af5a95c64965623c072c5b552e98b5bc8264e07911d3a597cd9f3db091
MD5 5e0530e36e2dea763e5fddbdae16906e
BLAKE2b-256 59dc5541d672aaca41151a8f19522f652565b8bde0601c6b368a6b528eacd689

See more details on using hashes here.

File details

Details for the file flotils-0.5.0-py3.7.egg.

File metadata

  • Download URL: flotils-0.5.0-py3.7.egg
  • Upload date:
  • Size: 24.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for flotils-0.5.0-py3.7.egg
Algorithm Hash digest
SHA256 60fc9d4db94c580db2250f928eb593c33f6f0cd00a00bc1f69f11ff0496e3789
MD5 c79c102c89122c6a780551276464ffe6
BLAKE2b-256 1c4691884d6c0e865d12e6d540c83645765cbf9c8a86986fc82f67f5a97d601a

See more details on using hashes here.

File details

Details for the file flotils-0.5.0-py2.py3-none-any.whl.

File metadata

  • Download URL: flotils-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for flotils-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0f918f65c28fa355b738b41d8895f23826e9b4afbf4ada6f6d103c8a346dd31a
MD5 cfa84898086d752b70e682d92f32bb21
BLAKE2b-256 72fea05ad2357850068e1c1d7dd0d5046f3277474ba80b77a15a20dd1e54d607

See more details on using hashes here.

File details

Details for the file flotils-0.5.0-py2.7.egg.

File metadata

  • Download URL: flotils-0.5.0-py2.7.egg
  • Upload date:
  • Size: 24.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for flotils-0.5.0-py2.7.egg
Algorithm Hash digest
SHA256 bd676cd8b3c33d3027b73bde03c53ff7fb9ad1dadbde301011bd48b406b6e8a5
MD5 009312453e483e26dedc40c4383fbae1
BLAKE2b-256 95e9b3dc8b90914838034a595587031e99d0edfc2aae0be9d508ca21ca77d249

See more details on using hashes here.

Supported by

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