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

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.transforms

  • to_snake - transform “camelCase” to python-esque, “camel_case”

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

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.8.tar.gz (5.3 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for dhp-0.0.8.tar.gz
Algorithm Hash digest
SHA256 4f339473dcc04ad9272bb617603ee16adbe2ae98c8b737fa0a3b079d6ce12fa5
MD5 9859d7e0f4832d2ed3e8e8b308e45d71
BLAKE2b-256 8177569f2a65fe560440c0145769c735b778e5a7011af5c1642524c639f0d780

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