Utility functions.
Unknown Field: copyright | |
Copyright 2006-2021 by the Pygments team, see AUTHORS. | |
Unknown Field: license | |
BSD, see LICENSE for details. |
Class | OptionError |
Undocumented |
Function | get_bool_opt |
Undocumented |
Function | get_choice_opt |
Undocumented |
Function | get_int_opt |
Undocumented |
Function | get_list_opt |
Undocumented |
Variable | doctype_lookup_re |
Undocumented |
Variable | split_path_re |
Undocumented |
Variable | tag_re |
Undocumented |
Variable | xml_decl_re |
Undocumented |
Class | ClassNotFound |
Raised if one of the lookup functions didn't find a matching class. |
Class | Future |
Generic class to defer some work. |
Class | UnclosingTextIOWrapper |
Undocumented |
Function | docstring_headline |
Undocumented |
Function | doctype_matches |
Check if the doctype matches a regular expression (if present). |
Function | duplicates_removed |
Returns a list with duplicates removed from the iterable it . |
Function | format_lines |
Formats a sequence of strings for output. |
Function | guess_decode |
Decode text with guessed encoding. |
Function | guess_decode_from_terminal |
Decode text coming from terminal term. |
Function | html_doctype_matches |
Check if the file looks like it has a html doctype. |
Function | looks_like_xml |
Check if a doctype exists or if we have some tags. |
Function | make_analysator |
Return a static text analyser function that returns float values. |
Function | shebang_matches |
Check if the given regular expression matches the last part of the shebang if one exists. |
Function | surrogatepair |
Given a unicode character code with length greater than 16 bits, return the two 16 bit surrogate pair. |
Function | terminal_encoding |
Return our best guess of encoding for the given term. |
Variable | _looks_like_xml_cache |
Undocumented |
Check if the doctype matches a regular expression (if present).
Note that this method only checks the first part of a DOCTYPE. eg: 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
Returns a list with duplicates removed from the iterable it
.
Order is preserved.
Decode text with guessed encoding.
First try UTF-8; this should fail for non-UTF-8 encodings. Then try the preferred locale encoding. Fall back to latin-1, which always works.
Decode text coming from terminal term.
First try the terminal encoding, if given. Then try UTF-8. Then try the preferred locale encoding. Fall back to latin-1, which always works.
Check if the given regular expression matches the last part of the shebang if one exists.
>>> from pygments.util import shebang_matches >>> shebang_matches('#!/usr/bin/env python', r'python(2\.\d)?') True >>> shebang_matches('#!/usr/bin/python2.4', r'python(2\.\d)?') True >>> shebang_matches('#!/usr/bin/python-ruby', r'python(2\.\d)?') False >>> shebang_matches('#!/usr/bin/python/ruby', r'python(2\.\d)?') False >>> shebang_matches('#!/usr/bin/startsomethingwith python', ... r'python(2\.\d)?') True
It also checks for common windows executable file extensions:
>>> shebang_matches('#!C:\\Python2.4\\Python.exe', r'python(2\.\d)?') True
Parameters ('-f' or '--foo' are ignored so 'perl' does the same as 'perl -e')
Note that this method automatically searches the whole string (eg: the regular expression is wrapped in '^$')