Skip to main content
Latest Version License Python Versions https://github.com/hgrecco/breadcrumbs/workflows/CI/badge.svg?branch=main https://github.com/hgrecco/breadcrumbs/workflows/Lint/badge.svg?branch=main https://coveralls.io/repos/github/hgrecco/breadcrumbs/badge.svg?branch=main

breadcrumbs: keep track of what is going on

This library started with a rather simple objective in mind: keep track of a sequence of transforming steps.

It is extremely easy to use:

>>> import breadcrumbs as bc
>>> crumb = bc.Crumb("start")
>>> crumb.info.update(value=35)
>>> crumb.info.update(other_value=70)
>>> print(crumb.info)
{'value': 35, 'other_value': 70}

A Crumb can has three attributes: a name (here Start), and two dicts (info and extra) to store additional information. You can also store dependent crumbs using the put_crumb method.

‘What is the big deal?’ you might ask, ‘You are just writing a dict!’ True, but the cool thing is that it works a little bit like logging and therefore you use it decoupled across you code:

>>> def func1():
...     bc.info.update(value=35)
>>> def func2():
...     bc.extra.update(other_value=70)
>>> crumb = bc.Crumb("start")
>>> with bc.context(crumb):
...     func2()
...     func1()
>>> print(crumb.info)
{'value': 35}
>>> print(crumb.extra)
{'other_value': 70}

func1 and func2 now nothing about crumb but it just works.

You can also decorate a function to do some things for you automatically.

>>> @bc.aware()
... def func1(x, y):
...     return x + y
>>> crumb = bc.Crumb("start")
>>> with bc.context(crumb):
...     func1(1, 2)
>>> print(crumb.trail)
(Crumb('func1', info={'x': 1, y: '2'}, extra={}))

So in trail you can see that func1 has been called with certain parameters. You can redact some parameters that might be memory intensive or pointless to store.

>>> @bc.aware(redact_params='y')
... def func1(x, y):
...     return x + y
>>> crumb = bc.Crumb("start")
>>> with bc.context(crumb):
...     func1(1, 2)
>>> print(crumb.trail)
(Crumb('func1', info={'x': 1}, extra={}))

To redact more parameters, just pass an iterable.

A useful feature is that a TrailMixin allows you to add object specific notes and teach this to functions.

>>> class MyCoolClass(bc.TrailMixin):
...     # Here goes your cool class
...     internal = 10
>>> @bc.aware(trail_param="obj")
... def func1(obj, x, y):
...     return (x + y) * obj.internal
>>> myobj = MyCoolClass()
>>> func1(myobj, 1, 2)
>>> print(myobj.trail)
(Crumb('func1', info={'x': 1, 'y': 2}, extra={}))

Quick Installation

To install breadcrumbs, simply:

$ pip install use-breadcrumbs

and then simply enjoy it!

It runs in Python 3.7+ with no other dependency. It is licensed under BSD.


breadcrumbs is maintained by a community. See AUTHORS for a complete list.

To review an ordered list of notable changes for each version of a project, see CHANGES

Download files

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

Source Distribution

use-breadcrumbs-0.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

use_breadcrumbs-0.2-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file use-breadcrumbs-0.2.tar.gz.

File metadata

  • Download URL: use-breadcrumbs-0.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for use-breadcrumbs-0.2.tar.gz
Algorithm Hash digest
SHA256 0ae5afd477d316fe5e2da63464a2b058428c73258f555e1ba54448c0a1c02fd6
MD5 edd10fe069809fb7264327758a8c8c34
BLAKE2b-256 e328cbd691a6a1092581a0dea365fed8d001daa8b5a677ab83181f82a6884c33

See more details on using hashes here.

File details

Details for the file use_breadcrumbs-0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: use_breadcrumbs-0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for use_breadcrumbs-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 86202f3d2f71e2a33bdf4320fe6f5e0a1b410ed152fcc688759868b21eb67147
MD5 7bfb045bc6d0636fe0a101968ed9a7f6
BLAKE2b-256 fe1262546b9f6e5c8d54bb6aaaaa9da2e247f0faa131896238af5f72c9fbedf9

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 Sentry Error logging StatusPage Status page