Skip to main content

Commonly Consumed Code Commodities

Project description

Commonly Consumed Code Commodities Build Status Coverage Status

Overview

The reusables library is a reference of python functions and classes that programmers may find themselves often recreating.

Example

import reusables

reusables.config_dict('my_config.cfg')
# {'Section 1': {'key 1': 'value 1', 'key2': 'Value2'}, 'Section 2': {}}

reusables.safe_path('/home/user/eViL User\0\\/newdir$^&*/new^%file.txt')
# '/home/user/eViL User__/newdir____/new__file.txt'

reusables.find_all_files(".", ext=reusables.exts.pictures)
# ['/home/user/background.jpg', '/home/user/private.png']

Extras

Also included is a Namespace class, similar to Bunch but designed so that dictionaries are recursively made into namespaces, and can be treated as either a dict or a namespace when accessed.

from reusables import Namespace

my_breakfast = {"spam" : {"eggs": {"sausage": {"bacon": "yummy"}}}}
namespace_breakfast = Namespace(**my_breakfast)

print(namespace_breakfast.spam.eggs.sausage.bacon)
# yummy

print(namespace_breakfast.spam.eggs['sausage'].bacon)
# yummy

str(namespace_breakfast['spam'].eggs)
# "{'sausage': {'bacon': 'yummy'}}"

dict(namespace_breakfast.spam.eggs['sausage'])
# {'bacon': 'yummy'}

repr(namespace_breakfast)
# "<Namespace: {'spam': {'eggs': {'sausage': {'...>"

Additional Info

This does not claim to provide the most accurate, fastest or most ‘pythonic’ way to implement these useful snippets, this is simply designed for easy reference. Any contributions that would help add functionality or improve existing code is warmly welcomed!

Copyright (c) 2014 - Chris Griffith - MIT License

Project details


Release history Release notifications

History Node

0.9.2

History Node

0.9.1

History Node

0.9.0

History Node

0.8.0

History Node

0.7.0

History Node

0.6.1

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.1

History Node

0.4.0

History Node

0.3.0

This version
History Node

0.2.0

History Node

0.1.3

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
reusables-0.2.0-py2.6.egg (32.2 kB) Copy SHA256 hash SHA256 Egg 2.6 May 15, 2014
reusables-0.2.0-py2.7.egg (32.1 kB) Copy SHA256 hash SHA256 Egg 2.7 May 15, 2014
reusables-0.2.0-py2-none-any.whl (15.7 kB) Copy SHA256 hash SHA256 Wheel 2.7 May 15, 2014
reusables-0.2.0-py3.2.egg (32.5 kB) Copy SHA256 hash SHA256 Egg 3.2 May 15, 2014
reusables-0.2.0-py3.3.egg (33.4 kB) Copy SHA256 hash SHA256 Egg 3.3 May 15, 2014
reusables-0.2.0-py3.4.egg (33.2 kB) Copy SHA256 hash SHA256 Egg 3.4 May 15, 2014
reusables-0.2.0-py3-none-any.whl (15.7 kB) Copy SHA256 hash SHA256 Wheel 3.4 May 15, 2014
reusables-0.2.0.tar.gz (13.3 kB) Copy SHA256 hash SHA256 Source None May 15, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page