pymills
Mills Python Library
copyright: | CopyRight (C) 2004-2013 by James Mills |
---|---|
license: | MIT (See: LICENSE) |
Data Types Library
Various custom data types not available in the standard python library.
Bases: dict
Bases: object
Bases: object
DB-API Wrapper Classes
...
Bases: exceptions.Exception
Bases: exceptions.Exception
Bases: exceptions.Exception
Bases: object
initializes x; see x.__class__.__doc__ for signature
Bases: pymills.dbapi.BaseSession
initializes x; see x.__class__.__doc__ for signature
Bases: pymills.dbapi.BaseSession
initializes x; see x.__class__.__doc__ for signature
Bases: pymills.dbapi.BaseSession
Bases: object
initializes x; see x.__class__.__doc__ for signature
Bases: pymills.pyodict.odict
This doesn’t accept keyword initialization as normal dicts to avoid a trap - inside a function or method the keyword args are accessible only as a dict, without a defined order, so their original order is lost.
Email Tools
A feature-rich Email class allowing you to create and send multi-part emails as well as a simple sendEmail function for simpler plain text emails.
Bases: object
Send a simple email to the given recipient with the given subject and message.
Math Tools
Module of small useful math tools aka common math routines.
Calculate the mean of a list of numbers given by xs
Calculate the standard deviation of a list of numbers give by xs
Miscellaneous
Various miscellaneous functions that don’t fit Use as documented.
Calculates the number of seconds, given hours (h), minutes (m) and seconds (s=0).
Example:
>>> hmsToSeconds(1)
3600
>>> hmsToSeconds(1, 24)
5040
>>> hmsToSeconds(1, 24, 54)
5094
Merge the last n items in list l joining with tokens t
l - list n - merge last n items from l t - token (default: ” ”)
Bases: pymills.pyodict._odict, dict
This doesn’t accept keyword initialization as normal dicts to avoid a trap - inside a function or method the keyword args are accessible only as a dict, without a defined order, so their original order is lost.
Table generation, display and manipulation module.
Classes to generate ASCII and HTML tables and traverse data.
Bases: object
Create a new Header
Container class that holds the definition of a table header and how each piece of data should be formatted and displayed.
An Optional list of kwargs can also be supplied that affect how this header is created:
Example:
>>> h = Header("Test")
>>> print h
Test
>>> print h.toHTML()
<th>Test</th>
>>>
initializes x; see x.__class__.__doc__ for signature
Bases: list
Create a new Row
Container class that holds the definition of a table row and a set of cells and how each cell should be formatted and displayed.
An Optional list of kwargs can also be supplied that affect how this row is created:
Example:
>>> c = Cell(22.0/7.0, format="%0.2f", align="right", cls="foo", style="hidden: true")
>>> r = Row([c], cls="asdf", style="qwerty")
>>> print r
3.14
>>> print r.toHTML()
<tr class="asdf" style="qwerty"><td align="right" class="foo" style="hidden: true">3.14</td></td>
>>>
initializes x; see x.__class__.__doc__ for signature
Bases: object
Create a new Cell
Container class that holds the definition of a table cell and it’s value and how it should be formatted and displayed.
An Optional list of kwargs can also be supplied that affect how this header is created:
Example:
>>> c = Cell(22.0/7.0, format="%0.2f", align="right", cls="foo", style="hidden: true")
>>> print c
3.14
>>> print c.toHTML()
<td align="right" class="foo" style="hidden: true">3.14</td>
>>>
initializes x; see x.__class__.__doc__ for signature
Bases: list
Create a new Table
Container class to hold a set of rows and headers allowing easy traversal and display.
An Optional list of kwargs can also be supplied that affect how this table is created:
Example:
>>> c = Cell(22.0/7.0, format="%0.2f", align="right", cls="foo", style="hidden: true")
>>> r = Row([c], cls="asdf", style="qwerty")
>>> h = Header("Test")
>>> t = Table([h], [r])
>>> print t
Test
----
3.14
----
>>> print t.toHTML()
<table><th>Test</th><tr class="asdf" style="qwerty"><td align="right" class="foo" style="hidden: true">3.14</td></td></table>
>>>
initializes x; see x.__class__.__doc__ for signature
Utilities
Various utility classes and functions.
Bases: exceptions.Exception
Error Exception
Bases: object
Create new State object
Creates a new state object that is suitable for holding different states of an application. Usefull in state-machines.
The way this works is rather simple. You create a new state object, and simply set the state. If the state doesn’t exist, it’s added to it’s internal data structure. The reason this is done is so that comparing states is consistent, and you can’t just compare with a non-existent state.
initializes x; see x.__class__.__doc__ for signature
Set the current state to the specified state given by s, adding it if it doesn’t exist.
Return a list of files in the specified path (root) applying the predicates listed in tests returning only the files that match the pattern. Some optional kwargs can be specified:
Return True if the specified file is readable, False otherwise.
Create a random password
Create a random password with the specified length and no. of digit, upper and lower case letters.
Parameters: |
|
---|---|
Returns: | A random password with the above constaints |
Return type: | str |
Return True if the specified email is valid, False otehrwise.
Safe imports: rollback after a failed import.
Initially inspired from the RollbackImporter in PyUnit, but it’s now much simpler and works better for our needs.
Removes HTML tags from str and returns the new string
Bases: object
Return memory usage in bytes.
Return resident memory usage in bytes.
Return stack size in bytes.
Bases: object
Print the given dictionary, d. Recursively print any nested dictionaries found. This function is _NOT_ a pretty printer, and prints a human-readable form of the given dictionary rather than something that can be re-read by Python.
Consume the interable iter and calculate and return the min and max of each item.
Return the name of the calling function. If n is specified, return the n’th function in the stack.