pymills Package¶
pymills
Package¶
pymills
Mills Python Library
copyright: | CopyRight (C) 2004-2013 by James Mills |
---|---|
license: | MIT (See: LICENSE) |
datatypes
Module¶
Data Types Library
Various custom data types not available in the standard python library.
-
class
pymills.datatypes.
OrderedDict
(d={})¶ Bases:
dict
-
clear
()¶
-
items
()¶
-
keys
()¶
-
popitem
()¶
-
setdefault
(key, failobj=None)¶
-
update
(d)¶
-
iteritems
()¶
-
itervalues
()¶
-
values
()¶
-
iterkeys
()¶
-
index
(key)¶
-
-
class
pymills.datatypes.
Queue
(size=None)¶ Bases:
object
-
push
(item)¶
-
get
(n=0, remove=False)¶
-
pop
(n=0)¶
-
peek
(n=0)¶
-
top
()¶
-
bottom
()¶
-
empty
()¶
-
size
()¶
-
full
()¶
-
-
class
pymills.datatypes.
Null
¶ Bases:
object
dbapi
Module¶
DB-API Wrapper Classes
...
-
pymills.dbapi.
mysql_session
(*args, **kwargs)¶
-
pymills.dbapi.
oracle_session
(*args, **kwargs)¶
-
pymills.dbapi.
sqlite_session
(*args, **kwargs)¶
-
pymills.dbapi.
create_connection
(type, *args, **kwargs)¶
-
pymills.dbapi.
Connection
(type, *args, **kwargs)¶
-
exception
pymills.dbapi.
DriverError
(driver, msg)¶ Bases:
exceptions.Exception
-
exception
pymills.dbapi.
ConnectionError
(driver, e)¶ Bases:
exceptions.Exception
-
exception
pymills.dbapi.
DatabaseError
(sql, e)¶ Bases:
exceptions.Exception
-
class
pymills.dbapi.
BaseSession
(cx)¶ Bases:
object
initializes x; see x.__class__.__doc__ for signature
-
cursor
(create=False)¶
-
close
()¶
-
rollback
()¶
-
commit
()¶
-
execute
(sql=None, *args, **kwargs)¶
-
do
(sql=None, *args, **kwargs)¶
-
-
class
pymills.dbapi.
SQLiteSession
(cx)¶ Bases:
pymills.dbapi.BaseSession
initializes x; see x.__class__.__doc__ for signature
-
class
pymills.dbapi.
MySQLSession
(cx)¶ Bases:
pymills.dbapi.BaseSession
initializes x; see x.__class__.__doc__ for signature
-
class
pymills.dbapi.
OracleSession
(*args, **kwargs)¶ Bases:
pymills.dbapi.BaseSession
-
ORACLE_ARRAYSIZE
= 2048¶
-
-
class
pymills.dbapi.
Records
(session, cursor)¶ Bases:
object
initializes x; see x.__class__.__doc__ for signature
-
next
() → the next value, or raise StopIteration¶
-
-
class
pymills.dbapi.
Record
(data=(), **kwds)¶ 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.
emailtools
Module¶
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.
-
class
pymills.emailtools.
Email
(sender, recipients, subject='', cc=[], bcc=[])¶ Bases:
object
-
add
(text='', file=None, attach=False, filename=None)¶
-
send
()¶
-
-
pymills.emailtools.
sendEmail
(sender, recipient, subject, message) → None¶ Send a simple email to the given recipient with the given subject and message.
-
pymills.emailtools.
get_mimetype
(filename)¶
-
pymills.emailtools.
mimify_file
(filename)¶
-
pymills.emailtools.
send_email
(to, subject, text, **params)¶
mathtools
Module¶
Math Tools
Module of small useful math tools aka common math routines.
-
pymills.mathtools.
mean
(xs)¶ Calculate the mean of a list of numbers given by xs
-
pymills.mathtools.
std
(xs)¶ Calculate the standard deviation of a list of numbers give by xs
misc
Module¶
Miscellaneous
Various miscellaneous functions that don’t fit Use as documented.
-
pymills.misc.
hmsToSeconds
(h=0, m=0, s=0) → int¶ 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
-
pymills.misc.
getTotalTime
(s, e)¶
-
pymills.misc.
addPercent
(value, percentage)¶
-
pymills.misc.
subPercent
(value, percentage)¶
-
pymills.misc.
bytes
(bytes)¶
-
pymills.misc.
duration
(seconds)¶
-
pymills.misc.
backMerge
(l, n, t=' ')¶ Merge the last n items in list l joining with tokens t
l - list n - merge last n items from l t - token (default: ” ”)
-
pymills.misc.
strToBool
(s)¶
-
pymills.misc.
beat
()¶
-
pymills.misc.
buildAverage
(stime, x)¶
pyodict
Module¶
-
class
pymills.pyodict.
odict
(data=(), **kwds)¶ 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
Module¶
Table generation, display and manipulation module.
Classes to generate ASCII and HTML tables and traverse data.
-
class
pymills.table.
Header
(name, table=None, **kwargs)¶ 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:
- type - the data type. Must be compatible with type(x)
- align - text alignment. one of “left”, “center”, or “right”
- hidden - whether this column of data and header is displayed.
- format - format str or callable used to format cells
- width - width to use when formatting strings by __str__ (used by align)
- cls - class attribute used by toHTML
- style - style attribute used by toHTML
- ccls - cell class attribute to use for each cell used by toHTML
- cstyle - cell style attribute to use for each cell used by toHTML
Example:
>>> h = Header("Test") >>> print h Test >>> print h.toHTML() <th>Test</th> >>>
initializes x; see x.__class__.__doc__ for signature
-
refresh
()¶
-
getWidth
()¶
-
toHTML
()¶
-
class
pymills.table.
Row
(cells, table=None, **kwargs)¶ 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:
- hidden - whether this row is displayed.
- cls - class attribute used by toHTML
- style - style attribute used by toHTML
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
-
refresh
()¶
-
toHTML
()¶
-
class
pymills.table.
Cell
(value, **kwargs)¶ 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:
- type - the data type. Must be compatible with type(x)
- align - text alignment. one of “left”, “center”, or “right”
- hidden - whether this cell is displayed
- format - format str or callable
- cls - class attribute used by toHTML
- style - style attribute used by toHTML
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
-
refresh
()¶
-
toHTML
()¶
-
getHeader
()¶
-
class
pymills.table.
Table
(headers, rows=[], **kwargs)¶ 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:
- cls - class attribute used by toHTML
- style - style attribute used by toHTML
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
-
append
(row)¶
-
refresh
()¶
-
toHTML
()¶
-
getXY
(x, y)¶
-
pymills.table.
test
()¶
utils
Module¶
Utilities
Various utility classes and functions.
-
exception
pymills.utils.
Error
¶ Bases:
exceptions.Exception
Error Exception
-
class
pymills.utils.
State
¶ 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
(s) → None¶ Set the current state to the specified state given by s, adding it if it doesn’t exist.
-
-
pymills.utils.
getFiles
(root, pattern=".*", tests=[isfile], **kwargs) → list of files¶ 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:
- full=True (Return full paths)
- recursive=True (Recursive mode)
-
pymills.utils.
isReadable
(file) → bool¶ Return True if the specified file is readable, False otherwise.
-
pymills.utils.
mkpasswd
(length=8, digits=2, upper=2, lower=2)¶ Create a random password
Create a random password with the specified length and no. of digit, upper and lower case letters.
Parameters: - length (int) – Maximum no. of characters in the password
- digits (int) – Minimum no. of digits in the password
- upper (int) – Minimum no. of upper case letters in the password
- lower (int) – Minimum no. of lower case letters in the password
Returns: A random password with the above constaints
Return type: str
-
pymills.utils.
validateEmail
(email) → bool¶ Return True if the specified email is valid, False otehrwise.
-
pymills.utils.
safe__import__
(moduleName, globals={'getFiles': <function getFiles at 0x7f39506eaf50>, 'chain': <type 'itertools.chain'>, 'resident': <function resident at 0x7f39504b1398>, 'Cache': <class 'pymills.utils.Cache'>, 'sample': <bound method Random.sample of <random.Random object at 0x2946280>>, 'State': <class 'pymills.utils.State'>, 'seed': <bound method Random.seed of <random.Random object at 0x2946280>>, 'minmax': <function minmax at 0x7f39504b1668>, 'isfile': <function isfile at 0x7f39557ee0c8>, 'safe__import__': <function safe__import__ at 0x7f39505257d0>, '__package__': 'pymills', 're': <module 're' from '/home/docs/checkouts/readthedocs.org/user_builds/pymills/envs/latest/lib/python2.7/re.pyc'>, 'memory': <function memory at 0x7f39504b1050>, 'stacksize': <function stacksize at 0x7f39504b1410>, '__doc__': 'Utilities\n\nVarious utility classes and functions.\n', 'printdict': <function printdict at 0x7f39504b1500>, 'string': <module 'string' from '/usr/lib/python2.7/string.pyc'>, '__builtins__': {'bytearray': <type 'bytearray'>, 'IndexError': <type 'exceptions.IndexError'>, 'all': <built-in function all>, 'help': Type help() for interactive help, or help(object) for help about object., 'vars': <built-in function vars>, 'SyntaxError': <type 'exceptions.SyntaxError'>, 'unicode': <type 'unicode'>, 'UnicodeDecodeError': <type 'exceptions.UnicodeDecodeError'>, 'memoryview': <type 'memoryview'>, 'isinstance': <built-in function isinstance>, 'copyright': Copyright (c) 2001-2014 Python Software Foundation. All Rights Reserved. Copyright (c) 2000 BeOpen.com. All Rights Reserved. Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved., 'NameError': <type 'exceptions.NameError'>, 'BytesWarning': <type 'exceptions.BytesWarning'>, 'dict': <type 'dict'>, 'input': <built-in function input>, 'oct': <built-in function oct>, 'bin': <built-in function bin>, 'SystemExit': <type 'exceptions.SystemExit'>, 'StandardError': <type 'exceptions.StandardError'>, 'format': <built-in function format>, 'repr': <built-in function repr>, 'sorted': <built-in function sorted>, 'False': False, 'RuntimeWarning': <type 'exceptions.RuntimeWarning'>, 'list': <type 'list'>, 'iter': <built-in function iter>, 'reload': <built-in function reload>, 'Warning': <type 'exceptions.Warning'>, '__package__': None, 'round': <built-in function round>, 'dir': <built-in function dir>, 'cmp': <built-in function cmp>, 'set': <type 'set'>, 'bytes': <type 'str'>, 'reduce': <built-in function reduce>, 'intern': <built-in function intern>, 'issubclass': <built-in function issubclass>, 'Ellipsis': Ellipsis, 'EOFError': <type 'exceptions.EOFError'>, 'locals': <built-in function locals>, 'BufferError': <type 'exceptions.BufferError'>, 'slice': <type 'slice'>, 'FloatingPointError': <type 'exceptions.FloatingPointError'>, 'sum': <built-in function sum>, 'getattr': <built-in function getattr>, 'abs': <built-in function abs>, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'print': <built-in function print>, 'True': True, 'FutureWarning': <type 'exceptions.FutureWarning'>, 'ImportWarning': <type 'exceptions.ImportWarning'>, 'None': None, 'hash': <built-in function hash>, 'ReferenceError': <type 'exceptions.ReferenceError'>, 'len': <built-in function len>, 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information., 'frozenset': <type 'frozenset'>, '__name__': '__builtin__', 'ord': <built-in function ord>, 'super': <type 'super'>, 'TypeError': <type 'exceptions.TypeError'>, 'license': See http://www.python.org/2.7/license.html, 'KeyboardInterrupt': <type 'exceptions.KeyboardInterrupt'>, 'UserWarning': <type 'exceptions.UserWarning'>, 'filter': <built-in function filter>, 'range': <built-in function range>, 'staticmethod': <type 'staticmethod'>, 'SystemError': <type 'exceptions.SystemError'>, 'BaseException': <type 'exceptions.BaseException'>, 'pow': <built-in function pow>, 'RuntimeError': <type 'exceptions.RuntimeError'>, 'float': <type 'float'>, 'MemoryError': <type 'exceptions.MemoryError'>, 'StopIteration': <type 'exceptions.StopIteration'>, 'globals': <built-in function globals>, 'divmod': <built-in function divmod>, 'enumerate': <type 'enumerate'>, 'apply': <built-in function apply>, 'LookupError': <type 'exceptions.LookupError'>, 'open': <built-in function open>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'basestring': <type 'basestring'>, 'UnicodeError': <type 'exceptions.UnicodeError'>, 'zip': <built-in function zip>, 'hex': <built-in function hex>, 'long': <type 'long'>, 'next': <built-in function next>, 'ImportError': <type 'exceptions.ImportError'>, 'chr': <built-in function chr>, 'xrange': <type 'xrange'>, 'type': <type 'type'>, '__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.", 'Exception': <type 'exceptions.Exception'>, 'tuple': <type 'tuple'>, 'UnicodeTranslateError': <type 'exceptions.UnicodeTranslateError'>, 'reversed': <type 'reversed'>, 'UnicodeEncodeError': <type 'exceptions.UnicodeEncodeError'>, 'IOError': <type 'exceptions.IOError'>, 'hasattr': <built-in function hasattr>, 'delattr': <built-in function delattr>, 'setattr': <built-in function setattr>, 'raw_input': <built-in function raw_input>, 'SyntaxWarning': <type 'exceptions.SyntaxWarning'>, 'compile': <built-in function compile>, 'ArithmeticError': <type 'exceptions.ArithmeticError'>, 'str': <type 'str'>, 'property': <type 'property'>, 'GeneratorExit': <type 'exceptions.GeneratorExit'>, 'int': <type 'int'>, '__import__': <built-in function __import__>, 'KeyError': <type 'exceptions.KeyError'>, 'coerce': <built-in function coerce>, 'PendingDeprecationWarning': <type 'exceptions.PendingDeprecationWarning'>, 'file': <type 'file'>, 'EnvironmentError': <type 'exceptions.EnvironmentError'>, 'unichr': <built-in function unichr>, 'id': <built-in function id>, 'OSError': <type 'exceptions.OSError'>, 'DeprecationWarning': <type 'exceptions.DeprecationWarning'>, 'min': <built-in function min>, 'UnicodeWarning': <type 'exceptions.UnicodeWarning'>, 'execfile': <built-in function execfile>, 'any': <built-in function any>, 'complex': <type 'complex'>, 'bool': <type 'bool'>, 'ValueError': <type 'exceptions.ValueError'>, 'NotImplemented': NotImplemented, 'map': <built-in function map>, 'buffer': <type 'buffer'>, 'max': <built-in function max>, 'object': <type 'object'>, 'TabError': <type 'exceptions.TabError'>, 'callable': <built-in function callable>, 'ZeroDivisionError': <type 'exceptions.ZeroDivisionError'>, 'eval': <built-in function eval>, '__debug__': True, 'IndentationError': <type 'exceptions.IndentationError'>, 'AssertionError': <type 'exceptions.AssertionError'>, 'classmethod': <type 'classmethod'>, 'UnboundLocalError': <type 'exceptions.UnboundLocalError'>, 'NotImplementedError': <type 'exceptions.NotImplementedError'>, 'AttributeError': <type 'exceptions.AttributeError'>, 'OverflowError': <type 'exceptions.OverflowError'>}, '__file__': '/home/docs/checkouts/readthedocs.org/user_builds/pymills/checkouts/latest/pymills/utils.py', 'choice': <bound method Random.choice of <random.Random object at 0x2946280>>, 'sys': <module 'sys' (built-in)>, 'MemoryStats': <class 'pymills.utils.MemoryStats'>, 'MixIn': <function MixIn at 0x7f39504b1488>, 'Error': <class 'pymills.utils.Error'>, '__name__': 'pymills.utils', 'notags': <function notags at 0x7f3950525f50>, 'caller': <function caller at 0x7f39504b16e0>, 'mkpasswd': <function mkpasswd at 0x7f3950525c08>, 'isReadable': <function isReadable at 0x7f3950525050>, 'time': <built-in function time>, 'validateEmail': <function validateEmail at 0x7f3950525cf8>, 'os': <module 'os' from '/home/docs/checkouts/readthedocs.org/user_builds/pymills/envs/latest/lib/python2.7/os.pyc'>}, locals={'getFiles': <function getFiles at 0x7f39506eaf50>, 'chain': <type 'itertools.chain'>, 'resident': <function resident at 0x7f39504b1398>, 'Cache': <class 'pymills.utils.Cache'>, 'sample': <bound method Random.sample of <random.Random object at 0x2946280>>, 'State': <class 'pymills.utils.State'>, 'seed': <bound method Random.seed of <random.Random object at 0x2946280>>, 'minmax': <function minmax at 0x7f39504b1668>, 'isfile': <function isfile at 0x7f39557ee0c8>, 'safe__import__': <function safe__import__ at 0x7f39505257d0>, '__package__': 'pymills', 're': <module 're' from '/home/docs/checkouts/readthedocs.org/user_builds/pymills/envs/latest/lib/python2.7/re.pyc'>, 'memory': <function memory at 0x7f39504b1050>, 'stacksize': <function stacksize at 0x7f39504b1410>, '__doc__': 'Utilities\n\nVarious utility classes and functions.\n', 'printdict': <function printdict at 0x7f39504b1500>, 'string': <module 'string' from '/usr/lib/python2.7/string.pyc'>, '__builtins__': {'bytearray': <type 'bytearray'>, 'IndexError': <type 'exceptions.IndexError'>, 'all': <built-in function all>, 'help': Type help() for interactive help, or help(object) for help about object., 'vars': <built-in function vars>, 'SyntaxError': <type 'exceptions.SyntaxError'>, 'unicode': <type 'unicode'>, 'UnicodeDecodeError': <type 'exceptions.UnicodeDecodeError'>, 'memoryview': <type 'memoryview'>, 'isinstance': <built-in function isinstance>, 'copyright': Copyright (c) 2001-2014 Python Software Foundation. All Rights Reserved. Copyright (c) 2000 BeOpen.com. All Rights Reserved. Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved., 'NameError': <type 'exceptions.NameError'>, 'BytesWarning': <type 'exceptions.BytesWarning'>, 'dict': <type 'dict'>, 'input': <built-in function input>, 'oct': <built-in function oct>, 'bin': <built-in function bin>, 'SystemExit': <type 'exceptions.SystemExit'>, 'StandardError': <type 'exceptions.StandardError'>, 'format': <built-in function format>, 'repr': <built-in function repr>, 'sorted': <built-in function sorted>, 'False': False, 'RuntimeWarning': <type 'exceptions.RuntimeWarning'>, 'list': <type 'list'>, 'iter': <built-in function iter>, 'reload': <built-in function reload>, 'Warning': <type 'exceptions.Warning'>, '__package__': None, 'round': <built-in function round>, 'dir': <built-in function dir>, 'cmp': <built-in function cmp>, 'set': <type 'set'>, 'bytes': <type 'str'>, 'reduce': <built-in function reduce>, 'intern': <built-in function intern>, 'issubclass': <built-in function issubclass>, 'Ellipsis': Ellipsis, 'EOFError': <type 'exceptions.EOFError'>, 'locals': <built-in function locals>, 'BufferError': <type 'exceptions.BufferError'>, 'slice': <type 'slice'>, 'FloatingPointError': <type 'exceptions.FloatingPointError'>, 'sum': <built-in function sum>, 'getattr': <built-in function getattr>, 'abs': <built-in function abs>, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'print': <built-in function print>, 'True': True, 'FutureWarning': <type 'exceptions.FutureWarning'>, 'ImportWarning': <type 'exceptions.ImportWarning'>, 'None': None, 'hash': <built-in function hash>, 'ReferenceError': <type 'exceptions.ReferenceError'>, 'len': <built-in function len>, 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information., 'frozenset': <type 'frozenset'>, '__name__': '__builtin__', 'ord': <built-in function ord>, 'super': <type 'super'>, 'TypeError': <type 'exceptions.TypeError'>, 'license': See http://www.python.org/2.7/license.html, 'KeyboardInterrupt': <type 'exceptions.KeyboardInterrupt'>, 'UserWarning': <type 'exceptions.UserWarning'>, 'filter': <built-in function filter>, 'range': <built-in function range>, 'staticmethod': <type 'staticmethod'>, 'SystemError': <type 'exceptions.SystemError'>, 'BaseException': <type 'exceptions.BaseException'>, 'pow': <built-in function pow>, 'RuntimeError': <type 'exceptions.RuntimeError'>, 'float': <type 'float'>, 'MemoryError': <type 'exceptions.MemoryError'>, 'StopIteration': <type 'exceptions.StopIteration'>, 'globals': <built-in function globals>, 'divmod': <built-in function divmod>, 'enumerate': <type 'enumerate'>, 'apply': <built-in function apply>, 'LookupError': <type 'exceptions.LookupError'>, 'open': <built-in function open>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'basestring': <type 'basestring'>, 'UnicodeError': <type 'exceptions.UnicodeError'>, 'zip': <built-in function zip>, 'hex': <built-in function hex>, 'long': <type 'long'>, 'next': <built-in function next>, 'ImportError': <type 'exceptions.ImportError'>, 'chr': <built-in function chr>, 'xrange': <type 'xrange'>, 'type': <type 'type'>, '__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.", 'Exception': <type 'exceptions.Exception'>, 'tuple': <type 'tuple'>, 'UnicodeTranslateError': <type 'exceptions.UnicodeTranslateError'>, 'reversed': <type 'reversed'>, 'UnicodeEncodeError': <type 'exceptions.UnicodeEncodeError'>, 'IOError': <type 'exceptions.IOError'>, 'hasattr': <built-in function hasattr>, 'delattr': <built-in function delattr>, 'setattr': <built-in function setattr>, 'raw_input': <built-in function raw_input>, 'SyntaxWarning': <type 'exceptions.SyntaxWarning'>, 'compile': <built-in function compile>, 'ArithmeticError': <type 'exceptions.ArithmeticError'>, 'str': <type 'str'>, 'property': <type 'property'>, 'GeneratorExit': <type 'exceptions.GeneratorExit'>, 'int': <type 'int'>, '__import__': <built-in function __import__>, 'KeyError': <type 'exceptions.KeyError'>, 'coerce': <built-in function coerce>, 'PendingDeprecationWarning': <type 'exceptions.PendingDeprecationWarning'>, 'file': <type 'file'>, 'EnvironmentError': <type 'exceptions.EnvironmentError'>, 'unichr': <built-in function unichr>, 'id': <built-in function id>, 'OSError': <type 'exceptions.OSError'>, 'DeprecationWarning': <type 'exceptions.DeprecationWarning'>, 'min': <built-in function min>, 'UnicodeWarning': <type 'exceptions.UnicodeWarning'>, 'execfile': <built-in function execfile>, 'any': <built-in function any>, 'complex': <type 'complex'>, 'bool': <type 'bool'>, 'ValueError': <type 'exceptions.ValueError'>, 'NotImplemented': NotImplemented, 'map': <built-in function map>, 'buffer': <type 'buffer'>, 'max': <built-in function max>, 'object': <type 'object'>, 'TabError': <type 'exceptions.TabError'>, 'callable': <built-in function callable>, 'ZeroDivisionError': <type 'exceptions.ZeroDivisionError'>, 'eval': <built-in function eval>, '__debug__': True, 'IndentationError': <type 'exceptions.IndentationError'>, 'AssertionError': <type 'exceptions.AssertionError'>, 'classmethod': <type 'classmethod'>, 'UnboundLocalError': <type 'exceptions.UnboundLocalError'>, 'NotImplementedError': <type 'exceptions.NotImplementedError'>, 'AttributeError': <type 'exceptions.AttributeError'>, 'OverflowError': <type 'exceptions.OverflowError'>}, '__file__': '/home/docs/checkouts/readthedocs.org/user_builds/pymills/checkouts/latest/pymills/utils.py', 'choice': <bound method Random.choice of <random.Random object at 0x2946280>>, 'sys': <module 'sys' (built-in)>, 'MemoryStats': <class 'pymills.utils.MemoryStats'>, 'MixIn': <function MixIn at 0x7f39504b1488>, 'Error': <class 'pymills.utils.Error'>, '__name__': 'pymills.utils', 'notags': <function notags at 0x7f3950525f50>, 'caller': <function caller at 0x7f39504b16e0>, 'mkpasswd': <function mkpasswd at 0x7f3950525c08>, 'isReadable': <function isReadable at 0x7f3950525050>, 'time': <built-in function time>, 'validateEmail': <function validateEmail at 0x7f3950525cf8>, 'os': <module 'os' from '/home/docs/checkouts/readthedocs.org/user_builds/pymills/envs/latest/lib/python2.7/os.pyc'>}, fromlist=[])¶ 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
-
class
pymills.utils.
MemoryStats
(pid=593)¶ Bases:
object
-
scale
= {'KB': 1024.0, 'MB': 1048576.0}¶
-
size
¶
-
rss
¶
-
stack
¶
-
-
pymills.utils.
memory
(since=0.0)¶ Return memory usage in bytes.
-
pymills.utils.
resident
(since=0.0)¶ Return resident memory usage in bytes.
-
pymills.utils.
stacksize
(since=0.0)¶ Return stack size in bytes.
-
pymills.utils.
MixIn
(cls, mixin, last=False)¶
-
class
pymills.utils.
Cache
(f)¶ Bases:
object
-
pymills.utils.
printdict
(d, level=0) → None¶ 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.
-
pymills.utils.
minmax
(iter) -> (min, max)¶ Consume the interable iter and calculate and return the min and max of each item.
-
pymills.utils.
caller
(n=1) → str¶ Return the name of the calling function. If n is specified, return the n’th function in the stack.