Home | Trees | Index | Help |
|
---|
Module vopu |
|
VoPU -- Volker's Python Utilities.
This module contains various functions and classes which are very useful for my daily work with Python.
Version:
1.9
Author:
Volker Grabsch <vog@notjusthosting.com>
License:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Requires:
Python 2.4 or higher
Classes | |
---|---|
InitAttributes |
Base class for objects whose constructor initializes all attributes. |
OrderedByCreation |
Base class for objects which are ordered by their creation time. |
StringStream |
Stream which writes into a byte string. |
Function Summary | |
---|---|
Convert a unicode string into CamelCase. | |
Escape a unicode string for LaTeX. | |
Return an iterator that steps through the lines of obj. | |
Split a labeled URI into its URI and its label. | |
Stream wrapper which automatically encodes and decodes. | |
Run all doc tests of this module. |
Variable Summary | |
---|---|
dict |
_latex_special_chars = {u'`': u'{}`', u'#': u'\\#', u'"'...
|
Function Details |
---|
camelcase(ustr, maxlen=None)Convert a unicode string into CamelCase. >>> camelcase(u"Abc") u'Abc' >>> camelcase(u"abc") u'Abc' >>> camelcase(u"ABC") u'Abc' >>> camelcase(u"This is a text") u'ThisIsAText' >>> camelcase(u"This is a text", None) u'ThisIsAText' When maxlen is not None, each word is truncated to the length maxlen. >>> camelcase(u"This is a text", 4) u'ThisIsAText' >>> camelcase(u"This is a text", 3) u'ThiIsATex' >>> camelcase(u"This is a text", 2) u'ThIsATe' >>> camelcase(u"This is a text", 1) u'TIAT' >>> camelcase(u"This is a text", 0) u'' >>> camelcase(u"") u''
|
escape_latex(s)Escape a unicode string for LaTeX. >>> s = u'\\"{}_&%a$b#\nc"\\' >>> escape_latex(s) u"\\textbackslash{}{''}\\{\\}\\_\\&\\%a\\$b\\#\\\\c{''}\\textbackslash{}" >>> print s \"{}_&%a$b# c"\ >>> print escape_latex(s) \textbackslash{}{''}\{\}\_\&\%a\$b\#\\c{''}\textbackslash{}
|
readlines(obj, encoding=u'utf8')Return an iterator that steps through the lines of obj. Line endings are preserved. The iterator returns unicode objects. >>> obj = u"Line1\nLine2\nLine3" >>> for line in readlines(obj): ... print repr(line) u'Line1\n' u'Line2\n' u'Line3' >>> obj = u"Line1\nLine2\nLine3\n" >>> for line in readlines(obj): ... print repr(line) u'Line1\n' u'Line2\n' u'Line3\n' >>> obj = "Line1\nLine2\nLine3\n" >>> for line in readlines(obj): ... print repr(line) u'Line1\n' u'Line2\n' u'Line3\n' >>> import os >>> stream = os.tmpfile() >>> stream.write("Line1\nLine2\nLine3\n") >>> stream.seek(0) >>> for line in readlines(obj): ... print repr(line) u'Line1\n' u'Line2\n' u'Line3\n'
|
split_labeled_uri(labeleduri, default=u'')Split a labeled URI into its URI and its label. If the labeled URI doesn't contain a label, return the default label. >>> split_labeled_uri(u"http://www.google.com/ This is Google.") (u'http://www.google.com/', u'This is Google.') >>> split_labeled_uri(u"http://www.google.com/ \t surrounding spaces ") (u'http://www.google.com/', u'surrounding spaces') >>> split_labeled_uri(u"http://www.google.com/ given label", u"default label") (u'http://www.google.com/', u'given label') >>> split_labeled_uri(u"http://www.google.com/", u"default label") (u'http://www.google.com/', u'default label')
|
UnicodeStream(stream, encoding=u'utf8')Stream wrapper which automatically encodes and decodes. Simpler interface to the codecs package. Return a stream whose methods read(), write(), ... take and return only unicode objects. These are encoded to and decoded from the given stream using the given encoding. >>> import sys >>> ustream = UnicodeStream(sys.stdout) >>> ustream.write(u"abc") abc >>> import os >>> stream = os.tmpfile() >>> stream.write("abc") >>> stream.seek(0) >>> ustream = UnicodeStream(stream) >>> ustream.read() u'abc'
|
_test()Run all doc tests of this module. |
Variable Details |
---|
_latex_special_chars
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Sun Aug 31 15:41:30 2008 | http://epydoc.sf.net |