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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Evaluator.__len__ | (self) | Returns number of recorded attempts. | Returns number of recorded attempts. | def __len__(self) -> int:
"""Returns number of recorded attempts."""
return len(self._log) | [
"def",
"__len__",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"self",
".",
"_log",
")"
] | [
531,
4
] | [
533,
29
] | python | en | ['en', 'en', 'en'] | True |
Agent.add_parser_arguments | (cls, parser: "argparse.ArgumentParser") | Add agent's parameters to the argument parser. | Add agent's parameters to the argument parser. | def add_parser_arguments(cls, parser: "argparse.ArgumentParser") -> None:
"""Add agent's parameters to the argument parser."""
del parser | [
"def",
"add_parser_arguments",
"(",
"cls",
",",
"parser",
":",
"\"argparse.ArgumentParser\"",
")",
"->",
"None",
":",
"del",
"parser"
] | [
70,
4
] | [
72,
18
] | python | en | ['en', 'en', 'en'] | True |
Agent.name | (cls) | Name of the agent for --agent flag. | Name of the agent for --agent flag. | def name(cls) -> str:
"""Name of the agent for --agent flag."""
name = cls.__name__
if name.endswith('Agent'):
name = name[:-5]
return name.lower() | [
"def",
"name",
"(",
"cls",
")",
"->",
"str",
":",
"name",
"=",
"cls",
".",
"__name__",
"if",
"name",
".",
"endswith",
"(",
"'Agent'",
")",
":",
"name",
"=",
"name",
"[",
":",
"-",
"5",
"]",
"return",
"name",
".",
"lower",
"(",
")"
] | [
75,
4
] | [
80,
27
] | python | en | ['en', 'en', 'en'] | True |
Agent.train | (cls, task_ids: TaskIds, action_tier_name: str,
**kwargs) | Train an agent and returns a state. | Train an agent and returns a state. | def train(cls, task_ids: TaskIds, action_tier_name: str,
**kwargs) -> State:
"""Train an agent and returns a state.""" | [
"def",
"train",
"(",
"cls",
",",
"task_ids",
":",
"TaskIds",
",",
"action_tier_name",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"State",
":"
] | [
84,
4
] | [
86,
49
] | python | en | ['en', 'en', 'en'] | True |
Agent.eval | (cls, state: State, task_ids: TaskIds, max_attempts_per_task: int,
action_tier_name, **kwargs) | Runs evaluation and logs all attemps with phyre.Evaluator. | Runs evaluation and logs all attemps with phyre.Evaluator. | def eval(cls, state: State, task_ids: TaskIds, max_attempts_per_task: int,
action_tier_name, **kwargs) -> phyre.Evaluator:
"""Runs evaluation and logs all attemps with phyre.Evaluator.""" | [
"def",
"eval",
"(",
"cls",
",",
"state",
":",
"State",
",",
"task_ids",
":",
"TaskIds",
",",
"max_attempts_per_task",
":",
"int",
",",
"action_tier_name",
",",
"*",
"*",
"kwargs",
")",
"->",
"phyre",
".",
"Evaluator",
":"
] | [
89,
4
] | [
91,
72
] | python | en | ['en', 'en', 'en'] | True |
MaxHeapWithSideLoad.pop_key | (self, key) | Remove key from the heap. | Remove key from the heap. | def pop_key(self, key):
"""Remove key from the heap."""
entry = self.key_to_entry[key]
del self.key_to_entry[key]
entry[-1] = 0
return entry[1], -entry[0] | [
"def",
"pop_key",
"(",
"self",
",",
"key",
")",
":",
"entry",
"=",
"self",
".",
"key_to_entry",
"[",
"key",
"]",
"del",
"self",
".",
"key_to_entry",
"[",
"key",
"]",
"entry",
"[",
"-",
"1",
"]",
"=",
"0",
"return",
"entry",
"[",
"1",
"]",
",",
... | [
133,
4
] | [
138,
34
] | python | en | ['en', 'en', 'en'] | True |
MaxHeapWithSideLoad.push | (self, key, priority) | Push a new key into the heap. | Push a new key into the heap. | def push(self, key, priority):
"""Push a new key into the heap."""
assert key not in self.key_to_entry, key
entry = [-priority, key, 1]
self.key_to_entry[key] = entry
heapq.heappush(self.heap, entry) | [
"def",
"push",
"(",
"self",
",",
"key",
",",
"priority",
")",
":",
"assert",
"key",
"not",
"in",
"self",
".",
"key_to_entry",
",",
"key",
"entry",
"=",
"[",
"-",
"priority",
",",
"key",
",",
"1",
"]",
"self",
".",
"key_to_entry",
"[",
"key",
"]",
... | [
140,
4
] | [
145,
40
] | python | en | ['en', 'mg', 'en'] | True |
MaxHeapWithSideLoad.pop_max | (self) | Get (key, priority) pair with the highest priority. | Get (key, priority) pair with the highest priority. | def pop_max(self):
"""Get (key, priority) pair with the highest priority."""
while True:
priority, key, is_valid = heapq.heappop(self.heap)
if not is_valid:
continue
del self.key_to_entry[key]
return key, -priority | [
"def",
"pop_max",
"(",
"self",
")",
":",
"while",
"True",
":",
"priority",
",",
"key",
",",
"is_valid",
"=",
"heapq",
".",
"heappop",
"(",
"self",
".",
"heap",
")",
"if",
"not",
"is_valid",
":",
"continue",
"del",
"self",
".",
"key_to_entry",
"[",
"k... | [
147,
4
] | [
154,
33
] | python | en | ['en', 'en', 'en'] | True |
MaxHeapWithSideLoad.copy | (self) | Create a clone of the queue. | Create a clone of the queue. | def copy(self):
"""Create a clone of the queue."""
return MaxHeapWithSideLoad([[k, -v] for v, k, is_valid in self.heap
if is_valid]) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"MaxHeapWithSideLoad",
"(",
"[",
"[",
"k",
",",
"-",
"v",
"]",
"for",
"v",
",",
"k",
",",
"is_valid",
"in",
"self",
".",
"heap",
"if",
"is_valid",
"]",
")"
] | [
156,
4
] | [
159,
49
] | python | en | ['en', 'en', 'en'] | True |
DQNAgent._extract_prefix_flags | (cls, prefix='dqn_', **kwargs) | Extract DQN-related train and test command line flags. | Extract DQN-related train and test command line flags. | def _extract_prefix_flags(cls, prefix='dqn_', **kwargs):
"""Extract DQN-related train and test command line flags."""
train_kwargs, eval_kwargs = {}, {}
for k, v in kwargs.items():
if k.startswith(prefix):
flag = k.split('_', 1)[1]
if flag in cls.EVAL_... | [
"def",
"_extract_prefix_flags",
"(",
"cls",
",",
"prefix",
"=",
"'dqn_'",
",",
"*",
"*",
"kwargs",
")",
":",
"train_kwargs",
",",
"eval_kwargs",
"=",
"{",
"}",
",",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
... | [
471,
4
] | [
482,
40
] | python | en | ['en', 'en', 'en'] | True |
FwdAgent.print_pixel_accs_summary | (cls, pxl_accs_lst, phyre_movable_ch) |
Print out the accuracy for each class, avg over moving class etc
Args:
pxl_accs_lst: List with each element (B, phyre.NUM_CLASSES)
phyre_movable_ch: The channels in phyre for movable objs
|
Print out the accuracy for each class, avg over moving class etc
Args:
pxl_accs_lst: List with each element (B, phyre.NUM_CLASSES)
phyre_movable_ch: The channels in phyre for movable objs
| def print_pixel_accs_summary(cls, pxl_accs_lst, phyre_movable_ch):
"""
Print out the accuracy for each class, avg over moving class etc
Args:
pxl_accs_lst: List with each element (B, phyre.NUM_CLASSES)
phyre_movable_ch: The channels in phyre for movable objs
"""
... | [
"def",
"print_pixel_accs_summary",
"(",
"cls",
",",
"pxl_accs_lst",
",",
"phyre_movable_ch",
")",
":",
"pxl_accs",
"=",
"np",
".",
"concatenate",
"(",
"pxl_accs_lst",
",",
"axis",
"=",
"0",
")",
"logging",
".",
"info",
"(",
"'Pixel accuracies for each color: %s'",... | [
602,
4
] | [
615,
41
] | python | en | ['en', 'error', 'th'] | False |
FwdAgent.read_actions_override | (cls, action_str) |
Parse the action string into a list
Format is x1:y1:r1::x2:y2:r2:: .. so on
|
Parse the action string into a list
Format is x1:y1:r1::x2:y2:r2:: .. so on
| def read_actions_override(cls, action_str):
"""
Parse the action string into a list
Format is x1:y1:r1::x2:y2:r2:: .. so on
"""
return [[float(el) for el in action.split(':')]
for action in action_str.split('::')] | [
"def",
"read_actions_override",
"(",
"cls",
",",
"action_str",
")",
":",
"return",
"[",
"[",
"float",
"(",
"el",
")",
"for",
"el",
"in",
"action",
".",
"split",
"(",
"':'",
")",
"]",
"for",
"action",
"in",
"action_str",
".",
"split",
"(",
"'::'",
")"... | [
618,
4
] | [
624,
53
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_table_list | (self, cursor) | Return a list of table and view names in the current database. | Return a list of table and view names in the current database. | def get_table_list(self, cursor):
"""Return a list of table and view names in the current database."""
cursor.execute("""
SELECT c.relname,
CASE WHEN {} THEN 'p' WHEN c.relkind IN ('m', 'v') THEN 'v' ELSE 't' END
FROM pg_catalog.pg_class c
LEFT JOIN pg_cat... | [
"def",
"get_table_list",
"(",
"self",
",",
"cursor",
")",
":",
"cursor",
".",
"execute",
"(",
"\"\"\"\n SELECT c.relname,\n CASE WHEN {} THEN 'p' WHEN c.relkind IN ('m', 'v') THEN 'v' ELSE 't' END\n FROM pg_catalog.pg_class c\n LEFT JOIN pg_catalog... | [
46,
4
] | [
57,
98
] | python | en | ['en', 'en', 'en'] | True |
DatabaseIntrospection.get_table_description | (self, cursor, table_name) |
Return a description of the table with the DB-API cursor.description
interface.
|
Return a description of the table with the DB-API cursor.description
interface.
| def get_table_description(self, cursor, table_name):
"""
Return a description of the table with the DB-API cursor.description
interface.
"""
# Query the pg_catalog tables as cursor.description does not reliably
# return the nullable property and information_schema.columns... | [
"def",
"get_table_description",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"# Query the pg_catalog tables as cursor.description does not reliably",
"# return the nullable property and information_schema.columns does not",
"# contain details of materialized views.",
"cursor",
... | [
59,
4
] | [
97,
9
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_relations | (self, cursor, table_name) |
Return a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
|
Return a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
| def get_relations(self, cursor, table_name):
"""
Return a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
"""
return {row[0]: (row[2], row[1]) for row in self.get_key_columns(cursor, table_name)} | [
"def",
"get_relations",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"return",
"{",
"row",
"[",
"0",
"]",
":",
"(",
"row",
"[",
"2",
"]",
",",
"row",
"[",
"1",
"]",
")",
"for",
"row",
"in",
"self",
".",
"get_key_columns",
"(",
"cursor... | [
118,
4
] | [
123,
93
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_constraints | (self, cursor, table_name) |
Retrieve any constraints or keys (unique, pk, fk, check, index) across
one or more columns. Also retrieve the definition of expression-based
indexes.
|
Retrieve any constraints or keys (unique, pk, fk, check, index) across
one or more columns. Also retrieve the definition of expression-based
indexes.
| def get_constraints(self, cursor, table_name):
"""
Retrieve any constraints or keys (unique, pk, fk, check, index) across
one or more columns. Also retrieve the definition of expression-based
indexes.
"""
constraints = {}
# Loop over the key table, collecting thin... | [
"def",
"get_constraints",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"constraints",
"=",
"{",
"}",
"# Loop over the key table, collecting things as constraints. The column",
"# array must return column names in the same order in which they were",
"# created.",
"cursor... | [
141,
4
] | [
233,
26
] | python | en | ['en', 'error', 'th'] | False |
_normalize_mode | (im, initial_call=False) |
Takes an image (or frame), returns an image in a mode that is appropriate
for saving in a Gif.
It may return the original image, or it may return an image converted to
palette or 'L' mode.
UNDONE: What is the point of mucking with the initial call palette, for
an image that shouldn't have a p... |
Takes an image (or frame), returns an image in a mode that is appropriate
for saving in a Gif. | def _normalize_mode(im, initial_call=False):
"""
Takes an image (or frame), returns an image in a mode that is appropriate
for saving in a Gif.
It may return the original image, or it may return an image converted to
palette or 'L' mode.
UNDONE: What is the point of mucking with the initial ca... | [
"def",
"_normalize_mode",
"(",
"im",
",",
"initial_call",
"=",
"False",
")",
":",
"if",
"im",
".",
"mode",
"in",
"RAWMODE",
":",
"im",
".",
"load",
"(",
")",
"return",
"im",
"if",
"Image",
".",
"getmodebase",
"(",
"im",
".",
"mode",
")",
"==",
"\"R... | [
350,
0
] | [
377,
26
] | python | en | ['en', 'error', 'th'] | False |
_normalize_palette | (im, palette, info) |
Normalizes the palette for image.
- Sets the palette to the incoming palette, if provided.
- Ensures that there's a palette for L mode images
- Optimizes the palette if necessary/desired.
:param im: Image object
:param palette: bytes object containing the source palette, or ....
:par... |
Normalizes the palette for image.
- Sets the palette to the incoming palette, if provided.
- Ensures that there's a palette for L mode images
- Optimizes the palette if necessary/desired. | def _normalize_palette(im, palette, info):
"""
Normalizes the palette for image.
- Sets the palette to the incoming palette, if provided.
- Ensures that there's a palette for L mode images
- Optimizes the palette if necessary/desired.
:param im: Image object
:param palette: bytes obje... | [
"def",
"_normalize_palette",
"(",
"im",
",",
"palette",
",",
"info",
")",
":",
"source_palette",
"=",
"None",
"if",
"palette",
":",
"# a bytes palette",
"if",
"isinstance",
"(",
"palette",
",",
"(",
"bytes",
",",
"bytearray",
",",
"list",
")",
")",
":",
... | [
380,
0
] | [
413,
13
] | python | en | ['en', 'error', 'th'] | False |
_get_optimize | (im, info) |
Palette optimization is a potentially expensive operation.
This function determines if the palette should be optimized using
some heuristics, then returns the list of palette entries in use.
:param im: Image object
:param info: encoderinfo
:returns: list of indexes of palette entries in use, ... |
Palette optimization is a potentially expensive operation. | def _get_optimize(im, info):
"""
Palette optimization is a potentially expensive operation.
This function determines if the palette should be optimized using
some heuristics, then returns the list of palette entries in use.
:param im: Image object
:param info: encoderinfo
:returns: list of... | [
"def",
"_get_optimize",
"(",
"im",
",",
"info",
")",
":",
"if",
"im",
".",
"mode",
"in",
"(",
"\"P\"",
",",
"\"L\"",
")",
"and",
"info",
"and",
"info",
".",
"get",
"(",
"\"optimize\"",
",",
"0",
")",
":",
"# Potentially expensive operation.",
"# The pale... | [
682,
0
] | [
716,
42
] | python | en | ['en', 'error', 'th'] | False |
_get_header_palette | (palette_bytes) |
Returns the palette, null padded to the next power of 2 (*3) bytes
suitable for direct inclusion in the GIF header
:param palette_bytes: Unpadded palette bytes, in RGBRGB form
:returns: Null padded palette
|
Returns the palette, null padded to the next power of 2 (*3) bytes
suitable for direct inclusion in the GIF header | def _get_header_palette(palette_bytes):
"""
Returns the palette, null padded to the next power of 2 (*3) bytes
suitable for direct inclusion in the GIF header
:param palette_bytes: Unpadded palette bytes, in RGBRGB form
:returns: Null padded palette
"""
color_table_size = _get_color_table_s... | [
"def",
"_get_header_palette",
"(",
"palette_bytes",
")",
":",
"color_table_size",
"=",
"_get_color_table_size",
"(",
"palette_bytes",
")",
"# add the missing amount of bytes",
"# the palette has to be 2<<n in size",
"actual_target_size_diff",
"=",
"(",
"2",
"<<",
"color_table_s... | [
729,
0
] | [
744,
24
] | python | en | ['en', 'error', 'th'] | False |
_get_palette_bytes | (im) |
Gets the palette for inclusion in the gif header
:param im: Image object
:returns: Bytes, len<=768 suitable for inclusion in gif header
|
Gets the palette for inclusion in the gif header | def _get_palette_bytes(im):
"""
Gets the palette for inclusion in the gif header
:param im: Image object
:returns: Bytes, len<=768 suitable for inclusion in gif header
"""
return im.palette.palette | [
"def",
"_get_palette_bytes",
"(",
"im",
")",
":",
"return",
"im",
".",
"palette",
".",
"palette"
] | [
747,
0
] | [
754,
29
] | python | en | ['en', 'error', 'th'] | False |
_get_global_header | (im, info) | Return a list of strings representing a GIF header | Return a list of strings representing a GIF header | def _get_global_header(im, info):
"""Return a list of strings representing a GIF header"""
# Header Block
# http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp
version = b"87a"
for extensionKey in ["transparency", "duration", "loop", "comment"]:
if info and extensionKey in ... | [
"def",
"_get_global_header",
"(",
"im",
",",
"info",
")",
":",
"# Header Block",
"# http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp",
"version",
"=",
"b\"87a\"",
"for",
"extensionKey",
"in",
"[",
"\"transparency\"",
",",
"\"duration\"",
",",
"\"loop\"",
... | [
777,
0
] | [
813,
5
] | python | en | ['en', 'en', 'en'] | True |
getheader | (im, palette=None, info=None) |
Legacy Method to get Gif data from image.
Warning:: May modify image data.
:param im: Image object
:param palette: bytes object containing the source palette, or ....
:param info: encoderinfo
:returns: tuple of(list of header items, optimized palette)
|
Legacy Method to get Gif data from image. | def getheader(im, palette=None, info=None):
"""
Legacy Method to get Gif data from image.
Warning:: May modify image data.
:param im: Image object
:param palette: bytes object containing the source palette, or ....
:param info: encoderinfo
:returns: tuple of(list of header items, optimized... | [
"def",
"getheader",
"(",
"im",
",",
"palette",
"=",
"None",
",",
"info",
"=",
"None",
")",
":",
"used_palette_colors",
"=",
"_get_optimize",
"(",
"im",
",",
"info",
")",
"if",
"info",
"is",
"None",
":",
"info",
"=",
"{",
"}",
"if",
"\"background\"",
... | [
836,
0
] | [
861,
38
] | python | en | ['en', 'error', 'th'] | False |
getdata | (im, offset=(0, 0), **params) |
Legacy Method
Return a list of strings representing this image.
The first string is a local image header, the rest contains
encoded image data.
:param im: Image object
:param offset: Tuple of (x, y) pixels. Defaults to (0,0)
:param \\**params: E.g. duration or other encoder info parameter... |
Legacy Method | def getdata(im, offset=(0, 0), **params):
"""
Legacy Method
Return a list of strings representing this image.
The first string is a local image header, the rest contains
encoded image data.
:param im: Image object
:param offset: Tuple of (x, y) pixels. Defaults to (0,0)
:param \\**para... | [
"def",
"getdata",
"(",
"im",
",",
"offset",
"=",
"(",
"0",
",",
"0",
")",
",",
"*",
"*",
"params",
")",
":",
"class",
"Collector",
":",
"data",
"=",
"[",
"]",
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"data",
".",
"appe... | [
866,
0
] | [
893,
18
] | python | en | ['en', 'error', 'th'] | False |
LogEntry.get_change_message | (self) |
If self.change_message is a JSON structure, interpret it as a change
string, properly translated.
|
If self.change_message is a JSON structure, interpret it as a change
string, properly translated.
| def get_change_message(self):
"""
If self.change_message is a JSON structure, interpret it as a change
string, properly translated.
"""
if self.change_message and self.change_message[0] == '[':
try:
change_message = json.loads(self.change_message)
... | [
"def",
"get_change_message",
"(",
"self",
")",
":",
"if",
"self",
".",
"change_message",
"and",
"self",
".",
"change_message",
"[",
"0",
"]",
"==",
"'['",
":",
"try",
":",
"change_message",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"change_message",
"... | [
95,
4
] | [
133,
38
] | python | en | ['en', 'error', 'th'] | False |
LogEntry.get_edited_object | (self) | Return the edited object represented by this log entry. | Return the edited object represented by this log entry. | def get_edited_object(self):
"""Return the edited object represented by this log entry."""
return self.content_type.get_object_for_this_type(pk=self.object_id) | [
"def",
"get_edited_object",
"(",
"self",
")",
":",
"return",
"self",
".",
"content_type",
".",
"get_object_for_this_type",
"(",
"pk",
"=",
"self",
".",
"object_id",
")"
] | [
135,
4
] | [
137,
76
] | python | en | ['en', 'en', 'en'] | True |
LogEntry.get_admin_url | (self) |
Return the admin URL to edit the object represented by this log entry.
|
Return the admin URL to edit the object represented by this log entry.
| def get_admin_url(self):
"""
Return the admin URL to edit the object represented by this log entry.
"""
if self.content_type and self.object_id:
url_name = 'admin:%s_%s_change' % (self.content_type.app_label, self.content_type.model)
try:
return re... | [
"def",
"get_admin_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"content_type",
"and",
"self",
".",
"object_id",
":",
"url_name",
"=",
"'admin:%s_%s_change'",
"%",
"(",
"self",
".",
"content_type",
".",
"app_label",
",",
"self",
".",
"content_type",
".",
... | [
139,
4
] | [
149,
19
] | python | en | ['en', 'error', 'th'] | False |
glibc_version_string | () | Returns glibc version string, or None if not using glibc. | Returns glibc version string, or None if not using glibc. | def glibc_version_string():
"Returns glibc version string, or None if not using glibc."
# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
# manpage says, "If filename is NULL, then the returned handle is for the
# main program". This way we can let the linker do the work to figure ou... | [
"def",
"glibc_version_string",
"(",
")",
":",
"# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen",
"# manpage says, \"If filename is NULL, then the returned handle is for the",
"# main program\". This way we can let the linker do the work to figure out",
"# which libc our process ... | [
9,
0
] | [
31,
22
] | python | en | ['en', 'en', 'en'] | True |
libc_ver | () | Try to determine the glibc version
Returns a tuple of strings (lib, version) which default to empty strings
in case the lookup fails.
| Try to determine the glibc version | def libc_ver():
"""Try to determine the glibc version
Returns a tuple of strings (lib, version) which default to empty strings
in case the lookup fails.
"""
glibc_version = glibc_version_string()
if glibc_version is None:
return ("", "")
else:
return ("glibc", glibc_version) | [
"def",
"libc_ver",
"(",
")",
":",
"glibc_version",
"=",
"glibc_version_string",
"(",
")",
"if",
"glibc_version",
"is",
"None",
":",
"return",
"(",
"\"\"",
",",
"\"\"",
")",
"else",
":",
"return",
"(",
"\"glibc\"",
",",
"glibc_version",
")"
] | [
75,
0
] | [
85,
39
] | python | en | ['en', 'en', 'en'] | True |
handle_recording | () | Play back the caller's recording. | Play back the caller's recording. | def handle_recording():
"""Play back the caller's recording."""
recording_url = request.values.get("RecordingUrl", None)
resp = VoiceResponse()
resp.say("Listen to your recorded message.")
resp.play(recording_url)
resp.say("Goodbye.")
return str(resp) | [
"def",
"handle_recording",
"(",
")",
":",
"recording_url",
"=",
"request",
".",
"values",
".",
"get",
"(",
"\"RecordingUrl\"",
",",
"None",
")",
"resp",
"=",
"VoiceResponse",
"(",
")",
"resp",
".",
"say",
"(",
"\"Listen to your recorded message.\"",
")",
"resp... | [
8,
0
] | [
17,
20
] | python | en | ['en', 'en', 'en'] | True |
sms_reply | () | Respond to incoming calls with a simple text message. | Respond to incoming calls with a simple text message. | def sms_reply():
"""Respond to incoming calls with a simple text message."""
# Start our TwiML response
resp = MessagingResponse()
# Add a message
resp.message("The Robots are coming! Head for the hills!")
return str(resp) | [
"def",
"sms_reply",
"(",
")",
":",
"# Start our TwiML response",
"resp",
"=",
"MessagingResponse",
"(",
")",
"# Add a message",
"resp",
".",
"message",
"(",
"\"The Robots are coming! Head for the hills!\"",
")",
"return",
"str",
"(",
"resp",
")"
] | [
6,
0
] | [
14,
20
] | python | en | ['en', 'en', 'en'] | True |
get_voice_twiml | () | Respond to incoming calls with a simple text message. | Respond to incoming calls with a simple text message. | def get_voice_twiml():
"""Respond to incoming calls with a simple text message."""
resp = VoiceResponse()
if "To" in request.form:
resp.dial(request.form["To"], caller_id="+15017122661")
else:
resp.say("Thanks for calling!")
return Response(str(resp), mimetype='text/xml') | [
"def",
"get_voice_twiml",
"(",
")",
":",
"resp",
"=",
"VoiceResponse",
"(",
")",
"if",
"\"To\"",
"in",
"request",
".",
"form",
":",
"resp",
".",
"dial",
"(",
"request",
".",
"form",
"[",
"\"To\"",
"]",
",",
"caller_id",
"=",
"\"+15017122661\"",
")",
"e... | [
7,
0
] | [
16,
51
] | python | en | ['en', 'en', 'en'] | True |
PrettyHelpFormatter._format_option_strings | (
self, option: optparse.Option, mvarfmt: str = " <{}>", optsep: str = ", "
) |
Return a comma-separated list of option strings and metavars.
:param option: tuple of (short opt, long opt), e.g: ('-f', '--format')
:param mvarfmt: metavar format string
:param optsep: separator
|
Return a comma-separated list of option strings and metavars. | def _format_option_strings(
self, option: optparse.Option, mvarfmt: str = " <{}>", optsep: str = ", "
) -> str:
"""
Return a comma-separated list of option strings and metavars.
:param option: tuple of (short opt, long opt), e.g: ('-f', '--format')
:param mvarfmt: metavar f... | [
"def",
"_format_option_strings",
"(",
"self",
",",
"option",
":",
"optparse",
".",
"Option",
",",
"mvarfmt",
":",
"str",
"=",
"\" <{}>\"",
",",
"optsep",
":",
"str",
"=",
"\", \"",
")",
"->",
"str",
":",
"opts",
"=",
"[",
"]",
"if",
"option",
".",
"_... | [
30,
4
] | [
54,
28
] | python | en | ['en', 'error', 'th'] | False |
PrettyHelpFormatter.format_usage | (self, usage: str) |
Ensure there is only one newline between usage and the first heading
if there is no description.
|
Ensure there is only one newline between usage and the first heading
if there is no description.
| def format_usage(self, usage: str) -> str:
"""
Ensure there is only one newline between usage and the first heading
if there is no description.
"""
msg = "\nUsage: {}\n".format(self.indent_lines(textwrap.dedent(usage), " "))
return msg | [
"def",
"format_usage",
"(",
"self",
",",
"usage",
":",
"str",
")",
"->",
"str",
":",
"msg",
"=",
"\"\\nUsage: {}\\n\"",
".",
"format",
"(",
"self",
".",
"indent_lines",
"(",
"textwrap",
".",
"dedent",
"(",
"usage",
")",
",",
"\" \"",
")",
")",
"return... | [
61,
4
] | [
67,
18
] | python | en | ['en', 'error', 'th'] | False |
CustomOptionParser.insert_option_group | (
self, idx: int, *args: Any, **kwargs: Any
) | Insert an OptionGroup at a given position. | Insert an OptionGroup at a given position. | def insert_option_group(
self, idx: int, *args: Any, **kwargs: Any
) -> optparse.OptionGroup:
"""Insert an OptionGroup at a given position."""
group = self.add_option_group(*args, **kwargs)
self.option_groups.pop()
self.option_groups.insert(idx, group)
return group | [
"def",
"insert_option_group",
"(",
"self",
",",
"idx",
":",
"int",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"optparse",
".",
"OptionGroup",
":",
"group",
"=",
"self",
".",
"add_option_group",
"(",
"*",
"args",
","... | [
132,
4
] | [
141,
20
] | python | en | ['en', 'en', 'en'] | True |
CustomOptionParser.option_list_all | (self) | Get a list of all options, including those in option groups. | Get a list of all options, including those in option groups. | def option_list_all(self) -> List[optparse.Option]:
"""Get a list of all options, including those in option groups."""
res = self.option_list[:]
for i in self.option_groups:
res.extend(i.option_list)
return res | [
"def",
"option_list_all",
"(",
"self",
")",
"->",
"List",
"[",
"optparse",
".",
"Option",
"]",
":",
"res",
"=",
"self",
".",
"option_list",
"[",
":",
"]",
"for",
"i",
"in",
"self",
".",
"option_groups",
":",
"res",
".",
"extend",
"(",
"i",
".",
"op... | [
144,
4
] | [
150,
18
] | python | en | ['en', 'en', 'en'] | True |
ConfigOptionParser._update_defaults | (self, defaults: Dict[str, Any]) | Updates the given defaults with values from the config files and
the environ. Does a little special handling for certain types of
options (lists). | Updates the given defaults with values from the config files and
the environ. Does a little special handling for certain types of
options (lists). | def _update_defaults(self, defaults: Dict[str, Any]) -> Dict[str, Any]:
"""Updates the given defaults with values from the config files and
the environ. Does a little special handling for certain types of
options (lists)."""
# Accumulate complex default state.
self.values = optp... | [
"def",
"_update_defaults",
"(",
"self",
",",
"defaults",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# Accumulate complex default state.",
"self",
".",
"values",
"=",
"optparse",
".",
"Values",
"(",
"se... | [
203,
4
] | [
265,
23
] | python | en | ['en', 'en', 'en'] | True |
ConfigOptionParser.get_default_values | (self) | Overriding to make updating the defaults after instantiation of
the option parser possible, _update_defaults() does the dirty work. | Overriding to make updating the defaults after instantiation of
the option parser possible, _update_defaults() does the dirty work. | def get_default_values(self) -> optparse.Values:
"""Overriding to make updating the defaults after instantiation of
the option parser possible, _update_defaults() does the dirty work."""
if not self.process_default_values:
# Old, pre-Optik 1.5 behaviour.
return optparse.V... | [
"def",
"get_default_values",
"(",
"self",
")",
"->",
"optparse",
".",
"Values",
":",
"if",
"not",
"self",
".",
"process_default_values",
":",
"# Old, pre-Optik 1.5 behaviour.",
"return",
"optparse",
".",
"Values",
"(",
"self",
".",
"defaults",
")",
"# Load the con... | [
267,
4
] | [
287,
40
] | 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_)
... | [
"def",
"_xml_escape",
"(",
"data",
")",
":",
"# ampersand must be replaced first\r",
"from_symbols",
"=",
"'&><\"\\''",
"to_symbols",
"=",
"(",
"'&'",
"+",
"s",
"+",
"';'",
"for",
"s",
"in",
"\"amp gt lt quot apos\"",
".",
"split",
"(",
")",
")",
"for",
"from_... | [
161,
0
] | [
169,
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 L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
... | 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 L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
... | 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 L{I{ParserElement.parseString}<ParserElement.parseStrin... | [
"def",
"col",
"(",
"loc",
",",
"strg",
")",
":",
"s",
"=",
"strg",
"return",
"1",
"if",
"0",
"<",
"loc",
"<",
"len",
"(",
"s",
")",
"and",
"s",
"[",
"loc",
"-",
"1",
"]",
"==",
"'\\n'",
"else",
"loc",
"-",
"s",
".",
"rfind",
"(",
"\"\\n\"",... | [
944,
0
] | [
955,
82
] | 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 L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
... | 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 L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
... | 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 L{I{ParserElement.parseString}<ParserElement.parse... | [
"def",
"lineno",
"(",
"loc",
",",
"strg",
")",
":",
"return",
"strg",
".",
"count",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"+",
"1"
] | [
957,
0
] | [
967,
37
] | 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... | [
969,
0
] | [
977,
30
] | 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"
] | [
988,
0
] | [
990,
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",
")"
] | [
197,
4
] | [
202,
61
] | python | en | ['en', 'ja', '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 ==... | [
"def",
"__getattr__",
"(",
"self",
",",
"aname",
")",
":",
"if",
"(",
"aname",
"==",
"\"lineno\"",
")",
":",
"return",
"lineno",
"(",
"self",
".",
"loc",
",",
"self",
".",
"pstr",
")",
"elif",
"(",
"aname",
"in",
"(",
"\"col\"",
",",
"\"column\"",
... | [
204,
4
] | [
217,
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 = "... | [
"def",
"markInputline",
"(",
"self",
",",
"markerString",
"=",
"\">!<\"",
")",
":",
"line_str",
"=",
"self",
".",
"line",
"line_column",
"=",
"self",
".",
"column",
"-",
"1",
"if",
"markerString",
":",
"line_str",
"=",
"\"\"",
".",
"join",
"(",
"(",
"l... | [
224,
4
] | [
233,
31
] | python | en | ['en', 'en', 'en'] | True |
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",
")"
] | [
482,
4
] | [
485,
35
] | python | en | ['en', 'en', 'en'] | True |
ParseResults.pop | ( self, *args, **kwargs) |
Removes and returns item at specified index (default=C{last}).
Supports both C{list} and C{dict} semantics for C{pop()}. If passed no
argument or an integer argument, it will use C{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=C{last}).
Supports both C{list} and C{dict} semantics for C{pop()}. If passed no
argument or an integer argument, it will use C{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=C{last}).
Supports both C{list} and C{dict} semantics for C{pop()}. If passed no
argument or an integer argument, it will use C{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'",
":",... | [
487,
4
] | [
537,
31
] | python | en | ['en', 'ja', '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 C{defaultValue} or C{None} if no
C{defaultValue} is specified.
Similar to C{dict.get()}.
Example::
integer = Word(nums)
date_str = integer(... |
Returns named result matching the given key, or if there is no
such name, then returns the given C{defaultValue} or C{None} if no
C{defaultValue} is specified.
Similar to C{dict.get()}.
Example::
integer = Word(nums)
date_str = integer(... | def get(self, key, defaultValue=None):
"""
Returns named result matching the given key, or if there is no
such name, then returns the given C{defaultValue} or C{None} if no
C{defaultValue} is specified.
Similar to C{dict.get()}.
Example::
in... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"defaultValue",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
":",
"return",
"self",
"[",
"key",
"]",
"else",
":",
"return",
"defaultValue"
] | [
539,
4
] | [
559,
31
] | python | en | ['en', 'ja', 'th'] | False |
ParseResults.insert | ( self, index, insStr ) |
Inserts new element at location index in the list of parsed tokens.
Similar to C{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 ... |
Inserts new element at location index in the list of parsed tokens.
Similar to C{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 ... | def insert( self, index, insStr ):
"""
Inserts new element at location index in the list of parsed tokens.
Similar to C{list.insert()}.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse actio... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"insStr",
")",
":",
"self",
".",
"__toklist",
".",
"insert",
"(",
"index",
",",
"insStr",
")",
"# fixup indices in token dictionary\r",
"for",
"name",
",",
"occurrences",
"in",
"self",
".",
"__tokdict",
".",
... | [
561,
4
] | [
579,
94
] | python | en | ['en', 'ja', '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_... |
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_... | 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 ... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"__toklist",
".",
"append",
"(",
"item",
")"
] | [
581,
4
] | [
593,
35
] | python | en | ['en', 'ja', '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):
token... |
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):
token... | 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_p... | [
"def",
"extend",
"(",
"self",
",",
"itemseq",
")",
":",
"if",
"isinstance",
"(",
"itemseq",
",",
"ParseResults",
")",
":",
"self",
"+=",
"itemseq",
"else",
":",
"self",
".",
"__toklist",
".",
"extend",
"(",
"itemseq",
")"
] | [
595,
4
] | [
611,
42
] | python | en | ['en', 'ja', '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",
"(",
")"
] | [
613,
4
] | [
618,
30
] | python | en | ['en', 'ja', '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 Par... |
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 Par... | 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... | [
"def",
"asList",
"(",
"self",
")",
":",
"return",
"[",
"res",
".",
"asList",
"(",
")",
"if",
"isinstance",
"(",
"res",
",",
"ParseResults",
")",
"else",
"res",
"for",
"res",
"in",
"self",
".",
"__toklist",
"]"
] | [
680,
4
] | [
694,
96
] | python | en | ['en', 'ja', '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(re... |
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(re... | 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')
... | [
"def",
"asDict",
"(",
"self",
")",
":",
"if",
"PY_3",
":",
"item_fn",
"=",
"self",
".",
"items",
"else",
":",
"item_fn",
"=",
"self",
".",
"iteritems",
"def",
"toItem",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"ParseResults",
")",
... | [
696,
4
] | [
729,
55
] | python | en | ['en', 'ja', 'th'] | False |
ParseResults.copy | ( self ) |
Returns a new copy of a C{ParseResults} object.
|
Returns a new copy of a C{ParseResults} object.
| def copy( self ):
"""
Returns a new copy of a C{ParseResults} object.
"""
ret = ParseResults( self.__toklist )
ret.__tokdict = self.__tokdict.copy()
ret.__parent = self.__parent
ret.__accumNames.update( self.__accumNames )
ret.__name = self.__name
... | [
"def",
"copy",
"(",
"self",
")",
":",
"ret",
"=",
"ParseResults",
"(",
"self",
".",
"__toklist",
")",
"ret",
".",
"__tokdict",
"=",
"self",
".",
"__tokdict",
".",
"copy",
"(",
")",
"ret",
".",
"__parent",
"=",
"self",
".",
"__parent",
"ret",
".",
"... | [
731,
4
] | [
740,
18
] | python | en | ['en', 'ja', '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)... | [
"def",
"asXML",
"(",
"self",
",",
"doctag",
"=",
"None",
",",
"namedItemsOnly",
"=",
"False",
",",
"indent",
"=",
"\"\"",
",",
"formatted",
"=",
"True",
")",
":",
"nl",
"=",
"\"\\n\"",
"out",
"=",
"[",
"]",
"namedItems",
"=",
"dict",
"(",
"(",
"v",... | [
742,
4
] | [
801,
27
] | python | en | ['en', 'ja', 'th'] | False |
ParseResults.getName | (self) |
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... |
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... | def getName(self):
"""
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_e... | [
"def",
"getName",
"(",
"self",
")",
":",
"if",
"self",
".",
"__name",
":",
"return",
"self",
".",
"__name",
"elif",
"self",
".",
"__parent",
":",
"par",
"=",
"self",
".",
"__parent",
"(",
")",
"if",
"par",
":",
"return",
"par",
".",
"__lookup",
"("... | [
810,
4
] | [
845,
23
] | python | en | ['en', 'ja', 'th'] | False |
ParseResults.dump | (self, indent='', depth=0, full=True) |
Diagnostic method for listing out the contents of a C{ParseResults}.
Accepts an optional C{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("m... |
Diagnostic method for listing out the contents of a C{ParseResults}.
Accepts an optional C{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("m... | def dump(self, indent='', depth=0, full=True):
"""
Diagnostic method for listing out the contents of a C{ParseResults}.
Accepts an optional C{indent} argument so that this string can be embedded
in a nested display of other data.
Example::
integer = Word(nums)... | [
"def",
"dump",
"(",
"self",
",",
"indent",
"=",
"''",
",",
"depth",
"=",
"0",
",",
"full",
"=",
"True",
")",
":",
"out",
"=",
"[",
"]",
"NL",
"=",
"'\\n'",
"out",
".",
"append",
"(",
"indent",
"+",
"_ustr",
"(",
"self",
".",
"asList",
"(",
")... | [
847,
4
] | [
890,
27
] | python | en | ['en', 'ja', 'th'] | False |
ParseResults.pprint | (self, *args, **kwargs) |
Pretty-printer for parsed results as a list, using the C{pprint} module.
Accepts additional positional or keyword args as defined for the
C{pprint.pprint} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pprint})
Example::
ident = Word(alphas, alphanums... |
Pretty-printer for parsed results as a list, using the C{pprint} module.
Accepts additional positional or keyword args as defined for the
C{pprint.pprint} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pprint})
Example::
ident = Word(alphas, alphanums... | def pprint(self, *args, **kwargs):
"""
Pretty-printer for parsed results as a list, using the C{pprint} module.
Accepts additional positional or keyword args as defined for the
C{pprint.pprint} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pprint})
Exampl... | [
"def",
"pprint",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pprint",
".",
"pprint",
"(",
"self",
".",
"asList",
"(",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
892,
4
] | [
913,
53
] | python | en | ['en', 'ja', '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
... | 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
... | 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']
... | [
"def",
"setDefaultWhitespaceChars",
"(",
"chars",
")",
":",
"ParserElement",
".",
"DEFAULT_WHITE_CHARS",
"=",
"chars"
] | [
1085,
4
] | [
1097,
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.pa... |
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.pa... | 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("d... | [
"def",
"inlineLiteralsUsing",
"(",
"cls",
")",
":",
"ParserElement",
".",
"_literalStringClass",
"=",
"cls"
] | [
1100,
4
] | [
1118,
47
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.copy | ( self ) |
Make a copy of this C{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 C{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().... | def copy( self ):
"""
Make a copy of this C{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",
"... | [
1143,
4
] | [
1164,
18
] | python | en | ['en', 'ja', '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 in... |
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 in... | 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").parseStr... | [
"def",
"setName",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"errmsg",
"=",
"\"Expected \"",
"+",
"self",
".",
"name",
"if",
"hasattr",
"(",
"self",
",",
"\"exception\"",
")",
":",
"self",
".",
"exception",
"."... | [
1166,
4
] | [
1178,
19
] | python | en | ['en', 'ja', '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 C{ParserElement} object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple plac... |
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original C{ParserElement} object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple plac... | 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 C{ParserElement} object;
this is so that the client can define a basic ele... | [
"def",
"setResultsName",
"(",
"self",
",",
"name",
",",
"listAllMatches",
"=",
"False",
")",
":",
"newself",
"=",
"self",
".",
"copy",
"(",
")",
"if",
"name",
".",
"endswith",
"(",
"\"*\"",
")",
":",
"name",
"=",
"name",
"[",
":",
"-",
"1",
"]",
... | [
1180,
4
] | [
1206,
22
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.setBreak | (self,breakFlag = True) | Method to invoke the Python pdb debugger when this element is
about to be parsed. Set C{breakFlag} to True to enable, False to
disable.
| Method to invoke the Python pdb debugger when this element is
about to be parsed. Set C{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 C{breakFlag} to True to enable, False to
disable.
"""
if breakFlag:
_parseMethod = self._parse
def breaker(instring, ... | [
"def",
"setBreak",
"(",
"self",
",",
"breakFlag",
"=",
"True",
")",
":",
"if",
"breakFlag",
":",
"_parseMethod",
"=",
"self",
".",
"_parse",
"def",
"breaker",
"(",
"instring",
",",
"loc",
",",
"doActions",
"=",
"True",
",",
"callPreParse",
"=",
"True",
... | [
1208,
4
] | [
1224,
19
] | python | en | ['en', 'en', 'en'] | True |
ParserElement.setParseAction | ( self, *fns, **kwargs ) |
Define action to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as C{fn(s,loc,toks)},
C{fn(loc,toks)}, C{fn(toks)}, or just C{fn()}, where:
- s = the original string being parsed (see note below)
... |
Define action to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as C{fn(s,loc,toks)},
C{fn(loc,toks)}, C{fn(toks)}, or just C{fn()}, where:
- s = the original string being parsed (see note below)
... | def setParseAction( self, *fns, **kwargs ):
"""
Define action to perform when successfully matching parse element definition.
Parse action fn is a callable method with 0-3 arguments, called as C{fn(s,loc,toks)},
C{fn(loc,toks)}, C{fn(toks)}, or just C{fn()}, where:
- s = ... | [
"def",
"setParseAction",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"parseAction",
"=",
"list",
"(",
"map",
"(",
"_trim_arity",
",",
"list",
"(",
"fns",
")",
")",
")",
"self",
".",
"callDuringTry",
"=",
"kwargs",
... | [
1226,
4
] | [
1262,
19
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.addParseAction | ( self, *fns, **kwargs ) |
Add parse action to expression's list of parse actions. See L{I{setParseAction}<setParseAction>}.
See examples in L{I{copy}<copy>}.
|
Add parse action to expression's list of parse actions. See L{I{setParseAction}<setParseAction>}.
See examples in L{I{copy}<copy>}.
| def addParseAction( self, *fns, **kwargs ):
"""
Add parse action to expression's list of parse actions. See L{I{setParseAction}<setParseAction>}.
See examples in L{I{copy}<copy>}.
"""
self.parseAction += list(map(_trim_arity, list(fns)))
self.callDuringTry... | [
"def",
"addParseAction",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"parseAction",
"+=",
"list",
"(",
"map",
"(",
"_trim_arity",
",",
"list",
"(",
"fns",
")",
")",
")",
"self",
".",
"callDuringTry",
"=",
"self",
"... | [
1264,
4
] | [
1272,
19
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.addCondition | (self, *fns, **kwargs) | Add a boolean predicate function to expression's list of parse actions. See
L{I{setParseAction}<setParseAction>} for function call signatures. Unlike C{setParseAction},
functions passed to C{addCondition} need to return boolean success/fail of the condition.
Optional keyword arguments:
... | Add a boolean predicate function to expression's list of parse actions. See
L{I{setParseAction}<setParseAction>} for function call signatures. Unlike C{setParseAction},
functions passed to C{addCondition} need to return boolean success/fail of the condition.
Optional keyword arguments:
... | def addCondition(self, *fns, **kwargs):
"""Add a boolean predicate function to expression's list of parse actions. See
L{I{setParseAction}<setParseAction>} for function call signatures. Unlike C{setParseAction},
functions passed to C{addCondition} need to return boolean success/fail of the ... | [
"def",
"addCondition",
"(",
"self",
",",
"*",
"fns",
",",
"*",
"*",
"kwargs",
")",
":",
"msg",
"=",
"kwargs",
".",
"get",
"(",
"\"message\"",
",",
"\"failed user-defined condition\"",
")",
"exc_type",
"=",
"ParseFatalException",
"if",
"kwargs",
".",
"get",
... | [
1274,
4
] | [
1299,
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
C{fn(s,loc,expr,err)} where:
- s = string being parsed
- loc = location where expression match was attempted and failed
- expr = the ... | Define action to perform if parsing fails at this expression.
Fail acton fn is a callable function that takes the arguments
C{fn(s,loc,expr,err)} where:
- s = string being parsed
- loc = location where expression match was attempted and failed
- expr = the ... | 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
C{fn(s,loc,expr,err)} where:
- s = string being parsed
- loc = location where expression match was atte... | [
"def",
"setFailAction",
"(",
"self",
",",
"fn",
")",
":",
"self",
".",
"failAction",
"=",
"fn",
"return",
"self"
] | [
1301,
4
] | [
1312,
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... | [
"def",
"enablePackrat",
"(",
"cache_size_limit",
"=",
"128",
")",
":",
"if",
"not",
"ParserElement",
".",
"_packratEnabled",
":",
"ParserElement",
".",
"_packratEnabled",
"=",
"True",
"if",
"cache_size_limit",
"is",
"None",
":",
"ParserElement",
".",
"packrat_cach... | [
1536,
4
] | [
1568,
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.
If you want the grammar to require that the entire input string be
successfully parsed, then set C{parseAll} to True (equivalent... |
Execute the parse expression with the given string.
This is the main interface to the client code, once the complete
expression has been built.
If you want the grammar to require that the entire input string be
successfully parsed, then set C{parseAll} to True (equivalent... | 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.
If you want the grammar to require that the entire input string be
... | [
"def",
"parseString",
"(",
"self",
",",
"instring",
",",
"parseAll",
"=",
"False",
")",
":",
"ParserElement",
".",
"resetCache",
"(",
")",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamline",
"(",
")",
"#~ self.saveAsList = True\r",
"for"... | [
1570,
4
] | [
1618,
25
] | python | en | ['en', 'ja', '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
C{maxMatches} argument, to clip scanning after 'n' matches are found. If
C{overlap} is specified, then overlapping matches will ... |
Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
C{maxMatches} argument, to clip scanning after 'n' matches are found. If
C{overlap} is specified, then overlapping matches will ... | 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
C{maxMatches} argument, to clip scanning after 'n' match... | [
"def",
"scanString",
"(",
"self",
",",
"instring",
",",
"maxMatches",
"=",
"_MAX_INT",
",",
"overlap",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamline",
"(",
")",
"for",
"e",
"in",
"self",
".",
"ignoreExpr... | [
1620,
4
] | [
1689,
25
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.transformString | ( self, instring ) |
Extension to C{L{scanString}}, to modify matching text with modified tokens that may
be returned from a parse action. To use C{transformString}, define a grammar and
attach a parse action to it that modifies the returned token list.
Invoking C{transformString()} on a target string ... |
Extension to C{L{scanString}}, to modify matching text with modified tokens that may
be returned from a parse action. To use C{transformString}, define a grammar and
attach a parse action to it that modifies the returned token list.
Invoking C{transformString()} on a target string ... | def transformString( self, instring ):
"""
Extension to C{L{scanString}}, to modify matching text with modified tokens that may
be returned from a parse action. To use C{transformString}, define a grammar and
attach a parse action to it that modifies the returned token list.
... | [
"def",
"transformString",
"(",
"self",
",",
"instring",
")",
":",
"out",
"=",
"[",
"]",
"lastE",
"=",
"0",
"# force preservation of <TAB>s, to minimize unwanted transformation of string, and to\r",
"# keep string locs straight between transformString and scanString\r",
"self",
".... | [
1691,
4
] | [
1732,
25
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.searchString | ( self, instring, maxMatches=_MAX_INT ) |
Another extension to C{L{scanString}}, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
C{maxMatches} argument, to clip searching after 'n' matches are found.
Example::
# a capitalized word starts wit... |
Another extension to C{L{scanString}}, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
C{maxMatches} argument, to clip searching after 'n' matches are found.
Example::
# a capitalized word starts wit... | def searchString( self, instring, maxMatches=_MAX_INT ):
"""
Another extension to C{L{scanString}}, simplifying the access to the tokens found
to match the given parse expression. May be called with optional
C{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",... | [
1734,
4
] | [
1755,
25
] | python | en | ['en', 'ja', '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 C{maxsplit} argument, to limit the number of splits;
and the optional C{includeSeparators} argument (default=C{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 C{maxsplit} argument, to limit the number of splits;
and the optional C{includeSeparators} argument (default=C{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 C{maxsplit} argument, to limit the number of splits;
and the optional C{includeSeparators} argument (de... | [
"def",
"split",
"(",
"self",
",",
"instring",
",",
"maxsplit",
"=",
"_MAX_INT",
",",
"includeSeparators",
"=",
"False",
")",
":",
"splits",
"=",
"0",
"last",
"=",
"0",
"for",
"t",
",",
"s",
",",
"e",
"in",
"self",
".",
"scanString",
"(",
"instring",
... | [
1757,
4
] | [
1777,
29
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__add__ | (self, other ) |
Implementation of + operator - returns C{L{And}}. Adding strings to a ParserElement
converts them to L{Literal}s by default.
Example::
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseStrin... |
Implementation of + operator - returns C{L{And}}. Adding strings to a ParserElement
converts them to L{Literal}s by default.
Example::
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseStrin... | def __add__(self, other ):
"""
Implementation of + operator - returns C{L{And}}. Adding strings to a ParserElement
converts them to L{Literal}s by default.
Example::
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
... | [
"def",
"__add__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement... | [
1779,
4
] | [
1797,
37
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__radd__ | (self, other ) |
Implementation of + operator when left operand is not a C{L{ParserElement}}
|
Implementation of + operator when left operand is not a C{L{ParserElement}}
| def __radd__(self, other ):
"""
Implementation of + operator when left operand is not a C{L{ParserElement}}
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warning... | [
"def",
"__radd__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElemen... | [
1799,
4
] | [
1809,
27
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__sub__ | (self, other) |
Implementation of - operator, returns C{L{And}} with error stop
|
Implementation of - operator, returns C{L{And}} with error stop
| def __sub__(self, other):
"""
Implementation of - operator, returns C{L{And}} with error stop
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warnings.warn("Cannot... | [
"def",
"__sub__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement... | [
1811,
4
] | [
1821,
55
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__rsub__ | (self, other ) |
Implementation of - operator when left operand is not a C{L{ParserElement}}
|
Implementation of - operator when left operand is not a C{L{ParserElement}}
| def __rsub__(self, other ):
"""
Implementation of - operator when left operand is not a C{L{ParserElement}}
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warning... | [
"def",
"__rsub__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElemen... | [
1823,
4
] | [
1833,
27
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__mul__ | (self,other) |
Implementation of * operator, allows use of C{expr * 3} in place of
C{expr + expr + expr}. Expressions may also me multiplied by a 2-integer
tuple, similar to C{{min,max}} multipliers in regular expressions. Tuples
may also include C{None} as in:
- C{expr*(n,None)} or C{... |
Implementation of * operator, allows use of C{expr * 3} in place of
C{expr + expr + expr}. Expressions may also me multiplied by a 2-integer
tuple, similar to C{{min,max}} multipliers in regular expressions. Tuples
may also include C{None} as in:
- C{expr*(n,None)} or C{... | def __mul__(self,other):
"""
Implementation of * operator, allows use of C{expr * 3} in place of
C{expr + expr + expr}. Expressions may also me multiplied by a 2-integer
tuple, similar to C{{min,max}} multipliers in regular expressions. Tuples
may also include C{None} as i... | [
"def",
"__mul__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"int",
")",
":",
"minElements",
",",
"optElements",
"=",
"other",
",",
"0",
"elif",
"isinstance",
"(",
"other",
",",
"tuple",
")",
":",
"other",
"=",
"(",
... | [
1835,
4
] | [
1901,
18
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__or__ | (self, other ) |
Implementation of | operator - returns C{L{MatchFirst}}
|
Implementation of | operator - returns C{L{MatchFirst}}
| def __or__(self, other ):
"""
Implementation of | operator - returns C{L{MatchFirst}}
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warnings.warn("Cannot combine... | [
"def",
"__or__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement"... | [
1906,
4
] | [
1916,
44
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__ror__ | (self, other ) |
Implementation of | operator when left operand is not a C{L{ParserElement}}
|
Implementation of | operator when left operand is not a C{L{ParserElement}}
| def __ror__(self, other ):
"""
Implementation of | operator when left operand is not a C{L{ParserElement}}
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warnings... | [
"def",
"__ror__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement... | [
1918,
4
] | [
1928,
27
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__xor__ | (self, other ) |
Implementation of ^ operator - returns C{L{Or}}
|
Implementation of ^ operator - returns C{L{Or}}
| def __xor__(self, other ):
"""
Implementation of ^ operator - returns C{L{Or}}
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warnings.warn("Cannot combine elemen... | [
"def",
"__xor__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement... | [
1930,
4
] | [
1940,
36
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__rxor__ | (self, other ) |
Implementation of ^ operator when left operand is not a C{L{ParserElement}}
|
Implementation of ^ operator when left operand is not a C{L{ParserElement}}
| def __rxor__(self, other ):
"""
Implementation of ^ operator when left operand is not a C{L{ParserElement}}
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warning... | [
"def",
"__rxor__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElemen... | [
1942,
4
] | [
1952,
27
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__and__ | (self, other ) |
Implementation of & operator - returns C{L{Each}}
|
Implementation of & operator - returns C{L{Each}}
| def __and__(self, other ):
"""
Implementation of & operator - returns C{L{Each}}
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warnings.warn("Cannot combine elem... | [
"def",
"__and__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElement... | [
1954,
4
] | [
1964,
38
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__rand__ | (self, other ) |
Implementation of & operator when left operand is not a C{L{ParserElement}}
|
Implementation of & operator when left operand is not a C{L{ParserElement}}
| def __rand__(self, other ):
"""
Implementation of & operator when left operand is not a C{L{ParserElement}}
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warning... | [
"def",
"__rand__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElemen... | [
1966,
4
] | [
1976,
27
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__invert__ | ( self ) |
Implementation of ~ operator - returns C{L{NotAny}}
|
Implementation of ~ operator - returns C{L{NotAny}}
| def __invert__( self ):
"""
Implementation of ~ operator - returns C{L{NotAny}}
"""
return NotAny( self ) | [
"def",
"__invert__",
"(",
"self",
")",
":",
"return",
"NotAny",
"(",
"self",
")"
] | [
1978,
4
] | [
1982,
29
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.__call__ | (self, name=None) |
Shortcut for C{L{setResultsName}}, with C{listAllMatches=False}.
If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be
passed as C{True}.
If C{name} is omitted, same as calling C{L{copy}}.
Example::
# thes... |
Shortcut for C{L{setResultsName}}, with C{listAllMatches=False}.
If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be
passed as C{True}.
If C{name} is omitted, same as calling C{L{copy}}.
Example::
# thes... | def __call__(self, name=None):
"""
Shortcut for C{L{setResultsName}}, with C{listAllMatches=False}.
If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be
passed as C{True}.
If C{name} is omitted, same as calling C{L{copy}... | [
"def",
"__call__",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"setResultsName",
"(",
"name",
")",
"else",
":",
"return",
"self",
".",
"copy",
"(",
")"
] | [
1984,
4
] | [
2001,
30
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.suppress | ( self ) |
Suppresses the output of this C{ParserElement}; useful to keep punctuation from
cluttering up returned output.
|
Suppresses the output of this C{ParserElement}; useful to keep punctuation from
cluttering up returned output.
| def suppress( self ):
"""
Suppresses the output of this C{ParserElement}; useful to keep punctuation from
cluttering up returned output.
"""
return Suppress( self ) | [
"def",
"suppress",
"(",
"self",
")",
":",
"return",
"Suppress",
"(",
"self",
")"
] | [
2003,
4
] | [
2008,
31
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.leaveWhitespace | ( self ) |
Disables the skipping of whitespace before matching the characters in the
C{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
C{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
C{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"
] | [
2010,
4
] | [
2017,
19
] | python | en | ['en', 'ja', '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"
] | [
2019,
4
] | [
2026,
19
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.parseWithTabs | ( self ) |
Overrides default behavior to expand C{<TAB>}s to spaces before parsing the input string.
Must be called before C{parseString} when the input grammar contains elements that
match C{<TAB>} characters.
|
Overrides default behavior to expand C{<TAB>}s to spaces before parsing the input string.
Must be called before C{parseString} when the input grammar contains elements that
match C{<TAB>} characters.
| def parseWithTabs( self ):
"""
Overrides default behavior to expand C{<TAB>}s to spaces before parsing the input string.
Must be called before C{parseString} when the input grammar contains elements that
match C{<TAB>} characters.
"""
self.keepTabs = True
r... | [
"def",
"parseWithTabs",
"(",
"self",
")",
":",
"self",
".",
"keepTabs",
"=",
"True",
"return",
"self"
] | [
2028,
4
] | [
2035,
19
] | python | en | ['en', 'ja', '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')... |
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')... | 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.p... | [
"def",
"ignore",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"Suppress",
"(",
"other",
")",
"if",
"isinstance",
"(",
"other",
",",
"Suppress",
")",
":",
"if",
"other",
"not",
"in",... | [
2037,
4
] | [
2058,
19
] | python | en | ['en', 'ja', '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",
",",
... | [
2060,
4
] | [
2068,
19
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.setDebug | ( self, flag=True ) |
Enable display of debugging messages while doing pattern matching.
Set C{flag} to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
term = wd | integer
... |
Enable display of debugging messages while doing pattern matching.
Set C{flag} to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
term = wd | integer
... | def setDebug( self, flag=True ):
"""
Enable display of debugging messages while doing pattern matching.
Set C{flag} to True to enable, False to disable.
Example::
wd = Word(alphas).setName("alphaword")
integer = Word(nums).setName("numword")
t... | [
"def",
"setDebug",
"(",
"self",
",",
"flag",
"=",
"True",
")",
":",
"if",
"flag",
":",
"self",
".",
"setDebugActions",
"(",
"_defaultStartDebugAction",
",",
"_defaultSuccessDebugAction",
",",
"_defaultExceptionDebugAction",
")",
"else",
":",
"self",
".",
"debug"... | [
2070,
4
] | [
2109,
19
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.validate | ( self, validateTrace=[] ) |
Check defined expressions for valid structure, check for infinite recursive definitions.
|
Check defined expressions for valid structure, check for infinite recursive definitions.
| def validate( self, validateTrace=[] ):
"""
Check defined expressions for valid structure, check for infinite recursive definitions.
"""
self.checkRecursion( [] ) | [
"def",
"validate",
"(",
"self",
",",
"validateTrace",
"=",
"[",
"]",
")",
":",
"self",
".",
"checkRecursion",
"(",
"[",
"]",
")"
] | [
2125,
4
] | [
2129,
33
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.parseFile | ( self, file_or_filename, parseAll=False ) |
Execute the parse expression on the given file or filename.
If a filename is specified (instead of a file object),
the entire file is opened, read, and closed before parsing.
|
Execute the parse expression on the given file or filename.
If a filename is specified (instead of a file object),
the entire file is opened, read, and closed before parsing.
| def parseFile( self, file_or_filename, parseAll=False ):
"""
Execute the parse expression on the given file or filename.
If a filename is specified (instead of a file object),
the entire file is opened, read, and closed before parsing.
"""
try:
file_con... | [
"def",
"parseFile",
"(",
"self",
",",
"file_or_filename",
",",
"parseAll",
"=",
"False",
")",
":",
"try",
":",
"file_contents",
"=",
"file_or_filename",
".",
"read",
"(",
")",
"except",
"AttributeError",
":",
"with",
"open",
"(",
"file_or_filename",
",",
"\"... | [
2131,
4
] | [
2149,
25
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.matches | (self, testString, parseAll=True) |
Method for quick testing of a parser against a test string. Good for simple
inline microtests of sub expressions while building up larger parser.
Parameters:
- testString - to test against this expression for a match
- parseAll - (default=C{True}) - flag to ... |
Method for quick testing of a parser against a test string. Good for simple
inline microtests of sub expressions while building up larger parser.
Parameters:
- testString - to test against this expression for a match
- parseAll - (default=C{True}) - flag to ... | def matches(self, testString, parseAll=True):
"""
Method for quick testing of a parser against a test string. Good for simple
inline microtests of sub expressions while building up larger parser.
Parameters:
- testString - to test against this expression for a... | [
"def",
"matches",
"(",
"self",
",",
"testString",
",",
"parseAll",
"=",
"True",
")",
":",
"try",
":",
"self",
".",
"parseString",
"(",
"_ustr",
"(",
"testString",
")",
",",
"parseAll",
"=",
"parseAll",
")",
"return",
"True",
"except",
"ParseBaseException",... | [
2171,
4
] | [
2188,
24
] | python | en | ['en', 'ja', 'th'] | False |
ParserElement.runTests | (self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False) |
Execute the parse expression on a series of test strings, showing each
test, the parsed results or where the parse failed. Quick and easy way to
run a parse expression against a list of sample strings.
Parameters:
- tests - a list of separate test strings, or ... |
Execute the parse expression on a series of test strings, showing each
test, the parsed results or where the parse failed. Quick and easy way to
run a parse expression against a list of sample strings.
Parameters:
- tests - a list of separate test strings, or ... | def runTests(self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False):
"""
Execute the parse expression on a series of test strings, showing each
test, the parsed results or where the parse failed. Quick and easy way to
run a parse expression aga... | [
"def",
"runTests",
"(",
"self",
",",
"tests",
",",
"parseAll",
"=",
"True",
",",
"comment",
"=",
"'#'",
",",
"fullDump",
"=",
"True",
",",
"printResults",
"=",
"True",
",",
"failureTests",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"tests",
",",
... | [
2190,
4
] | [
2319,
34
] | python | en | ['en', 'ja', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.