Skip to main content

A collection of handy modules, almost guaranteed to get you into trouble.

Project description

dhp is a library of snippets almost guaranteed to get you into trouble.

I obtained it from a vendor, on the corner, outside of PyCon.

Actually, this is a growing repository of routines that I find helpful from time to time. I think you might too.

Example Phrasebook Contents

See the Full Documentation for a complete listing.

dhp.doq

  • DOQ Data Object Query mapper. Query simple data sources with an ORM like style.

from dhp.doq import DOQ

doq = DOQ(data_objects=data_source)
for rec in doq.filter(occupation='Publisher'):
  print(rec)

dhp.structures

  • DictDot - subclasses Python’s built-in dict object and offers attribute access to the dictionary.

from dhp.structures import DictDot

my_dict = {'hovercraft': 'eels', 'speed': 42}
dicdot = DictDot(my_dict)
assert dicdot.hovercraft == 'eels'
assert dicdot.speed == 42

dhp.test

  • tempfile_containing - generate a temporary file that contains indicated contents and returns the filename for use. When finished the tempfile is removed.

from dhp.test import tempfile_containing

contents = 'I will not buy this record, it is scratched.'
with tempfile_containing(contents) as fname:
    do_something(fname)

dhp.xml

  • xml_to_dict - parse any ugly xml to a python dictionary.

from dhp.xml import xml_to_dict

xml = '<vehicle type="Hovercraft"><filled/><cargo>eels</cargo></vehicle>'
xml_to_dict(xml)

{'vehicle': {'@type':'Hovercraft',
             'cargo':'eels',
             'filled': None}
}

Supports

Tested on Python 2.7, 3.2, 3.3, 3.4

Build Status Documentation Status

Requirements

None.

Installation

Make sure to get the latest version.

pip install dhp

Documentation

Full Docs

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

dhp-0.0.14.tar.gz (14.9 kB view details)

Uploaded Source

File details

Details for the file dhp-0.0.14.tar.gz.

File metadata

  • Download URL: dhp-0.0.14.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dhp-0.0.14.tar.gz
Algorithm Hash digest
SHA256 c01dd4253981df615ce9f5816a26d8fa2d6e120370674f7463e8573956a054af
MD5 657aa3f18a75c8c9a39d803c1f5abca1
BLAKE2b-256 1a86d61a7f60bee3348bc67bd5531e2103135993ca770239dff85d5848d25c14

See more details on using hashes here.

Supported by

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