Search is not available for this dataset
text stringlengths 75 104k |
|---|
def _handle_results(self):
"""
Call back function to be implemented by the CLI.
"""
# Only process if we get HTTP result of 200
if self._api_result.status_code == requests.codes.ok:
self._relays = json.loads(self._api_result.text)
self._filter()
... |
def fromlist(cls, files, equal=False, offensive=False, lang=None):
"""Initialize based on a list of fortune files"""
self = cls.__new__(cls)
self.files = fortunes = []
count = 0
for file in files:
fortune = load_fortune(file, offensive=offensive, lang=lang)
... |
def set_chance(cls, files, equal=False, offensive=False, lang=None): # where files are (name, chance)
"""Initialize based on a list of fortune files with set chances"""
self = cls.__new__(cls)
total = 0.
file = []
leftover = []
for name, chance in files:
if to... |
def main(context, **kwargs):
"""
virtue discovers and runs tests found in the given objects.
Provide it with one or more tests (packages, modules or objects) to run.
"""
result = run(**kwargs)
context.exit(not result.wasSuccessful()) |
def grammar(self, text):
"""grammar = {comment} , rule , {comment | rule} ;"""
self._attempting(text)
return concatenation([
zero_or_more(
self.comment,
ignore_whitespace=True
),
self.rule,
zero_or_more(
alternation([
self.comment,
self.rul... |
def comment(self, text):
"""comment = "(*" . {printable - "*" | "*" . printable - ")"} . "*)" ;"""
self._attempting(text)
return concatenation([
"(*",
zero_or_more(
alternation([
exclusion(
self.printable,
"*"
),
concatenation([
... |
def rule(self, text):
"""rule = identifier , "=" , expression , ";" ;"""
self._attempting(text)
return concatenation([
self.identifier,
"=",
self.expression,
";",
], ignore_whitespace=True)(text).retyped(TokenType.rule) |
def special_handling(self, text):
"""special_handling = "?" , identifier , "?" ;"""
self._attempting(text)
return concatenation([
"?",
self.identifier,
"?",
], ignore_whitespace=True)(text).retyped(TokenType.special_handling) |
def number(self, text):
"""number = digit - "0" . {digit} ;"""
self._attempting(text)
return concatenation([
exclusion(
self.digit,
"0"
),
zero_or_more(
self.digit,
ignore_whitespace=False
),
], ignore_whitespace=False)(text).compressed(TokenType.n... |
def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.metricName is not None:
self.metricName = self.args.metricName
if self.args.measurement is not None:
self.measurement = self.args.... |
def _handle_results(self):
"""
Call back function to be implemented by the CLI.
"""
# Only process if we get HTTP result of 200
if self._api_result.status_code == requests.codes.ok:
payload = json.loads(self._api_result.text)
out = json.dumps(payload, sor... |
def grammar(self):
"""The parse tree generated by the source."""
if self._grammar is None:
self.parser = Parser()
grammar = self.parser.parse(self.input_source)
self._grammar = grammar.trimmed().flattened().flattened(self._flatten)
return self._grammar |
def rules(self):
"""The AST rules."""
if self._rules is None:
self._rules = []
for child in self.grammar.children:
if child.is_type(TokenType.rule):
name, expression = child.children
self._rules.append(Rule(name.value, self._expression_to_asn(expression), name.position, c... |
def comments(self):
"""The AST comments."""
if self._comments is None:
self._comments = [c for c in self.grammar.children if c.is_type(TokenType.comment)]
return self._comments |
def directives(self):
"""The diretives parsed from the comments."""
if self._directives is None:
self._directives = []
for comment in self.comments:
self._directives.extend(self.directives_from_comment(comment))
return self._directives |
def output_source(self):
"""The python source of the parser generated from the input source."""
if self._output_source is None:
self._output_source = self._compile()
return self._output_source |
def _compile(self):
"""Returns the python source code for the generated parser."""
fmt = """\"\"\"This parser was generated by pyebnf on {date}.\"\"\"
from enum import Enum
from pyebnf import parser_base as PB
from pyebnf.primitive import alternation, concatenation, exclusion, one_or_more
from ... |
def _get_imports(self):
"""Reads the directives and generates source code for custom imports."""
import_directives = [d for d in self.directives if d.name == "import"]
if import_directives:
return "\n" + "\n".join(d.args["value"] for d in import_directives)
else:
return "" |
def _get_token_type_enum(self):
"""Builds the python source code for the Parser TokenType enum."""
fmt = "class TokenType(Enum):\n" \
"{indent}\"\"\"The token types for parse nodes generated by the Parser.\"\"\"\n" \
"{indent}" + \
"\n{indent}".join("{1} = {0}".format(num + 1, r.na... |
def _get_class_definition(self):
"""Builds the class definition of the parser."""
fmt = """class Parser({parser_base}):
{indent}\"\"\"This class contains methods for reading source code and generating a parse tree.\"\"\"
{indent}entry_point = "{entry_point}"
{rule_definit... |
def _get_entry_point(self):
"""Gets the entry_point value for the parser."""
ep = self._find_directive("entry_point")
if ep:
return ep.args["value"]
else:
return self.rules[0].name |
def _get_rule_definition(self, rule):
"""Generates the source code for a rule."""
fmt = """def {rule_fxn_name}(self, text):
{indent}\"\"\"{rule_source}\"\"\"
{indent}self._attempting(text)
{indent}return {rule_definition}(text){transform}
"""
fmt = self._clea... |
def _get_rule_source(self, rule):
"""Gets the variable part of the source code for a rule."""
p = len(self.input_source) + rule.position
source = self.input_source[p:p + rule.consumed].rstrip()
return self._indent(source, depth=self.indent + " ", skip_first_line=True) |
def _get_rule_transform(self, rule):
"""The return value for each rule can be either retyped, compressed or left alone. This method
determines that and returns the source code text for accomplishing it.
"""
rd = self._find_directive(lambda d: d.name == "rule" and d.args.get("name") == rule.name)
if... |
def _expression_to_asn(self, expression):
"""Convert an expression to an Abstract Syntax Tree Node."""
new_children = [self._node_to_asn(c) for c in expression.children]
return self._remove_grouping_groups(infix_to_optree(new_children)) |
def _node_to_asn(self, node):
"""Convert a parse tree node into an absract syntax tree node."""
if node.is_type(TokenType.identifier):
return Identifier(node.svalue)
elif node.is_type(TokenType.terminal):
return Terminal(node.svalue)
elif node.is_type(TokenType.option_group):
expr = ... |
def _hoist_operands(self, operands, pred):
"""Flattens a list of optree operands based on a pred.
This is used to convert concatenation([x, concatenation[y, ...]]) (or alternation) to
concatenation([x, y, ...]).
"""
hopper = list(operands)
new_operands = []
while hopper:
target = hopp... |
def _remove_grouping_groups(self, optree):
"""Grouping groups are implied by optrees, this function hoists grouping group expressions up
to their parent node.
"""
new_operands = []
for operand in optree.operands:
if isinstance(operand, OptreeNode):
new_operands.append(self._remove_grou... |
def _ast_to_code(self, node, **kwargs):
"""Convert an abstract syntax tree to python source code."""
if isinstance(node, OptreeNode):
return self._ast_optree_node_to_code(node, **kwargs)
elif isinstance(node, Identifier):
return self._ast_identifier_to_code(node, **kwargs)
elif isinstance(no... |
def _ast_optree_node_to_code(self, node, **kwargs):
"""Convert an abstract syntax operator tree to python source code."""
opnode = node.opnode
if opnode is None:
return self._ast_to_code(node.operands[0])
else:
operator = opnode.operator
if operator is OP_ALTERNATE:
return self... |
def _ast_terminal_to_code(self, terminal, **kwargs):
"""Convert an AST terminal to python source code."""
value = _replace(terminal.value)
if self.use_terminal_shorthand:
return [value]
else:
return ["terminal({})".format(value)] |
def _ast_option_group_to_code(self, option_group, **kwargs):
"""Convert an AST option group to python source code."""
lines = ["option("]
lines.extend(self._indent(self._ast_to_code(option_group.expression)))
lines.append(")")
return lines |
def _ast_repetition_group_to_code(self, repetition_group, ignore_whitespace=False, **kwargs):
"""Convert an AST repetition group to python source code."""
lines = ["zero_or_more("]
lines.extend(self._indent(self._ast_to_code(repetition_group.expression)))
lines[-1] += ","
lines.append(self._indent("... |
def _ast_special_handling_to_code(self, special_handling, **kwargs):
"""Convert an AST sepcial handling to python source code."""
ident = special_handling.value.svalue
if ident in PB_SPECIAL_HANDLING:
return ["PB.{0}".format(ident)]
else:
return ["self.{0}".format(ident)] |
def _ast_op_alternate_to_code(self, opr, **kwargs):
"""Convert an AST alternate op to python source code."""
hoist_target = OP_ALTERNATE
operands = self._hoist_operands(opr.operands, lambda t: isinstance(t, OptreeNode) and t.opnode.operator is hoist_target)
lines = ["alternation(["]
for op in opera... |
def _ast_op_concat_to_code(self, opr, *, ignore_whitespace, **kwargs):
"""Convert an AST concatenate op to python source code."""
hoist_target = OP_CONCAT if ignore_whitespace else OP_WS_CONCAT
operands = self._hoist_operands(opr.operands, lambda t: isinstance(t, OptreeNode) and t.opnode.operator is hoist_t... |
def _ast_op_exclude_to_code(self, opr, **kwargs):
"""Convert an AST exclude op to python source code."""
opl, opr = opr.operands
lines = ["exclusion("]
lines.extend(self._indent(self._ast_to_code(opl)))
lines[-1] += ","
lines.extend(self._indent(self._ast_to_code(opr)))
lines.append(")")
... |
def _ast_op_multiply_to_code(self, opr, ignore_whitespace=False, **kwargs):
"""Convert an AST multiply op to python source code."""
opl, opr = opr.operands
if isinstance(opl, Number):
times = opl.value
subject = self._ast_to_code(opr)
else:
times = opr.value
subject = self._ast_... |
def _ast_op_repeat_to_code(self, opr, ignore_whitespace=False, **kwargs):
"""Convert an AST repeat op to python source code."""
lines = ["one_or_more("]
lines.extend(self._indent(self._ast_to_code(opr.operands[0])))
lines[-1] += ","
lines.append(self._indent("ignore_whitespace={}".format(bool(ignore... |
def _indent(self, text, depth=1, *, skip_first_line=False, suffix=""):
"""Indent text by depth * self.indent.
Text can be either a string, or a list of strings. If it is a string, it will be split on
newline to a list of strings.
if skip_first_line is true, the first line will not be indented like the... |
def _find_directives(self, pred):
"""Finds all directives with a certain name, or that passes a predicate."""
if isinstance(pred, str):
return [d for d in self.directives if d.name == pred]
else:
return [d for d in self.directives if pred(d)] |
def _flatten(child, parent):
"""Custom flattening method for the parse tree."""
return parent.is_type(TokenType.expression) and child.node_type == parent.node_type |
def directives_from_comment(cls, comment):
"""A directive is a line in a comment that begins with '!'."""
comment_contents = comment.value[2:-2].strip()
comment_lines = (l.strip() for l in comment_contents.split("\n"))
directives = (l[1:].strip() for l in comment_lines if l.startswith("!"))
for dir... |
def parse_directive_def(cls, directive_def):
"""Turns a directive definition string into a directive object."""
name, *kwargs = esc_split(directive_def, ignore_empty=True)
return Directive(name, {key: value for key, value in (esc_split(arg, "=") for arg in kwargs)}) |
def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.hostGroupName is not None:
self.url_parameters = {"name": self.args.hostGroupName} |
def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.plugin_name is not None:
self.plugin_name = self.args.plugin_name
self.path = "v1/plugins/{0}".format(self.plugin_name) |
def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
self._alarm_id = self.args.alarm_id if self.args.alarm_id is not None else None |
def _handle_results(self):
"""
Handle the results of the API call
"""
# Only process if we get HTTP return code other 200.
if self._api_result.status_code != requests.codes.ok:
print(self.colorize_json(self._api_result.text)) |
def key_to_str(modifiers, key, mods_table = mods, key_table = wx, key_prefix = 'WXK_'):
"""
Returns a human-readable version of numerical modifiers and key.
To make the key suitable for global hotkey usage, supply:
mods_table = global_mods, key_table = win32con, key_prefix = 'VK_'
"""
logger.debug('Converting (... |
def str_to_key(value, key_table = wx, accel_format = 'ACCEL_%s', key_format = 'WXK_%s', key_transpositions = {}):
"""
Turns a string like "CTRL_ALT+K" into (3, 75).
To get a global hotkey, try passing:
key_table = win32con, accel_format = 'MOD_%s', key_format = 'VK_%s', key_transpositions = {'CTRL': 'CONTROL'}
"... |
def get_id(id):
"""Get a new id if the provided one is None."""
if id == None:
id = wx.NewId()
logger.debug('Generated new ID %s.', id)
else:
logger.debug('Using provided id %s.', id)
return id |
def add_accelerator(control, key, func, id = None):
"""
Adds a key to the control.
control: The control that the accelerator should be added to.
key: A string like "CTRL+F", or "CMD+T" that specifies the key to use.
func: The function that should be called when key is pressed.
id: The id to Bind the event to. D... |
def remove_accelerator(control, key):
"""
Removes an accelerator from control.
control: The control to affect.
key: The key to remove.
"""
key = str_to_key(key)
t = _tables.get(control, [])
for a in t:
if a[:2] == key:
t.remove(a)
if t:
_tables[control] = t
else:
del _tables[control]
upd... |
def add_hotkey(control, key, func, id = None):
"""
Add a global hotkey bound to control via id that should call func.
control: The control to bind to.
key: The hotkey to use.
func: The func to call.
id: The new ID to use (defaults to creating a new ID.
"""
if win32con is None:
raise RuntimeError('win32con i... |
def remove_hotkey(control, key):
"""
Remove a global hotkey.
control - The control to affect
key - The key to remove.
"""
l = _hotkeys.get(control, [])
for a in l:
key_str, id = a
if key_str == key:
control.Unbind(wx.EVT_HOTKEY, id = id)
control.UnregisterHotKey(id)
l.remove(a)
if l:
_hotke... |
def add_arguments(self):
"""
Configure handling of command line arguments.
"""
self.add_logging_argument()
self.parser.add_argument('-a', '--api-host', dest='api_host', action='store', metavar="api_host",
help='{0} API host endpoint'.format(self.p... |
def _configure_logging(self):
"""
Configure logging based on command line options
"""
if self.args.logLevel is not None:
logging.basicConfig(level=self.levels[self.args.logLevel])
logging.info("Set logging level to {0}".format(self.args.logLevel)) |
def get_arguments(self):
"""
CLIs get called back so that they can process any command line arguments
that are given. This method handles the standard command line arguments for:
API Host, user, password, etc.
"""
# We call this first so that logging is enabled as soon a... |
def _validate_arguments(self):
"""
Validates the command line arguments passed to the CLI
Derived classes that override need to call this method before
validating their arguments
"""
if self._email is None:
self.set_error_message("E-mail for the account not pr... |
def execute(self):
"""
Run the steps to execute the CLI
"""
# Set default arguments from environment variables
self._get_environment()
# Call our member function to add command line arguments, child classes that override need
# to call the ApiCli version first t... |
def infix_to_postfix(nodes, *, recurse_types=None):
"""Convert a list of nodes in infix order to a list of nodes in postfix order.
E.G. with normal algebraic precedence, 3 + 4 * 5 -> 3 4 5 * +
"""
output = []
operators = []
for node in nodes:
if isinstance(node, OperatorNode):
# Drain out all op... |
def postfix_to_optree(nodes):
"""Convert a list of nodes in postfix order to an Optree."""
while len(nodes) > 1:
nodes = _reduce(nodes)
if len(nodes) == 0:
raise OperatorError("Empty node list")
node = nodes[0]
if isinstance(node, OperatorNode):
raise OperatorError("Operator without operands")
... |
def _reduce(nodes):
"""Finds the first operator in the list, converts it and its operands to a OptreeNode, then
returns a new list with the operator and operands replaced by the new OptreeNode.
"""
i = 0
while i < len(nodes):
if isinstance(nodes[i], OperatorNode):
break
else:
i += 1
if ... |
def pprint(root, depth=0, space_unit=" "):
"""Pretty print an optree, starting at root."""
spacing = space_unit * depth
if isinstance(root, OptreeNode):
print("{0}Operator ({1})".format(spacing, root.opnode.operator.symbol if root.opnode else "None -> IDENTITY"))
for operand in root.operands:
pp... |
def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.pluginName is not None:
self.pluginName = self.args.pluginName |
def _process_properties(self, properties):
"""
Transforms the command line properties into python dictionary
:return:
"""
if properties is not None:
self._properties = {}
for p in properties:
d = p.split('=')
self._propertie... |
def add_arguments(self):
"""
Add the specific arguments of this CLI
"""
MetricCommon.add_arguments(self)
self.parser.add_argument('-n', '--metric-name', dest='metricName', action='store',
required=True, metavar='metric_name', help='Metric identifi... |
def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
MetricCommon.get_arguments(self)
if self.args.metricName is not None:
self.metricName = self.args.metricName
if self.args.displayName is not None:
se... |
def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
self._alarm_name = self.args.alarm_name if self.args.alarm_name is not None else None |
def read(self):
"""
Load the metrics file from the given path
"""
f = open(self.path, "r")
self.manifest_json = f.read() |
def load(self):
"""
Read the file and parse JSON into dictionary
"""
manifest = PluginManifest(self.file_path)
manifest.get()
self.manifest = manifest.get_manifest() |
def getMetricDefinition(self, name):
"""
Looks up the metric definition from the definitions from the API call
"""
metric = None
for m in self.metric_definitions:
if m['name'] == name:
metric = m
break
return metric |
def printMetricsHeader(self, m, d):
"""
Prints out table header based on the size of the data in columns
"""
mstr = "Metric Name"
dstr = "Description"
print('|{0}{1}|{2}{3}|'.format(mstr, ' ' * (m - len(mstr)), dstr, ' ' * (d - len(dstr))))
print('|:{0}|:{1}|'.fo... |
def getFieldsColumnLengths(self):
"""
Gets the maximum length of each column in the field table
"""
nameLen = 0
descLen = 0
for f in self.fields:
nameLen = max(nameLen, len(f['title']))
descLen = max(descLen, len(f['description']))
return (... |
def getMetricsColumnLengths(self):
"""
Gets the maximum length of each column
"""
displayLen = 0
descLen = 0
for m in self.metrics:
displayLen = max(displayLen, len(m['displayName']))
descLen = max(descLen, len(m['description']))
return (di... |
def escapeUnderscores(self):
"""
Escape underscores so that the markdown is correct
"""
new_metrics = []
for m in self.metrics:
m['name'] = m['name'].replace("_", "\_")
new_metrics.append(m)
self.metrics = new_metrics |
def printFieldsHeader(self, f, d):
"""
Prints out table header based on the size of the data in columns
"""
fstr = "Field Name"
dstr = "Description"
f = max(f, len(fstr))
d = max(d, len(dstr))
print('|{0}{1}|{2}{3}|'.format(fstr, ' ' * (f - len(fstr)), ds... |
def printMetrics(self, m, d):
"""
Prints out table rows based on the size of the data in columns
"""
for metric in self.metrics:
mstr = metric['displayName']
dstr = metric['description']
mlen = m - len(mstr)
dlen = d - len(dstr)
... |
def printFields(self, f, d):
"""
Prints out table rows based on the size of the data in columns
"""
for field in self.fields:
fstr = field["title"]
dstr = field["description"]
flen = f - len(fstr)
dlen = d - len(dstr)
print("|{0... |
def outputFieldMarkdown(self):
"""
Sends the field definitions ot standard out
"""
f, d = self.getFieldsColumnLengths()
fc, dc = self.printFieldsHeader(f, d)
f = max(fc, f)
d = max(dc, d)
self.printFields(f, d) |
def outputMetricMarkdown(self):
"""
Sends the markdown of the metric definitions to standard out
"""
self.escapeUnderscores()
m, d = self.getMetricsColumnLengths()
self.printMetricsHeader(m, d)
self.printMetrics(m, d) |
def generateMarkdown(self):
"""
Look up each of the metrics and then output in Markdown
"""
self.generateMetricDefinitions()
self.generateFieldDefinitions()
self.generateDashboardDefinitions()
self.outputMarkdown() |
def parse(self, text):
"""Attempt to parse source code."""
self.original_text = text
try:
return getattr(self, self.entry_point)(text)
except (DeadEnd) as exc:
raise ParserError(self.most_consumed, "Failed to parse input") from exc
return tree |
def _attempting(self, text):
"""Keeps track of the furthest point in the source code the parser has reached to this point."""
consumed = len(self.original_text) - len(text)
self.most_consumed = max(consumed, self.most_consumed) |
def add_arguments(self):
"""
Add specific command line arguments for this command
"""
# Call our parent to add the default arguments
ApiCli.add_arguments(self)
# Command specific arguments
self.parser.add_argument('-f', '--format', dest='format', action='stor... |
def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.metric_name is not None:
self._metric_name = self.args.metric_name
if self.args.sample is not None:
self.sample = self.args.sample... |
def parse_time_date(self, s):
"""
Attempt to parse the passed in string into a valid datetime.
If we get a parse error then assume the string is an epoch time
and convert to a datetime.
"""
try:
ret = parser.parse(str(s))
except ValueError:
... |
def output_csv(self, text):
"""
Output results in CSV format
"""
payload = json.loads(text)
# Print CSV header
print("{0},{1},{2},{3},{4}".format('timestamp', 'metric', 'aggregate', 'source', 'value'))
metric_name = self._metric_name
# Loop through the agg... |
def output_json(self, text):
"""
Output results in structured JSON format
"""
payload = json.loads(text)
data = []
metric_name = self._metric_name
for r in payload['result']['aggregates']['key']:
timestamp = self._format_timestamp(r[0][0])
... |
def output_raw(self, text):
"""
Output results in raw JSON format
"""
payload = json.loads(text)
out = json.dumps(payload, sort_keys=True, indent=self._indent, separators=(',', ': '))
print(self.colorize_json(out)) |
def output_xml(self, text):
"""
Output results in JSON format
"""
# Create the main document nodes
document = Element('results')
comment = Comment('Generated by TrueSight Pulse measurement-get CLI')
document.append(comment)
aggregates = SubElement(documen... |
def _handle_results(self):
"""
Call back function to be implemented by the CLI.
"""
# Only process if we get HTTP result of 200
if self._api_result.status_code == requests.codes.ok:
if self.format == "json":
self.output_json(self._api_result.text)
... |
def trimmed_pred_default(node, parent):
"""The default predicate used in Node.trimmed."""
return isinstance(node, ParseNode) and (node.is_empty or node.is_type(ParseNodeType.terminal)) |
def pprint(root, depth=0, space_unit=" ", *, source_len=0, file=None):
"""Pretting print a parse tree."""
spacing = space_unit * depth
if isinstance(root, str):
print("{0}terminal@(?): {1}".format(spacing, root), file=file)
else:
if root.position is None:
position = -1
elif root.position <... |
def zero_or_more(extractor, *, ignore_whitespace=False):
"""Returns a partial of _get_repetition with bounds set to (0, None) that accepts only a text
argument.
"""
return partial(_get_repetition, extractor, bounds=(0, None), ignore_whitespace=ignore_whitespace) |
def one_or_more(extractor, *, ignore_whitespace=False):
"""Returns a partial of _get_repetition with bounds set to (1, None) that accepts only a text
argument.
"""
return partial(_get_repetition, extractor, bounds=(1, None), ignore_whitespace=ignore_whitespace) |
def repeated(extractor, times, *, ignore_whitespace=False):
"""Returns a partial of _get_repetition with bounds set to (times, times) that accepts only a text
argument.
"""
return partial(_get_repetition,
extractor,
bounds=(times, times),
ignore_whitespace=igno... |
def repetition(extractor, bounds, *, ignore_whitespace=False):
"""Returns a partial of _get_repetition that accepts only a text argument."""
return partial(_get_repetition, extractor, bounds=bounds, ignore_whitespace=ignore_whitespace) |
def _get_terminal(value, text):
"""Checks the beginning of text for a value. If it is found, a terminal ParseNode is returned
filled out appropriately for the value it found. DeadEnd is raised if the value does not match.
"""
if text and text.startswith(value):
return ParseNode(ParseNodeType.terminal,
... |
def _get_concatenation(extractors, text, *, ignore_whitespace=True):
"""Returns a concatenation ParseNode whose children are the nodes returned by each of the
methods in the extractors enumerable.
If ignore_whitespace is True, whitespace will be ignored and then attached to the child it
preceeded.
"""
igno... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.