Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
Page.start_index | (self) |
Return the 1-based index of the first object on this page,
relative to total objects in the paginator.
|
Return the 1-based index of the first object on this page,
relative to total objects in the paginator.
| def start_index(self):
"""
Return the 1-based index of the first object on this page,
relative to total objects in the paginator.
"""
# Special case, return zero if no items.
if self.paginator.count == 0:
return 0
return (self.paginator.per_page * (sel... | [
"def",
"start_index",
"(",
"self",
")",
":",
"# Special case, return zero if no items.",
"if",
"self",
".",
"paginator",
".",
"count",
"==",
"0",
":",
"return",
"0",
"return",
"(",
"self",
".",
"paginator",
".",
"per_page",
"*",
"(",
"self",
".",
"number",
... | [
205,
4
] | [
213,
64
] | python | en | ['en', 'error', 'th'] | False |
Page.end_index | (self) |
Return the 1-based index of the last object on this page,
relative to total objects found (hits).
|
Return the 1-based index of the last object on this page,
relative to total objects found (hits).
| def end_index(self):
"""
Return the 1-based index of the last object on this page,
relative to total objects found (hits).
"""
# Special case for the last page because there can be orphans.
if self.number == self.paginator.num_pages:
return self.paginator.coun... | [
"def",
"end_index",
"(",
"self",
")",
":",
"# Special case for the last page because there can be orphans.",
"if",
"self",
".",
"number",
"==",
"self",
".",
"paginator",
".",
"num_pages",
":",
"return",
"self",
".",
"paginator",
".",
"count",
"return",
"self",
"."... | [
215,
4
] | [
223,
52
] | python | en | ['en', 'error', 'th'] | False |
DataSource.__getitem__ | (self, index) | Allows use of the index [] operator to get a layer at the index. | Allows use of the index [] operator to get a layer at the index. | def __getitem__(self, index):
"Allows use of the index [] operator to get a layer at the index."
if isinstance(index, str):
try:
layer = capi.get_layer_by_name(self.ptr, force_bytes(index))
except GDALException:
raise IndexError('Invalid OGR layer ... | [
"def",
"__getitem__",
"(",
"self",
",",
"index",
")",
":",
"if",
"isinstance",
"(",
"index",
",",
"str",
")",
":",
"try",
":",
"layer",
"=",
"capi",
".",
"get_layer_by_name",
"(",
"self",
".",
"ptr",
",",
"force_bytes",
"(",
"index",
")",
")",
"excep... | [
87,
4
] | [
101,
33
] | python | en | ['en', 'en', 'en'] | True |
DataSource.__len__ | (self) | Return the number of layers within the data source. | Return the number of layers within the data source. | def __len__(self):
"Return the number of layers within the data source."
return self.layer_count | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"self",
".",
"layer_count"
] | [
103,
4
] | [
105,
31
] | python | en | ['en', 'en', 'en'] | True |
DataSource.__str__ | (self) | Return OGR GetName and Driver for the Data Source. | Return OGR GetName and Driver for the Data Source. | def __str__(self):
"Return OGR GetName and Driver for the Data Source."
return '%s (%s)' % (self.name, self.driver) | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"'%s (%s)'",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"driver",
")"
] | [
107,
4
] | [
109,
51
] | python | en | ['en', 'en', 'en'] | True |
DataSource.layer_count | (self) | Return the number of layers in the data source. | Return the number of layers in the data source. | def layer_count(self):
"Return the number of layers in the data source."
return capi.get_layer_count(self._ptr) | [
"def",
"layer_count",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_layer_count",
"(",
"self",
".",
"_ptr",
")"
] | [
112,
4
] | [
114,
46
] | python | en | ['en', 'en', 'en'] | True |
DataSource.name | (self) | Return the name of the data source. | Return the name of the data source. | def name(self):
"Return the name of the data source."
name = capi.get_ds_name(self._ptr)
return force_str(name, self.encoding, strings_only=True) | [
"def",
"name",
"(",
"self",
")",
":",
"name",
"=",
"capi",
".",
"get_ds_name",
"(",
"self",
".",
"_ptr",
")",
"return",
"force_str",
"(",
"name",
",",
"self",
".",
"encoding",
",",
"strings_only",
"=",
"True",
")"
] | [
117,
4
] | [
120,
64
] | python | en | ['en', 'en', 'en'] | True |
get_func_full_args | (func) |
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
|
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
| def get_func_full_args(func):
"""
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
"""
params = _get_callable_parameters(func)
args = []
for param in params... | [
"def",
"get_func_full_args",
"(",
"func",
")",
":",
"params",
"=",
"_get_callable_parameters",
"(",
"func",
")",
"args",
"=",
"[",
"]",
"for",
"param",
"in",
"params",
":",
"name",
"=",
"param",
".",
"name",
"# Ignore 'self'",
"if",
"name",
"==",
"'self'",... | [
26,
0
] | [
47,
15
] | python | en | ['en', 'error', 'th'] | False |
func_accepts_kwargs | (func) | Return True if function 'func' accepts keyword arguments **kwargs. | Return True if function 'func' accepts keyword arguments **kwargs. | def func_accepts_kwargs(func):
"""Return True if function 'func' accepts keyword arguments **kwargs."""
return any(
p for p in _get_callable_parameters(func)
if p.kind == p.VAR_KEYWORD
) | [
"def",
"func_accepts_kwargs",
"(",
"func",
")",
":",
"return",
"any",
"(",
"p",
"for",
"p",
"in",
"_get_callable_parameters",
"(",
"func",
")",
"if",
"p",
".",
"kind",
"==",
"p",
".",
"VAR_KEYWORD",
")"
] | [
50,
0
] | [
55,
5
] | python | en | ['en', 'en', 'en'] | True |
func_accepts_var_args | (func) |
Return True if function 'func' accepts positional arguments *args.
|
Return True if function 'func' accepts positional arguments *args.
| def func_accepts_var_args(func):
"""
Return True if function 'func' accepts positional arguments *args.
"""
return any(
p for p in _get_callable_parameters(func)
if p.kind == p.VAR_POSITIONAL
) | [
"def",
"func_accepts_var_args",
"(",
"func",
")",
":",
"return",
"any",
"(",
"p",
"for",
"p",
"in",
"_get_callable_parameters",
"(",
"func",
")",
"if",
"p",
".",
"kind",
"==",
"p",
".",
"VAR_POSITIONAL",
")"
] | [
58,
0
] | [
65,
5
] | python | en | ['en', 'error', 'th'] | False |
method_has_no_args | (meth) | Return True if a method only accepts 'self'. | Return True if a method only accepts 'self'. | def method_has_no_args(meth):
"""Return True if a method only accepts 'self'."""
count = len([
p for p in _get_callable_parameters(meth)
if p.kind == p.POSITIONAL_OR_KEYWORD
])
return count == 0 if inspect.ismethod(meth) else count == 1 | [
"def",
"method_has_no_args",
"(",
"meth",
")",
":",
"count",
"=",
"len",
"(",
"[",
"p",
"for",
"p",
"in",
"_get_callable_parameters",
"(",
"meth",
")",
"if",
"p",
".",
"kind",
"==",
"p",
".",
"POSITIONAL_OR_KEYWORD",
"]",
")",
"return",
"count",
"==",
... | [
68,
0
] | [
74,
63
] | python | en | ['en', 'en', 'en'] | True |
Extractor.fit | (self, documents, labels, weights=None) |
Fit :class`Extractor` features and model to a training dataset.
Args:
blocks (List[Block])
labels (``np.ndarray``)
weights (``np.ndarray``)
Returns:
:class`Extractor`
|
Fit :class`Extractor` features and model to a training dataset. | def fit(self, documents, labels, weights=None):
"""
Fit :class`Extractor` features and model to a training dataset.
Args:
blocks (List[Block])
labels (``np.ndarray``)
weights (``np.ndarray``)
Returns:
:class`Extractor`
"""
... | [
"def",
"fit",
"(",
"self",
",",
"documents",
",",
"labels",
",",
"weights",
"=",
"None",
")",
":",
"block_groups",
"=",
"np",
".",
"array",
"(",
"[",
"self",
".",
"blockifier",
".",
"blockify",
"(",
"doc",
")",
"for",
"doc",
"in",
"documents",
"]",
... | [
68,
4
] | [
94,
19
] | python | en | ['en', 'error', 'th'] | False |
Extractor.get_html_labels_weights | (self, data) |
Gather the html, labels, and weights of many files' data.
Primarily useful for training/testing an :class`Extractor`.
Args:
data: Output of :func:`dragnet.data_processing.prepare_all_data`.
Returns:
Tuple[List[Block], np.array(int), np.array(int)]: All blocks, ... |
Gather the html, labels, and weights of many files' data.
Primarily useful for training/testing an :class`Extractor`. | def get_html_labels_weights(self, data):
"""
Gather the html, labels, and weights of many files' data.
Primarily useful for training/testing an :class`Extractor`.
Args:
data: Output of :func:`dragnet.data_processing.prepare_all_data`.
Returns:
Tuple[List... | [
"def",
"get_html_labels_weights",
"(",
"self",
",",
"data",
")",
":",
"all_html",
"=",
"[",
"]",
"all_labels",
"=",
"[",
"]",
"all_weights",
"=",
"[",
"]",
"for",
"html",
",",
"content",
",",
"comments",
"in",
"data",
":",
"all_html",
".",
"append",
"(... | [
96,
4
] | [
117,
78
] | python | en | ['en', 'error', 'th'] | False |
Extractor._get_labels_and_weights | (self, content, comments) |
Args:
content (Tuple[np.array[int], np.array[int], List[str]])
comments (Tuple[np.array[int], np.array[int], List[str]])
Returns:
Tuple[np.array[int], np.array[int], List[str]]
|
Args:
content (Tuple[np.array[int], np.array[int], List[str]])
comments (Tuple[np.array[int], np.array[int], List[str]]) | def _get_labels_and_weights(self, content, comments):
"""
Args:
content (Tuple[np.array[int], np.array[int], List[str]])
comments (Tuple[np.array[int], np.array[int], List[str]])
Returns:
Tuple[np.array[int], np.array[int], List[str]]
"""
# ex... | [
"def",
"_get_labels_and_weights",
"(",
"self",
",",
"content",
",",
"comments",
")",
":",
"# extract content and comments",
"if",
"'content'",
"in",
"self",
".",
"to_extract",
"and",
"'comments'",
"in",
"self",
".",
"to_extract",
":",
"labels",
"=",
"np",
".",
... | [
126,
4
] | [
150,
30
] | python | en | ['en', 'error', 'th'] | False |
Extractor.extract | (self, html, encoding=None, as_blocks=False) |
Extract the main content and/or comments from an HTML document and
return it as a string or as a sequence of block objects.
Args:
html (str): HTML document as a string.
encoding (str): Encoding of ``html``. If None (encoding unknown), the
original encodi... |
Extract the main content and/or comments from an HTML document and
return it as a string or as a sequence of block objects. | def extract(self, html, encoding=None, as_blocks=False):
"""
Extract the main content and/or comments from an HTML document and
return it as a string or as a sequence of block objects.
Args:
html (str): HTML document as a string.
encoding (str): Encoding of ``htm... | [
"def",
"extract",
"(",
"self",
",",
"html",
",",
"encoding",
"=",
"None",
",",
"as_blocks",
"=",
"False",
")",
":",
"preds",
",",
"blocks",
"=",
"self",
".",
"predict",
"(",
"html",
",",
"encoding",
"=",
"encoding",
",",
"return_blocks",
"=",
"True",
... | [
152,
4
] | [
172,
65
] | python | en | ['en', 'error', 'th'] | False |
Extractor.predict | (self, documents, **kwargs) |
Predict class (content=1 or not-content=0) of the blocks in one or many
HTML document(s).
Args:
documents (str or List[str]): HTML document(s)
Returns:
``np.ndarray`` or List[``np.ndarray``]: array of binary predictions
for content (1) or not-co... |
Predict class (content=1 or not-content=0) of the blocks in one or many
HTML document(s). | def predict(self, documents, **kwargs):
"""
Predict class (content=1 or not-content=0) of the blocks in one or many
HTML document(s).
Args:
documents (str or List[str]): HTML document(s)
Returns:
``np.ndarray`` or List[``np.ndarray``]: array of binary pr... | [
"def",
"predict",
"(",
"self",
",",
"documents",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"documents",
",",
"(",
"str",
",",
"bytes",
",",
"unicode_",
",",
"np",
".",
"unicode_",
")",
")",
":",
"return",
"self",
".",
"_predict_one"... | [
175,
4
] | [
190,
90
] | python | en | ['en', 'error', 'th'] | False |
Extractor._predict_one | (self, document, encoding=None, return_blocks=False) |
Predict class (content=1 or not-content=0) of each block in an HTML
document.
Args:
documents (str): HTML document
Returns:
``np.ndarray``: array of binary predictions for content (1) or
not-content (0).
|
Predict class (content=1 or not-content=0) of each block in an HTML
document. | def _predict_one(self, document, encoding=None, return_blocks=False):
"""
Predict class (content=1 or not-content=0) of each block in an HTML
document.
Args:
documents (str): HTML document
Returns:
``np.ndarray``: array of binary predictions for content ... | [
"def",
"_predict_one",
"(",
"self",
",",
"document",
",",
"encoding",
"=",
"None",
",",
"return_blocks",
"=",
"False",
")",
":",
"# blockify",
"blocks",
"=",
"self",
".",
"blockifier",
".",
"blockify",
"(",
"document",
",",
"encoding",
"=",
"encoding",
")"... | [
193,
4
] | [
225,
24
] | python | en | ['en', 'error', 'th'] | False |
Cache.__init__ | (self, max_age) | Constructor.
Args:
max_age: Cache expiration in seconds.
| Constructor. | def __init__(self, max_age):
"""Constructor.
Args:
max_age: Cache expiration in seconds.
"""
self._max_age = max_age | [
"def",
"__init__",
"(",
"self",
",",
"max_age",
")",
":",
"self",
".",
"_max_age",
"=",
"max_age"
] | [
34,
2
] | [
40,
29
] | python | en | ['en', 'en', 'en'] | False |
sms_reply | () | Respond to incoming calls with a MMS message. | Respond to incoming calls with a MMS message. | def sms_reply():
"""Respond to incoming calls with a MMS message."""
# Start our TwiML response
resp = MessagingResponse()
# Add a text message
msg = resp.message("The Robots are coming! Head for the hills!")
# Add a picture message
msg.media(
"https://farm8.staticflickr.com/7090/6... | [
"def",
"sms_reply",
"(",
")",
":",
"# Start our TwiML response",
"resp",
"=",
"MessagingResponse",
"(",
")",
"# Add a text message",
"msg",
"=",
"resp",
".",
"message",
"(",
"\"The Robots are coming! Head for the hills!\"",
")",
"# Add a picture message",
"msg",
".",
"m... | [
7,
0
] | [
20,
20
] | python | en | ['en', 'en', 'en'] | True |
config_file | (kind="local") | Get the filename of the distutils, local, global, or per-user config
`kind` must be one of "local", "global", or "user"
| Get the filename of the distutils, local, global, or per-user config | def config_file(kind="local"):
"""Get the filename of the distutils, local, global, or per-user config
`kind` must be one of "local", "global", or "user"
"""
if kind == 'local':
return 'setup.cfg'
if kind == 'global':
return os.path.join(
os.path.dirname(distutils.__file... | [
"def",
"config_file",
"(",
"kind",
"=",
"\"local\"",
")",
":",
"if",
"kind",
"==",
"'local'",
":",
"return",
"'setup.cfg'",
"if",
"kind",
"==",
"'global'",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"d... | [
13,
0
] | [
29,
5
] | python | en | ['en', 'en', 'en'] | True |
edit_config | (filename, settings, dry_run=False) | Edit a configuration file to include `settings`
`settings` is a dictionary of dictionaries or ``None`` values, keyed by
command/section name. A ``None`` value means to delete the entire section,
while a dictionary lists settings to be changed or deleted in that section.
A setting of ``None`` means to ... | Edit a configuration file to include `settings` | def edit_config(filename, settings, dry_run=False):
"""Edit a configuration file to include `settings`
`settings` is a dictionary of dictionaries or ``None`` values, keyed by
command/section name. A ``None`` value means to delete the entire section,
while a dictionary lists settings to be changed or d... | [
"def",
"edit_config",
"(",
"filename",
",",
"settings",
",",
"dry_run",
"=",
"False",
")",
":",
"log",
".",
"debug",
"(",
"\"Reading configuration from %s\"",
",",
"filename",
")",
"opts",
"=",
"configparser",
".",
"RawConfigParser",
"(",
")",
"opts",
".",
"... | [
32,
0
] | [
72,
25
] | python | en | ['en', 'en', 'en'] | True |
_xml_escape | (data) | Escape &, <, >, ", ', etc. in a string of data. | Escape &, <, >, ", ', etc. in a string of data. | def _xml_escape(data):
"""Escape &, <, >, ", ', etc. in a string of data."""
# ampersand must be replaced first
from_symbols = '&><"\''
to_symbols = ('&' + s + ';' for s in "amp gt lt quot apos".split())
for from_, to_ in zip(from_symbols, to_symbols):
data = data.replace(from_, to_)
re... | [
"def",
"_xml_escape",
"(",
"data",
")",
":",
"# ampersand must be replaced first",
"from_symbols",
"=",
"'&><\"\\''",
"to_symbols",
"=",
"(",
"'&'",
"+",
"s",
"+",
"';'",
"for",
"s",
"in",
"\"amp gt lt quot apos\"",
".",
"split",
"(",
")",
")",
"for",
"from_",... | [
269,
0
] | [
277,
15
] | python | en | ['en', 'en', 'en'] | True |
col | (loc, strg) | Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See
:class:`ParserElement.parseString` for more
information on parsing strings contai... | Returns current column within a string, counting newlines as line separators.
The first column is number 1. | def col (loc, strg):
"""Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See
:class:`ParserElement.parseString` for more
informati... | [
"def",
"col",
"(",
"loc",
",",
"strg",
")",
":",
"s",
"=",
"strg",
"return",
"1",
"if",
"0",
"<",
"loc",
"<",
"len",
"(",
"s",
")",
"and",
"s",
"[",
"loc",
"-",
"1",
"]",
"==",
"'\\n'",
"else",
"loc",
"-",
"s",
".",
"rfind",
"(",
"\"\\n\"",... | [
1210,
0
] | [
1222,
86
] | python | en | ['en', 'en', 'en'] | True |
lineno | (loc, strg) | Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note - the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See :class:`ParserElement.parseString`
for more information on parsing strings c... | Returns current line number within a string, counting newlines as line separators.
The first line is number 1. | def lineno(loc, strg):
"""Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note - the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See :class:`ParserElement.parseString`
for more in... | [
"def",
"lineno",
"(",
"loc",
",",
"strg",
")",
":",
"return",
"strg",
".",
"count",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"+",
"1"
] | [
1224,
0
] | [
1234,
39
] | python | en | ['en', 'en', 'en'] | True |
line | (loc, strg) | Returns the line of text containing loc within a string, counting newlines as line separators.
| Returns the line of text containing loc within a string, counting newlines as line separators.
| def line(loc, strg):
"""Returns the line of text containing loc within a string, counting newlines as line separators.
"""
lastCR = strg.rfind("\n", 0, loc)
nextCR = strg.find("\n", loc)
if nextCR >= 0:
return strg[lastCR + 1:nextCR]
else:
return strg[lastCR + 1:] | [
"def",
"line",
"(",
"loc",
",",
"strg",
")",
":",
"lastCR",
"=",
"strg",
".",
"rfind",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"nextCR",
"=",
"strg",
".",
"find",
"(",
"\"\\n\"",
",",
"loc",
")",
"if",
"nextCR",
">=",
"0",
":",
"return",
"st... | [
1236,
0
] | [
1244,
32
] | python | en | ['en', 'en', 'en'] | True |
nullDebugAction | (*args) | Do-nothing' debug action, to suppress debugging output during parsing. | Do-nothing' debug action, to suppress debugging output during parsing. | def nullDebugAction(*args):
"""'Do-nothing' debug action, to suppress debugging output during parsing."""
pass | [
"def",
"nullDebugAction",
"(",
"*",
"args",
")",
":",
"pass"
] | [
1255,
0
] | [
1257,
8
] | python | en | ['en', 'jv', 'en'] | True |
ParseBaseException._from_exception | (cls, pe) |
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
|
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
| def _from_exception(cls, pe):
"""
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
"""
return cls(pe.pstr, pe.loc, pe.msg, pe.parserElement) | [
"def",
"_from_exception",
"(",
"cls",
",",
"pe",
")",
":",
"return",
"cls",
"(",
"pe",
".",
"pstr",
",",
"pe",
".",
"loc",
",",
"pe",
".",
"msg",
",",
"pe",
".",
"parserElement",
")"
] | [
315,
4
] | [
320,
61
] | python | en | ['en', 'error', 'th'] | False |
ParseBaseException.__getattr__ | (self, aname) | supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| def __getattr__(self, aname):
"""supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
"""
if aname == "lineno":
... | [
"def",
"__getattr__",
"(",
"self",
",",
"aname",
")",
":",
"if",
"aname",
"==",
"\"lineno\"",
":",
"return",
"lineno",
"(",
"self",
".",
"loc",
",",
"self",
".",
"pstr",
")",
"elif",
"aname",
"in",
"(",
"\"col\"",
",",
"\"column\"",
")",
":",
"return... | [
322,
4
] | [
335,
39
] | python | en | ['en', 'en', 'en'] | True |
ParseBaseException.markInputline | (self, markerString=">!<") | Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| def markInputline(self, markerString=">!<"):
"""Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
"""
line_str = self.line
line_column = self.column - 1
if markerString:
line_str = "".join((lin... | [
"def",
"markInputline",
"(",
"self",
",",
"markerString",
"=",
"\">!<\"",
")",
":",
"line_str",
"=",
"self",
".",
"line",
"line_column",
"=",
"self",
".",
"column",
"-",
"1",
"if",
"markerString",
":",
"line_str",
"=",
"\"\"",
".",
"join",
"(",
"(",
"l... | [
349,
4
] | [
358,
31
] | python | en | ['en', 'en', 'en'] | True |
ParseException.explain | (exc, depth=16) |
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised.
Parameters:
- exc - exception raised during parsing (need not be a ParseException, in support
of Python exceptions that ... |
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised. | def explain(exc, depth=16):
"""
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised.
Parameters:
- exc - exception raised during parsing (need not be a ParseException, in suppor... | [
"def",
"explain",
"(",
"exc",
",",
"depth",
"=",
"16",
")",
":",
"import",
"inspect",
"if",
"depth",
"is",
"None",
":",
"depth",
"=",
"sys",
".",
"getrecursionlimit",
"(",
")",
"ret",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"exc",
",",
"ParseBaseExce... | [
386,
4
] | [
452,
29
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.haskeys | (self) | Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names. | Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names. | def haskeys(self):
"""Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names."""
return bool(self.__tokdict) | [
"def",
"haskeys",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"__tokdict",
")"
] | [
695,
4
] | [
698,
35
] | python | en | ['en', 'en', 'en'] | True |
ParseResults.pop | (self, *args, **kwargs) |
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed tokens. If passed
a non-integer argum... |
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed tokens. If passed
a non-integer argum... | def pop(self, *args, **kwargs):
"""
Removes and returns item at specified index (default= ``last``).
Supports both ``list`` and ``dict`` semantics for ``pop()``. If
passed no argument or an integer argument, it will use ``list``
semantics and pop tokens from the list of parsed to... | [
"def",
"pop",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"args",
":",
"args",
"=",
"[",
"-",
"1",
"]",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"'default'",
":",... | [
700,
4
] | [
753,
31
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.get | (self, key, defaultValue=None) |
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified.
Similar to ``dict.get()``.
Example::
integer = Word(nums)
date_str = integer("year") + '/... |
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified. | def get(self, key, defaultValue=None):
"""
Returns named result matching the given key, or if there is no
such name, then returns the given ``defaultValue`` or ``None`` if no
``defaultValue`` is specified.
Similar to ``dict.get()``.
Example::
integer = Word... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"defaultValue",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
":",
"return",
"self",
"[",
"key",
"]",
"else",
":",
"return",
"defaultValue"
] | [
755,
4
] | [
776,
31
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.insert | (self, index, insStr) |
Inserts new element at location index in the list of parsed tokens.
Similar to ``list.insert()``.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to insert the parse location in the front of the parsed res... |
Inserts new element at location index in the list of parsed tokens. | def insert(self, index, insStr):
"""
Inserts new element at location index in the list of parsed tokens.
Similar to ``list.insert()``.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to insert the p... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"insStr",
")",
":",
"self",
".",
"__toklist",
".",
"insert",
"(",
"index",
",",
"insStr",
")",
"# fixup indices in token dictionary",
"for",
"name",
",",
"occurrences",
"in",
"self",
".",
"__tokdict",
".",
"... | [
778,
4
] | [
797,
94
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.append | (self, item) |
Add single element to end of ParseResults list of elements.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to compute the sum of the parsed integers, and add it to the end
def append_sum(tokens):
... |
Add single element to end of ParseResults list of elements. | def append(self, item):
"""
Add single element to end of ParseResults list of elements.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to compute the sum of the parsed integers, and add it to the end
... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"__toklist",
".",
"append",
"(",
"item",
")"
] | [
799,
4
] | [
812,
35
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.extend | (self, itemseq) |
Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
tokens.extend(reversed([... |
Add sequence of elements to end of ParseResults list of elements. | def extend(self, itemseq):
"""
Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
... | [
"def",
"extend",
"(",
"self",
",",
"itemseq",
")",
":",
"if",
"isinstance",
"(",
"itemseq",
",",
"ParseResults",
")",
":",
"self",
".",
"__iadd__",
"(",
"itemseq",
")",
"else",
":",
"self",
".",
"__toklist",
".",
"extend",
"(",
"itemseq",
")"
] | [
814,
4
] | [
831,
42
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.clear | (self) |
Clear all elements and results names.
|
Clear all elements and results names.
| def clear(self):
"""
Clear all elements and results names.
"""
del self.__toklist[:]
self.__tokdict.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"del",
"self",
".",
"__toklist",
"[",
":",
"]",
"self",
".",
"__tokdict",
".",
"clear",
"(",
")"
] | [
833,
4
] | [
838,
30
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asList | (self) |
Returns the parse results as a nested list of matching tokens, all converted to strings.
Example::
patt = OneOrMore(Word(alphas))
result = patt.parseString("sldkj lsdkj sldkj")
# even though the result prints in string-like form, it is actually a pyparsing ParseRes... |
Returns the parse results as a nested list of matching tokens, all converted to strings. | def asList(self):
"""
Returns the parse results as a nested list of matching tokens, all converted to strings.
Example::
patt = OneOrMore(Word(alphas))
result = patt.parseString("sldkj lsdkj sldkj")
# even though the result prints in string-like form, it is ... | [
"def",
"asList",
"(",
"self",
")",
":",
"return",
"[",
"res",
".",
"asList",
"(",
")",
"if",
"isinstance",
"(",
"res",
",",
"ParseResults",
")",
"else",
"res",
"for",
"res",
"in",
"self",
".",
"__toklist",
"]"
] | [
892,
4
] | [
907,
97
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asDict | (self) |
Returns the named parse results as a nested dictionary.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
result = date_str.parseString('12/31/1999')
print(type(result), repr(result)) # -> <class ... |
Returns the named parse results as a nested dictionary. | def asDict(self):
"""
Returns the named parse results as a nested dictionary.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
result = date_str.parseString('12/31/1999')
print(type(result... | [
"def",
"asDict",
"(",
"self",
")",
":",
"if",
"PY_3",
":",
"item_fn",
"=",
"self",
".",
"items",
"else",
":",
"item_fn",
"=",
"self",
".",
"iteritems",
"def",
"toItem",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"ParseResults",
")",
... | [
909,
4
] | [
943,
57
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.copy | (self) |
Returns a new copy of a :class:`ParseResults` object.
|
Returns a new copy of a :class:`ParseResults` object.
| def copy(self):
"""
Returns a new copy of a :class:`ParseResults` object.
"""
ret = ParseResults(self.__toklist)
ret.__tokdict = dict(self.__tokdict.items())
ret.__parent = self.__parent
ret.__accumNames.update(self.__accumNames)
ret.__name = self.__name
... | [
"def",
"copy",
"(",
"self",
")",
":",
"ret",
"=",
"ParseResults",
"(",
"self",
".",
"__toklist",
")",
"ret",
".",
"__tokdict",
"=",
"dict",
"(",
"self",
".",
"__tokdict",
".",
"items",
"(",
")",
")",
"ret",
".",
"__parent",
"=",
"self",
".",
"__par... | [
945,
4
] | [
954,
18
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.asXML | (self, doctag=None, namedItemsOnly=False, indent="", formatted=True) |
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
|
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
| def asXML(self, doctag=None, namedItemsOnly=False, indent="", formatted=True):
"""
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
"""
nl = "\n"
out = []
namedItems = dict((v[1], k) for (k, vlist) in se... | [
"def",
"asXML",
"(",
"self",
",",
"doctag",
"=",
"None",
",",
"namedItemsOnly",
"=",
"False",
",",
"indent",
"=",
"\"\"",
",",
"formatted",
"=",
"True",
")",
":",
"nl",
"=",
"\"\\n\"",
"out",
"=",
"[",
"]",
"namedItems",
"=",
"dict",
"(",
"(",
"v",... | [
956,
4
] | [
1015,
27
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.getName | (self) | r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location.
Example::
integer = Word(nums)
ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
house_number_expr = Suppress('#') + Word(nums, a... | r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location. | def getName(self):
r"""
Returns the results name for this token expression. Useful when several
different expressions might match at a particular location.
Example::
integer = Word(nums)
ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
house_number_expr = S... | [
"def",
"getName",
"(",
"self",
")",
":",
"if",
"self",
".",
"__name",
":",
"return",
"self",
".",
"__name",
"elif",
"self",
".",
"__parent",
":",
"par",
"=",
"self",
".",
"__parent",
"(",
")",
"if",
"par",
":",
"return",
"par",
".",
"__lookup",
"("... | [
1024,
4
] | [
1062,
23
] | python | cy | ['en', 'cy', 'hi'] | False |
ParseResults.dump | (self, indent='', full=True, include_list=True, _depth=0) |
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data.
Example::
integer = Word(nums)
date_str = integer("year") + '/' + integer("... |
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data. | def dump(self, indent='', full=True, include_list=True, _depth=0):
"""
Diagnostic method for listing out the contents of
a :class:`ParseResults`. Accepts an optional ``indent`` argument so
that this string can be embedded in a nested display of other data.
Example::
... | [
"def",
"dump",
"(",
"self",
",",
"indent",
"=",
"''",
",",
"full",
"=",
"True",
",",
"include_list",
"=",
"True",
",",
"_depth",
"=",
"0",
")",
":",
"out",
"=",
"[",
"]",
"NL",
"=",
"'\\n'",
"if",
"include_list",
":",
"out",
".",
"append",
"(",
... | [
1064,
4
] | [
1127,
27
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.pprint | (self, *args, **kwargs) |
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ .
Example::
... |
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ . | def pprint(self, *args, **kwargs):
"""
Pretty-printer for parsed results as a list, using the
`pprint <https://docs.python.org/3/library/pprint.html>`_ module.
Accepts additional positional or keyword args as defined for
`pprint.pprint <https://docs.python.org/3/library/pprint.ht... | [
"def",
"pprint",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pprint",
".",
"pprint",
"(",
"self",
".",
"asList",
"(",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
1129,
4
] | [
1154,
53
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.from_dict | (cls, other, name=None) |
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
|
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
| def from_dict(cls, other, name=None):
"""
Helper classmethod to construct a ParseResults from a dict, preserving the
name-value relations as results names. If an optional 'name' argument is
given, a nested ParseResults will be returned
"""
def is_iterable(obj):
... | [
"def",
"from_dict",
"(",
"cls",
",",
"other",
",",
"name",
"=",
"None",
")",
":",
"def",
"is_iterable",
"(",
"obj",
")",
":",
"try",
":",
"iter",
"(",
"obj",
")",
"except",
"Exception",
":",
"return",
"False",
"else",
":",
"if",
"PY_3",
":",
"retur... | [
1181,
4
] | [
1206,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setDefaultWhitespaceChars | (chars) | r"""
Overrides the default whitespace chars
Example::
# default whitespace chars are space, <TAB> and newline
OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl']
# change to just treat newline as significant
Parser... | r"""
Overrides the default whitespace chars | def setDefaultWhitespaceChars(chars):
r"""
Overrides the default whitespace chars
Example::
# default whitespace chars are space, <TAB> and newline
OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl']
# change to just t... | [
"def",
"setDefaultWhitespaceChars",
"(",
"chars",
")",
":",
"ParserElement",
".",
"DEFAULT_WHITE_CHARS",
"=",
"chars"
] | [
1356,
4
] | [
1369,
49
] | python | cy | ['en', 'cy', 'hi'] | False |
ParserElement.inlineLiteralsUsing | (cls) |
Set class to be used for inclusion of string literals into a parser.
Example::
# default literal class used is Literal
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
date_str.parseString("1999/12/31") #... |
Set class to be used for inclusion of string literals into a parser. | def inlineLiteralsUsing(cls):
"""
Set class to be used for inclusion of string literals into a parser.
Example::
# default literal class used is Literal
integer = Word(nums)
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
... | [
"def",
"inlineLiteralsUsing",
"(",
"cls",
")",
":",
"ParserElement",
".",
"_literalStringClass",
"=",
"cls"
] | [
1372,
4
] | [
1391,
47
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.copy | (self) |
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element.
Example::
integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
integerK = integer.copy()... |
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element. | def copy(self):
"""
Make a copy of this :class:`ParserElement`. Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element.
Example::
integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
... | [
"def",
"copy",
"(",
"self",
")",
":",
"cpy",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"cpy",
".",
"parseAction",
"=",
"self",
".",
"parseAction",
"[",
":",
"]",
"cpy",
".",
"ignoreExprs",
"=",
"self",
".",
"ignoreExprs",
"[",
":",
"]",
"if",
"... | [
1422,
4
] | [
1449,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setName | (self, name) |
Define name for this expression, makes debugging and exception messages clearer.
Example::
Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1)
Word(nums).setName("integer").parseString("ABC") # -> Exception: Expected integer (at ch... |
Define name for this expression, makes debugging and exception messages clearer. | def setName(self, name):
"""
Define name for this expression, makes debugging and exception messages clearer.
Example::
Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1)
Word(nums).setName("integer").parseString("ABC") # -... | [
"def",
"setName",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"errmsg",
"=",
"\"Expected \"",
"+",
"self",
".",
"name",
"if",
"__diag__",
".",
"enable_debug_on_named_expressions",
":",
"self",
".",
"setDebug",
"(",
... | [
1451,
4
] | [
1464,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setResultsName | (self, name, listAllMatches=False) |
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple pla... |
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple pla... | def setResultsName(self, name, listAllMatches=False):
"""
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic elem... | [
"def",
"setResultsName",
"(",
"self",
",",
"name",
",",
"listAllMatches",
"=",
"False",
")",
":",
"return",
"self",
".",
"_setResultsName",
"(",
"name",
",",
"listAllMatches",
")"
] | [
1466,
4
] | [
1487,
57
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setBreak | (self, breakFlag=True) | Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
| Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
| def setBreak(self, breakFlag=True):
"""Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``breakFlag`` to True to enable, False to
disable.
"""
if breakFlag:
_parseMethod = self._parse
def breaker(instring, loc, do... | [
"def",
"setBreak",
"(",
"self",
",",
"breakFlag",
"=",
"True",
")",
":",
"if",
"breakFlag",
":",
"_parseMethod",
"=",
"self",
".",
"_parse",
"def",
"breaker",
"(",
"instring",
",",
"loc",
",",
"doActions",
"=",
"True",
",",
"callPreParse",
"=",
"True",
... | [
1498,
4
] | [
1515,
19
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.setParseAction | (self, *fns, **kwargs) |
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where:
- s = the original string being parsed (se... |
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where: | def setParseAction(self, *fns, **kwargs):
"""
Define one or more actions to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as ``fn(s, loc, toks)`` ,
``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where:
... | [
"def",
"setParseAction",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"list",
"(",
"fns",
")",
"==",
"[",
"None",
",",
"]",
":",
"self",
".",
"parseAction",
"=",
"[",
"]",
"else",
":",
"if",
"not",
"all",
"(",
"callabl... | [
1517,
4
] | [
1564,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.addParseAction | (self, *fns, **kwargs) |
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`.
See examples in :class:`copy`.
|
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`. | def addParseAction(self, *fns, **kwargs):
"""
Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`.
See examples in :class:`copy`.
"""
self.parseAction += list(map(_trim_arity, list(fns)))
self.callDuringTry = self.callDuringTr... | [
"def",
"addParseAction",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"parseAction",
"+=",
"list",
"(",
"map",
"(",
"_trim_arity",
",",
"list",
"(",
"fns",
")",
")",
")",
"self",
".",
"callDuringTry",
"=",
"self",
"... | [
1566,
4
] | [
1574,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.addCondition | (self, *fns, **kwargs) | Add a boolean predicate function to expression's list of parse actions. See
:class:`setParseAction` for function call signatures. Unlike ``setParseAction``,
functions passed to ``addCondition`` need to return boolean success/fail of the condition.
Optional keyword arguments:
- message =... | Add a boolean predicate function to expression's list of parse actions. See
:class:`setParseAction` for function call signatures. Unlike ``setParseAction``,
functions passed to ``addCondition`` need to return boolean success/fail of the condition. | def addCondition(self, *fns, **kwargs):
"""Add a boolean predicate function to expression's list of parse actions. See
:class:`setParseAction` for function call signatures. Unlike ``setParseAction``,
functions passed to ``addCondition`` need to return boolean success/fail of the condition.
... | [
"def",
"addCondition",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"fn",
"in",
"fns",
":",
"self",
".",
"parseAction",
".",
"append",
"(",
"conditionAsParseAction",
"(",
"fn",
",",
"message",
"=",
"kwargs",
".",
"get",
"("... | [
1576,
4
] | [
1599,
19
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.setFailAction | (self, fn) | Define action to perform if parsing fails at this expression.
Fail acton fn is a callable function that takes the arguments
``fn(s, loc, expr, err)`` where:
- s = string being parsed
- loc = location where expression match was attempted and failed
- expr = the pars... | Define action to perform if parsing fails at this expression.
Fail acton fn is a callable function that takes the arguments
``fn(s, loc, expr, err)`` where:
- s = string being parsed
- loc = location where expression match was attempted and failed
- expr = the pars... | def setFailAction(self, fn):
"""Define action to perform if parsing fails at this expression.
Fail acton fn is a callable function that takes the arguments
``fn(s, loc, expr, err)`` where:
- s = string being parsed
- loc = location where expression match was attempted... | [
"def",
"setFailAction",
"(",
"self",
",",
"fn",
")",
":",
"self",
".",
"failAction",
"=",
"fn",
"return",
"self"
] | [
1601,
4
] | [
1612,
19
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.enablePackrat | (cache_size_limit=128) | Enables "packrat" parsing, which adds memoizing to the parsing logic.
Repeated parse attempts at the same string location (which happens
often in many complex grammars) can immediately return a cached value,
instead of re-executing parsing/validating code. Memoizing is done of
... | Enables "packrat" parsing, which adds memoizing to the parsing logic.
Repeated parse attempts at the same string location (which happens
often in many complex grammars) can immediately return a cached value,
instead of re-executing parsing/validating code. Memoizing is done of
... | def enablePackrat(cache_size_limit=128):
"""Enables "packrat" parsing, which adds memoizing to the parsing logic.
Repeated parse attempts at the same string location (which happens
often in many complex grammars) can immediately return a cached value,
instead of re-executing par... | [
"def",
"enablePackrat",
"(",
"cache_size_limit",
"=",
"128",
")",
":",
"if",
"not",
"ParserElement",
".",
"_packratEnabled",
":",
"ParserElement",
".",
"_packratEnabled",
"=",
"True",
"if",
"cache_size_limit",
"is",
"None",
":",
"ParserElement",
".",
"packrat_cach... | [
1866,
4
] | [
1898,
60
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.parseString | (self, instring, parseAll=False) |
Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built.
Returns the parsed data as a :class:`ParseResults` object, which may be
accessed as a list, or as a dict or object with attributes if ... |
Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built. | def parseString(self, instring, parseAll=False):
"""
Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built.
Returns the parsed data as a :class:`ParseResults` object, which may be
ac... | [
"def",
"parseString",
"(",
"self",
",",
"instring",
",",
"parseAll",
"=",
"False",
")",
":",
"ParserElement",
".",
"resetCache",
"(",
")",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamline",
"(",
")",
"# ~ self.saveAsList = True",
"for",... | [
1900,
4
] | [
1956,
25
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.scanString | (self, instring, maxMatches=_MAX_INT, overlap=False) |
Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
``maxMatches`` argument, to clip scanning after 'n' matches are found. If
``overlap`` is specified, then overlapping matches will be... |
Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
``maxMatches`` argument, to clip scanning after 'n' matches are found. If
``overlap`` is specified, then overlapping matches will be... | def scanString(self, instring, maxMatches=_MAX_INT, overlap=False):
"""
Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
``maxMatches`` argument, to clip scanning after 'n' matches ar... | [
"def",
"scanString",
"(",
"self",
",",
"instring",
",",
"maxMatches",
"=",
"_MAX_INT",
",",
"overlap",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamline",
"(",
")",
"for",
"e",
"in",
"self",
".",
"ignoreExpr... | [
1958,
4
] | [
2030,
25
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.transformString | (self, instring) |
Extension to :class:`scanString`, to modify matching text with modified tokens that may
be returned from a parse action. To use ``transformString``, define a grammar and
attach a parse action to it that modifies the returned token list.
Invoking ``transformString()`` on a target string... |
Extension to :class:`scanString`, to modify matching text with modified tokens that may
be returned from a parse action. To use ``transformString``, define a grammar and
attach a parse action to it that modifies the returned token list.
Invoking ``transformString()`` on a target string... | def transformString(self, instring):
"""
Extension to :class:`scanString`, to modify matching text with modified tokens that may
be returned from a parse action. To use ``transformString``, define a grammar and
attach a parse action to it that modifies the returned token list.
I... | [
"def",
"transformString",
"(",
"self",
",",
"instring",
")",
":",
"out",
"=",
"[",
"]",
"lastE",
"=",
"0",
"# force preservation of <TAB>s, to minimize unwanted transformation of string, and to",
"# keep string locs straight between transformString and scanString",
"self",
".",
... | [
2032,
4
] | [
2078,
25
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.searchString | (self, instring, maxMatches=_MAX_INT) |
Another extension to :class:`scanString`, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
``maxMatches`` argument, to clip searching after 'n' matches are found.
Example::
# a capitalized word starts with an uppe... |
Another extension to :class:`scanString`, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
``maxMatches`` argument, to clip searching after 'n' matches are found. | def searchString(self, instring, maxMatches=_MAX_INT):
"""
Another extension to :class:`scanString`, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
``maxMatches`` argument, to clip searching after 'n' matches are found.
... | [
"def",
"searchString",
"(",
"self",
",",
"instring",
",",
"maxMatches",
"=",
"_MAX_INT",
")",
":",
"try",
":",
"return",
"ParseResults",
"(",
"[",
"t",
"for",
"t",
",",
"s",
",",
"e",
"in",
"self",
".",
"scanString",
"(",
"instring",
",",
"maxMatches",... | [
2080,
4
] | [
2110,
25
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.split | (self, instring, maxsplit=_MAX_INT, includeSeparators=False) |
Generator method to split a string using the given expression as a separator.
May be called with optional ``maxsplit`` argument, to limit the number of splits;
and the optional ``includeSeparators`` argument (default= ``False``), if the separating
matching text should be included in the... |
Generator method to split a string using the given expression as a separator.
May be called with optional ``maxsplit`` argument, to limit the number of splits;
and the optional ``includeSeparators`` argument (default= ``False``), if the separating
matching text should be included in the... | def split(self, instring, maxsplit=_MAX_INT, includeSeparators=False):
"""
Generator method to split a string using the given expression as a separator.
May be called with optional ``maxsplit`` argument, to limit the number of splits;
and the optional ``includeSeparators`` argument (defa... | [
"def",
"split",
"(",
"self",
",",
"instring",
",",
"maxsplit",
"=",
"_MAX_INT",
",",
"includeSeparators",
"=",
"False",
")",
":",
"splits",
"=",
"0",
"last",
"=",
"0",
"for",
"t",
",",
"s",
",",
"e",
"in",
"self",
".",
"scanString",
"(",
"instring",
... | [
2112,
4
] | [
2135,
29
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__add__ | (self, other) |
Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement
converts them to :class:`Literal`s by default.
Example::
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseString(hel... |
Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement
converts them to :class:`Literal`s by default. | def __add__(self, other):
"""
Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement
converts them to :class:`Literal`s by default.
Example::
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
prin... | [
"def",
"__add__",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"Ellipsis",
":",
"return",
"_PendingSkip",
"(",
"self",
")",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",... | [
2137,
4
] | [
2173,
33
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__radd__ | (self, other) |
Implementation of + operator when left operand is not a :class:`ParserElement`
|
Implementation of + operator when left operand is not a :class:`ParserElement`
| def __radd__(self, other):
"""
Implementation of + operator when left operand is not a :class:`ParserElement`
"""
if other is Ellipsis:
return SkipTo(self)("_skipped*") + self
if isinstance(other, basestring):
other = self._literalStringClass(other)
... | [
"def",
"__radd__",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"Ellipsis",
":",
"return",
"SkipTo",
"(",
"self",
")",
"(",
"\"_skipped*\"",
")",
"+",
"self",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"... | [
2175,
4
] | [
2188,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__sub__ | (self, other) |
Implementation of - operator, returns :class:`And` with error stop
|
Implementation of - operator, returns :class:`And` with error stop
| def __sub__(self, other):
"""
Implementation of - operator, returns :class:`And` with error stop
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combine element of... | [
"def",
"__sub__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")",... | [
2190,
4
] | [
2200,
46
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__rsub__ | (self, other) |
Implementation of - operator when left operand is not a :class:`ParserElement`
|
Implementation of - operator when left operand is not a :class:`ParserElement`
| def __rsub__(self, other):
"""
Implementation of - operator when left operand is not a :class:`ParserElement`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combi... | [
"def",
"__rsub__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")"... | [
2202,
4
] | [
2212,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__mul__ | (self, other) |
Implementation of * operator, allows use of ``expr * 3`` in place of
``expr + expr + expr``. Expressions may also me multiplied by a 2-integer
tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples
may also include ``None`` as in:
- ``expr*(n, None)`` or ... |
Implementation of * operator, allows use of ``expr * 3`` in place of
``expr + expr + expr``. Expressions may also me multiplied by a 2-integer
tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples
may also include ``None`` as in:
- ``expr*(n, None)`` or ... | def __mul__(self, other):
"""
Implementation of * operator, allows use of ``expr * 3`` in place of
``expr + expr + expr``. Expressions may also me multiplied by a 2-integer
tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples
may also include ``None`` as ... | [
"def",
"__mul__",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"Ellipsis",
":",
"other",
"=",
"(",
"0",
",",
"None",
")",
"elif",
"isinstance",
"(",
"other",
",",
"tuple",
")",
"and",
"other",
"[",
":",
"1",
"]",
"==",
"(",
"Ellipsis... | [
2214,
4
] | [
2286,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__or__ | (self, other) |
Implementation of | operator - returns :class:`MatchFirst`
|
Implementation of | operator - returns :class:`MatchFirst`
| def __or__(self, other):
"""
Implementation of | operator - returns :class:`MatchFirst`
"""
if other is Ellipsis:
return _PendingSkip(self, must_skip=True)
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance... | [
"def",
"__or__",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"Ellipsis",
":",
"return",
"_PendingSkip",
"(",
"self",
",",
"must_skip",
"=",
"True",
")",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
... | [
2291,
4
] | [
2304,
40
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__ror__ | (self, other) |
Implementation of | operator when left operand is not a :class:`ParserElement`
|
Implementation of | operator when left operand is not a :class:`ParserElement`
| def __ror__(self, other):
"""
Implementation of | operator when left operand is not a :class:`ParserElement`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combin... | [
"def",
"__ror__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")",... | [
2306,
4
] | [
2316,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__xor__ | (self, other) |
Implementation of ^ operator - returns :class:`Or`
|
Implementation of ^ operator - returns :class:`Or`
| def __xor__(self, other):
"""
Implementation of ^ operator - returns :class:`Or`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combine element of type %s with Pa... | [
"def",
"__xor__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")",... | [
2318,
4
] | [
2328,
32
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__rxor__ | (self, other) |
Implementation of ^ operator when left operand is not a :class:`ParserElement`
|
Implementation of ^ operator when left operand is not a :class:`ParserElement`
| def __rxor__(self, other):
"""
Implementation of ^ operator when left operand is not a :class:`ParserElement`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combi... | [
"def",
"__rxor__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")"... | [
2330,
4
] | [
2340,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__and__ | (self, other) |
Implementation of & operator - returns :class:`Each`
|
Implementation of & operator - returns :class:`Each`
| def __and__(self, other):
"""
Implementation of & operator - returns :class:`Each`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combine element of type %s with ... | [
"def",
"__and__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")",... | [
2342,
4
] | [
2352,
34
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__rand__ | (self, other) |
Implementation of & operator when left operand is not a :class:`ParserElement`
|
Implementation of & operator when left operand is not a :class:`ParserElement`
| def __rand__(self, other):
"""
Implementation of & operator when left operand is not a :class:`ParserElement`
"""
if isinstance(other, basestring):
other = self._literalStringClass(other)
if not isinstance(other, ParserElement):
warnings.warn("Cannot combi... | [
"def",
"__rand__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"self",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement",
")"... | [
2354,
4
] | [
2364,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__invert__ | (self) |
Implementation of ~ operator - returns :class:`NotAny`
|
Implementation of ~ operator - returns :class:`NotAny`
| def __invert__(self):
"""
Implementation of ~ operator - returns :class:`NotAny`
"""
return NotAny(self) | [
"def",
"__invert__",
"(",
"self",
")",
":",
"return",
"NotAny",
"(",
"self",
")"
] | [
2366,
4
] | [
2370,
27
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__getitem__ | (self, key) |
use ``[]`` indexing notation as a short form for expression repetition:
- ``expr[n]`` is equivalent to ``expr*n``
- ``expr[m, n]`` is equivalent to ``expr*(m, n)``
- ``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + ZeroOrMore(expr)``
(read as "... |
use ``[]`` indexing notation as a short form for expression repetition:
- ``expr[n]`` is equivalent to ``expr*n``
- ``expr[m, n]`` is equivalent to ``expr*(m, n)``
- ``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + ZeroOrMore(expr)``
(read as "... | def __getitem__(self, key):
"""
use ``[]`` indexing notation as a short form for expression repetition:
- ``expr[n]`` is equivalent to ``expr*n``
- ``expr[m, n]`` is equivalent to ``expr*(m, n)``
- ``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + Zero... | [
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"# convert single arg keys to tuples",
"try",
":",
"if",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"key",
"=",
"(",
"key",
",",
")",
"iter",
"(",
"key",
")",
"except",
"TypeError",
":",
"ke... | [
2377,
4
] | [
2411,
18
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.__call__ | (self, name=None) |
Shortcut for :class:`setResultsName`, with ``listAllMatches=False``.
If ``name`` is given with a trailing ``'*'`` character, then ``listAllMatches`` will be
passed as ``True``.
If ``name` is omitted, same as calling :class:`copy`.
Example::
# these are equivalent... |
Shortcut for :class:`setResultsName`, with ``listAllMatches=False``. | def __call__(self, name=None):
"""
Shortcut for :class:`setResultsName`, with ``listAllMatches=False``.
If ``name`` is given with a trailing ``'*'`` character, then ``listAllMatches`` will be
passed as ``True``.
If ``name` is omitted, same as calling :class:`copy`.
Exa... | [
"def",
"__call__",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_setResultsName",
"(",
"name",
")",
"else",
":",
"return",
"self",
".",
"copy",
"(",
")"
] | [
2413,
4
] | [
2431,
30
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.suppress | (self) |
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
cluttering up returned output.
|
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
cluttering up returned output.
| def suppress(self):
"""
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
cluttering up returned output.
"""
return Suppress(self) | [
"def",
"suppress",
"(",
"self",
")",
":",
"return",
"Suppress",
"(",
"self",
")"
] | [
2433,
4
] | [
2438,
29
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.leaveWhitespace | (self) |
Disables the skipping of whitespace before matching the characters in the
:class:`ParserElement`'s defined pattern. This is normally only used internally by
the pyparsing module, but may be needed in some whitespace-sensitive grammars.
|
Disables the skipping of whitespace before matching the characters in the
:class:`ParserElement`'s defined pattern. This is normally only used internally by
the pyparsing module, but may be needed in some whitespace-sensitive grammars.
| def leaveWhitespace(self):
"""
Disables the skipping of whitespace before matching the characters in the
:class:`ParserElement`'s defined pattern. This is normally only used internally by
the pyparsing module, but may be needed in some whitespace-sensitive grammars.
"""
... | [
"def",
"leaveWhitespace",
"(",
"self",
")",
":",
"self",
".",
"skipWhitespace",
"=",
"False",
"return",
"self"
] | [
2440,
4
] | [
2447,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setWhitespaceChars | (self, chars) |
Overrides the default whitespace chars
|
Overrides the default whitespace chars
| def setWhitespaceChars(self, chars):
"""
Overrides the default whitespace chars
"""
self.skipWhitespace = True
self.whiteChars = chars
self.copyDefaultWhiteChars = False
return self | [
"def",
"setWhitespaceChars",
"(",
"self",
",",
"chars",
")",
":",
"self",
".",
"skipWhitespace",
"=",
"True",
"self",
".",
"whiteChars",
"=",
"chars",
"self",
".",
"copyDefaultWhiteChars",
"=",
"False",
"return",
"self"
] | [
2449,
4
] | [
2456,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.parseWithTabs | (self) |
Overrides default behavior to expand ``<TAB>``s to spaces before parsing the input string.
Must be called before ``parseString`` when the input grammar contains elements that
match ``<TAB>`` characters.
|
Overrides default behavior to expand ``<TAB>``s to spaces before parsing the input string.
Must be called before ``parseString`` when the input grammar contains elements that
match ``<TAB>`` characters.
| def parseWithTabs(self):
"""
Overrides default behavior to expand ``<TAB>``s to spaces before parsing the input string.
Must be called before ``parseString`` when the input grammar contains elements that
match ``<TAB>`` characters.
"""
self.keepTabs = True
return ... | [
"def",
"parseWithTabs",
"(",
"self",
")",
":",
"self",
".",
"keepTabs",
"=",
"True",
"return",
"self"
] | [
2458,
4
] | [
2465,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.ignore | (self, other) |
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns.
Example::
patt = OneOrMore(Word(alphas))
patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj'... |
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns. | def ignore(self, other):
"""
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns.
Example::
patt = OneOrMore(Word(alphas))
patt.parseString('ablaj... | [
"def",
"ignore",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"Suppress",
"(",
"other",
")",
"if",
"isinstance",
"(",
"other",
",",
"Suppress",
")",
":",
"if",
"other",
"not",
"in",... | [
2467,
4
] | [
2489,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setDebugActions | (self, startAction, successAction, exceptionAction) |
Enable display of debugging messages while doing pattern matching.
|
Enable display of debugging messages while doing pattern matching.
| def setDebugActions(self, startAction, successAction, exceptionAction):
"""
Enable display of debugging messages while doing pattern matching.
"""
self.debugActions = (startAction or _defaultStartDebugAction,
successAction or _defaultSuccessDebugAction,
... | [
"def",
"setDebugActions",
"(",
"self",
",",
"startAction",
",",
"successAction",
",",
"exceptionAction",
")",
":",
"self",
".",
"debugActions",
"=",
"(",
"startAction",
"or",
"_defaultStartDebugAction",
",",
"successAction",
"or",
"_defaultSuccessDebugAction",
",",
... | [
2491,
4
] | [
2499,
19
] | python | en | ['en', 'error', 'th'] | False |
ParserElement.setDebug | (self, flag=True) |
Enable display of debugging messages while doing pattern matching.
Set ``flag`` to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
term = wd | integer
# turn on debuggin... |
Enable display of debugging messages while doing pattern matching.
Set ``flag`` to True to enable, False to disable. | def setDebug(self, flag=True):
"""
Enable display of debugging messages while doing pattern matching.
Set ``flag`` to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
term = wd... | [
"def",
"setDebug",
"(",
"self",
",",
"flag",
"=",
"True",
")",
":",
"if",
"flag",
":",
"self",
".",
"setDebugActions",
"(",
"_defaultStartDebugAction",
",",
"_defaultSuccessDebugAction",
",",
"_defaultExceptionDebugAction",
")",
"else",
":",
"self",
".",
"debug"... | [
2501,
4
] | [
2542,
19
] | python | en | ['en', 'error', 'th'] | False |
_hash_dict | (d) | Return a stable sha224 of a dictionary. | Return a stable sha224 of a dictionary. | def _hash_dict(d):
# type: (Dict[str, str]) -> str
"""Return a stable sha224 of a dictionary."""
s = json.dumps(d, sort_keys=True, separators=(",", ":"), ensure_ascii=True)
return hashlib.sha224(s.encode("ascii")).hexdigest() | [
"def",
"_hash_dict",
"(",
"d",
")",
":",
"# type: (Dict[str, str]) -> str",
"s",
"=",
"json",
".",
"dumps",
"(",
"d",
",",
"sort_keys",
"=",
"True",
",",
"separators",
"=",
"(",
"\",\"",
",",
"\":\"",
")",
",",
"ensure_ascii",
"=",
"True",
")",
"return",... | [
22,
0
] | [
26,
56
] | python | en | ['en', 'en', 'en'] | True |
Cache._get_cache_path_parts | (self, link) | Get parts of part that must be os.path.joined with cache_dir
| Get parts of part that must be os.path.joined with cache_dir
| def _get_cache_path_parts(self, link):
# type: (Link) -> List[str]
"""Get parts of part that must be os.path.joined with cache_dir
"""
# We want to generate an url to use as our cache key, we don't want to
# just re-use the URL because it might have other items in the fragment
... | [
"def",
"_get_cache_path_parts",
"(",
"self",
",",
"link",
")",
":",
"# type: (Link) -> List[str]",
"# We want to generate an url to use as our cache key, we don't want to",
"# just re-use the URL because it might have other items in the fragment",
"# and we don't care about those.",
"key_par... | [
51,
4
] | [
84,
20
] | python | en | ['en', 'en', 'en'] | True |
Cache.get_path_for_link | (self, link) | Return a directory to store cached items in for link.
| Return a directory to store cached items in for link.
| def get_path_for_link(self, link):
# type: (Link) -> str
"""Return a directory to store cached items in for link.
"""
raise NotImplementedError() | [
"def",
"get_path_for_link",
"(",
"self",
",",
"link",
")",
":",
"# type: (Link) -> str",
"raise",
"NotImplementedError",
"(",
")"
] | [
109,
4
] | [
113,
35
] | python | en | ['en', 'en', 'en'] | True |
Cache.get | (
self,
link, # type: Link
package_name, # type: Optional[str]
supported_tags, # type: List[Tag]
) | Returns a link to a cached item if it exists, otherwise returns the
passed link.
| Returns a link to a cached item if it exists, otherwise returns the
passed link.
| def get(
self,
link, # type: Link
package_name, # type: Optional[str]
supported_tags, # type: List[Tag]
):
# type: (...) -> Link
"""Returns a link to a cached item if it exists, otherwise returns the
passed link.
"""
raise NotImp... | [
"def",
"get",
"(",
"self",
",",
"link",
",",
"# type: Link",
"package_name",
",",
"# type: Optional[str]",
"supported_tags",
",",
"# type: List[Tag]",
")",
":",
"# type: (...) -> Link",
"raise",
"NotImplementedError",
"(",
")"
] | [
115,
4
] | [
125,
35
] | python | en | ['en', 'en', 'en'] | True |
SimpleWheelCache.get_path_for_link | (self, link) | Return a directory to store cached wheels for link
Because there are M wheels for any one sdist, we provide a directory
to cache them in, and then consult that directory when looking up
cache hits.
We only insert things into the cache if they have plausible version
numbers, so ... | Return a directory to store cached wheels for link | def get_path_for_link(self, link):
# type: (Link) -> str
"""Return a directory to store cached wheels for link
Because there are M wheels for any one sdist, we provide a directory
to cache them in, and then consult that directory when looking up
cache hits.
We only inse... | [
"def",
"get_path_for_link",
"(",
"self",
",",
"link",
")",
":",
"# type: (Link) -> str",
"parts",
"=",
"self",
".",
"_get_cache_path_parts",
"(",
"link",
")",
"assert",
"self",
".",
"cache_dir",
"# Store wheels within the root cache_dir",
"return",
"os",
".",
"path"... | [
136,
4
] | [
155,
61
] | python | en | ['en', 'en', 'en'] | True |
WheelCache.get_cache_entry | (
self,
link, # type: Link
package_name, # type: Optional[str]
supported_tags, # type: List[Tag]
) | Returns a CacheEntry with a link to a cached item if it exists or
None. The cache entry indicates if the item was found in the persistent
or ephemeral cache.
| Returns a CacheEntry with a link to a cached item if it exists or
None. The cache entry indicates if the item was found in the persistent
or ephemeral cache.
| def get_cache_entry(
self,
link, # type: Link
package_name, # type: Optional[str]
supported_tags, # type: List[Tag]
):
# type: (...) -> Optional[CacheEntry]
"""Returns a CacheEntry with a link to a cached item if it exists or
None. The cache ent... | [
"def",
"get_cache_entry",
"(",
"self",
",",
"link",
",",
"# type: Link",
"package_name",
",",
"# type: Optional[str]",
"supported_tags",
",",
"# type: List[Tag]",
")",
":",
"# type: (...) -> Optional[CacheEntry]",
"retval",
"=",
"self",
".",
"_wheel_cache",
".",
"get",
... | [
259,
4
] | [
286,
19
] | python | en | ['en', 'en', 'en'] | True |
_mkdir_if_not_exist | (path) |
mkdir if not exists, ignore the exception when multiprocess mkdir together
|
mkdir if not exists, ignore the exception when multiprocess mkdir together
| def _mkdir_if_not_exist(path):
"""
mkdir if not exists, ignore the exception when multiprocess mkdir together
"""
if not os.path.exists(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno == errno.EEXIST and os.path.isdir(path):
logger.wa... | [
"def",
"_mkdir_if_not_exist",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"==",
"e... | [
31,
0
] | [
44,
64
] | python | en | ['en', 'error', 'th'] | False |
load_params | (exe, prog, path, ignore_params=None) |
Load model from the given path.
Args:
exe (fluid.Executor): The fluid.Executor object.
prog (fluid.Program): load weight to which Program object.
path (string): URL string or loca model path.
ignore_params (list): ignore variable to load when finetuning.
It can be sp... |
Load model from the given path.
Args:
exe (fluid.Executor): The fluid.Executor object.
prog (fluid.Program): load weight to which Program object.
path (string): URL string or loca model path.
ignore_params (list): ignore variable to load when finetuning.
It can be sp... | def load_params(exe, prog, path, ignore_params=None):
"""
Load model from the given path.
Args:
exe (fluid.Executor): The fluid.Executor object.
prog (fluid.Program): load weight to which Program object.
path (string): URL string or loca model path.
ignore_params (list): igno... | [
"def",
"load_params",
"(",
"exe",
",",
"prog",
",",
"path",
",",
"ignore_params",
"=",
"None",
")",
":",
"if",
"not",
"(",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
"or",
"os",
".",
"path",
".",
"exists",
"(",
"path",
"+",
"'.pdparams'",
... | [
60,
0
] | [
108,
48
] | python | en | ['en', 'error', 'th'] | False |
init_model | (config, program, exe) |
load model from checkpoint or pretrained_model
|
load model from checkpoint or pretrained_model
| def init_model(config, program, exe):
"""
load model from checkpoint or pretrained_model
"""
checkpoints = config.get('checkpoints')
if checkpoints:
paddle.static.load(program, checkpoints, exe)
logger.info(
logger.coloring("Finish initing model from {}".format(checkpoint... | [
"def",
"init_model",
"(",
"config",
",",
"program",
",",
"exe",
")",
":",
"checkpoints",
"=",
"config",
".",
"get",
"(",
"'checkpoints'",
")",
"if",
"checkpoints",
":",
"paddle",
".",
"static",
".",
"load",
"(",
"program",
",",
"checkpoints",
",",
"exe",... | [
111,
0
] | [
131,
45
] | python | en | ['en', 'error', 'th'] | False |
save_model | (program, model_path, epoch_id, prefix='ppcls') |
save model to the target path
|
save model to the target path
| def save_model(program, model_path, epoch_id, prefix='ppcls'):
"""
save model to the target path
"""
model_path = os.path.join(model_path, str(epoch_id))
_mkdir_if_not_exist(model_path)
model_prefix = os.path.join(model_path, prefix)
paddle.static.save(program, model_prefix)
logger.info(... | [
"def",
"save_model",
"(",
"program",
",",
"model_path",
",",
"epoch_id",
",",
"prefix",
"=",
"'ppcls'",
")",
":",
"model_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"model_path",
",",
"str",
"(",
"epoch_id",
")",
")",
"_mkdir_if_not_exist",
"(",
"mo... | [
134,
0
] | [
144,
34
] | python | en | ['en', 'error', 'th'] | False |
Requirement.project_name | (self) | The "project name" of a requirement.
This is different from ``name`` if this requirement contains extras,
in which case ``name`` would contain the ``[...]`` part, while this
refers to the name of the project.
| The "project name" of a requirement. | def project_name(self) -> NormalizedName:
"""The "project name" of a requirement.
This is different from ``name`` if this requirement contains extras,
in which case ``name`` would contain the ``[...]`` part, while this
refers to the name of the project.
"""
raise NotImpl... | [
"def",
"project_name",
"(",
"self",
")",
"->",
"NormalizedName",
":",
"raise",
"NotImplementedError",
"(",
"\"Subclass should override\"",
")"
] | [
66,
4
] | [
73,
61
] | python | en | ['en', 'en', 'en'] | True |
Requirement.name | (self) | The name identifying this requirement in the resolver.
This is different from ``project_name`` if this requirement contains
extras, where ``project_name`` would not contain the ``[...]`` part.
| The name identifying this requirement in the resolver. | def name(self) -> str:
"""The name identifying this requirement in the resolver.
This is different from ``project_name`` if this requirement contains
extras, where ``project_name`` would not contain the ``[...]`` part.
"""
raise NotImplementedError("Subclass should override") | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"raise",
"NotImplementedError",
"(",
"\"Subclass should override\"",
")"
] | [
76,
4
] | [
82,
61
] | python | en | ['en', 'en', 'en'] | True |
Candidate.project_name | (self) | The "project name" of the candidate.
This is different from ``name`` if this candidate contains extras,
in which case ``name`` would contain the ``[...]`` part, while this
refers to the name of the project.
| The "project name" of the candidate. | def project_name(self) -> NormalizedName:
"""The "project name" of the candidate.
This is different from ``name`` if this candidate contains extras,
in which case ``name`` would contain the ``[...]`` part, while this
refers to the name of the project.
"""
raise NotImplem... | [
"def",
"project_name",
"(",
"self",
")",
"->",
"NormalizedName",
":",
"raise",
"NotImplementedError",
"(",
"\"Override in subclass\"",
")"
] | [
102,
4
] | [
109,
57
] | python | en | ['en', 'en', 'en'] | True |
Candidate.name | (self) | The name identifying this candidate in the resolver.
This is different from ``project_name`` if this candidate contains
extras, where ``project_name`` would not contain the ``[...]`` part.
| The name identifying this candidate in the resolver. | def name(self) -> str:
"""The name identifying this candidate in the resolver.
This is different from ``project_name`` if this candidate contains
extras, where ``project_name`` would not contain the ``[...]`` part.
"""
raise NotImplementedError("Override in subclass") | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"raise",
"NotImplementedError",
"(",
"\"Override in subclass\"",
")"
] | [
112,
4
] | [
118,
57
] | python | en | ['en', 'en', 'en'] | True |
ListFilter.has_output | (self) |
Return True if some choices would be output for this filter.
|
Return True if some choices would be output for this filter.
| def has_output(self):
"""
Return True if some choices would be output for this filter.
"""
raise NotImplementedError('subclasses of ListFilter must provide a has_output() method') | [
"def",
"has_output",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of ListFilter must provide a has_output() method'",
")"
] | [
33,
4
] | [
37,
96
] | python | en | ['en', 'error', 'th'] | False |
ListFilter.choices | (self, changelist) |
Return choices ready to be output in the template.
`changelist` is the ChangeList to be displayed.
|
Return choices ready to be output in the template. | def choices(self, changelist):
"""
Return choices ready to be output in the template.
`changelist` is the ChangeList to be displayed.
"""
raise NotImplementedError('subclasses of ListFilter must provide a choices() method') | [
"def",
"choices",
"(",
"self",
",",
"changelist",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of ListFilter must provide a choices() method'",
")"
] | [
39,
4
] | [
45,
93
] | python | en | ['en', 'error', 'th'] | False |
ListFilter.queryset | (self, request, queryset) |
Return the filtered queryset.
|
Return the filtered queryset.
| def queryset(self, request, queryset):
"""
Return the filtered queryset.
"""
raise NotImplementedError('subclasses of ListFilter must provide a queryset() method') | [
"def",
"queryset",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of ListFilter must provide a queryset() method'",
")"
] | [
47,
4
] | [
51,
94
] | python | en | ['en', 'error', 'th'] | False |
ListFilter.expected_parameters | (self) |
Return the list of parameter names that are expected from the
request's query string and that will be used by this filter.
|
Return the list of parameter names that are expected from the
request's query string and that will be used by this filter.
| def expected_parameters(self):
"""
Return the list of parameter names that are expected from the
request's query string and that will be used by this filter.
"""
raise NotImplementedError('subclasses of ListFilter must provide an expected_parameters() method') | [
"def",
"expected_parameters",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of ListFilter must provide an expected_parameters() method'",
")"
] | [
53,
4
] | [
58,
106
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.