This module contains some functions which may be useful.
Bases: object
New in version 1.1.
A file-like object that wraps an already opened and seeked file.
This file-like can be read by PIL and is used to open an image contained in another file.
Returns item next to value in the sequence seq
Example:
>>> next_in_seq("abcd", "b")
'c'
>>> next_in_seq(range(5), 2)
3
Returns next revision for revision. For example, if revision represents an int, it returns a string of the value + 1.
If it can not find a new revision, it returns “”
Example:
>>> get_next_revision("a")
'b'
>>> get_next_revision("r")
's'
>>> get_next_revision("z")
'aa'
>>> get_next_revision("A")
'B'
>>> get_next_revision("R")
'S'
>>> get_next_revision("Z")
'AA'
>>> get_next_revision("1")
'2'
>>> get_next_revision("41")
'42'
>>> get_next_revision("0041")
'0042'
>>> get_next_revision("a.b")
'a.c'
>>> get_next_revision("a-a")
'a-b'
>>> get_next_revision("a,a")
'a,b'
>>> get_next_revision("a.3")
'a.4'
>>> get_next_revision("a.b.1")
'a.b.2'
>>> get_next_revision("plop")
''
>>> get_next_revision("a.plop")
''
>>> get_next_revision("")
''
Convert value from from_ unit to to unit.
Example:
>>> "%.3f" % convert(10, "cm", "mm")
'100.000'
>>> "%.3f" % convert(10, "mm", "cm")
'1.000'
>>> "%.3f" % convert(10, "in", "cm")
'25.400'
>>> "%.3f" % convert(72, "pt", "in")
'1.000'
>>> "%.3f" % convert(72, "pc", "in")
'12.000'
Converts length to a length in mm, formatted as %.1f
Example
>>> normalize_length("29.7cm")
'297.0'
>>> normalize_length("21.00001cm")
'210.0'
>>> normalize_length("7.5in")
'190.5'
Converts a size to a page format
Example:
>>> size_to_format("29.7cm", "21cm")
'Other'
>>> size_to_format("21cm", "29.7cm")
'A4'
Converts a level (int, starting from 0) to a sign role
Example:
>>> level_to_sign_str(0)
'sign_1st_level'
>>> level_to_sign_str(1)
'sign_2nd_level'
>>> level_to_sign_str(2)
'sign_3rd_level'
>>> level_to_sign_str(3)
'sign_4th_level'
>>> level_to_sign_str(4)
'sign_5th_level'
>>> level_to_sign_str(10)
'sign_11th_level'
Decorator which memoize result of func. func must not take arguments
Generates a random password of length characters.
Returns True if openPLM can generate pdf files, i.e, pisa (xhtml2pdf) is installed.
New in version 1.1.
Returns the extension of filename (dot include).
It stripped all ”.{number}” extensions if they are present.
>>> get_ext("filename.png")
'.png'
>>> get_ext("filename.prt.2")
'.prt'
>>> get_ext("filename.prt")
'.prt'
>>> get_ext("filename.1")
'.1'
New in version 1.1.
Returns the pages to display for the pagination
New in version 1.2.
Returns a clean version of a filename that should be more suitable as a document name.
>>> filename_to_name("/tmp/hello.pdf")
'hello'
>>> filename_to_name(u"/tmp/Hello_world.pdf")
u'Hello world'
>>> filename_to_name(u"/tmp/heLLoWorlD.xyz")
u'heLLoWorlD'