Package rrlog :: Module tool
[hide private]
[frames] | no frames]

Module tool

source code


Author: Ruben Reifenberg

Classes [hide private]
  ListRotator
Iteriert durch eine gegebene Liste, beginnend mit erstem Element.
  StrIndenter
Erzeugt einen String, dessen Laenge von der Stacktiefe abhaengt.
Functions [hide private]
int
_cutcount(l, max)
How many elements to cut away from something with len l, when we want restlen+len(decimal-digit-of-cut-count) < max?
source code
ASCII str or None
lu2a(unistr, max=50, errorstr='~~~')
Limited Unicode To Ascii (limited: the result length is limited) Intended for ASCII-logging of untrusted (e.g.user input) unicode strings.
source code
 
lu2a_de(unistr, max=50, errorstr='~~~')
Note: In case of unistr containing non-ascii characters, this method gets slow (because it does a python loop over each character.)
source code
 
mStrftime(dt, formatStr)
Returns: str, made by dt.strftime
source code
 
traceToShortStr(maxLines=3, exc_info=None, use_cr=True)
Returns: short str describing the current ex.stacktrace (end-first), "" if there is no current ex.traceback.
source code
 
mail_smtp(server, serverpw, to_address, from_address, subject, content, charset='latin-1')
Sendet subject/content als latin-1.
source code
Function Details [hide private]

_cutcount(l, max)

source code 

How many elements to cut away from something with len l, when we want restlen+len(decimal-digit-of-cut-count) < max?

Returns: int
count of chars to cut away (cutcount) (can be > l when max is too low)

lu2a(unistr, max=50, errorstr='~~~')

source code 

Limited Unicode To Ascii (limited: the result length is limited) Intended for ASCII-logging of untrusted (e.g.user input) unicode strings. The length limitation is intended for storage in length-limited ASCII Database fields.

Parameters:
  • unistr - Python Unicode or None
  • max - >=3, length limit of the RESULT STRING (default 50)
  • errorstr - Returned in case max is too low to return the regular result.
Returns: ASCII str or None
The argument but with: All non-ascii chars replaced by "\xhexvalue". If N chars (of the result string) are thrown away, "[N+]" is appened at the end.

lu2a_de(unistr, max=50, errorstr='~~~')

source code 

Note: In case of unistr containing non-ascii characters, this method gets slow (because it does a python loop over each character.)

See Also: lu2a Additionally, the german umlauts are replaced by AE,OE... to make it more readable (by the drawback of information loss, of course.)

mStrftime(dt, formatStr)

source code 
Parameters:
  • dt - datetime.datetime
  • formatStr - strftime format string for dt with an extension: %3N is milliseconds
Returns:
str, made by dt.strftime

traceToShortStr(maxLines=3, exc_info=None, use_cr=True)

source code 
Parameters:
  • exc_info - as given by sys.exc_info(). If None, it is obtained by calling sys.exc_info
  • use_cr - If True, "\n" is used between the path lines. Otherwise, "<" will separate the lines.
Returns:
short str describing the current ex.stacktrace (end-first), "" if there is no current ex.traceback.

mail_smtp(server, serverpw, to_address, from_address, subject, content, charset='latin-1')

source code 

Sendet subject/content als latin-1. String-Parameter; subject/content may be unicode or str.

Parameters:
  • server - e.g.."mail.gmx.net"
  • serverpw - SMTP server password
Returns:
None