PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` babel.util
Package babel :: Module util

Module util

Various utility classes and functions.
Classes
  odict
Ordered dict implementation.
Functions
iterator
distinct(iterable)
Yield all items in an iterable collection that are distinct.
bool
pathmatch(pattern, filename)
Extended pathname pattern matching.
list
wraptext(text, width=70, initial_indent='', subsequent_indent='')
Simple wrapper around the textwrap.wrap function in the standard library.
 
relpath(path, start='.')
Return a relative version of a path
Variables
tzinfo UTC = <UTC>
tzinfo object for UTC (Universal Time).
tzinfo LOCALTZ = LocalTimezone()
tzinfo object for local time-zone.
Function Details

distinct(iterable)

 

Yield all items in an iterable collection that are distinct.

Unlike when using sets for a similar effect, the original ordering of the items in the collection is preserved by this function.

>>> print list(distinct([1, 2, 1, 3, 4, 4]))
[1, 2, 3, 4]
>>> print list(distinct('foobar'))
['f', 'o', 'b', 'a', 'r']
Parameters:
  • iterable - the iterable collection providing the data
Returns: iterator
the distinct items in the collection

pathmatch(pattern, filename)

 

Extended pathname pattern matching.

This function is similar to what is provided by the fnmatch module in the Python standard library, but:

  • can match complete (relative or absolute) path names, and not just file names, and
  • also supports a convenience pattern ("**") to match files at any directory level.

Examples:

>>> pathmatch('**.py', 'bar.py')
True
>>> pathmatch('**.py', 'foo/bar/baz.py')
True
>>> pathmatch('**.py', 'templates/index.html')
False
>>> pathmatch('**/templates/*.html', 'templates/index.html')
True
>>> pathmatch('**/templates/*.html', 'templates/foo/bar.html')
False
Parameters:
  • pattern - the glob pattern
  • filename - the path name of the file to match against
Returns: bool
True if the path name matches the pattern, False otherwise

wraptext(text, width=70, initial_indent='', subsequent_indent='')

 
Simple wrapper around the textwrap.wrap function in the standard library. This version does not wrap lines on hyphens in words.
Parameters:
  • text - the text to wrap
  • width - the maximum line width
  • initial_indent - string that will be prepended to the first line of wrapped output
  • subsequent_indent - string that will be prepended to all lines save the first of wrapped output
Returns: list
a list of lines