skip to navigation
skip to content

bag 0.9.0

A library for several purposes, including javascript i18n and stuff for the Pyramid web framework.

Package Documentation

bag contains code for many purposes, which I find myself reusing in multiple programs – so this code must be version-controlled. I use SQLAlchemy and Pyramid a lot.

Documentation is at

The library, tested on Python 2.7, 3.3, 3.4 and 3.5, is hosted at

  • bag 0.8.0 is the last version that supported Python 2.6.
  • bag 0.9.0 is the last version that supported Python 2.7.

This version of bag was published with releaser.

Most important library contents

  • bag.csv2 – The infamous csv Python module does not support unicode; problem solved.
  • bag.spreadsheet – Import CSV and Excel spreadsheets based on headers on the first row. There is also a buffered CSV writer for outputting CSV in a web app.
  • bag.email_validator – The ultimate functions for email validation and domain validation, as well as an email address harvester.
  • bag.pathlib_complement – A Path subclass that does what pathlib doesn’t do.
  • bag.web.burla – Powerful URL generation independent of web frameworks, working in Python and in the client (Javascript) too. Also provided is Pyramid integration for it.
  • bag.web.flash_msg – Advanced flash messages for any web framework. Also provided is Pyramid integration.
  • bag.web.subcommand – Use argh to dispatch to subcommands with their command-line arguments.
  • bag.web.transecma – Complete solution for javascript internationalization. Compatible with jquery templates. Includes transecma.js.
  • bag.web.web_deps – Ensure your javascript libraries and CSS stylesheets appear in the right order, and require them from different parts of your code.

If you use the Pyramid web framework

If you use SQLAlchemy


  • delete_old_branches – Deletes git branches that have already been merged onto the current branch. Optionally, filter the branches by age (in days).
  • reorder_po – Reorders .po files (usually after transifex messes up the order of the translations in them) so the diff is always readable.

Less important library contents

  • bag.check_rst – Verifies reStructuredText content for correctness.
  • bag.console – Functions for user interaction at the console.
  • bag.corrupt_image – Read image files and do something if they are corrupt.
  • bag.file_existence_manager – Tools for finding duplicate files using hashes.
  • bag.log – Convenient logging initialization.
  • bag.html – Encode and decode HTML and XML entities.
  • bag.memoizeMemoize decorator with a LRU (least recently used) cache, which can take a keymaker function as an argument.
  • bag.more_codecs – Got text in some weird encoding that Python doesn’t know? OK, use iconv to decode it.
  • bag.show_progress – Don’t leave your user wondering if your program is hanging; print the progress every few seconds.
  • bag.streams – Functions that use streams (open files).
  • bag.text – Functions for working with unicode strings.
  • bag.text.words – Contains lists of nouns and adjectives and can generate a random combination words – good for generating funny test data.
  • bag.time – Functions to make it easier to work with datetimes. Includes a JSON encoder that supports time, datetime and Decimal.
File Type Py Version Uploaded on Size
bag-0.9.0-py2.py3-none-any.whl (md5) Python Wheel 3.5 2016-09-04 134KB
bag-0.9.0.tar.gz (md5) Source 2016-09-04 111KB