partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | MetricMarkdown.printFields | Prints out table rows based on the size of the data in columns | boundary/metric_markdown.py | 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 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... | [
"Prints",
"out",
"table",
"rows",
"based",
"on",
"the",
"size",
"of",
"the",
"data",
"in",
"columns"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/metric_markdown.py#L161-L170 | [
"def",
"printFields",
"(",
"self",
",",
"f",
",",
"d",
")",
":",
"for",
"field",
"in",
"self",
".",
"fields",
":",
"fstr",
"=",
"field",
"[",
"\"title\"",
"]",
"dstr",
"=",
"field",
"[",
"\"description\"",
"]",
"flen",
"=",
"f",
"-",
"len",
"(",
... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MetricMarkdown.outputFieldMarkdown | Sends the field definitions ot standard out | boundary/metric_markdown.py | 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 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) | [
"Sends",
"the",
"field",
"definitions",
"ot",
"standard",
"out"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/metric_markdown.py#L201-L210 | [
"def",
"outputFieldMarkdown",
"(",
"self",
")",
":",
"f",
",",
"d",
"=",
"self",
".",
"getFieldsColumnLengths",
"(",
")",
"fc",
",",
"dc",
"=",
"self",
".",
"printFieldsHeader",
"(",
"f",
",",
"d",
")",
"f",
"=",
"max",
"(",
"fc",
",",
"f",
")",
... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MetricMarkdown.outputMetricMarkdown | Sends the markdown of the metric definitions to standard out | boundary/metric_markdown.py | 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 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) | [
"Sends",
"the",
"markdown",
"of",
"the",
"metric",
"definitions",
"to",
"standard",
"out"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/metric_markdown.py#L212-L220 | [
"def",
"outputMetricMarkdown",
"(",
"self",
")",
":",
"self",
".",
"escapeUnderscores",
"(",
")",
"m",
",",
"d",
"=",
"self",
".",
"getMetricsColumnLengths",
"(",
")",
"self",
".",
"printMetricsHeader",
"(",
"m",
",",
"d",
")",
"self",
".",
"printMetrics",... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MetricMarkdown.generateMarkdown | Look up each of the metrics and then output in Markdown | boundary/metric_markdown.py | def generateMarkdown(self):
"""
Look up each of the metrics and then output in Markdown
"""
self.generateMetricDefinitions()
self.generateFieldDefinitions()
self.generateDashboardDefinitions()
self.outputMarkdown() | def generateMarkdown(self):
"""
Look up each of the metrics and then output in Markdown
"""
self.generateMetricDefinitions()
self.generateFieldDefinitions()
self.generateDashboardDefinitions()
self.outputMarkdown() | [
"Look",
"up",
"each",
"of",
"the",
"metrics",
"and",
"then",
"output",
"in",
"Markdown"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/metric_markdown.py#L233-L240 | [
"def",
"generateMarkdown",
"(",
"self",
")",
":",
"self",
".",
"generateMetricDefinitions",
"(",
")",
"self",
".",
"generateFieldDefinitions",
"(",
")",
"self",
".",
"generateDashboardDefinitions",
"(",
")",
"self",
".",
"outputMarkdown",
"(",
")"
] | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | ParserBase.parse | Attempt to parse source code. | pyebnf/parser_base.py | 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 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 | [
"Attempt",
"to",
"parse",
"source",
"code",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/parser_base.py#L30-L38 | [
"def",
"parse",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"original_text",
"=",
"text",
"try",
":",
"return",
"getattr",
"(",
"self",
",",
"self",
".",
"entry_point",
")",
"(",
"text",
")",
"except",
"(",
"DeadEnd",
")",
"as",
"exc",
":",
"r... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParserBase._attempting | Keeps track of the furthest point in the source code the parser has reached to this point. | pyebnf/parser_base.py | 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 _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) | [
"Keeps",
"track",
"of",
"the",
"furthest",
"point",
"in",
"the",
"source",
"code",
"the",
"parser",
"has",
"reached",
"to",
"this",
"point",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/parser_base.py#L40-L43 | [
"def",
"_attempting",
"(",
"self",
",",
"text",
")",
":",
"consumed",
"=",
"len",
"(",
"self",
".",
"original_text",
")",
"-",
"len",
"(",
"text",
")",
"self",
".",
"most_consumed",
"=",
"max",
"(",
"consumed",
",",
"self",
".",
"most_consumed",
")"
] | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | MeasurementGet.add_arguments | Add specific command line arguments for this command | boundary/measurement_get.py | 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 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... | [
"Add",
"specific",
"command",
"line",
"arguments",
"for",
"this",
"command"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/measurement_get.py#L48-L75 | [
"def",
"add_arguments",
"(",
"self",
")",
":",
"# Call our parent to add the default arguments",
"ApiCli",
".",
"add_arguments",
"(",
"self",
")",
"# Command specific arguments",
"self",
".",
"parser",
".",
"add_argument",
"(",
"'-f'",
",",
"'--format'",
",",
"dest",
... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MeasurementGet.get_arguments | Extracts the specific arguments of this CLI | boundary/measurement_get.py | 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 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... | [
"Extracts",
"the",
"specific",
"arguments",
"of",
"this",
"CLI"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/measurement_get.py#L77-L126 | [
"def",
"get_arguments",
"(",
"self",
")",
":",
"ApiCli",
".",
"get_arguments",
"(",
"self",
")",
"if",
"self",
".",
"args",
".",
"metric_name",
"is",
"not",
"None",
":",
"self",
".",
"_metric_name",
"=",
"self",
".",
"args",
".",
"metric_name",
"if",
"... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MeasurementGet.parse_time_date | 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. | boundary/measurement_get.py | 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 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:
... | [
"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",
"."
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/measurement_get.py#L128-L141 | [
"def",
"parse_time_date",
"(",
"self",
",",
"s",
")",
":",
"try",
":",
"ret",
"=",
"parser",
".",
"parse",
"(",
"str",
"(",
"s",
")",
")",
"except",
"ValueError",
":",
"try",
":",
"ret",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"int",
"(",
"s",
... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MeasurementGet.output_csv | Output results in CSV format | boundary/measurement_get.py | 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_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... | [
"Output",
"results",
"in",
"CSV",
"format"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/measurement_get.py#L157-L171 | [
"def",
"output_csv",
"(",
"self",
",",
"text",
")",
":",
"payload",
"=",
"json",
".",
"loads",
"(",
"text",
")",
"# Print CSV header",
"print",
"(",
"\"{0},{1},{2},{3},{4}\"",
".",
"format",
"(",
"'timestamp'",
",",
"'metric'",
",",
"'aggregate'",
",",
"'sou... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MeasurementGet.output_json | Output results in structured JSON format | boundary/measurement_get.py | 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_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])
... | [
"Output",
"results",
"in",
"structured",
"JSON",
"format"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/measurement_get.py#L173-L192 | [
"def",
"output_json",
"(",
"self",
",",
"text",
")",
":",
"payload",
"=",
"json",
".",
"loads",
"(",
"text",
")",
"data",
"=",
"[",
"]",
"metric_name",
"=",
"self",
".",
"_metric_name",
"for",
"r",
"in",
"payload",
"[",
"'result'",
"]",
"[",
"'aggreg... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MeasurementGet.output_raw | Output results in raw JSON format | boundary/measurement_get.py | 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_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)) | [
"Output",
"results",
"in",
"raw",
"JSON",
"format"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/measurement_get.py#L194-L200 | [
"def",
"output_raw",
"(",
"self",
",",
"text",
")",
":",
"payload",
"=",
"json",
".",
"loads",
"(",
"text",
")",
"out",
"=",
"json",
".",
"dumps",
"(",
"payload",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"self",
".",
"_indent",
",",
"sepa... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MeasurementGet.output_xml | Output results in JSON format | boundary/measurement_get.py | 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 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... | [
"Output",
"results",
"in",
"JSON",
"format"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/measurement_get.py#L202-L244 | [
"def",
"output_xml",
"(",
"self",
",",
"text",
")",
":",
"# Create the main document nodes",
"document",
"=",
"Element",
"(",
"'results'",
")",
"comment",
"=",
"Comment",
"(",
"'Generated by TrueSight Pulse measurement-get CLI'",
")",
"document",
".",
"append",
"(",
... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | MeasurementGet._handle_results | Call back function to be implemented by the CLI. | boundary/measurement_get.py | 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 _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)
... | [
"Call",
"back",
"function",
"to",
"be",
"implemented",
"by",
"the",
"CLI",
"."
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/measurement_get.py#L246-L262 | [
"def",
"_handle_results",
"(",
"self",
")",
":",
"# Only process if we get HTTP result of 200",
"if",
"self",
".",
"_api_result",
".",
"status_code",
"==",
"requests",
".",
"codes",
".",
"ok",
":",
"if",
"self",
".",
"format",
"==",
"\"json\"",
":",
"self",
".... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | trimmed_pred_default | The default predicate used in Node.trimmed. | pyebnf/primitive.py | 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 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)) | [
"The",
"default",
"predicate",
"used",
"in",
"Node",
".",
"trimmed",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L22-L24 | [
"def",
"trimmed_pred_default",
"(",
"node",
",",
"parent",
")",
":",
"return",
"isinstance",
"(",
"node",
",",
"ParseNode",
")",
"and",
"(",
"node",
".",
"is_empty",
"or",
"node",
".",
"is_type",
"(",
"ParseNodeType",
".",
"terminal",
")",
")"
] | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | pprint | Pretting print a parse tree. | pyebnf/primitive.py | 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 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 <... | [
"Pretting",
"print",
"a",
"parse",
"tree",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L234-L253 | [
"def",
"pprint",
"(",
"root",
",",
"depth",
"=",
"0",
",",
"space_unit",
"=",
"\" \"",
",",
"*",
",",
"source_len",
"=",
"0",
",",
"file",
"=",
"None",
")",
":",
"spacing",
"=",
"space_unit",
"*",
"depth",
"if",
"isinstance",
"(",
"root",
",",
"... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | zero_or_more | Returns a partial of _get_repetition with bounds set to (0, None) that accepts only a text
argument. | pyebnf/primitive.py | 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 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) | [
"Returns",
"a",
"partial",
"of",
"_get_repetition",
"with",
"bounds",
"set",
"to",
"(",
"0",
"None",
")",
"that",
"accepts",
"only",
"a",
"text",
"argument",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L286-L290 | [
"def",
"zero_or_more",
"(",
"extractor",
",",
"*",
",",
"ignore_whitespace",
"=",
"False",
")",
":",
"return",
"partial",
"(",
"_get_repetition",
",",
"extractor",
",",
"bounds",
"=",
"(",
"0",
",",
"None",
")",
",",
"ignore_whitespace",
"=",
"ignore_whitesp... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | one_or_more | Returns a partial of _get_repetition with bounds set to (1, None) that accepts only a text
argument. | pyebnf/primitive.py | 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 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) | [
"Returns",
"a",
"partial",
"of",
"_get_repetition",
"with",
"bounds",
"set",
"to",
"(",
"1",
"None",
")",
"that",
"accepts",
"only",
"a",
"text",
"argument",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L293-L297 | [
"def",
"one_or_more",
"(",
"extractor",
",",
"*",
",",
"ignore_whitespace",
"=",
"False",
")",
":",
"return",
"partial",
"(",
"_get_repetition",
",",
"extractor",
",",
"bounds",
"=",
"(",
"1",
",",
"None",
")",
",",
"ignore_whitespace",
"=",
"ignore_whitespa... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | repeated | Returns a partial of _get_repetition with bounds set to (times, times) that accepts only a text
argument. | pyebnf/primitive.py | 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 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... | [
"Returns",
"a",
"partial",
"of",
"_get_repetition",
"with",
"bounds",
"set",
"to",
"(",
"times",
"times",
")",
"that",
"accepts",
"only",
"a",
"text",
"argument",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L300-L307 | [
"def",
"repeated",
"(",
"extractor",
",",
"times",
",",
"*",
",",
"ignore_whitespace",
"=",
"False",
")",
":",
"return",
"partial",
"(",
"_get_repetition",
",",
"extractor",
",",
"bounds",
"=",
"(",
"times",
",",
"times",
")",
",",
"ignore_whitespace",
"="... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | repetition | Returns a partial of _get_repetition that accepts only a text argument. | pyebnf/primitive.py | 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 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) | [
"Returns",
"a",
"partial",
"of",
"_get_repetition",
"that",
"accepts",
"only",
"a",
"text",
"argument",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L310-L312 | [
"def",
"repetition",
"(",
"extractor",
",",
"bounds",
",",
"*",
",",
"ignore_whitespace",
"=",
"False",
")",
":",
"return",
"partial",
"(",
"_get_repetition",
",",
"extractor",
",",
"bounds",
"=",
"bounds",
",",
"ignore_whitespace",
"=",
"ignore_whitespace",
"... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | _get_terminal | 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. | pyebnf/primitive.py | 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_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,
... | [
"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",
... | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L320-L330 | [
"def",
"_get_terminal",
"(",
"value",
",",
"text",
")",
":",
"if",
"text",
"and",
"text",
".",
"startswith",
"(",
"value",
")",
":",
"return",
"ParseNode",
"(",
"ParseNodeType",
".",
"terminal",
",",
"children",
"=",
"[",
"value",
"]",
",",
"consumed",
... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | _get_concatenation | 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. | pyebnf/primitive.py | 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... | 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... | [
"Returns",
"a",
"concatenation",
"ParseNode",
"whose",
"children",
"are",
"the",
"nodes",
"returned",
"by",
"each",
"of",
"the",
"methods",
"in",
"the",
"extractors",
"enumerable",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L333-L360 | [
"def",
"_get_concatenation",
"(",
"extractors",
",",
"text",
",",
"*",
",",
"ignore_whitespace",
"=",
"True",
")",
":",
"ignored_ws",
",",
"use_text",
"=",
"_split_ignored",
"(",
"text",
",",
"ignore_whitespace",
")",
"extractor",
",",
"",
"*",
"remaining",
... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | _get_alternation | Tries each extractor on the given text and returns the 'best fit'.
Best fit is defined by as the extractor whose result consumed the most text. If more than one
extractor is the best fit, the result of the one that appeared earliest in the list is returned.
If all extractors raise a DeadEnd, this method too wil... | pyebnf/primitive.py | def _get_alternation(extractors, text):
"""Tries each extractor on the given text and returns the 'best fit'.
Best fit is defined by as the extractor whose result consumed the most text. If more than one
extractor is the best fit, the result of the one that appeared earliest in the list is returned.
If all ex... | def _get_alternation(extractors, text):
"""Tries each extractor on the given text and returns the 'best fit'.
Best fit is defined by as the extractor whose result consumed the most text. If more than one
extractor is the best fit, the result of the one that appeared earliest in the list is returned.
If all ex... | [
"Tries",
"each",
"extractor",
"on",
"the",
"given",
"text",
"and",
"returns",
"the",
"best",
"fit",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L363-L388 | [
"def",
"_get_alternation",
"(",
"extractors",
",",
"text",
")",
":",
"candidates",
"=",
"[",
"]",
"for",
"extractor",
"in",
"extractors",
":",
"try",
":",
"candidates",
".",
"append",
"(",
"_call_extractor",
"(",
"extractor",
",",
"text",
")",
")",
"except... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | _get_repetition | Tries to pull text with extractor repeatedly.
Bounds is a 2-tuple of (lbound, ubound) where lbound is a number and ubound is a number or None.
If the ubound is None, this method will execute extractor on text until extrator raises DeadEnd.
Otherwise, extractor will be called until it raises DeadEnd, or it has ex... | pyebnf/primitive.py | def _get_repetition(extractor, text, *, bounds=(0, None), ignore_whitespace=False):
"""Tries to pull text with extractor repeatedly.
Bounds is a 2-tuple of (lbound, ubound) where lbound is a number and ubound is a number or None.
If the ubound is None, this method will execute extractor on text until extrator ra... | def _get_repetition(extractor, text, *, bounds=(0, None), ignore_whitespace=False):
"""Tries to pull text with extractor repeatedly.
Bounds is a 2-tuple of (lbound, ubound) where lbound is a number and ubound is a number or None.
If the ubound is None, this method will execute extractor on text until extrator ra... | [
"Tries",
"to",
"pull",
"text",
"with",
"extractor",
"repeatedly",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L391-L431 | [
"def",
"_get_repetition",
"(",
"extractor",
",",
"text",
",",
"*",
",",
"bounds",
"=",
"(",
"0",
",",
"None",
")",
",",
"ignore_whitespace",
"=",
"False",
")",
":",
"minr",
",",
"maxr",
"=",
"bounds",
"children",
"=",
"[",
"]",
"while",
"maxr",
"is",... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | _get_exclusion | Returns extractor's result if exclusion does not match.
If exclusion raises DeadEnd (meaning it did not match) then the result of extractor(text) is
returned. Otherwise, if exclusion does not raise DeadEnd it means it did match, and we then
raise DeadEnd. | pyebnf/primitive.py | def _get_exclusion(extractor, exclusion, text):
"""Returns extractor's result if exclusion does not match.
If exclusion raises DeadEnd (meaning it did not match) then the result of extractor(text) is
returned. Otherwise, if exclusion does not raise DeadEnd it means it did match, and we then
raise DeadEnd.
""... | def _get_exclusion(extractor, exclusion, text):
"""Returns extractor's result if exclusion does not match.
If exclusion raises DeadEnd (meaning it did not match) then the result of extractor(text) is
returned. Otherwise, if exclusion does not raise DeadEnd it means it did match, and we then
raise DeadEnd.
""... | [
"Returns",
"extractor",
"s",
"result",
"if",
"exclusion",
"does",
"not",
"match",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L434-L450 | [
"def",
"_get_exclusion",
"(",
"extractor",
",",
"exclusion",
",",
"text",
")",
":",
"try",
":",
"_call_extractor",
"(",
"exclusion",
",",
"text",
")",
"exclusion_matches",
"=",
"True",
"except",
"DeadEnd",
":",
"exclusion_matches",
"=",
"False",
"if",
"exclusi... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | _split_ignored | Return (leading whitespace, trailing text) if ignore_whitespace is true, or ("", text) if
False. | pyebnf/primitive.py | def _split_ignored(text, ignore_whitespace=True):
"""Return (leading whitespace, trailing text) if ignore_whitespace is true, or ("", text) if
False.
"""
if ignore_whitespace:
leading_ws_count = _count_leading_whitespace(text)
ignored_ws = text[:leading_ws_count]
use_text = text[leading_ws_count:]
... | def _split_ignored(text, ignore_whitespace=True):
"""Return (leading whitespace, trailing text) if ignore_whitespace is true, or ("", text) if
False.
"""
if ignore_whitespace:
leading_ws_count = _count_leading_whitespace(text)
ignored_ws = text[:leading_ws_count]
use_text = text[leading_ws_count:]
... | [
"Return",
"(",
"leading",
"whitespace",
"trailing",
"text",
")",
"if",
"ignore_whitespace",
"is",
"true",
"or",
"(",
"text",
")",
"if",
"False",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L453-L463 | [
"def",
"_split_ignored",
"(",
"text",
",",
"ignore_whitespace",
"=",
"True",
")",
":",
"if",
"ignore_whitespace",
":",
"leading_ws_count",
"=",
"_count_leading_whitespace",
"(",
"text",
")",
"ignored_ws",
"=",
"text",
"[",
":",
"leading_ws_count",
"]",
"use_text",... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | _count_leading_whitespace | Returns the number of characters at the beginning of text that are whitespace. | pyebnf/primitive.py | def _count_leading_whitespace(text):
"""Returns the number of characters at the beginning of text that are whitespace."""
idx = 0
for idx, char in enumerate(text):
if not char.isspace():
return idx
return idx + 1 | def _count_leading_whitespace(text):
"""Returns the number of characters at the beginning of text that are whitespace."""
idx = 0
for idx, char in enumerate(text):
if not char.isspace():
return idx
return idx + 1 | [
"Returns",
"the",
"number",
"of",
"characters",
"at",
"the",
"beginning",
"of",
"text",
"that",
"are",
"whitespace",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L466-L472 | [
"def",
"_count_leading_whitespace",
"(",
"text",
")",
":",
"idx",
"=",
"0",
"for",
"idx",
",",
"char",
"in",
"enumerate",
"(",
"text",
")",
":",
"if",
"not",
"char",
".",
"isspace",
"(",
")",
":",
"return",
"idx",
"return",
"idx",
"+",
"1"
] | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | _call_extractor | This method calls an extractor on some text.
If extractor is just a string, it is passed as the first value to _get_terminal. Otherwise it is
treated as a callable and text is passed directly to it.
This makes it so you can have a shorthand of terminal(val) <-> val. | pyebnf/primitive.py | def _call_extractor(extractor, text):
"""This method calls an extractor on some text.
If extractor is just a string, it is passed as the first value to _get_terminal. Otherwise it is
treated as a callable and text is passed directly to it.
This makes it so you can have a shorthand of terminal(val) <-> val.
... | def _call_extractor(extractor, text):
"""This method calls an extractor on some text.
If extractor is just a string, it is passed as the first value to _get_terminal. Otherwise it is
treated as a callable and text is passed directly to it.
This makes it so you can have a shorthand of terminal(val) <-> val.
... | [
"This",
"method",
"calls",
"an",
"extractor",
"on",
"some",
"text",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L475-L486 | [
"def",
"_call_extractor",
"(",
"extractor",
",",
"text",
")",
":",
"if",
"isinstance",
"(",
"extractor",
",",
"str",
")",
":",
"return",
"_get_terminal",
"(",
"extractor",
",",
"text",
")",
"else",
":",
"return",
"extractor",
"(",
"text",
")"
] | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.position | Gets the position of the text the ParseNode processed. If the ParseNode does not have its
own position, it looks to its first child for its position.
'Value Nodes' (terminals) must have their own position, otherwise this method will throw an
exception when it tries to get the position property of the strin... | pyebnf/primitive.py | def position(self):
"""Gets the position of the text the ParseNode processed. If the ParseNode does not have its
own position, it looks to its first child for its position.
'Value Nodes' (terminals) must have their own position, otherwise this method will throw an
exception when it tries to get the pos... | def position(self):
"""Gets the position of the text the ParseNode processed. If the ParseNode does not have its
own position, it looks to its first child for its position.
'Value Nodes' (terminals) must have their own position, otherwise this method will throw an
exception when it tries to get the pos... | [
"Gets",
"the",
"position",
"of",
"the",
"text",
"the",
"ParseNode",
"processed",
".",
"If",
"the",
"ParseNode",
"does",
"not",
"have",
"its",
"own",
"position",
"it",
"looks",
"to",
"its",
"first",
"child",
"for",
"its",
"position",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L49-L61 | [
"def",
"position",
"(",
"self",
")",
":",
"pos",
"=",
"self",
".",
"_position",
"if",
"pos",
"is",
"None",
"and",
"self",
".",
"children",
":",
"ch1",
"=",
"self",
".",
"children",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"ch1",
",",
"ParseNode",
")... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.is_empty | Returns True if this node has no children, or if all of its children are ParseNode instances
and are empty. | pyebnf/primitive.py | def is_empty(self):
"""Returns True if this node has no children, or if all of its children are ParseNode instances
and are empty.
"""
return all(isinstance(c, ParseNode) and c.is_empty for c in self.children) | def is_empty(self):
"""Returns True if this node has no children, or if all of its children are ParseNode instances
and are empty.
"""
return all(isinstance(c, ParseNode) and c.is_empty for c in self.children) | [
"Returns",
"True",
"if",
"this",
"node",
"has",
"no",
"children",
"or",
"if",
"all",
"of",
"its",
"children",
"are",
"ParseNode",
"instances",
"and",
"are",
"empty",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L64-L68 | [
"def",
"is_empty",
"(",
"self",
")",
":",
"return",
"all",
"(",
"isinstance",
"(",
"c",
",",
"ParseNode",
")",
"and",
"c",
".",
"is_empty",
"for",
"c",
"in",
"self",
".",
"children",
")"
] | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.add_ignored | Add ignored text to the node. This will add the length of the ignored text to the node's
consumed property. | pyebnf/primitive.py | def add_ignored(self, ignored):
"""Add ignored text to the node. This will add the length of the ignored text to the node's
consumed property.
"""
if ignored:
if self.ignored:
self.ignored = ignored + self.ignored
else:
self.ignored = ignored
self.consumed += len(ignored... | def add_ignored(self, ignored):
"""Add ignored text to the node. This will add the length of the ignored text to the node's
consumed property.
"""
if ignored:
if self.ignored:
self.ignored = ignored + self.ignored
else:
self.ignored = ignored
self.consumed += len(ignored... | [
"Add",
"ignored",
"text",
"to",
"the",
"node",
".",
"This",
"will",
"add",
"the",
"length",
"of",
"the",
"ignored",
"text",
"to",
"the",
"node",
"s",
"consumed",
"property",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L87-L97 | [
"def",
"add_ignored",
"(",
"self",
",",
"ignored",
")",
":",
"if",
"ignored",
":",
"if",
"self",
".",
"ignored",
":",
"self",
".",
"ignored",
"=",
"ignored",
"+",
"self",
".",
"ignored",
"else",
":",
"self",
".",
"ignored",
"=",
"ignored",
"self",
".... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.is_type | Returns True if node_type == value.
If value is a tuple, node_type is checked against each member and True is returned if any of
them match. | pyebnf/primitive.py | def is_type(self, value):
"""Returns True if node_type == value.
If value is a tuple, node_type is checked against each member and True is returned if any of
them match.
"""
if isinstance(value, tuple):
for opt in value:
if self.node_type == opt:
return True
return Fal... | def is_type(self, value):
"""Returns True if node_type == value.
If value is a tuple, node_type is checked against each member and True is returned if any of
them match.
"""
if isinstance(value, tuple):
for opt in value:
if self.node_type == opt:
return True
return Fal... | [
"Returns",
"True",
"if",
"node_type",
"==",
"value",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L99-L111 | [
"def",
"is_type",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"tuple",
")",
":",
"for",
"opt",
"in",
"value",
":",
"if",
"self",
".",
"node_type",
"==",
"opt",
":",
"return",
"True",
"return",
"False",
"else",
":",
"... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.flattened | Flattens nodes by hoisting children up to ancestor nodes.
A node is hoisted if pred(node) returns True. | pyebnf/primitive.py | def flattened(self, pred=flattened_pred_default):
"""Flattens nodes by hoisting children up to ancestor nodes.
A node is hoisted if pred(node) returns True.
"""
if self.is_value:
return self
new_children = []
for child in self.children:
if child.is_empty:
continue
n... | def flattened(self, pred=flattened_pred_default):
"""Flattens nodes by hoisting children up to ancestor nodes.
A node is hoisted if pred(node) returns True.
"""
if self.is_value:
return self
new_children = []
for child in self.children:
if child.is_empty:
continue
n... | [
"Flattens",
"nodes",
"by",
"hoisting",
"children",
"up",
"to",
"ancestor",
"nodes",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L113-L138 | [
"def",
"flattened",
"(",
"self",
",",
"pred",
"=",
"flattened_pred_default",
")",
":",
"if",
"self",
".",
"is_value",
":",
"return",
"self",
"new_children",
"=",
"[",
"]",
"for",
"child",
"in",
"self",
".",
"children",
":",
"if",
"child",
".",
"is_empty"... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.trimmed | Trim a ParseTree.
A node is trimmed if pred(node) returns True. | pyebnf/primitive.py | def trimmed(self, pred=trimmed_pred_default):
"""Trim a ParseTree.
A node is trimmed if pred(node) returns True.
"""
new_children = []
for child in self.children:
if isinstance(child, ParseNode):
new_child = child.trimmed(pred)
else:
new_child = child
if not pred... | def trimmed(self, pred=trimmed_pred_default):
"""Trim a ParseTree.
A node is trimmed if pred(node) returns True.
"""
new_children = []
for child in self.children:
if isinstance(child, ParseNode):
new_child = child.trimmed(pred)
else:
new_child = child
if not pred... | [
"Trim",
"a",
"ParseTree",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L140-L160 | [
"def",
"trimmed",
"(",
"self",
",",
"pred",
"=",
"trimmed_pred_default",
")",
":",
"new_children",
"=",
"[",
"]",
"for",
"child",
"in",
"self",
".",
"children",
":",
"if",
"isinstance",
"(",
"child",
",",
"ParseNode",
")",
":",
"new_child",
"=",
"child",... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.merged | Returns a new ParseNode whose type is this node's type, and whose children are all the
children from this node and the other whose length is not 0. | pyebnf/primitive.py | def merged(self, other):
"""Returns a new ParseNode whose type is this node's type, and whose children are all the
children from this node and the other whose length is not 0.
"""
children = [c for c in itertools.chain(self.children, other.children) if len(c) > 0]
# NOTE: Only terminals should have ... | def merged(self, other):
"""Returns a new ParseNode whose type is this node's type, and whose children are all the
children from this node and the other whose length is not 0.
"""
children = [c for c in itertools.chain(self.children, other.children) if len(c) > 0]
# NOTE: Only terminals should have ... | [
"Returns",
"a",
"new",
"ParseNode",
"whose",
"type",
"is",
"this",
"node",
"s",
"type",
"and",
"whose",
"children",
"are",
"all",
"the",
"children",
"from",
"this",
"node",
"and",
"the",
"other",
"whose",
"length",
"is",
"not",
"0",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L162-L174 | [
"def",
"merged",
"(",
"self",
",",
"other",
")",
":",
"children",
"=",
"[",
"c",
"for",
"c",
"in",
"itertools",
".",
"chain",
"(",
"self",
".",
"children",
",",
"other",
".",
"children",
")",
"if",
"len",
"(",
"c",
")",
">",
"0",
"]",
"# NOTE: On... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.retyped | Returns a new node with the same contents as self, but with a new node_type. | pyebnf/primitive.py | def retyped(self, new_type):
"""Returns a new node with the same contents as self, but with a new node_type."""
return ParseNode(new_type,
children=list(self.children),
consumed=self.consumed,
position=self.position,
ignored... | def retyped(self, new_type):
"""Returns a new node with the same contents as self, but with a new node_type."""
return ParseNode(new_type,
children=list(self.children),
consumed=self.consumed,
position=self.position,
ignored... | [
"Returns",
"a",
"new",
"node",
"with",
"the",
"same",
"contents",
"as",
"self",
"but",
"with",
"a",
"new",
"node_type",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L176-L182 | [
"def",
"retyped",
"(",
"self",
",",
"new_type",
")",
":",
"return",
"ParseNode",
"(",
"new_type",
",",
"children",
"=",
"list",
"(",
"self",
".",
"children",
")",
",",
"consumed",
"=",
"self",
".",
"consumed",
",",
"position",
"=",
"self",
".",
"positi... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | ParseNode.compressed | Turns the node into a value node, whose single string child is the concatenation of all its
children. | pyebnf/primitive.py | def compressed(self, new_type=None, *, include_ignored=False):
"""Turns the node into a value node, whose single string child is the concatenation of all its
children.
"""
values = []
consumed = 0
ignored = None
for i, child in enumerate(self.children):
consumed += child.consumed
... | def compressed(self, new_type=None, *, include_ignored=False):
"""Turns the node into a value node, whose single string child is the concatenation of all its
children.
"""
values = []
consumed = 0
ignored = None
for i, child in enumerate(self.children):
consumed += child.consumed
... | [
"Turns",
"the",
"node",
"into",
"a",
"value",
"node",
"whose",
"single",
"string",
"child",
"is",
"the",
"concatenation",
"of",
"all",
"its",
"children",
"."
] | treycucco/pyebnf | python | https://github.com/treycucco/pyebnf/blob/3634ddabbe5d73508bcc20f4a591f86a46634e1d/pyebnf/primitive.py#L184-L208 | [
"def",
"compressed",
"(",
"self",
",",
"new_type",
"=",
"None",
",",
"*",
",",
"include_ignored",
"=",
"False",
")",
":",
"values",
"=",
"[",
"]",
"consumed",
"=",
"0",
"ignored",
"=",
"None",
"for",
"i",
",",
"child",
"in",
"enumerate",
"(",
"self",... | 3634ddabbe5d73508bcc20f4a591f86a46634e1d |
test | HostgroupModify.get_arguments | Extracts the specific arguments of this CLI | boundary/hostgroup_modify.py | def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
# Get the host group name
if self.args.host_group_name is not None:
self.host_group_name = self.args.host_group_name
# Get the list of sources sep... | def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
# Get the host group name
if self.args.host_group_name is not None:
self.host_group_name = self.args.host_group_name
# Get the list of sources sep... | [
"Extracts",
"the",
"specific",
"arguments",
"of",
"this",
"CLI"
] | boundary/pulse-api-cli | python | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/hostgroup_modify.py#L32-L58 | [
"def",
"get_arguments",
"(",
"self",
")",
":",
"ApiCli",
".",
"get_arguments",
"(",
"self",
")",
"# Get the host group name",
"if",
"self",
".",
"args",
".",
"host_group_name",
"is",
"not",
"None",
":",
"self",
".",
"host_group_name",
"=",
"self",
".",
"args... | b01ca65b442eed19faac309c9d62bbc3cb2c098f |
test | Symbol.get_scope_list | Return the list of all contained scope from global to local | pyrser/type_system/symbol.py | def get_scope_list(self) -> list:
"""
Return the list of all contained scope from global to local
"""
# by default only return scoped name
lstparent = [self]
p = self.get_parent()
while p is not None:
lstparent.append(p)
p = p.get_parent()
... | def get_scope_list(self) -> list:
"""
Return the list of all contained scope from global to local
"""
# by default only return scoped name
lstparent = [self]
p = self.get_parent()
while p is not None:
lstparent.append(p)
p = p.get_parent()
... | [
"Return",
"the",
"list",
"of",
"all",
"contained",
"scope",
"from",
"global",
"to",
"local"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/symbol.py#L39-L49 | [
"def",
"get_scope_list",
"(",
"self",
")",
"->",
"list",
":",
"# by default only return scoped name",
"lstparent",
"=",
"[",
"self",
"]",
"p",
"=",
"self",
".",
"get_parent",
"(",
")",
"while",
"p",
"is",
"not",
"None",
":",
"lstparent",
".",
"append",
"("... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Symbol.get_scope_names | Return the list of all contained scope from global to local | pyrser/type_system/symbol.py | def get_scope_names(self) -> list:
"""
Return the list of all contained scope from global to local
"""
# allow global scope to have an None string instance
lscope = []
for scope in reversed(self.get_scope_list()):
if scope.name is not None:
# h... | def get_scope_names(self) -> list:
"""
Return the list of all contained scope from global to local
"""
# allow global scope to have an None string instance
lscope = []
for scope in reversed(self.get_scope_list()):
if scope.name is not None:
# h... | [
"Return",
"the",
"list",
"of",
"all",
"contained",
"scope",
"from",
"global",
"to",
"local"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/symbol.py#L51-L61 | [
"def",
"get_scope_names",
"(",
"self",
")",
"->",
"list",
":",
"# allow global scope to have an None string instance",
"lscope",
"=",
"[",
"]",
"for",
"scope",
"in",
"reversed",
"(",
"self",
".",
"get_scope_list",
"(",
")",
")",
":",
"if",
"scope",
".",
"name"... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Cursor.position | The current position of the cursor. | pyrser/parsing/stream.py | def position(self) -> Position:
"""The current position of the cursor."""
return Position(self._index, self._lineno, self._col_offset) | def position(self) -> Position:
"""The current position of the cursor."""
return Position(self._index, self._lineno, self._col_offset) | [
"The",
"current",
"position",
"of",
"the",
"cursor",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L40-L42 | [
"def",
"position",
"(",
"self",
")",
"->",
"Position",
":",
"return",
"Position",
"(",
"self",
".",
"_index",
",",
"self",
".",
"_lineno",
",",
"self",
".",
"_col_offset",
")"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Cursor.max_readed_position | The index of the deepest character readed. | pyrser/parsing/stream.py | def max_readed_position(self) -> Position:
"""The index of the deepest character readed."""
return Position(self._maxindex, self._maxline, self._maxcol) | def max_readed_position(self) -> Position:
"""The index of the deepest character readed."""
return Position(self._maxindex, self._maxline, self._maxcol) | [
"The",
"index",
"of",
"the",
"deepest",
"character",
"readed",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L51-L53 | [
"def",
"max_readed_position",
"(",
"self",
")",
"->",
"Position",
":",
"return",
"Position",
"(",
"self",
".",
"_maxindex",
",",
"self",
".",
"_maxline",
",",
"self",
".",
"_maxcol",
")"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Cursor.step_next_char | Puts the cursor on the next character. | pyrser/parsing/stream.py | def step_next_char(self):
"""Puts the cursor on the next character."""
self._index += 1
self._col_offset += 1
if self._index > self._maxindex:
self._maxindex = self._index
self._maxcol = self._col_offset
self._maxline = self._lineno | def step_next_char(self):
"""Puts the cursor on the next character."""
self._index += 1
self._col_offset += 1
if self._index > self._maxindex:
self._maxindex = self._index
self._maxcol = self._col_offset
self._maxline = self._lineno | [
"Puts",
"the",
"cursor",
"on",
"the",
"next",
"character",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L55-L62 | [
"def",
"step_next_char",
"(",
"self",
")",
":",
"self",
".",
"_index",
"+=",
"1",
"self",
".",
"_col_offset",
"+=",
"1",
"if",
"self",
".",
"_index",
">",
"self",
".",
"_maxindex",
":",
"self",
".",
"_maxindex",
"=",
"self",
".",
"_index",
"self",
".... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Cursor.step_next_line | Sets cursor as beginning of next line. | pyrser/parsing/stream.py | def step_next_line(self):
"""Sets cursor as beginning of next line."""
self._eol.append(self.position)
self._lineno += 1
self._col_offset = 0 | def step_next_line(self):
"""Sets cursor as beginning of next line."""
self._eol.append(self.position)
self._lineno += 1
self._col_offset = 0 | [
"Sets",
"cursor",
"as",
"beginning",
"of",
"next",
"line",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L69-L73 | [
"def",
"step_next_line",
"(",
"self",
")",
":",
"self",
".",
"_eol",
".",
"append",
"(",
"self",
".",
"position",
")",
"self",
".",
"_lineno",
"+=",
"1",
"self",
".",
"_col_offset",
"=",
"0"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Cursor.step_prev_line | Sets cursor as end of previous line. | pyrser/parsing/stream.py | def step_prev_line(self):
"""Sets cursor as end of previous line."""
#TODO(bps): raise explicit error for unregistered eol
#assert self._eol[-1].index == self._index
if len(self._eol) > 0:
self.position = self._eol.pop() | def step_prev_line(self):
"""Sets cursor as end of previous line."""
#TODO(bps): raise explicit error for unregistered eol
#assert self._eol[-1].index == self._index
if len(self._eol) > 0:
self.position = self._eol.pop() | [
"Sets",
"cursor",
"as",
"end",
"of",
"previous",
"line",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L75-L80 | [
"def",
"step_prev_line",
"(",
"self",
")",
":",
"#TODO(bps): raise explicit error for unregistered eol",
"#assert self._eol[-1].index == self._index",
"if",
"len",
"(",
"self",
".",
"_eol",
")",
">",
"0",
":",
"self",
".",
"position",
"=",
"self",
".",
"_eol",
".",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Stream.last_readed_line | Usefull string to compute error message. | pyrser/parsing/stream.py | def last_readed_line(self) -> str:
"""Usefull string to compute error message."""
mpos = self._cursor.max_readed_position
mindex = mpos.index
# search last \n
prevline = mindex - 1 if mindex == self.eos_index else mindex
while prevline >= 0 and self._content[prevline] != ... | def last_readed_line(self) -> str:
"""Usefull string to compute error message."""
mpos = self._cursor.max_readed_position
mindex = mpos.index
# search last \n
prevline = mindex - 1 if mindex == self.eos_index else mindex
while prevline >= 0 and self._content[prevline] != ... | [
"Usefull",
"string",
"to",
"compute",
"error",
"message",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L156-L169 | [
"def",
"last_readed_line",
"(",
"self",
")",
"->",
"str",
":",
"mpos",
"=",
"self",
".",
"_cursor",
".",
"max_readed_position",
"mindex",
"=",
"mpos",
".",
"index",
"# search last \\n",
"prevline",
"=",
"mindex",
"-",
"1",
"if",
"mindex",
"==",
"self",
"."... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Stream.incpos | Increment the cursor to the next character. | pyrser/parsing/stream.py | def incpos(self, length: int=1) -> int:
"""Increment the cursor to the next character."""
if length < 0:
raise ValueError("length must be positive")
i = 0
while (i < length):
if self._cursor.index < self._len:
if self.peek_char == '\n':
... | def incpos(self, length: int=1) -> int:
"""Increment the cursor to the next character."""
if length < 0:
raise ValueError("length must be positive")
i = 0
while (i < length):
if self._cursor.index < self._len:
if self.peek_char == '\n':
... | [
"Increment",
"the",
"cursor",
"to",
"the",
"next",
"character",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L171-L182 | [
"def",
"incpos",
"(",
"self",
",",
"length",
":",
"int",
"=",
"1",
")",
"->",
"int",
":",
"if",
"length",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"length must be positive\"",
")",
"i",
"=",
"0",
"while",
"(",
"i",
"<",
"length",
")",
":",
"if"... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Stream.save_context | Save current position. | pyrser/parsing/stream.py | def save_context(self) -> bool:
"""Save current position."""
self._contexts.append(self._cursor.position)
return True | def save_context(self) -> bool:
"""Save current position."""
self._contexts.append(self._cursor.position)
return True | [
"Save",
"current",
"position",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L199-L202 | [
"def",
"save_context",
"(",
"self",
")",
"->",
"bool",
":",
"self",
".",
"_contexts",
".",
"append",
"(",
"self",
".",
"_cursor",
".",
"position",
")",
"return",
"True"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Stream.restore_context | Rollback to previous saved position. | pyrser/parsing/stream.py | def restore_context(self) -> bool:
"""Rollback to previous saved position."""
self._cursor.position = self._contexts.pop()
return False | def restore_context(self) -> bool:
"""Rollback to previous saved position."""
self._cursor.position = self._contexts.pop()
return False | [
"Rollback",
"to",
"previous",
"saved",
"position",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/stream.py#L204-L207 | [
"def",
"restore_context",
"(",
"self",
")",
"->",
"bool",
":",
"self",
".",
"_cursor",
".",
"position",
"=",
"self",
".",
"_contexts",
".",
"pop",
"(",
")",
"return",
"False"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | to_fmt | Return an Fmt representation for pretty-printing | pyrser/type_system/to_fmt.py | def to_fmt(self) -> fmt.indentable:
"""
Return an Fmt representation for pretty-printing
"""
qual = "scope"
txt = fmt.sep(" ", [qual])
name = self.show_name()
if name != "":
txt.lsdata.append(name)
if len(self._hsig) > 0 or len(self.mapTypeTranslate) > 0:
lsb = []
... | def to_fmt(self) -> fmt.indentable:
"""
Return an Fmt representation for pretty-printing
"""
qual = "scope"
txt = fmt.sep(" ", [qual])
name = self.show_name()
if name != "":
txt.lsdata.append(name)
if len(self._hsig) > 0 or len(self.mapTypeTranslate) > 0:
lsb = []
... | [
"Return",
"an",
"Fmt",
"representation",
"for",
"pretty",
"-",
"printing"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/to_fmt.py#L19-L38 | [
"def",
"to_fmt",
"(",
"self",
")",
"->",
"fmt",
".",
"indentable",
":",
"qual",
"=",
"\"scope\"",
"txt",
"=",
"fmt",
".",
"sep",
"(",
"\" \"",
",",
"[",
"qual",
"]",
")",
"name",
"=",
"self",
".",
"show_name",
"(",
")",
"if",
"name",
"!=",
"\"\""... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | to_fmt | Return an Fmt representation for pretty-printing | pyrser/type_system/to_fmt.py | def to_fmt(self):
"""
Return an Fmt representation for pretty-printing
"""
qual = "evalctx"
lseval = []
block = fmt.block(":\n", "", fmt.tab(lseval))
txt = fmt.sep(" ", [qual, block])
lseval.append(self._sig.to_fmt())
if len(self.resolution) > 0:
lsb = []
for k in sor... | def to_fmt(self):
"""
Return an Fmt representation for pretty-printing
"""
qual = "evalctx"
lseval = []
block = fmt.block(":\n", "", fmt.tab(lseval))
txt = fmt.sep(" ", [qual, block])
lseval.append(self._sig.to_fmt())
if len(self.resolution) > 0:
lsb = []
for k in sor... | [
"Return",
"an",
"Fmt",
"representation",
"for",
"pretty",
"-",
"printing"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/to_fmt.py#L60-L92 | [
"def",
"to_fmt",
"(",
"self",
")",
":",
"qual",
"=",
"\"evalctx\"",
"lseval",
"=",
"[",
"]",
"block",
"=",
"fmt",
".",
"block",
"(",
"\":\\n\"",
",",
"\"\"",
",",
"fmt",
".",
"tab",
"(",
"lseval",
")",
")",
"txt",
"=",
"fmt",
".",
"sep",
"(",
"... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | to_fmt | Return a Fmt representation of Translator for pretty-printing | pyrser/type_system/to_fmt.py | def to_fmt(self, with_from=False) -> fmt.indentable:
"""
Return a Fmt representation of Translator for pretty-printing
"""
txt = fmt.sep("\n", [
fmt.sep(
" ",
[
self._type_source,
"to",
self._type_target,
'='... | def to_fmt(self, with_from=False) -> fmt.indentable:
"""
Return a Fmt representation of Translator for pretty-printing
"""
txt = fmt.sep("\n", [
fmt.sep(
" ",
[
self._type_source,
"to",
self._type_target,
'='... | [
"Return",
"a",
"Fmt",
"representation",
"of",
"Translator",
"for",
"pretty",
"-",
"printing"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/to_fmt.py#L96-L113 | [
"def",
"to_fmt",
"(",
"self",
",",
"with_from",
"=",
"False",
")",
"->",
"fmt",
".",
"indentable",
":",
"txt",
"=",
"fmt",
".",
"sep",
"(",
"\"\\n\"",
",",
"[",
"fmt",
".",
"sep",
"(",
"\" \"",
",",
"[",
"self",
".",
"_type_source",
",",
"\"to\"",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | to_fmt | Return an Fmt representation for pretty-printing | pyrser/type_system/to_fmt.py | def to_fmt(self):
"""
Return an Fmt representation for pretty-printing
"""
params = ""
txt = fmt.sep(" ", ['val'])
name = self.show_name()
if name != "":
txt.lsdata.append(name)
txt.lsdata.append('(%s)' % self.value)
txt.lsdata.append(': ' + self.tret)
return txt | def to_fmt(self):
"""
Return an Fmt representation for pretty-printing
"""
params = ""
txt = fmt.sep(" ", ['val'])
name = self.show_name()
if name != "":
txt.lsdata.append(name)
txt.lsdata.append('(%s)' % self.value)
txt.lsdata.append(': ' + self.tret)
return txt | [
"Return",
"an",
"Fmt",
"representation",
"for",
"pretty",
"-",
"printing"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/to_fmt.py#L152-L163 | [
"def",
"to_fmt",
"(",
"self",
")",
":",
"params",
"=",
"\"\"",
"txt",
"=",
"fmt",
".",
"sep",
"(",
"\" \"",
",",
"[",
"'val'",
"]",
")",
"name",
"=",
"self",
".",
"show_name",
"(",
")",
"if",
"name",
"!=",
"\"\"",
":",
"txt",
".",
"lsdata",
"."... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | to_fmt | Return an Fmt representation for pretty-printing | pyrser/type_system/to_fmt.py | def to_fmt(self):
"""
Return an Fmt representation for pretty-printing
"""
params = ""
txt = fmt.sep(" ", ['fun'])
name = self.show_name()
if name != "":
txt.lsdata.append(name)
tparams = []
if self.tparams is not None:
tparams = list(self.tparams)
if self.variadi... | def to_fmt(self):
"""
Return an Fmt representation for pretty-printing
"""
params = ""
txt = fmt.sep(" ", ['fun'])
name = self.show_name()
if name != "":
txt.lsdata.append(name)
tparams = []
if self.tparams is not None:
tparams = list(self.tparams)
if self.variadi... | [
"Return",
"an",
"Fmt",
"representation",
"for",
"pretty",
"-",
"printing"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/to_fmt.py#L181-L198 | [
"def",
"to_fmt",
"(",
"self",
")",
":",
"params",
"=",
"\"\"",
"txt",
"=",
"fmt",
".",
"sep",
"(",
"\" \"",
",",
"[",
"'fun'",
"]",
")",
"name",
"=",
"self",
".",
"show_name",
"(",
")",
"if",
"name",
"!=",
"\"\"",
":",
"txt",
".",
"lsdata",
"."... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | walk | TODO: should_test_type?? | pyrser/ast/walk.py | def walk(self, lc: state.LivingContext, user_data=None, parent=None):
"""
TODO: should_test_type??
"""
global _cacheid
# root node autorefence
if parent is None:
parent = self
## walk attributes
if hasattr(self, '__dict__') and not isinstance(self, node.ListNode):
for k i... | def walk(self, lc: state.LivingContext, user_data=None, parent=None):
"""
TODO: should_test_type??
"""
global _cacheid
# root node autorefence
if parent is None:
parent = self
## walk attributes
if hasattr(self, '__dict__') and not isinstance(self, node.ListNode):
for k i... | [
"TODO",
":",
"should_test_type??"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/ast/walk.py#L11-L76 | [
"def",
"walk",
"(",
"self",
",",
"lc",
":",
"state",
".",
"LivingContext",
",",
"user_data",
"=",
"None",
",",
"parent",
"=",
"None",
")",
":",
"global",
"_cacheid",
"# root node autorefence",
"if",
"parent",
"is",
"None",
":",
"parent",
"=",
"self",
"##... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.set_name | You could set the name after construction | pyrser/type_system/scope.py | def set_name(self, name: str):
""" You could set the name after construction """
self.name = name
# update internal names
lsig = self._hsig.values()
self._hsig = {}
for s in lsig:
self._hsig[s.internal_name()] = s | def set_name(self, name: str):
""" You could set the name after construction """
self.name = name
# update internal names
lsig = self._hsig.values()
self._hsig = {}
for s in lsig:
self._hsig[s.internal_name()] = s | [
"You",
"could",
"set",
"the",
"name",
"after",
"construction"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L83-L90 | [
"def",
"set_name",
"(",
"self",
",",
"name",
":",
"str",
")",
":",
"self",
".",
"name",
"=",
"name",
"# update internal names",
"lsig",
"=",
"self",
".",
"_hsig",
".",
"values",
"(",
")",
"self",
".",
"_hsig",
"=",
"{",
"}",
"for",
"s",
"in",
"lsig... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.count_types | Count subtypes | pyrser/type_system/scope.py | def count_types(self) -> int:
""" Count subtypes """
n = 0
for s in self._hsig.values():
if type(s).__name__ == 'Type':
n += 1
return n | def count_types(self) -> int:
""" Count subtypes """
n = 0
for s in self._hsig.values():
if type(s).__name__ == 'Type':
n += 1
return n | [
"Count",
"subtypes"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L92-L98 | [
"def",
"count_types",
"(",
"self",
")",
"->",
"int",
":",
"n",
"=",
"0",
"for",
"s",
"in",
"self",
".",
"_hsig",
".",
"values",
"(",
")",
":",
"if",
"type",
"(",
"s",
")",
".",
"__name__",
"==",
"'Type'",
":",
"n",
"+=",
"1",
"return",
"n"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.count_vars | Count var define by this scope | pyrser/type_system/scope.py | def count_vars(self) -> int:
""" Count var define by this scope """
n = 0
for s in self._hsig.values():
if hasattr(s, 'is_var') and s.is_var:
n += 1
return n | def count_vars(self) -> int:
""" Count var define by this scope """
n = 0
for s in self._hsig.values():
if hasattr(s, 'is_var') and s.is_var:
n += 1
return n | [
"Count",
"var",
"define",
"by",
"this",
"scope"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L100-L106 | [
"def",
"count_vars",
"(",
"self",
")",
"->",
"int",
":",
"n",
"=",
"0",
"for",
"s",
"in",
"self",
".",
"_hsig",
".",
"values",
"(",
")",
":",
"if",
"hasattr",
"(",
"s",
",",
"'is_var'",
")",
"and",
"s",
".",
"is_var",
":",
"n",
"+=",
"1",
"re... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.count_funs | Count function define by this scope | pyrser/type_system/scope.py | def count_funs(self) -> int:
""" Count function define by this scope """
n = 0
for s in self._hsig.values():
if hasattr(s, 'is_fun') and s.is_fun:
n += 1
return n | def count_funs(self) -> int:
""" Count function define by this scope """
n = 0
for s in self._hsig.values():
if hasattr(s, 'is_fun') and s.is_fun:
n += 1
return n | [
"Count",
"function",
"define",
"by",
"this",
"scope"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L108-L114 | [
"def",
"count_funs",
"(",
"self",
")",
"->",
"int",
":",
"n",
"=",
"0",
"for",
"s",
"in",
"self",
".",
"_hsig",
".",
"values",
"(",
")",
":",
"if",
"hasattr",
"(",
"s",
",",
"'is_fun'",
")",
"and",
"s",
".",
"is_fun",
":",
"n",
"+=",
"1",
"re... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.__update_count | Update internal counters | pyrser/type_system/scope.py | def __update_count(self):
""" Update internal counters """
self._ntypes = self.count_types()
self._nvars = self.count_vars()
self._nfuns = self.count_funs() | def __update_count(self):
""" Update internal counters """
self._ntypes = self.count_types()
self._nvars = self.count_vars()
self._nfuns = self.count_funs() | [
"Update",
"internal",
"counters"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L116-L120 | [
"def",
"__update_count",
"(",
"self",
")",
":",
"self",
".",
"_ntypes",
"=",
"self",
".",
"count_types",
"(",
")",
"self",
".",
"_nvars",
"=",
"self",
".",
"count_vars",
"(",
")",
"self",
".",
"_nfuns",
"=",
"self",
".",
"count_funs",
"(",
")"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.update | Update the Set with values of another Set | pyrser/type_system/scope.py | def update(self, sig: list or Scope) -> Scope:
""" Update the Set with values of another Set """
values = sig
if hasattr(sig, 'values'):
values = sig.values()
for s in values:
if self.is_namespace:
s.set_parent(self)
if isinstance(s, Sc... | def update(self, sig: list or Scope) -> Scope:
""" Update the Set with values of another Set """
values = sig
if hasattr(sig, 'values'):
values = sig.values()
for s in values:
if self.is_namespace:
s.set_parent(self)
if isinstance(s, Sc... | [
"Update",
"the",
"Set",
"with",
"values",
"of",
"another",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L161-L173 | [
"def",
"update",
"(",
"self",
",",
"sig",
":",
"list",
"or",
"Scope",
")",
"->",
"Scope",
":",
"values",
"=",
"sig",
"if",
"hasattr",
"(",
"sig",
",",
"'values'",
")",
":",
"values",
"=",
"sig",
".",
"values",
"(",
")",
"for",
"s",
"in",
"values"... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.union | Create a new Set produce by the union of 2 Set | pyrser/type_system/scope.py | def union(self, sig: Scope) -> Scope:
""" Create a new Set produce by the union of 2 Set """
new = Scope(sig=self._hsig.values(), state=self.state)
new |= sig
return new | def union(self, sig: Scope) -> Scope:
""" Create a new Set produce by the union of 2 Set """
new = Scope(sig=self._hsig.values(), state=self.state)
new |= sig
return new | [
"Create",
"a",
"new",
"Set",
"produce",
"by",
"the",
"union",
"of",
"2",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L180-L184 | [
"def",
"union",
"(",
"self",
",",
"sig",
":",
"Scope",
")",
"->",
"Scope",
":",
"new",
"=",
"Scope",
"(",
"sig",
"=",
"self",
".",
"_hsig",
".",
"values",
"(",
")",
",",
"state",
"=",
"self",
".",
"state",
")",
"new",
"|=",
"sig",
"return",
"ne... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.intersection_update | Update Set with common values of another Set | pyrser/type_system/scope.py | def intersection_update(self, oset: Scope) -> Scope:
""" Update Set with common values of another Set """
keys = list(self._hsig.keys())
for k in keys:
if k not in oset:
del self._hsig[k]
else:
self._hsig[k] = oset.get(k)
return sel... | def intersection_update(self, oset: Scope) -> Scope:
""" Update Set with common values of another Set """
keys = list(self._hsig.keys())
for k in keys:
if k not in oset:
del self._hsig[k]
else:
self._hsig[k] = oset.get(k)
return sel... | [
"Update",
"Set",
"with",
"common",
"values",
"of",
"another",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L191-L199 | [
"def",
"intersection_update",
"(",
"self",
",",
"oset",
":",
"Scope",
")",
"->",
"Scope",
":",
"keys",
"=",
"list",
"(",
"self",
".",
"_hsig",
".",
"keys",
"(",
")",
")",
"for",
"k",
"in",
"keys",
":",
"if",
"k",
"not",
"in",
"oset",
":",
"del",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.intersection | Create a new Set produce by the intersection of 2 Set | pyrser/type_system/scope.py | def intersection(self, sig: Scope) -> Scope:
""" Create a new Set produce by the intersection of 2 Set """
new = Scope(sig=self._hsig.values(), state=self.state)
new &= sig
return new | def intersection(self, sig: Scope) -> Scope:
""" Create a new Set produce by the intersection of 2 Set """
new = Scope(sig=self._hsig.values(), state=self.state)
new &= sig
return new | [
"Create",
"a",
"new",
"Set",
"produce",
"by",
"the",
"intersection",
"of",
"2",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L206-L210 | [
"def",
"intersection",
"(",
"self",
",",
"sig",
":",
"Scope",
")",
"->",
"Scope",
":",
"new",
"=",
"Scope",
"(",
"sig",
"=",
"self",
".",
"_hsig",
".",
"values",
"(",
")",
",",
"state",
"=",
"self",
".",
"state",
")",
"new",
"&=",
"sig",
"return"... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.difference_update | Remove values common with another Set | pyrser/type_system/scope.py | def difference_update(self, oset: Scope) -> Scope:
""" Remove values common with another Set """
keys = list(self._hsig.keys())
for k in keys:
if k in oset:
del self._hsig[k]
return self | def difference_update(self, oset: Scope) -> Scope:
""" Remove values common with another Set """
keys = list(self._hsig.keys())
for k in keys:
if k in oset:
del self._hsig[k]
return self | [
"Remove",
"values",
"common",
"with",
"another",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L217-L223 | [
"def",
"difference_update",
"(",
"self",
",",
"oset",
":",
"Scope",
")",
"->",
"Scope",
":",
"keys",
"=",
"list",
"(",
"self",
".",
"_hsig",
".",
"keys",
"(",
")",
")",
"for",
"k",
"in",
"keys",
":",
"if",
"k",
"in",
"oset",
":",
"del",
"self",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.difference | Create a new Set produce by a Set subtracted by another Set | pyrser/type_system/scope.py | def difference(self, sig: Scope) -> Scope:
""" Create a new Set produce by a Set subtracted by another Set """
new = Scope(sig=self._hsig.values(), state=self.state)
new -= sig
return new | def difference(self, sig: Scope) -> Scope:
""" Create a new Set produce by a Set subtracted by another Set """
new = Scope(sig=self._hsig.values(), state=self.state)
new -= sig
return new | [
"Create",
"a",
"new",
"Set",
"produce",
"by",
"a",
"Set",
"subtracted",
"by",
"another",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L230-L234 | [
"def",
"difference",
"(",
"self",
",",
"sig",
":",
"Scope",
")",
"->",
"Scope",
":",
"new",
"=",
"Scope",
"(",
"sig",
"=",
"self",
".",
"_hsig",
".",
"values",
"(",
")",
",",
"state",
"=",
"self",
".",
"state",
")",
"new",
"-=",
"sig",
"return",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.symmetric_difference_update | Remove common values
and Update specific values from another Set | pyrser/type_system/scope.py | def symmetric_difference_update(self, oset: Scope) -> Scope:
""" Remove common values
and Update specific values from another Set
"""
skey = set()
keys = list(self._hsig.keys())
for k in keys:
if k in oset:
skey.add(k)
for k in oset... | def symmetric_difference_update(self, oset: Scope) -> Scope:
""" Remove common values
and Update specific values from another Set
"""
skey = set()
keys = list(self._hsig.keys())
for k in keys:
if k in oset:
skey.add(k)
for k in oset... | [
"Remove",
"common",
"values",
"and",
"Update",
"specific",
"values",
"from",
"another",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L241-L255 | [
"def",
"symmetric_difference_update",
"(",
"self",
",",
"oset",
":",
"Scope",
")",
"->",
"Scope",
":",
"skey",
"=",
"set",
"(",
")",
"keys",
"=",
"list",
"(",
"self",
".",
"_hsig",
".",
"keys",
"(",
")",
")",
"for",
"k",
"in",
"keys",
":",
"if",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.symmetric_difference | Create a new Set with values present in only one Set | pyrser/type_system/scope.py | def symmetric_difference(self, sig: Scope) -> Scope:
""" Create a new Set with values present in only one Set """
new = Scope(sig=self._hsig.values(), state=self.state)
new ^= sig
return new | def symmetric_difference(self, sig: Scope) -> Scope:
""" Create a new Set with values present in only one Set """
new = Scope(sig=self._hsig.values(), state=self.state)
new ^= sig
return new | [
"Create",
"a",
"new",
"Set",
"with",
"values",
"present",
"in",
"only",
"one",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L262-L266 | [
"def",
"symmetric_difference",
"(",
"self",
",",
"sig",
":",
"Scope",
")",
"->",
"Scope",
":",
"new",
"=",
"Scope",
"(",
"sig",
"=",
"self",
".",
"_hsig",
".",
"values",
"(",
")",
",",
"state",
"=",
"self",
".",
"state",
")",
"new",
"^=",
"sig",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.add | Add it to the Set | pyrser/type_system/scope.py | def add(self, it: Signature) -> bool:
""" Add it to the Set """
if isinstance(it, Scope):
it.state = StateScope.EMBEDDED
txt = it.internal_name()
it.set_parent(self)
if self.is_namespace:
txt = it.internal_name()
if txt == "":
txt = '_'... | def add(self, it: Signature) -> bool:
""" Add it to the Set """
if isinstance(it, Scope):
it.state = StateScope.EMBEDDED
txt = it.internal_name()
it.set_parent(self)
if self.is_namespace:
txt = it.internal_name()
if txt == "":
txt = '_'... | [
"Add",
"it",
"to",
"the",
"Set"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L269-L283 | [
"def",
"add",
"(",
"self",
",",
"it",
":",
"Signature",
")",
"->",
"bool",
":",
"if",
"isinstance",
"(",
"it",
",",
"Scope",
")",
":",
"it",
".",
"state",
"=",
"StateScope",
".",
"EMBEDDED",
"txt",
"=",
"it",
".",
"internal_name",
"(",
")",
"it",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.remove | Remove it but raise KeyError if not found | pyrser/type_system/scope.py | def remove(self, it: Signature) -> bool:
""" Remove it but raise KeyError if not found """
txt = it.internal_name()
if txt not in self._hsig:
raise KeyError(it.show_name() + ' not in Set')
sig = self._hsig[txt]
if isinstance(sig, Scope):
sig.state = StateS... | def remove(self, it: Signature) -> bool:
""" Remove it but raise KeyError if not found """
txt = it.internal_name()
if txt not in self._hsig:
raise KeyError(it.show_name() + ' not in Set')
sig = self._hsig[txt]
if isinstance(sig, Scope):
sig.state = StateS... | [
"Remove",
"it",
"but",
"raise",
"KeyError",
"if",
"not",
"found"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L285-L294 | [
"def",
"remove",
"(",
"self",
",",
"it",
":",
"Signature",
")",
"->",
"bool",
":",
"txt",
"=",
"it",
".",
"internal_name",
"(",
")",
"if",
"txt",
"not",
"in",
"self",
".",
"_hsig",
":",
"raise",
"KeyError",
"(",
"it",
".",
"show_name",
"(",
")",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.discard | Remove it only if present | pyrser/type_system/scope.py | def discard(self, it: Signature) -> bool:
""" Remove it only if present """
txt = it.internal_name()
if txt in self._hsig:
sig = self._hsig[txt]
if isinstance(sig, Scope):
sig.state = StateScope.LINKED
del self._hsig[txt]
return Tru... | def discard(self, it: Signature) -> bool:
""" Remove it only if present """
txt = it.internal_name()
if txt in self._hsig:
sig = self._hsig[txt]
if isinstance(sig, Scope):
sig.state = StateScope.LINKED
del self._hsig[txt]
return Tru... | [
"Remove",
"it",
"only",
"if",
"present"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L296-L305 | [
"def",
"discard",
"(",
"self",
",",
"it",
":",
"Signature",
")",
"->",
"bool",
":",
"txt",
"=",
"it",
".",
"internal_name",
"(",
")",
"if",
"txt",
"in",
"self",
".",
"_hsig",
":",
"sig",
"=",
"self",
".",
"_hsig",
"[",
"txt",
"]",
"if",
"isinstan... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.values | Retrieve all values | pyrser/type_system/scope.py | def values(self) -> [Signature]:
""" Retrieve all values """
if self.state == StateScope.EMBEDDED and self.parent is not None:
return list(self._hsig.values()) + list(self.parent().values())
else:
return self._hsig.values() | def values(self) -> [Signature]:
""" Retrieve all values """
if self.state == StateScope.EMBEDDED and self.parent is not None:
return list(self._hsig.values()) + list(self.parent().values())
else:
return self._hsig.values() | [
"Retrieve",
"all",
"values"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L321-L326 | [
"def",
"values",
"(",
"self",
")",
"->",
"[",
"Signature",
"]",
":",
"if",
"self",
".",
"state",
"==",
"StateScope",
".",
"EMBEDDED",
"and",
"self",
".",
"parent",
"is",
"not",
"None",
":",
"return",
"list",
"(",
"self",
".",
"_hsig",
".",
"values",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.first | Retrieve the first Signature ordered by mangling descendant | pyrser/type_system/scope.py | def first(self) -> Signature:
""" Retrieve the first Signature ordered by mangling descendant """
k = sorted(self._hsig.keys())
return self._hsig[k[0]] | def first(self) -> Signature:
""" Retrieve the first Signature ordered by mangling descendant """
k = sorted(self._hsig.keys())
return self._hsig[k[0]] | [
"Retrieve",
"the",
"first",
"Signature",
"ordered",
"by",
"mangling",
"descendant"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L333-L336 | [
"def",
"first",
"(",
"self",
")",
"->",
"Signature",
":",
"k",
"=",
"sorted",
"(",
"self",
".",
"_hsig",
".",
"keys",
"(",
")",
")",
"return",
"self",
".",
"_hsig",
"[",
"k",
"[",
"0",
"]",
"]"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.last | Retrieve the last Signature ordered by mangling descendant | pyrser/type_system/scope.py | def last(self) -> Signature:
""" Retrieve the last Signature ordered by mangling descendant """
k = sorted(self._hsig.keys())
return self._hsig[k[-1]] | def last(self) -> Signature:
""" Retrieve the last Signature ordered by mangling descendant """
k = sorted(self._hsig.keys())
return self._hsig[k[-1]] | [
"Retrieve",
"the",
"last",
"Signature",
"ordered",
"by",
"mangling",
"descendant"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L338-L341 | [
"def",
"last",
"(",
"self",
")",
"->",
"Signature",
":",
"k",
"=",
"sorted",
"(",
"self",
".",
"_hsig",
".",
"keys",
"(",
")",
")",
"return",
"self",
".",
"_hsig",
"[",
"k",
"[",
"-",
"1",
"]",
"]"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.get | Get a signature instance by its internal_name | pyrser/type_system/scope.py | def get(self, key: str, default=None) -> Signature:
""" Get a signature instance by its internal_name """
item = default
if key in self._hsig:
item = self._hsig[key]
return item | def get(self, key: str, default=None) -> Signature:
""" Get a signature instance by its internal_name """
item = default
if key in self._hsig:
item = self._hsig[key]
return item | [
"Get",
"a",
"signature",
"instance",
"by",
"its",
"internal_name"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L343-L348 | [
"def",
"get",
"(",
"self",
",",
"key",
":",
"str",
",",
"default",
"=",
"None",
")",
"->",
"Signature",
":",
"item",
"=",
"default",
"if",
"key",
"in",
"self",
".",
"_hsig",
":",
"item",
"=",
"self",
".",
"_hsig",
"[",
"key",
"]",
"return",
"item... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.get_by_symbol_name | Retrieve a Set of all signature by symbol name | pyrser/type_system/scope.py | def get_by_symbol_name(self, name: str) -> Scope:
""" Retrieve a Set of all signature by symbol name """
lst = []
for s in self.values():
if s.name == name:
# create an EvalCtx only when necessary
lst.append(EvalCtx.from_sig(s))
# include paren... | def get_by_symbol_name(self, name: str) -> Scope:
""" Retrieve a Set of all signature by symbol name """
lst = []
for s in self.values():
if s.name == name:
# create an EvalCtx only when necessary
lst.append(EvalCtx.from_sig(s))
# include paren... | [
"Retrieve",
"a",
"Set",
"of",
"all",
"signature",
"by",
"symbol",
"name"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L350-L368 | [
"def",
"get_by_symbol_name",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"Scope",
":",
"lst",
"=",
"[",
"]",
"for",
"s",
"in",
"self",
".",
"values",
"(",
")",
":",
"if",
"s",
".",
"name",
"==",
"name",
":",
"# create an EvalCtx only when necessar... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.getsig_by_symbol_name | Retrieve the unique Signature of a symbol.
Fail if the Signature is not unique | pyrser/type_system/scope.py | def getsig_by_symbol_name(self, name: str) -> Signature:
""" Retrieve the unique Signature of a symbol.
Fail if the Signature is not unique
"""
subscope = self.get_by_symbol_name(name)
if len(subscope) != 1:
raise KeyError("%s have multiple candidates in scope" % name... | def getsig_by_symbol_name(self, name: str) -> Signature:
""" Retrieve the unique Signature of a symbol.
Fail if the Signature is not unique
"""
subscope = self.get_by_symbol_name(name)
if len(subscope) != 1:
raise KeyError("%s have multiple candidates in scope" % name... | [
"Retrieve",
"the",
"unique",
"Signature",
"of",
"a",
"symbol",
".",
"Fail",
"if",
"the",
"Signature",
"is",
"not",
"unique"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L370-L378 | [
"def",
"getsig_by_symbol_name",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"Signature",
":",
"subscope",
"=",
"self",
".",
"get_by_symbol_name",
"(",
"name",
")",
"if",
"len",
"(",
"subscope",
")",
"!=",
"1",
":",
"raise",
"KeyError",
"(",
"\"%s ha... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.get_by_return_type | Retrieve a Set of all signature by (return) type | pyrser/type_system/scope.py | def get_by_return_type(self, tname: str) -> Scope:
""" Retrieve a Set of all signature by (return) type """
lst = []
for s in self.values():
if hasattr(s, 'tret') and s.tret == tname:
lst.append(EvalCtx.from_sig(s))
rscope = Scope(sig=lst, state=StateScope.LIN... | def get_by_return_type(self, tname: str) -> Scope:
""" Retrieve a Set of all signature by (return) type """
lst = []
for s in self.values():
if hasattr(s, 'tret') and s.tret == tname:
lst.append(EvalCtx.from_sig(s))
rscope = Scope(sig=lst, state=StateScope.LIN... | [
"Retrieve",
"a",
"Set",
"of",
"all",
"signature",
"by",
"(",
"return",
")",
"type"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L380-L389 | [
"def",
"get_by_return_type",
"(",
"self",
",",
"tname",
":",
"str",
")",
"->",
"Scope",
":",
"lst",
"=",
"[",
"]",
"for",
"s",
"in",
"self",
".",
"values",
"(",
")",
":",
"if",
"hasattr",
"(",
"s",
",",
"'tret'",
")",
"and",
"s",
".",
"tret",
"... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.get_all_polymorphic_return | For now, polymorphic return type are handle by symbol artefact.
--> possible multi-polymorphic but with different constraint attached! | pyrser/type_system/scope.py | def get_all_polymorphic_return(self) -> bool:
""" For now, polymorphic return type are handle by symbol artefact.
--> possible multi-polymorphic but with different constraint attached!
"""
lst = []
for s in self.values():
if hasattr(s, 'tret') and s.tret.is_polymorph... | def get_all_polymorphic_return(self) -> bool:
""" For now, polymorphic return type are handle by symbol artefact.
--> possible multi-polymorphic but with different constraint attached!
"""
lst = []
for s in self.values():
if hasattr(s, 'tret') and s.tret.is_polymorph... | [
"For",
"now",
"polymorphic",
"return",
"type",
"are",
"handle",
"by",
"symbol",
"artefact",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L391-L404 | [
"def",
"get_all_polymorphic_return",
"(",
"self",
")",
"->",
"bool",
":",
"lst",
"=",
"[",
"]",
"for",
"s",
"in",
"self",
".",
"values",
"(",
")",
":",
"if",
"hasattr",
"(",
"s",
",",
"'tret'",
")",
"and",
"s",
".",
"tret",
".",
"is_polymorphic",
"... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.get_by_params | Retrieve a Set of all signature that match the parameter list.
Return a pair:
pair[0] the overloads for the functions
pair[1] the overloads for the parameters
(a list of candidate list of parameters) | pyrser/type_system/scope.py | def get_by_params(self, params: [Scope]) -> (Scope, [[Scope]]):
""" Retrieve a Set of all signature that match the parameter list.
Return a pair:
pair[0] the overloads for the functions
pair[1] the overloads for the parameters
(a list of candidate list of paramet... | def get_by_params(self, params: [Scope]) -> (Scope, [[Scope]]):
""" Retrieve a Set of all signature that match the parameter list.
Return a pair:
pair[0] the overloads for the functions
pair[1] the overloads for the parameters
(a list of candidate list of paramet... | [
"Retrieve",
"a",
"Set",
"of",
"all",
"signature",
"that",
"match",
"the",
"parameter",
"list",
".",
"Return",
"a",
"pair",
":"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L406-L504 | [
"def",
"get_by_params",
"(",
"self",
",",
"params",
":",
"[",
"Scope",
"]",
")",
"->",
"(",
"Scope",
",",
"[",
"[",
"Scope",
"]",
"]",
")",
":",
"lst",
"=",
"[",
"]",
"scopep",
"=",
"[",
"]",
"# for each of our signatures",
"for",
"s",
"in",
"self"... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.callInjector | If don't have injector call from parent | pyrser/type_system/scope.py | def callInjector(self, old: Node, trans: Translator) -> Node:
""" If don't have injector call from parent """
if self.astTranslatorInjector is None:
if self.parent is not None:
# TODO: think if we forward for all StateScope
# forward to parent scope
... | def callInjector(self, old: Node, trans: Translator) -> Node:
""" If don't have injector call from parent """
if self.astTranslatorInjector is None:
if self.parent is not None:
# TODO: think if we forward for all StateScope
# forward to parent scope
... | [
"If",
"don",
"t",
"have",
"injector",
"call",
"from",
"parent"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L515-L524 | [
"def",
"callInjector",
"(",
"self",
",",
"old",
":",
"Node",
",",
"trans",
":",
"Translator",
")",
"->",
"Node",
":",
"if",
"self",
".",
"astTranslatorInjector",
"is",
"None",
":",
"if",
"self",
".",
"parent",
"is",
"not",
"None",
":",
"# TODO: think if ... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Scope.findTranslationTo | Find an arrow (->)
aka a function able to translate something to t2 | pyrser/type_system/scope.py | def findTranslationTo(self, t2: str) -> (bool, Signature, Translator):
""" Find an arrow (->)
aka a function able to translate something to t2
"""
if not t2.is_polymorphic:
collect = []
for s in self.values():
t1 = s.tret
if t1.is_p... | def findTranslationTo(self, t2: str) -> (bool, Signature, Translator):
""" Find an arrow (->)
aka a function able to translate something to t2
"""
if not t2.is_polymorphic:
collect = []
for s in self.values():
t1 = s.tret
if t1.is_p... | [
"Find",
"an",
"arrow",
"(",
"-",
">",
")",
"aka",
"a",
"function",
"able",
"to",
"translate",
"something",
"to",
"t2"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/scope.py#L526-L546 | [
"def",
"findTranslationTo",
"(",
"self",
",",
"t2",
":",
"str",
")",
"->",
"(",
"bool",
",",
"Signature",
",",
"Translator",
")",
":",
"if",
"not",
"t2",
".",
"is_polymorphic",
":",
"collect",
"=",
"[",
"]",
"for",
"s",
"in",
"self",
".",
"values",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | normalize | Normalize an AST nodes.
all builtins containers are replace by referencable subclasses | pyrser/parsing/node.py | def normalize(ast: Node) -> Node:
"""
Normalize an AST nodes.
all builtins containers are replace by referencable subclasses
"""
res = ast
typemap = {DictNode, ListNode, TupleNode}
if type(ast) is dict:
res = DictNode(ast)
elif type(ast) is list:
res = ListNode(ast)
... | def normalize(ast: Node) -> Node:
"""
Normalize an AST nodes.
all builtins containers are replace by referencable subclasses
"""
res = ast
typemap = {DictNode, ListNode, TupleNode}
if type(ast) is dict:
res = DictNode(ast)
elif type(ast) is list:
res = ListNode(ast)
... | [
"Normalize",
"an",
"AST",
"nodes",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/node.py#L438-L463 | [
"def",
"normalize",
"(",
"ast",
":",
"Node",
")",
"->",
"Node",
":",
"res",
"=",
"ast",
"typemap",
"=",
"{",
"DictNode",
",",
"ListNode",
",",
"TupleNode",
"}",
"if",
"type",
"(",
"ast",
")",
"is",
"dict",
":",
"res",
"=",
"DictNode",
"(",
"ast",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Node.check | Debug method, help detect cycle and/or
other incoherence in a tree of Node | pyrser/parsing/node.py | def check(self, ndict: dict, info="") -> bool:
"""
Debug method, help detect cycle and/or
other incoherence in a tree of Node
"""
def iscycle(thing, ndict: dict, info: str) -> bool:
# check if not already here
idthing = id(thing)
ndict[info] = ... | def check(self, ndict: dict, info="") -> bool:
"""
Debug method, help detect cycle and/or
other incoherence in a tree of Node
"""
def iscycle(thing, ndict: dict, info: str) -> bool:
# check if not already here
idthing = id(thing)
ndict[info] = ... | [
"Debug",
"method",
"help",
"detect",
"cycle",
"and",
"/",
"or",
"other",
"incoherence",
"in",
"a",
"tree",
"of",
"Node"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/node.py#L21-L70 | [
"def",
"check",
"(",
"self",
",",
"ndict",
":",
"dict",
",",
"info",
"=",
"\"\"",
")",
"->",
"bool",
":",
"def",
"iscycle",
"(",
"thing",
",",
"ndict",
":",
"dict",
",",
"info",
":",
"str",
")",
"->",
"bool",
":",
"# check if not already here",
"idth... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Node.set | allow to completly mutate the node into any subclasses of Node | pyrser/parsing/node.py | def set(self, othernode):
"""allow to completly mutate the node into any subclasses of Node"""
self.__class__ = othernode.__class__
self.clean()
if len(othernode) > 0:
for k, v in othernode.items():
self[k] = v
for k, v in vars(othernode).items():
... | def set(self, othernode):
"""allow to completly mutate the node into any subclasses of Node"""
self.__class__ = othernode.__class__
self.clean()
if len(othernode) > 0:
for k, v in othernode.items():
self[k] = v
for k, v in vars(othernode).items():
... | [
"allow",
"to",
"completly",
"mutate",
"the",
"node",
"into",
"any",
"subclasses",
"of",
"Node"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/node.py#L81-L89 | [
"def",
"set",
"(",
"self",
",",
"othernode",
")",
":",
"self",
".",
"__class__",
"=",
"othernode",
".",
"__class__",
"self",
".",
"clean",
"(",
")",
"if",
"len",
"(",
"othernode",
")",
">",
"0",
":",
"for",
"k",
",",
"v",
"in",
"othernode",
".",
... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | ListNodeItem.values | in order | pyrser/parsing/node.py | def values(self):
"""
in order
"""
tmp = self
while tmp is not None:
yield tmp.data
tmp = tmp.next | def values(self):
"""
in order
"""
tmp = self
while tmp is not None:
yield tmp.data
tmp = tmp.next | [
"in",
"order"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/node.py#L389-L396 | [
"def",
"values",
"(",
"self",
")",
":",
"tmp",
"=",
"self",
"while",
"tmp",
"is",
"not",
"None",
":",
"yield",
"tmp",
".",
"data",
"tmp",
"=",
"tmp",
".",
"next"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | ListNodeItem.rvalues | in reversed order | pyrser/parsing/node.py | def rvalues(self):
"""
in reversed order
"""
tmp = self
while tmp is not None:
yield tmp.data
tmp = tmp.prev | def rvalues(self):
"""
in reversed order
"""
tmp = self
while tmp is not None:
yield tmp.data
tmp = tmp.prev | [
"in",
"reversed",
"order"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/node.py#L398-L405 | [
"def",
"rvalues",
"(",
"self",
")",
":",
"tmp",
"=",
"self",
"while",
"tmp",
"is",
"not",
"None",
":",
"yield",
"tmp",
".",
"data",
"tmp",
"=",
"tmp",
".",
"prev"
] | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | _pixel_masked | Checks whether a hit (column/row) is masked or not. Array is 2D array with boolean elements corresponding to pixles indicating whether a pixel is disabled or not. | pixel_clusterizer/cluster_functions.py | def _pixel_masked(hit, array):
''' Checks whether a hit (column/row) is masked or not. Array is 2D array with boolean elements corresponding to pixles indicating whether a pixel is disabled or not.
'''
if array.shape[0] > hit["column"] and array.shape[1] > hit["row"]:
return array[hit["column"], hit... | def _pixel_masked(hit, array):
''' Checks whether a hit (column/row) is masked or not. Array is 2D array with boolean elements corresponding to pixles indicating whether a pixel is disabled or not.
'''
if array.shape[0] > hit["column"] and array.shape[1] > hit["row"]:
return array[hit["column"], hit... | [
"Checks",
"whether",
"a",
"hit",
"(",
"column",
"/",
"row",
")",
"is",
"masked",
"or",
"not",
".",
"Array",
"is",
"2D",
"array",
"with",
"boolean",
"elements",
"corresponding",
"to",
"pixles",
"indicating",
"whether",
"a",
"pixel",
"is",
"disabled",
"or",
... | SiLab-Bonn/pixel_clusterizer | python | https://github.com/SiLab-Bonn/pixel_clusterizer/blob/d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d/pixel_clusterizer/cluster_functions.py#L13-L19 | [
"def",
"_pixel_masked",
"(",
"hit",
",",
"array",
")",
":",
"if",
"array",
".",
"shape",
"[",
"0",
"]",
">",
"hit",
"[",
"\"column\"",
"]",
"and",
"array",
".",
"shape",
"[",
"1",
"]",
">",
"hit",
"[",
"\"row\"",
"]",
":",
"return",
"array",
"[",... | d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d |
test | _finish_cluster | Set hit and cluster information of the cluster (e.g. number of hits in the cluster (cluster_size), total cluster charge (charge), ...). | pixel_clusterizer/cluster_functions.py | def _finish_cluster(hits, clusters, cluster_size, cluster_hit_indices, cluster_index, cluster_id, charge_correction, noisy_pixels, disabled_pixels):
''' Set hit and cluster information of the cluster (e.g. number of hits in the cluster (cluster_size), total cluster charge (charge), ...).
'''
cluster_charge ... | def _finish_cluster(hits, clusters, cluster_size, cluster_hit_indices, cluster_index, cluster_id, charge_correction, noisy_pixels, disabled_pixels):
''' Set hit and cluster information of the cluster (e.g. number of hits in the cluster (cluster_size), total cluster charge (charge), ...).
'''
cluster_charge ... | [
"Set",
"hit",
"and",
"cluster",
"information",
"of",
"the",
"cluster",
"(",
"e",
".",
"g",
".",
"number",
"of",
"hits",
"in",
"the",
"cluster",
"(",
"cluster_size",
")",
"total",
"cluster",
"charge",
"(",
"charge",
")",
"...",
")",
"."
] | SiLab-Bonn/pixel_clusterizer | python | https://github.com/SiLab-Bonn/pixel_clusterizer/blob/d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d/pixel_clusterizer/cluster_functions.py#L33-L77 | [
"def",
"_finish_cluster",
"(",
"hits",
",",
"clusters",
",",
"cluster_size",
",",
"cluster_hit_indices",
",",
"cluster_index",
",",
"cluster_id",
",",
"charge_correction",
",",
"noisy_pixels",
",",
"disabled_pixels",
")",
":",
"cluster_charge",
"=",
"0",
"max_cluste... | d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d |
test | _finish_event | Set hit and cluster information of the event (e.g. number of cluster in the event (n_cluster), ...). | pixel_clusterizer/cluster_functions.py | def _finish_event(hits, clusters, start_event_hit_index, stop_event_hit_index, start_event_cluster_index, stop_event_cluster_index):
''' Set hit and cluster information of the event (e.g. number of cluster in the event (n_cluster), ...).
'''
for hit_index in range(start_event_hit_index, stop_event_hit_index... | def _finish_event(hits, clusters, start_event_hit_index, stop_event_hit_index, start_event_cluster_index, stop_event_cluster_index):
''' Set hit and cluster information of the event (e.g. number of cluster in the event (n_cluster), ...).
'''
for hit_index in range(start_event_hit_index, stop_event_hit_index... | [
"Set",
"hit",
"and",
"cluster",
"information",
"of",
"the",
"event",
"(",
"e",
".",
"g",
".",
"number",
"of",
"cluster",
"in",
"the",
"event",
"(",
"n_cluster",
")",
"...",
")",
"."
] | SiLab-Bonn/pixel_clusterizer | python | https://github.com/SiLab-Bonn/pixel_clusterizer/blob/d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d/pixel_clusterizer/cluster_functions.py#L81-L97 | [
"def",
"_finish_event",
"(",
"hits",
",",
"clusters",
",",
"start_event_hit_index",
",",
"stop_event_hit_index",
",",
"start_event_cluster_index",
",",
"stop_event_cluster_index",
")",
":",
"for",
"hit_index",
"in",
"range",
"(",
"start_event_hit_index",
",",
"stop_even... | d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d |
test | _hit_ok | Check if given hit is withing the limits. | pixel_clusterizer/cluster_functions.py | def _hit_ok(hit, min_hit_charge, max_hit_charge):
''' Check if given hit is withing the limits.
'''
# Omit hits with charge < min_hit_charge
if hit['charge'] < min_hit_charge:
return False
# Omit hits with charge > max_hit_charge
if max_hit_charge != 0 and hit['charge'] > max_hit_charge... | def _hit_ok(hit, min_hit_charge, max_hit_charge):
''' Check if given hit is withing the limits.
'''
# Omit hits with charge < min_hit_charge
if hit['charge'] < min_hit_charge:
return False
# Omit hits with charge > max_hit_charge
if max_hit_charge != 0 and hit['charge'] > max_hit_charge... | [
"Check",
"if",
"given",
"hit",
"is",
"withing",
"the",
"limits",
"."
] | SiLab-Bonn/pixel_clusterizer | python | https://github.com/SiLab-Bonn/pixel_clusterizer/blob/d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d/pixel_clusterizer/cluster_functions.py#L101-L112 | [
"def",
"_hit_ok",
"(",
"hit",
",",
"min_hit_charge",
",",
"max_hit_charge",
")",
":",
"# Omit hits with charge < min_hit_charge",
"if",
"hit",
"[",
"'charge'",
"]",
"<",
"min_hit_charge",
":",
"return",
"False",
"# Omit hits with charge > max_hit_charge",
"if",
"max_hit... | d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d |
test | _set_1d_array | Set array elemets to value for given number of elements (if size is negative number set all elements to value). | pixel_clusterizer/cluster_functions.py | def _set_1d_array(array, value, size=-1):
''' Set array elemets to value for given number of elements (if size is negative number set all elements to value).
'''
if size >= 0:
for i in range(size):
array[i] = value
else:
for i in range(array.shape[0]):
array[i] = ... | def _set_1d_array(array, value, size=-1):
''' Set array elemets to value for given number of elements (if size is negative number set all elements to value).
'''
if size >= 0:
for i in range(size):
array[i] = value
else:
for i in range(array.shape[0]):
array[i] = ... | [
"Set",
"array",
"elemets",
"to",
"value",
"for",
"given",
"number",
"of",
"elements",
"(",
"if",
"size",
"is",
"negative",
"number",
"set",
"all",
"elements",
"to",
"value",
")",
"."
] | SiLab-Bonn/pixel_clusterizer | python | https://github.com/SiLab-Bonn/pixel_clusterizer/blob/d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d/pixel_clusterizer/cluster_functions.py#L125-L133 | [
"def",
"_set_1d_array",
"(",
"array",
",",
"value",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"size",
">=",
"0",
":",
"for",
"i",
"in",
"range",
"(",
"size",
")",
":",
"array",
"[",
"i",
"]",
"=",
"value",
"else",
":",
"for",
"i",
"in",
"ra... | d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d |
test | _is_in_max_difference | Helper function to determine the difference of two values that can be np.uints. Works in python and numba mode.
Circumvents numba bug #1653 | pixel_clusterizer/cluster_functions.py | def _is_in_max_difference(value_1, value_2, max_difference):
''' Helper function to determine the difference of two values that can be np.uints. Works in python and numba mode.
Circumvents numba bug #1653
'''
if value_1 <= value_2:
return value_2 - value_1 <= max_difference
return value_1 - ... | def _is_in_max_difference(value_1, value_2, max_difference):
''' Helper function to determine the difference of two values that can be np.uints. Works in python and numba mode.
Circumvents numba bug #1653
'''
if value_1 <= value_2:
return value_2 - value_1 <= max_difference
return value_1 - ... | [
"Helper",
"function",
"to",
"determine",
"the",
"difference",
"of",
"two",
"values",
"that",
"can",
"be",
"np",
".",
"uints",
".",
"Works",
"in",
"python",
"and",
"numba",
"mode",
".",
"Circumvents",
"numba",
"bug",
"#1653"
] | SiLab-Bonn/pixel_clusterizer | python | https://github.com/SiLab-Bonn/pixel_clusterizer/blob/d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d/pixel_clusterizer/cluster_functions.py#L137-L143 | [
"def",
"_is_in_max_difference",
"(",
"value_1",
",",
"value_2",
",",
"max_difference",
")",
":",
"if",
"value_1",
"<=",
"value_2",
":",
"return",
"value_2",
"-",
"value_1",
"<=",
"max_difference",
"return",
"value_1",
"-",
"value_2",
"<=",
"max_difference"
] | d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d |
test | _cluster_hits | Main precompiled function that loopes over the hits and clusters them | pixel_clusterizer/cluster_functions.py | def _cluster_hits(hits, clusters, assigned_hit_array, cluster_hit_indices, column_cluster_distance, row_cluster_distance, frame_cluster_distance, min_hit_charge, max_hit_charge, ignore_same_hits, noisy_pixels, disabled_pixels):
''' Main precompiled function that loopes over the hits and clusters them
'''
to... | def _cluster_hits(hits, clusters, assigned_hit_array, cluster_hit_indices, column_cluster_distance, row_cluster_distance, frame_cluster_distance, min_hit_charge, max_hit_charge, ignore_same_hits, noisy_pixels, disabled_pixels):
''' Main precompiled function that loopes over the hits and clusters them
'''
to... | [
"Main",
"precompiled",
"function",
"that",
"loopes",
"over",
"the",
"hits",
"and",
"clusters",
"them"
] | SiLab-Bonn/pixel_clusterizer | python | https://github.com/SiLab-Bonn/pixel_clusterizer/blob/d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d/pixel_clusterizer/cluster_functions.py#L161-L285 | [
"def",
"_cluster_hits",
"(",
"hits",
",",
"clusters",
",",
"assigned_hit_array",
",",
"cluster_hit_indices",
",",
"column_cluster_distance",
",",
"row_cluster_distance",
",",
"frame_cluster_distance",
",",
"min_hit_charge",
",",
"max_hit_charge",
",",
"ignore_same_hits",
... | d2c8c3072fb03ebb7c6a3e8c57350fbbe38efd4d |
test | EvalCtx.get_compute_sig | Compute a signature Using resolution!!!
TODO: discuss of relevance of a final generation for a signature | pyrser/type_system/evalctx.py | def get_compute_sig(self) -> Signature:
"""
Compute a signature Using resolution!!!
TODO: discuss of relevance of a final generation for a signature
"""
tret = []
tparams = []
for t in self.tret.components:
if t in self.resolution and self.resolution[... | def get_compute_sig(self) -> Signature:
"""
Compute a signature Using resolution!!!
TODO: discuss of relevance of a final generation for a signature
"""
tret = []
tparams = []
for t in self.tret.components:
if t in self.resolution and self.resolution[... | [
"Compute",
"a",
"signature",
"Using",
"resolution!!!"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/evalctx.py#L95-L135 | [
"def",
"get_compute_sig",
"(",
"self",
")",
"->",
"Signature",
":",
"tret",
"=",
"[",
"]",
"tparams",
"=",
"[",
"]",
"for",
"t",
"in",
"self",
".",
"tret",
".",
"components",
":",
"if",
"t",
"in",
"self",
".",
"resolution",
"and",
"self",
".",
"res... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | EvalCtx.set_parent | When we add a parent (from Symbol), don't forget to resolve. | pyrser/type_system/evalctx.py | def set_parent(self, parent) -> object:
"""
When we add a parent (from Symbol), don't forget to resolve.
"""
ret = self
if parent is not None:
ret = self._sig.set_parent(parent)
self.resolve()
elif not hasattr(self, 'parent'):
# only if... | def set_parent(self, parent) -> object:
"""
When we add a parent (from Symbol), don't forget to resolve.
"""
ret = self
if parent is not None:
ret = self._sig.set_parent(parent)
self.resolve()
elif not hasattr(self, 'parent'):
# only if... | [
"When",
"we",
"add",
"a",
"parent",
"(",
"from",
"Symbol",
")",
"don",
"t",
"forget",
"to",
"resolve",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/evalctx.py#L137-L148 | [
"def",
"set_parent",
"(",
"self",
",",
"parent",
")",
"->",
"object",
":",
"ret",
"=",
"self",
"if",
"parent",
"is",
"not",
"None",
":",
"ret",
"=",
"self",
".",
"_sig",
".",
"set_parent",
"(",
"parent",
")",
"self",
".",
"resolve",
"(",
")",
"elif... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | EvalCtx.resolve | Process the signature and find definition for type. | pyrser/type_system/evalctx.py | def resolve(self):
"""
Process the signature and find definition for type.
"""
# collect types for resolution
t2resolv = []
if hasattr(self._sig, 'tret'):
t2resolv.append(self._sig.tret)
if hasattr(self._sig, 'tparams') and self._sig.tparams is not Non... | def resolve(self):
"""
Process the signature and find definition for type.
"""
# collect types for resolution
t2resolv = []
if hasattr(self._sig, 'tret'):
t2resolv.append(self._sig.tret)
if hasattr(self._sig, 'tparams') and self._sig.tparams is not Non... | [
"Process",
"the",
"signature",
"and",
"find",
"definition",
"for",
"type",
"."
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/evalctx.py#L165-L197 | [
"def",
"resolve",
"(",
"self",
")",
":",
"# collect types for resolution",
"t2resolv",
"=",
"[",
"]",
"if",
"hasattr",
"(",
"self",
".",
"_sig",
",",
"'tret'",
")",
":",
"t2resolv",
".",
"append",
"(",
"self",
".",
"_sig",
".",
"tret",
")",
"if",
"hasa... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | EvalCtx.get_resolved_names | Use self.resolution to subsitute type_name.
Allow to instanciate polymorphic type ?1, ?toto | pyrser/type_system/evalctx.py | def get_resolved_names(self, type_name: TypeName) -> list:
"""
Use self.resolution to subsitute type_name.
Allow to instanciate polymorphic type ?1, ?toto
"""
if not isinstance(type_name, TypeName):
raise Exception("Take a TypeName as parameter not a %s"
... | def get_resolved_names(self, type_name: TypeName) -> list:
"""
Use self.resolution to subsitute type_name.
Allow to instanciate polymorphic type ?1, ?toto
"""
if not isinstance(type_name, TypeName):
raise Exception("Take a TypeName as parameter not a %s"
... | [
"Use",
"self",
".",
"resolution",
"to",
"subsitute",
"type_name",
".",
"Allow",
"to",
"instanciate",
"polymorphic",
"type",
"?1",
"?toto"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/evalctx.py#L199-L217 | [
"def",
"get_resolved_names",
"(",
"self",
",",
"type_name",
":",
"TypeName",
")",
"->",
"list",
":",
"if",
"not",
"isinstance",
"(",
"type_name",
",",
"TypeName",
")",
":",
"raise",
"Exception",
"(",
"\"Take a TypeName as parameter not a %s\"",
"%",
"type",
"(",... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | EvalCtx.set_resolved_name | Warning!!! Need to rethink it when global poly type | pyrser/type_system/evalctx.py | def set_resolved_name(self, ref: dict, type_name2solve: TypeName,
type_name_ref: TypeName):
"""
Warning!!! Need to rethink it when global poly type
"""
if self.resolution[type_name2solve.value] is None:
self.resolution[type_name2solve.value] = ref[ty... | def set_resolved_name(self, ref: dict, type_name2solve: TypeName,
type_name_ref: TypeName):
"""
Warning!!! Need to rethink it when global poly type
"""
if self.resolution[type_name2solve.value] is None:
self.resolution[type_name2solve.value] = ref[ty... | [
"Warning!!!",
"Need",
"to",
"rethink",
"it",
"when",
"global",
"poly",
"type"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/evalctx.py#L219-L225 | [
"def",
"set_resolved_name",
"(",
"self",
",",
"ref",
":",
"dict",
",",
"type_name2solve",
":",
"TypeName",
",",
"type_name_ref",
":",
"TypeName",
")",
":",
"if",
"self",
".",
"resolution",
"[",
"type_name2solve",
".",
"value",
"]",
"is",
"None",
":",
"self... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
test | Tuple.to_fmt | Return an Fmt representation for pretty-printing | pyrser/type_system/tuple.py | def to_fmt(self) -> fmt.indentable:
"""
Return an Fmt representation for pretty-printing
"""
lsb = []
if len(self._lsig) > 0:
for s in self._lsig:
lsb.append(s.to_fmt())
block = fmt.block("(", ")", fmt.sep(', ', lsb))
qual = "tuple"
... | def to_fmt(self) -> fmt.indentable:
"""
Return an Fmt representation for pretty-printing
"""
lsb = []
if len(self._lsig) > 0:
for s in self._lsig:
lsb.append(s.to_fmt())
block = fmt.block("(", ")", fmt.sep(', ', lsb))
qual = "tuple"
... | [
"Return",
"an",
"Fmt",
"representation",
"for",
"pretty",
"-",
"printing"
] | LionelAuroux/pyrser | python | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/tuple.py#L22-L33 | [
"def",
"to_fmt",
"(",
"self",
")",
"->",
"fmt",
".",
"indentable",
":",
"lsb",
"=",
"[",
"]",
"if",
"len",
"(",
"self",
".",
"_lsig",
")",
">",
"0",
":",
"for",
"s",
"in",
"self",
".",
"_lsig",
":",
"lsb",
".",
"append",
"(",
"s",
".",
"to_fm... | f153a97ef2b6bf915a1ed468c0252a9a59b754d5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.