James Gardner: Home > Work > Code > StringConvert > 0.3.0 > API Documentation

StringConvert v0.3.0 documentation

API Documentation

exception stringconvert.StringConvertError
stringconvert.stringToUnicode(encoding='utf8', errors='strict')
Decodes the string using the codec registered for encoding. encoding defaults to utf8. errors may be given to set a different error handling scheme. The default is 'strict', meaning that encoding errors lead to the conversion failing. Other possible values are 'ignore', 'replace' and any other name registered via the codecs module register_error() function.
stringconvert.unicodeToBoolean(true_values=[, u'yes', u'1', u'on', u'true'], false_values=[, u'no', u'0', u'off', u'false'], strip=True)
stringconvert.unicodeToDate(format='%Y-%m-%d', strip=True)
stringconvert.unicodeToDatetime(format='%Y-%m-%d %H:%M', strip=True)
stringconvert.unicodeToFloat(min=None, max=None)
stringconvert.unicodeToInteger(min=None, max=None, msg_invalid=None)
stringconvert.unicodeToTime(format='%H:%M', strip=True)
stringconvert.unicodeToUnicode(min=None, max=None)

Email converter, desgined to be compatible with FormEncode

stringconvert.email.listOfEmails(split_name=False, extract_organisation=False)
stringconvert.email.parse_invite(invite, split_name=False, extract_organisation=False)
stringconvert.email.parse_name(name, i)
stringconvert.email.unicodeToEmail(resolve_domain=False, strip=True, msg_empty=u'Please enter an email address', msg_no_at=u'An email address must contain a @ character', msg_multiple_at=u'An email address must contain only one @ character', msg_bad_username=u'The username portion of the email address is invalid (the portion before the @: %(username)s)', msg_socket=u'Could not connect to the server for that email, please choose a valid email', msg_bad_domain=u'The domain portion of the email address is invalid (the portion after the @: %(domain)s)', msg_no_such_domain=u'The domain of the email address does not exist (the portion after the @: %(domain)s)')

Convert an email address.

If you pass resolve_domain=True, then it will try to resolve the domain name to make sure it’s valid. This takes longer though. You must have the PyDNS modules installed to look up DNS (MX and A) records.

On Debian-based systems you can install it like this:

$ sudo apt-get install python-dns

on others:

$ easy_install PyDNS
James Gardner: Home > Work > Code > StringConvert > 0.3.0 > API Documentation