repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
nocarryr/python-dispatch | pydispatch/utils.py | WeakMethodContainer.del_instance | def del_instance(self, obj):
"""Remove any stored instance methods that belong to an object
Args:
obj: The instance object to remove
"""
to_remove = set()
for wrkey, _obj in self.iter_instances():
if obj is _obj:
to_remove.add(wrkey)
... | python | def del_instance(self, obj):
"""Remove any stored instance methods that belong to an object
Args:
obj: The instance object to remove
"""
to_remove = set()
for wrkey, _obj in self.iter_instances():
if obj is _obj:
to_remove.add(wrkey)
... | [
"def",
"del_instance",
"(",
"self",
",",
"obj",
")",
":",
"to_remove",
"=",
"set",
"(",
")",
"for",
"wrkey",
",",
"_obj",
"in",
"self",
".",
"iter_instances",
"(",
")",
":",
"if",
"obj",
"is",
"_obj",
":",
"to_remove",
".",
"add",
"(",
"wrkey",
")"... | Remove any stored instance methods that belong to an object
Args:
obj: The instance object to remove | [
"Remove",
"any",
"stored",
"instance",
"methods",
"that",
"belong",
"to",
"an",
"object"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/utils.py#L74-L85 | train |
nocarryr/python-dispatch | pydispatch/utils.py | WeakMethodContainer.iter_instances | def iter_instances(self):
"""Iterate over the stored objects
Yields:
wrkey: The two-tuple key used to store the object
obj: The instance or function object
"""
for wrkey in set(self.keys()):
obj = self.get(wrkey)
if obj is None:
... | python | def iter_instances(self):
"""Iterate over the stored objects
Yields:
wrkey: The two-tuple key used to store the object
obj: The instance or function object
"""
for wrkey in set(self.keys()):
obj = self.get(wrkey)
if obj is None:
... | [
"def",
"iter_instances",
"(",
"self",
")",
":",
"for",
"wrkey",
"in",
"set",
"(",
"self",
".",
"keys",
"(",
")",
")",
":",
"obj",
"=",
"self",
".",
"get",
"(",
"wrkey",
")",
"if",
"obj",
"is",
"None",
":",
"continue",
"yield",
"wrkey",
",",
"obj"... | Iterate over the stored objects
Yields:
wrkey: The two-tuple key used to store the object
obj: The instance or function object | [
"Iterate",
"over",
"the",
"stored",
"objects"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/utils.py#L86-L97 | train |
nocarryr/python-dispatch | pydispatch/utils.py | WeakMethodContainer.iter_methods | def iter_methods(self):
"""Iterate over stored functions and instance methods
Yields:
Instance methods or function objects
"""
for wrkey, obj in self.iter_instances():
f, obj_id = wrkey
if f == 'function':
yield self[wrkey]
... | python | def iter_methods(self):
"""Iterate over stored functions and instance methods
Yields:
Instance methods or function objects
"""
for wrkey, obj in self.iter_instances():
f, obj_id = wrkey
if f == 'function':
yield self[wrkey]
... | [
"def",
"iter_methods",
"(",
"self",
")",
":",
"for",
"wrkey",
",",
"obj",
"in",
"self",
".",
"iter_instances",
"(",
")",
":",
"f",
",",
"obj_id",
"=",
"wrkey",
"if",
"f",
"==",
"'function'",
":",
"yield",
"self",
"[",
"wrkey",
"]",
"else",
":",
"yi... | Iterate over stored functions and instance methods
Yields:
Instance methods or function objects | [
"Iterate",
"over",
"stored",
"functions",
"and",
"instance",
"methods"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/utils.py#L98-L109 | train |
acutesoftware/AIKIF | aikif/cls_file_mapping.py | load_data_subject_areas | def load_data_subject_areas(subject_file):
"""
reads the subject file to a list, to confirm config is setup
"""
lst = []
if os.path.exists(subject_file):
with open(subject_file, 'r') as f:
for line in f:
lst.append(line.strip())
else:
print('MISSING DA... | python | def load_data_subject_areas(subject_file):
"""
reads the subject file to a list, to confirm config is setup
"""
lst = []
if os.path.exists(subject_file):
with open(subject_file, 'r') as f:
for line in f:
lst.append(line.strip())
else:
print('MISSING DA... | [
"def",
"load_data_subject_areas",
"(",
"subject_file",
")",
":",
"lst",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"subject_file",
")",
":",
"with",
"open",
"(",
"subject_file",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"... | reads the subject file to a list, to confirm config is setup | [
"reads",
"the",
"subject",
"file",
"to",
"a",
"list",
"to",
"confirm",
"config",
"is",
"setup"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L27-L39 | train |
acutesoftware/AIKIF | aikif/cls_file_mapping.py | check_ontology | def check_ontology(fname):
"""
reads the ontology yaml file and does basic verifcation
"""
with open(fname, 'r') as stream:
y = yaml.safe_load(stream)
import pprint
pprint.pprint(y) | python | def check_ontology(fname):
"""
reads the ontology yaml file and does basic verifcation
"""
with open(fname, 'r') as stream:
y = yaml.safe_load(stream)
import pprint
pprint.pprint(y) | [
"def",
"check_ontology",
"(",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"stream",
":",
"y",
"=",
"yaml",
".",
"safe_load",
"(",
"stream",
")",
"import",
"pprint",
"pprint",
".",
"pprint",
"(",
"y",
")"
] | reads the ontology yaml file and does basic verifcation | [
"reads",
"the",
"ontology",
"yaml",
"file",
"and",
"does",
"basic",
"verifcation"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L135-L142 | train |
acutesoftware/AIKIF | aikif/cls_file_mapping.py | FileMap.find_type | def find_type(self, txt):
"""
top level function used to simply return the
ONE ACTUAL string used for data types
"""
searchString = txt.upper()
match = 'Unknown'
for i in self.lst_type:
if searchString in i:
match = i
return ma... | python | def find_type(self, txt):
"""
top level function used to simply return the
ONE ACTUAL string used for data types
"""
searchString = txt.upper()
match = 'Unknown'
for i in self.lst_type:
if searchString in i:
match = i
return ma... | [
"def",
"find_type",
"(",
"self",
",",
"txt",
")",
":",
"searchString",
"=",
"txt",
".",
"upper",
"(",
")",
"match",
"=",
"'Unknown'",
"for",
"i",
"in",
"self",
".",
"lst_type",
":",
"if",
"searchString",
"in",
"i",
":",
"match",
"=",
"i",
"return",
... | top level function used to simply return the
ONE ACTUAL string used for data types | [
"top",
"level",
"function",
"used",
"to",
"simply",
"return",
"the",
"ONE",
"ACTUAL",
"string",
"used",
"for",
"data",
"types"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L105-L115 | train |
acutesoftware/AIKIF | aikif/cls_file_mapping.py | FileMap.get_full_filename | def get_full_filename(self, dataType, subjectArea):
"""
returns the file based on dataType and subjectArea
"""
return dataPath + os.sep + 'core' + os.sep + dataType + '_' + subjectArea + '.CSV' | python | def get_full_filename(self, dataType, subjectArea):
"""
returns the file based on dataType and subjectArea
"""
return dataPath + os.sep + 'core' + os.sep + dataType + '_' + subjectArea + '.CSV' | [
"def",
"get_full_filename",
"(",
"self",
",",
"dataType",
",",
"subjectArea",
")",
":",
"return",
"dataPath",
"+",
"os",
".",
"sep",
"+",
"'core'",
"+",
"os",
".",
"sep",
"+",
"dataType",
"+",
"'_'",
"+",
"subjectArea",
"+",
"'.CSV'"
] | returns the file based on dataType and subjectArea | [
"returns",
"the",
"file",
"based",
"on",
"dataType",
"and",
"subjectArea"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L117-L121 | train |
acutesoftware/AIKIF | aikif/lib/cls_plan_BDI.py | Plan_BDI.load_plan | def load_plan(self, fname):
""" read the list of thoughts from a text file """
with open(fname, "r") as f:
for line in f:
if line != '':
tpe, txt = self.parse_plan_from_string(line)
#print('tpe= "' + tpe + '"', txt)
... | python | def load_plan(self, fname):
""" read the list of thoughts from a text file """
with open(fname, "r") as f:
for line in f:
if line != '':
tpe, txt = self.parse_plan_from_string(line)
#print('tpe= "' + tpe + '"', txt)
... | [
"def",
"load_plan",
"(",
"self",
",",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
"!=",
"''",
":",
"tpe",
",",
"txt",
"=",
"self",
".",
"parse_plan_from_string",
... | read the list of thoughts from a text file | [
"read",
"the",
"list",
"of",
"thoughts",
"from",
"a",
"text",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_plan_BDI.py#L48-L64 | train |
acutesoftware/AIKIF | aikif/lib/cls_plan_BDI.py | Plan_BDI.add_constraint | def add_constraint(self, name, tpe, val):
"""
adds a constraint for the plan
"""
self.constraint.append([name, tpe, val]) | python | def add_constraint(self, name, tpe, val):
"""
adds a constraint for the plan
"""
self.constraint.append([name, tpe, val]) | [
"def",
"add_constraint",
"(",
"self",
",",
"name",
",",
"tpe",
",",
"val",
")",
":",
"self",
".",
"constraint",
".",
"append",
"(",
"[",
"name",
",",
"tpe",
",",
"val",
"]",
")"
] | adds a constraint for the plan | [
"adds",
"a",
"constraint",
"for",
"the",
"plan"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_plan_BDI.py#L100-L104 | train |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.get_maps_stats | def get_maps_stats(self):
"""
calculates basic stats on the MapRule elements of the maps
to give a quick overview.
"""
tpes = {}
for m in self.maps:
if m.tpe in tpes:
tpes[m.tpe] += 1
else:
tpes[m.tpe] = 1
re... | python | def get_maps_stats(self):
"""
calculates basic stats on the MapRule elements of the maps
to give a quick overview.
"""
tpes = {}
for m in self.maps:
if m.tpe in tpes:
tpes[m.tpe] += 1
else:
tpes[m.tpe] = 1
re... | [
"def",
"get_maps_stats",
"(",
"self",
")",
":",
"tpes",
"=",
"{",
"}",
"for",
"m",
"in",
"self",
".",
"maps",
":",
"if",
"m",
".",
"tpe",
"in",
"tpes",
":",
"tpes",
"[",
"m",
".",
"tpe",
"]",
"+=",
"1",
"else",
":",
"tpes",
"[",
"m",
".",
"... | calculates basic stats on the MapRule elements of the maps
to give a quick overview. | [
"calculates",
"basic",
"stats",
"on",
"the",
"MapRule",
"elements",
"of",
"the",
"maps",
"to",
"give",
"a",
"quick",
"overview",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L40-L51 | train |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.save_rules | def save_rules(self, op_file):
"""
save the rules to file after web updates or program changes
"""
with open(op_file, 'w') as f:
for m in self.maps:
f.write(m.format_for_file_output()) | python | def save_rules(self, op_file):
"""
save the rules to file after web updates or program changes
"""
with open(op_file, 'w') as f:
for m in self.maps:
f.write(m.format_for_file_output()) | [
"def",
"save_rules",
"(",
"self",
",",
"op_file",
")",
":",
"with",
"open",
"(",
"op_file",
",",
"'w'",
")",
"as",
"f",
":",
"for",
"m",
"in",
"self",
".",
"maps",
":",
"f",
".",
"write",
"(",
"m",
".",
"format_for_file_output",
"(",
")",
")"
] | save the rules to file after web updates or program changes | [
"save",
"the",
"rules",
"to",
"file",
"after",
"web",
"updates",
"or",
"program",
"changes"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L65-L71 | train |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.process_rule | def process_rule(self, m, dct, tpe):
"""
uses the MapRule 'm' to run through the 'dict'
and extract data based on the rule
"""
print('TODO - ' + tpe + ' + applying rule ' + str(m).replace('\n', '') ) | python | def process_rule(self, m, dct, tpe):
"""
uses the MapRule 'm' to run through the 'dict'
and extract data based on the rule
"""
print('TODO - ' + tpe + ' + applying rule ' + str(m).replace('\n', '') ) | [
"def",
"process_rule",
"(",
"self",
",",
"m",
",",
"dct",
",",
"tpe",
")",
":",
"print",
"(",
"'TODO - '",
"+",
"tpe",
"+",
"' + applying rule '",
"+",
"str",
"(",
"m",
")",
".",
"replace",
"(",
"'\\n'",
",",
"''",
")",
")"
] | uses the MapRule 'm' to run through the 'dict'
and extract data based on the rule | [
"uses",
"the",
"MapRule",
"m",
"to",
"run",
"through",
"the",
"dict",
"and",
"extract",
"data",
"based",
"on",
"the",
"rule"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L123-L128 | train |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.format_raw_data | def format_raw_data(self, tpe, raw_data):
"""
uses type to format the raw information to a dictionary
usable by the mapper
"""
if tpe == 'text':
formatted_raw_data = self.parse_text_to_dict(raw_data)
elif tpe == 'file':
formatted_raw_data ... | python | def format_raw_data(self, tpe, raw_data):
"""
uses type to format the raw information to a dictionary
usable by the mapper
"""
if tpe == 'text':
formatted_raw_data = self.parse_text_to_dict(raw_data)
elif tpe == 'file':
formatted_raw_data ... | [
"def",
"format_raw_data",
"(",
"self",
",",
"tpe",
",",
"raw_data",
")",
":",
"if",
"tpe",
"==",
"'text'",
":",
"formatted_raw_data",
"=",
"self",
".",
"parse_text_to_dict",
"(",
"raw_data",
")",
"elif",
"tpe",
"==",
"'file'",
":",
"formatted_raw_data",
"=",... | uses type to format the raw information to a dictionary
usable by the mapper | [
"uses",
"type",
"to",
"format",
"the",
"raw",
"information",
"to",
"a",
"dictionary",
"usable",
"by",
"the",
"mapper"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L131-L143 | train |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.parse_text_to_dict | def parse_text_to_dict(self, txt):
"""
takes a string and parses via NLP, ready for mapping
"""
op = {}
print('TODO - import NLP, split into verbs / nouns')
op['nouns'] = txt
op['verbs'] = txt
return op | python | def parse_text_to_dict(self, txt):
"""
takes a string and parses via NLP, ready for mapping
"""
op = {}
print('TODO - import NLP, split into verbs / nouns')
op['nouns'] = txt
op['verbs'] = txt
return op | [
"def",
"parse_text_to_dict",
"(",
"self",
",",
"txt",
")",
":",
"op",
"=",
"{",
"}",
"print",
"(",
"'TODO - import NLP, split into verbs / nouns'",
")",
"op",
"[",
"'nouns'",
"]",
"=",
"txt",
"op",
"[",
"'verbs'",
"]",
"=",
"txt",
"return",
"op"
] | takes a string and parses via NLP, ready for mapping | [
"takes",
"a",
"string",
"and",
"parses",
"via",
"NLP",
"ready",
"for",
"mapping"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L145-L154 | train |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.parse_file_to_dict | def parse_file_to_dict(self, fname):
"""
process the file according to the mapping rules.
The cols list must match the columns in the filename
"""
print('TODO - parse_file_to_dict' + fname)
for m in self.maps:
if m.tpe == 'file':
if m.key[0:3] ... | python | def parse_file_to_dict(self, fname):
"""
process the file according to the mapping rules.
The cols list must match the columns in the filename
"""
print('TODO - parse_file_to_dict' + fname)
for m in self.maps:
if m.tpe == 'file':
if m.key[0:3] ... | [
"def",
"parse_file_to_dict",
"(",
"self",
",",
"fname",
")",
":",
"print",
"(",
"'TODO - parse_file_to_dict'",
"+",
"fname",
")",
"for",
"m",
"in",
"self",
".",
"maps",
":",
"if",
"m",
".",
"tpe",
"==",
"'file'",
":",
"if",
"m",
".",
"key",
"[",
"0",... | process the file according to the mapping rules.
The cols list must match the columns in the filename | [
"process",
"the",
"file",
"according",
"to",
"the",
"mapping",
"rules",
".",
"The",
"cols",
"list",
"must",
"match",
"the",
"columns",
"in",
"the",
"filename"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L156-L165 | train |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.create_map_from_file | def create_map_from_file(self, data_filename):
"""
reads the data_filename into a matrix and calls the main
function '' to generate a .rule file based on the data in the map
For all datafiles mapped, there exists a .rule file to define it
"""
o... | python | def create_map_from_file(self, data_filename):
"""
reads the data_filename into a matrix and calls the main
function '' to generate a .rule file based on the data in the map
For all datafiles mapped, there exists a .rule file to define it
"""
o... | [
"def",
"create_map_from_file",
"(",
"self",
",",
"data_filename",
")",
":",
"op_filename",
"=",
"data_filename",
"+",
"'.rule'",
"dataset",
"=",
"mod_datatable",
".",
"DataTable",
"(",
"data_filename",
",",
"','",
")",
"dataset",
".",
"load_to_array",
"(",
")",
... | reads the data_filename into a matrix and calls the main
function '' to generate a .rule file based on the data in the map
For all datafiles mapped, there exists a .rule file to define it | [
"reads",
"the",
"data_filename",
"into",
"a",
"matrix",
"and",
"calls",
"the",
"main",
"function",
"to",
"generate",
"a",
".",
"rule",
"file",
"based",
"on",
"the",
"data",
"in",
"the",
"map",
"For",
"all",
"datafiles",
"mapped",
"there",
"exists",
"a",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L198-L222 | train |
acutesoftware/AIKIF | scripts/examples/aggie/aggie.py | Aggie.run | def run(self):
"""
loops until exit command given
"""
while self.status != 'EXIT':
print(self.process_input(self.get_input()))
print('Bye') | python | def run(self):
"""
loops until exit command given
"""
while self.status != 'EXIT':
print(self.process_input(self.get_input()))
print('Bye') | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"self",
".",
"status",
"!=",
"'EXIT'",
":",
"print",
"(",
"self",
".",
"process_input",
"(",
"self",
".",
"get_input",
"(",
")",
")",
")",
"print",
"(",
"'Bye'",
")"
] | loops until exit command given | [
"loops",
"until",
"exit",
"command",
"given"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/aggie/aggie.py#L45-L52 | train |
acutesoftware/AIKIF | scripts/examples/aggie/aggie.py | Aggie.process_input | def process_input(self, question):
"""
takes a question and returns the best answer based on known skills
"""
ans = ''
if self.status == 'EXIT':
print('bye')
sys.exit()
if '?' in question:
ans = self.info.find_answer(question)
... | python | def process_input(self, question):
"""
takes a question and returns the best answer based on known skills
"""
ans = ''
if self.status == 'EXIT':
print('bye')
sys.exit()
if '?' in question:
ans = self.info.find_answer(question)
... | [
"def",
"process_input",
"(",
"self",
",",
"question",
")",
":",
"ans",
"=",
"''",
"if",
"self",
".",
"status",
"==",
"'EXIT'",
":",
"print",
"(",
"'bye'",
")",
"sys",
".",
"exit",
"(",
")",
"if",
"'?'",
"in",
"question",
":",
"ans",
"=",
"self",
... | takes a question and returns the best answer based on known skills | [
"takes",
"a",
"question",
"and",
"returns",
"the",
"best",
"answer",
"based",
"on",
"known",
"skills"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/aggie/aggie.py#L60-L83 | train |
acutesoftware/AIKIF | aikif/web_app/page_data.py | show_data_file | def show_data_file(fname):
""" shows a data file in CSV format - all files live in CORE folder """
txt = '<H2>' + fname + '</H2>'
print (fname)
#try:
txt += web.read_csv_to_html_table(fname, 'Y') # it is ok to use a table for actual table data
#except:
# txt += '<H2>ERROR - cant read file</... | python | def show_data_file(fname):
""" shows a data file in CSV format - all files live in CORE folder """
txt = '<H2>' + fname + '</H2>'
print (fname)
#try:
txt += web.read_csv_to_html_table(fname, 'Y') # it is ok to use a table for actual table data
#except:
# txt += '<H2>ERROR - cant read file</... | [
"def",
"show_data_file",
"(",
"fname",
")",
":",
"txt",
"=",
"'<H2>'",
"+",
"fname",
"+",
"'</H2>'",
"print",
"(",
"fname",
")",
"txt",
"+=",
"web",
".",
"read_csv_to_html_table",
"(",
"fname",
",",
"'Y'",
")",
"txt",
"+=",
"'</div>\\n'",
"return",
"txt"... | shows a data file in CSV format - all files live in CORE folder | [
"shows",
"a",
"data",
"file",
"in",
"CSV",
"format",
"-",
"all",
"files",
"live",
"in",
"CORE",
"folder"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_data.py#L28-L39 | train |
Nachtfeuer/pipeline | spline/components/bash.py | managed_process | def managed_process(process):
"""Wrapper for subprocess.Popen to work across various Python versions, when using the with syntax."""
try:
yield process
finally:
for stream in [process.stdout, process.stdin, process.stderr]:
if stream:
stream.close()
proces... | python | def managed_process(process):
"""Wrapper for subprocess.Popen to work across various Python versions, when using the with syntax."""
try:
yield process
finally:
for stream in [process.stdout, process.stdin, process.stderr]:
if stream:
stream.close()
proces... | [
"def",
"managed_process",
"(",
"process",
")",
":",
"try",
":",
"yield",
"process",
"finally",
":",
"for",
"stream",
"in",
"[",
"process",
".",
"stdout",
",",
"process",
".",
"stdin",
",",
"process",
".",
"stderr",
"]",
":",
"if",
"stream",
":",
"strea... | Wrapper for subprocess.Popen to work across various Python versions, when using the with syntax. | [
"Wrapper",
"for",
"subprocess",
".",
"Popen",
"to",
"work",
"across",
"various",
"Python",
"versions",
"when",
"using",
"the",
"with",
"syntax",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L33-L41 | train |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.get_temporary_scripts_path | def get_temporary_scripts_path(self):
"""
Get path for temporary scripts.
Returns:
str: path for temporary scripts or None if not set
"""
result = None
if len(self.config.temporary_scripts_path) > 0:
if os.path.isdir(self.config.temporary_scripts_... | python | def get_temporary_scripts_path(self):
"""
Get path for temporary scripts.
Returns:
str: path for temporary scripts or None if not set
"""
result = None
if len(self.config.temporary_scripts_path) > 0:
if os.path.isdir(self.config.temporary_scripts_... | [
"def",
"get_temporary_scripts_path",
"(",
"self",
")",
":",
"result",
"=",
"None",
"if",
"len",
"(",
"self",
".",
"config",
".",
"temporary_scripts_path",
")",
">",
"0",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"config",
".",
"temp... | Get path for temporary scripts.
Returns:
str: path for temporary scripts or None if not set | [
"Get",
"path",
"for",
"temporary",
"scripts",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L84-L95 | train |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.create_file_for | def create_file_for(self, script):
"""
Create a temporary, executable bash file.
It also does render given script (string) with the model and
the provided environment variables and optional also an item
when using the B{with} field.
Args:
script (str): eithe... | python | def create_file_for(self, script):
"""
Create a temporary, executable bash file.
It also does render given script (string) with the model and
the provided environment variables and optional also an item
when using the B{with} field.
Args:
script (str): eithe... | [
"def",
"create_file_for",
"(",
"self",
",",
"script",
")",
":",
"temp",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"\"pipeline-script-\"",
",",
"mode",
"=",
"'w+t'",
",",
"suffix",
"=",
"\".sh\"",
",",
"delete",
"=",
"False",
",",
"dir... | Create a temporary, executable bash file.
It also does render given script (string) with the model and
the provided environment variables and optional also an item
when using the B{with} field.
Args:
script (str): either pather and filename or Bash code.
Returns:
... | [
"Create",
"a",
"temporary",
"executable",
"bash",
"file",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L97-L136 | train |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.render_bash_options | def render_bash_options(self):
"""Rendering Bash options."""
options = ''
if self.config.debug:
options += "set -x\n"
if self.config.strict:
options += "set -euo pipefail\n"
return options | python | def render_bash_options(self):
"""Rendering Bash options."""
options = ''
if self.config.debug:
options += "set -x\n"
if self.config.strict:
options += "set -euo pipefail\n"
return options | [
"def",
"render_bash_options",
"(",
"self",
")",
":",
"options",
"=",
"''",
"if",
"self",
".",
"config",
".",
"debug",
":",
"options",
"+=",
"\"set -x\\n\"",
"if",
"self",
".",
"config",
".",
"strict",
":",
"options",
"+=",
"\"set -euo pipefail\\n\"",
"return... | Rendering Bash options. | [
"Rendering",
"Bash",
"options",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L138-L145 | train |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.process_file | def process_file(self, filename):
"""Processing one file."""
if self.config.dry_run:
if not self.config.internal:
self.logger.info("Dry run mode for script %s", filename)
with open(filename) as handle:
for line in handle:
yield ... | python | def process_file(self, filename):
"""Processing one file."""
if self.config.dry_run:
if not self.config.internal:
self.logger.info("Dry run mode for script %s", filename)
with open(filename) as handle:
for line in handle:
yield ... | [
"def",
"process_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"config",
".",
"dry_run",
":",
"if",
"not",
"self",
".",
"config",
".",
"internal",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Dry run mode for script %s\"",
",",
"fi... | Processing one file. | [
"Processing",
"one",
"file",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L170-L182 | train |
sethmlarson/selectors2 | selectors2.py | BaseSelector.unregister | def unregister(self, fileobj):
""" Unregister a file object from being monitored. """
try:
key = self._fd_to_key.pop(self._fileobj_lookup(fileobj))
except KeyError:
raise KeyError("{0!r} is not registered".format(fileobj))
# Getting the fileno of a closed socket ... | python | def unregister(self, fileobj):
""" Unregister a file object from being monitored. """
try:
key = self._fd_to_key.pop(self._fileobj_lookup(fileobj))
except KeyError:
raise KeyError("{0!r} is not registered".format(fileobj))
# Getting the fileno of a closed socket ... | [
"def",
"unregister",
"(",
"self",
",",
"fileobj",
")",
":",
"try",
":",
"key",
"=",
"self",
".",
"_fd_to_key",
".",
"pop",
"(",
"self",
".",
"_fileobj_lookup",
"(",
"fileobj",
")",
")",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"\"{0!r} is not... | Unregister a file object from being monitored. | [
"Unregister",
"a",
"file",
"object",
"from",
"being",
"monitored",
"."
] | 9bdf3d86578d1a84738cac6eb4127281b75bd669 | https://github.com/sethmlarson/selectors2/blob/9bdf3d86578d1a84738cac6eb4127281b75bd669/selectors2.py#L161-L179 | train |
acutesoftware/AIKIF | aikif/comms.py | Message.prepare | def prepare(self):
"""
does some basic validation
"""
try:
assert(type(self.sender) is Channel)
assert(type(self.receiver) is Channel)
return True
except:
return False | python | def prepare(self):
"""
does some basic validation
"""
try:
assert(type(self.sender) is Channel)
assert(type(self.receiver) is Channel)
return True
except:
return False | [
"def",
"prepare",
"(",
"self",
")",
":",
"try",
":",
"assert",
"(",
"type",
"(",
"self",
".",
"sender",
")",
"is",
"Channel",
")",
"assert",
"(",
"type",
"(",
"self",
".",
"receiver",
")",
"is",
"Channel",
")",
"return",
"True",
"except",
":",
"ret... | does some basic validation | [
"does",
"some",
"basic",
"validation"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/comms.py#L97-L106 | train |
acutesoftware/AIKIF | aikif/comms.py | Message.send | def send(self):
"""
this handles the message transmission
"""
#print('sending message to ' + self.receiver)
if self.prepare():
## TODO - send message via library
print('sending message')
lg.record_process('comms.py', 'Sending message ' + self.t... | python | def send(self):
"""
this handles the message transmission
"""
#print('sending message to ' + self.receiver)
if self.prepare():
## TODO - send message via library
print('sending message')
lg.record_process('comms.py', 'Sending message ' + self.t... | [
"def",
"send",
"(",
"self",
")",
":",
"if",
"self",
".",
"prepare",
"(",
")",
":",
"print",
"(",
"'sending message'",
")",
"lg",
".",
"record_process",
"(",
"'comms.py'",
",",
"'Sending message '",
"+",
"self",
".",
"title",
")",
"return",
"True",
"else"... | this handles the message transmission | [
"this",
"handles",
"the",
"message",
"transmission"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/comms.py#L109-L121 | train |
acutesoftware/AIKIF | aikif/index.py | buildIndex | def buildIndex(ipFile, ndxFile, append='Y', silent='N', useShortFileName='Y'):
"""
this creates an index of a text file specifically for use in AIKIF
separates the ontology descriptions highest followed by values and lastly
a final pass to get all delimited word parts.
"""
if silent == 'N':
... | python | def buildIndex(ipFile, ndxFile, append='Y', silent='N', useShortFileName='Y'):
"""
this creates an index of a text file specifically for use in AIKIF
separates the ontology descriptions highest followed by values and lastly
a final pass to get all delimited word parts.
"""
if silent == 'N':
... | [
"def",
"buildIndex",
"(",
"ipFile",
",",
"ndxFile",
",",
"append",
"=",
"'Y'",
",",
"silent",
"=",
"'N'",
",",
"useShortFileName",
"=",
"'Y'",
")",
":",
"if",
"silent",
"==",
"'N'",
":",
"pass",
"if",
"append",
"==",
"'N'",
":",
"try",
":",
"os",
"... | this creates an index of a text file specifically for use in AIKIF
separates the ontology descriptions highest followed by values and lastly
a final pass to get all delimited word parts. | [
"this",
"creates",
"an",
"index",
"of",
"a",
"text",
"file",
"specifically",
"for",
"use",
"in",
"AIKIF",
"separates",
"the",
"ontology",
"descriptions",
"highest",
"followed",
"by",
"values",
"and",
"lastly",
"a",
"final",
"pass",
"to",
"get",
"all",
"delim... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L61-L87 | train |
acutesoftware/AIKIF | aikif/index.py | format_op_row | def format_op_row(ipFile, totLines, totWords, uniqueWords):
"""
Format the output row with stats
"""
txt = os.path.basename(ipFile).ljust(36) + ' '
txt += str(totLines).rjust(7) + ' '
txt += str(totWords).rjust(7) + ' '
txt += str(len(uniqueWords)).rjust(7) + ' '
return txt | python | def format_op_row(ipFile, totLines, totWords, uniqueWords):
"""
Format the output row with stats
"""
txt = os.path.basename(ipFile).ljust(36) + ' '
txt += str(totLines).rjust(7) + ' '
txt += str(totWords).rjust(7) + ' '
txt += str(len(uniqueWords)).rjust(7) + ' '
return txt | [
"def",
"format_op_row",
"(",
"ipFile",
",",
"totLines",
",",
"totWords",
",",
"uniqueWords",
")",
":",
"txt",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"ipFile",
")",
".",
"ljust",
"(",
"36",
")",
"+",
"' '",
"txt",
"+=",
"str",
"(",
"totLines",
... | Format the output row with stats | [
"Format",
"the",
"output",
"row",
"with",
"stats"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L89-L97 | train |
acutesoftware/AIKIF | aikif/index.py | format_op_hdr | def format_op_hdr():
"""
Build the header
"""
txt = 'Base Filename'.ljust(36) + ' '
txt += 'Lines'.rjust(7) + ' '
txt += 'Words'.rjust(7) + ' '
txt += 'Unique'.ljust(8) + ''
return txt | python | def format_op_hdr():
"""
Build the header
"""
txt = 'Base Filename'.ljust(36) + ' '
txt += 'Lines'.rjust(7) + ' '
txt += 'Words'.rjust(7) + ' '
txt += 'Unique'.ljust(8) + ''
return txt | [
"def",
"format_op_hdr",
"(",
")",
":",
"txt",
"=",
"'Base Filename'",
".",
"ljust",
"(",
"36",
")",
"+",
"' '",
"txt",
"+=",
"'Lines'",
".",
"rjust",
"(",
"7",
")",
"+",
"' '",
"txt",
"+=",
"'Words'",
".",
"rjust",
"(",
"7",
")",
"+",
"' '",
"tx... | Build the header | [
"Build",
"the",
"header"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L99-L107 | train |
acutesoftware/AIKIF | aikif/index.py | AppendIndexDictionaryToFile | def AppendIndexDictionaryToFile(uniqueWords, ndxFile, ipFile, useShortFileName='Y'):
"""
Save the list of unique words to the master list
"""
if useShortFileName == 'Y':
f = os.path.basename(ipFile)
else:
f = ipFile
with open(ndxFile, "a", encoding='utf-8', errors='replace') as... | python | def AppendIndexDictionaryToFile(uniqueWords, ndxFile, ipFile, useShortFileName='Y'):
"""
Save the list of unique words to the master list
"""
if useShortFileName == 'Y':
f = os.path.basename(ipFile)
else:
f = ipFile
with open(ndxFile, "a", encoding='utf-8', errors='replace') as... | [
"def",
"AppendIndexDictionaryToFile",
"(",
"uniqueWords",
",",
"ndxFile",
",",
"ipFile",
",",
"useShortFileName",
"=",
"'Y'",
")",
":",
"if",
"useShortFileName",
"==",
"'Y'",
":",
"f",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"ipFile",
")",
"else",
":... | Save the list of unique words to the master list | [
"Save",
"the",
"list",
"of",
"unique",
"words",
"to",
"the",
"master",
"list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L110-L127 | train |
acutesoftware/AIKIF | aikif/index.py | DisplayIndexAsDictionary | def DisplayIndexAsDictionary(word_occurrences):
"""
print the index as a dict
"""
word_keys = word_occurrences.keys()
for num, word in enumerate(word_keys):
line_nums = word_occurrences[word]
print(word + " ")
if num > 3:
break | python | def DisplayIndexAsDictionary(word_occurrences):
"""
print the index as a dict
"""
word_keys = word_occurrences.keys()
for num, word in enumerate(word_keys):
line_nums = word_occurrences[word]
print(word + " ")
if num > 3:
break | [
"def",
"DisplayIndexAsDictionary",
"(",
"word_occurrences",
")",
":",
"word_keys",
"=",
"word_occurrences",
".",
"keys",
"(",
")",
"for",
"num",
",",
"word",
"in",
"enumerate",
"(",
"word_keys",
")",
":",
"line_nums",
"=",
"word_occurrences",
"[",
"word",
"]",... | print the index as a dict | [
"print",
"the",
"index",
"as",
"a",
"dict"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L129-L138 | train |
acutesoftware/AIKIF | aikif/index.py | show | def show(title, lst, full=-1):
"""
for testing, simply shows a list details
"""
txt = title + ' (' + str(len(lst)) + ') items :\n '
num = 0
for i in lst:
if full == -1 or num < full:
if type(i) is str:
txt = txt + i + ',\n '
else:
t... | python | def show(title, lst, full=-1):
"""
for testing, simply shows a list details
"""
txt = title + ' (' + str(len(lst)) + ') items :\n '
num = 0
for i in lst:
if full == -1 or num < full:
if type(i) is str:
txt = txt + i + ',\n '
else:
t... | [
"def",
"show",
"(",
"title",
",",
"lst",
",",
"full",
"=",
"-",
"1",
")",
":",
"txt",
"=",
"title",
"+",
"' ('",
"+",
"str",
"(",
"len",
"(",
"lst",
")",
")",
"+",
"') items :\\n '",
"num",
"=",
"0",
"for",
"i",
"in",
"lst",
":",
"if",
"full"... | for testing, simply shows a list details | [
"for",
"testing",
"simply",
"shows",
"a",
"list",
"details"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L140-L159 | train |
acutesoftware/AIKIF | aikif/index.py | getWordList | def getWordList(ipFile, delim):
"""
extract a unique list of words and have line numbers that word appears
"""
indexedWords = {}
totWords = 0
totLines = 0
with codecs.open(ipFile, "r",encoding='utf-8', errors='replace') as f:
for line in f:
totLines = totLines + 1
... | python | def getWordList(ipFile, delim):
"""
extract a unique list of words and have line numbers that word appears
"""
indexedWords = {}
totWords = 0
totLines = 0
with codecs.open(ipFile, "r",encoding='utf-8', errors='replace') as f:
for line in f:
totLines = totLines + 1
... | [
"def",
"getWordList",
"(",
"ipFile",
",",
"delim",
")",
":",
"indexedWords",
"=",
"{",
"}",
"totWords",
"=",
"0",
"totLines",
"=",
"0",
"with",
"codecs",
".",
"open",
"(",
"ipFile",
",",
"\"r\"",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"... | extract a unique list of words and have line numbers that word appears | [
"extract",
"a",
"unique",
"list",
"of",
"words",
"and",
"have",
"line",
"numbers",
"that",
"word",
"appears"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L161-L179 | train |
acutesoftware/AIKIF | aikif/index.py | multi_split | def multi_split(txt, delims):
"""
split by multiple delimiters
"""
res = [txt]
for delimChar in delims:
txt, res = res, []
for word in txt:
if len(word) > 1:
res += word.split(delimChar)
return res | python | def multi_split(txt, delims):
"""
split by multiple delimiters
"""
res = [txt]
for delimChar in delims:
txt, res = res, []
for word in txt:
if len(word) > 1:
res += word.split(delimChar)
return res | [
"def",
"multi_split",
"(",
"txt",
",",
"delims",
")",
":",
"res",
"=",
"[",
"txt",
"]",
"for",
"delimChar",
"in",
"delims",
":",
"txt",
",",
"res",
"=",
"res",
",",
"[",
"]",
"for",
"word",
"in",
"txt",
":",
"if",
"len",
"(",
"word",
")",
">",
... | split by multiple delimiters | [
"split",
"by",
"multiple",
"delimiters"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L181-L191 | train |
Nachtfeuer/pipeline | spline/components/script.py | Script.creator | def creator(entry, config):
"""Preparing and creating script."""
script = render(config.script, model=config.model, env=config.env, item=config.item)
temp = tempfile.NamedTemporaryFile(prefix="script-", suffix=".py", mode='w+t', delete=False)
temp.writelines(script)
temp.close()... | python | def creator(entry, config):
"""Preparing and creating script."""
script = render(config.script, model=config.model, env=config.env, item=config.item)
temp = tempfile.NamedTemporaryFile(prefix="script-", suffix=".py", mode='w+t', delete=False)
temp.writelines(script)
temp.close()... | [
"def",
"creator",
"(",
"entry",
",",
"config",
")",
":",
"script",
"=",
"render",
"(",
"config",
".",
"script",
",",
"model",
"=",
"config",
".",
"model",
",",
"env",
"=",
"config",
".",
"env",
",",
"item",
"=",
"config",
".",
"item",
")",
"temp",
... | Preparing and creating script. | [
"Preparing",
"and",
"creating",
"script",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/script.py#L43-L58 | train |
acutesoftware/AIKIF | aikif/cls_log.py | force_to_string | def force_to_string(unknown):
"""
converts and unknown type to string for display purposes.
"""
result = ''
if type(unknown) is str:
result = unknown
if type(unknown) is int:
result = str(unknown)
if type(unknown) is float:
result = str(unknown)
if type(unkno... | python | def force_to_string(unknown):
"""
converts and unknown type to string for display purposes.
"""
result = ''
if type(unknown) is str:
result = unknown
if type(unknown) is int:
result = str(unknown)
if type(unknown) is float:
result = str(unknown)
if type(unkno... | [
"def",
"force_to_string",
"(",
"unknown",
")",
":",
"result",
"=",
"''",
"if",
"type",
"(",
"unknown",
")",
"is",
"str",
":",
"result",
"=",
"unknown",
"if",
"type",
"(",
"unknown",
")",
"is",
"int",
":",
"result",
"=",
"str",
"(",
"unknown",
")",
... | converts and unknown type to string for display purposes. | [
"converts",
"and",
"unknown",
"type",
"to",
"string",
"for",
"display",
"purposes",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L311-L327 | train |
acutesoftware/AIKIF | aikif/cls_log.py | Log.add_watch_point | def add_watch_point(self, string, rating, importance=5):
"""
For a log session you can add as many watch points
which are used in the aggregation and extraction of
key things that happen.
Each watch point has a rating (up to you and can range
from success to total failu... | python | def add_watch_point(self, string, rating, importance=5):
"""
For a log session you can add as many watch points
which are used in the aggregation and extraction of
key things that happen.
Each watch point has a rating (up to you and can range
from success to total failu... | [
"def",
"add_watch_point",
"(",
"self",
",",
"string",
",",
"rating",
",",
"importance",
"=",
"5",
")",
":",
"d",
"=",
"{",
"}",
"d",
"[",
"'string'",
"]",
"=",
"string",
"d",
"[",
"'rating'",
"]",
"=",
"rating",
"d",
"[",
"'importance'",
"]",
"=",
... | For a log session you can add as many watch points
which are used in the aggregation and extraction of
key things that happen.
Each watch point has a rating (up to you and can range
from success to total failure and an importance for
finer control of display | [
"For",
"a",
"log",
"session",
"you",
"can",
"add",
"as",
"many",
"watch",
"points",
"which",
"are",
"used",
"in",
"the",
"aggregation",
"and",
"extraction",
"of",
"key",
"things",
"that",
"happen",
".",
"Each",
"watch",
"point",
"has",
"a",
"rating",
"("... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L46-L59 | train |
acutesoftware/AIKIF | aikif/cls_log.py | Log.estimate_complexity | def estimate_complexity(self, x,y,z,n):
"""
calculates a rough guess of runtime based on product of parameters
"""
num_calculations = x * y * z * n
run_time = num_calculations / 100000 # a 2014 PC does about 100k calcs in a second (guess based on prior logs)
return sel... | python | def estimate_complexity(self, x,y,z,n):
"""
calculates a rough guess of runtime based on product of parameters
"""
num_calculations = x * y * z * n
run_time = num_calculations / 100000 # a 2014 PC does about 100k calcs in a second (guess based on prior logs)
return sel... | [
"def",
"estimate_complexity",
"(",
"self",
",",
"x",
",",
"y",
",",
"z",
",",
"n",
")",
":",
"num_calculations",
"=",
"x",
"*",
"y",
"*",
"z",
"*",
"n",
"run_time",
"=",
"num_calculations",
"/",
"100000",
"return",
"self",
".",
"show_time_as_short_string... | calculates a rough guess of runtime based on product of parameters | [
"calculates",
"a",
"rough",
"guess",
"of",
"runtime",
"based",
"on",
"product",
"of",
"parameters"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L89-L95 | train |
acutesoftware/AIKIF | aikif/cls_log.py | Log.show_time_as_short_string | def show_time_as_short_string(self, seconds):
"""
converts seconds to a string in terms of
seconds -> years to show complexity of algorithm
"""
if seconds < 60:
return str(seconds) + ' seconds'
elif seconds < 3600:
return str(round(seconds/60, 1)... | python | def show_time_as_short_string(self, seconds):
"""
converts seconds to a string in terms of
seconds -> years to show complexity of algorithm
"""
if seconds < 60:
return str(seconds) + ' seconds'
elif seconds < 3600:
return str(round(seconds/60, 1)... | [
"def",
"show_time_as_short_string",
"(",
"self",
",",
"seconds",
")",
":",
"if",
"seconds",
"<",
"60",
":",
"return",
"str",
"(",
"seconds",
")",
"+",
"' seconds'",
"elif",
"seconds",
"<",
"3600",
":",
"return",
"str",
"(",
"round",
"(",
"seconds",
"/",
... | converts seconds to a string in terms of
seconds -> years to show complexity of algorithm | [
"converts",
"seconds",
"to",
"a",
"string",
"in",
"terms",
"of",
"seconds",
"-",
">",
"years",
"to",
"show",
"complexity",
"of",
"algorithm"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L98-L113 | train |
acutesoftware/AIKIF | aikif/cls_log.py | Log._log | def _log(self, fname, txt, prg=''):
"""
logs an entry to fname along with standard date and user details
"""
if os.sep not in fname:
fname = self.log_folder + os.sep + fname
delim = ','
q = '"'
dte = TodayAsString()
usr = GetUserName()
... | python | def _log(self, fname, txt, prg=''):
"""
logs an entry to fname along with standard date and user details
"""
if os.sep not in fname:
fname = self.log_folder + os.sep + fname
delim = ','
q = '"'
dte = TodayAsString()
usr = GetUserName()
... | [
"def",
"_log",
"(",
"self",
",",
"fname",
",",
"txt",
",",
"prg",
"=",
"''",
")",
":",
"if",
"os",
".",
"sep",
"not",
"in",
"fname",
":",
"fname",
"=",
"self",
".",
"log_folder",
"+",
"os",
".",
"sep",
"+",
"fname",
"delim",
"=",
"','",
"q",
... | logs an entry to fname along with standard date and user details | [
"logs",
"an",
"entry",
"to",
"fname",
"along",
"with",
"standard",
"date",
"and",
"user",
"details"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L115-L132 | train |
acutesoftware/AIKIF | aikif/cls_log.py | Log.record_source | def record_source(self, src, prg=''):
"""
function to collect raw data from the web and hard drive
Examples - new source file for ontologies, email contacts list, folder for xmas photos
"""
self._log(self.logFileSource , force_to_string(src), prg) | python | def record_source(self, src, prg=''):
"""
function to collect raw data from the web and hard drive
Examples - new source file for ontologies, email contacts list, folder for xmas photos
"""
self._log(self.logFileSource , force_to_string(src), prg) | [
"def",
"record_source",
"(",
"self",
",",
"src",
",",
"prg",
"=",
"''",
")",
":",
"self",
".",
"_log",
"(",
"self",
".",
"logFileSource",
",",
"force_to_string",
"(",
"src",
")",
",",
"prg",
")"
] | function to collect raw data from the web and hard drive
Examples - new source file for ontologies, email contacts list, folder for xmas photos | [
"function",
"to",
"collect",
"raw",
"data",
"from",
"the",
"web",
"and",
"hard",
"drive",
"Examples",
"-",
"new",
"source",
"file",
"for",
"ontologies",
"email",
"contacts",
"list",
"folder",
"for",
"xmas",
"photos"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L135-L140 | train |
acutesoftware/AIKIF | aikif/cls_log.py | Log.record_command | def record_command(self, cmd, prg=''):
"""
record the command passed - this is usually the name of the program
being run or task being run
"""
self._log(self.logFileCommand , force_to_string(cmd), prg) | python | def record_command(self, cmd, prg=''):
"""
record the command passed - this is usually the name of the program
being run or task being run
"""
self._log(self.logFileCommand , force_to_string(cmd), prg) | [
"def",
"record_command",
"(",
"self",
",",
"cmd",
",",
"prg",
"=",
"''",
")",
":",
"self",
".",
"_log",
"(",
"self",
".",
"logFileCommand",
",",
"force_to_string",
"(",
"cmd",
")",
",",
"prg",
")"
] | record the command passed - this is usually the name of the program
being run or task being run | [
"record",
"the",
"command",
"passed",
"-",
"this",
"is",
"usually",
"the",
"name",
"of",
"the",
"program",
"being",
"run",
"or",
"task",
"being",
"run"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L148-L153 | train |
acutesoftware/AIKIF | aikif/cls_log.py | Log.record_result | def record_result(self, res, prg=''):
"""
record the output of the command. Records the result, can have
multiple results, so will need to work out a consistent way to aggregate this
"""
self._log(self.logFileResult , force_to_string(res), prg) | python | def record_result(self, res, prg=''):
"""
record the output of the command. Records the result, can have
multiple results, so will need to work out a consistent way to aggregate this
"""
self._log(self.logFileResult , force_to_string(res), prg) | [
"def",
"record_result",
"(",
"self",
",",
"res",
",",
"prg",
"=",
"''",
")",
":",
"self",
".",
"_log",
"(",
"self",
".",
"logFileResult",
",",
"force_to_string",
"(",
"res",
")",
",",
"prg",
")"
] | record the output of the command. Records the result, can have
multiple results, so will need to work out a consistent way to aggregate this | [
"record",
"the",
"output",
"of",
"the",
"command",
".",
"Records",
"the",
"result",
"can",
"have",
"multiple",
"results",
"so",
"will",
"need",
"to",
"work",
"out",
"a",
"consistent",
"way",
"to",
"aggregate",
"this"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L155-L160 | train |
acutesoftware/AIKIF | aikif/cls_log.py | LogSummary.extract_logs | def extract_logs(self, fname, prg):
"""
read a logfile and return entries for a program
"""
op = []
with open(fname, 'r') as f:
for line in f:
if prg in line:
op.append(line)
return op | python | def extract_logs(self, fname, prg):
"""
read a logfile and return entries for a program
"""
op = []
with open(fname, 'r') as f:
for line in f:
if prg in line:
op.append(line)
return op | [
"def",
"extract_logs",
"(",
"self",
",",
"fname",
",",
"prg",
")",
":",
"op",
"=",
"[",
"]",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"prg",
"in",
"line",
":",
"op",
".",
"append",
"(... | read a logfile and return entries for a program | [
"read",
"a",
"logfile",
"and",
"return",
"entries",
"for",
"a",
"program"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L216-L225 | train |
acutesoftware/AIKIF | aikif/cls_log.py | LogSummary.summarise_events | def summarise_events(self):
"""
takes the logfiles and produces an event summary matrix
date command result process source
20140421 9 40 178 9
20140423 0 0 6 0
20140424 19 1 47 19
... | python | def summarise_events(self):
"""
takes the logfiles and produces an event summary matrix
date command result process source
20140421 9 40 178 9
20140423 0 0 6 0
20140424 19 1 47 19
... | [
"def",
"summarise_events",
"(",
"self",
")",
":",
"all_dates",
"=",
"[",
"]",
"d_command",
"=",
"self",
".",
"_count_by_date",
"(",
"self",
".",
"command_file",
",",
"all_dates",
")",
"d_result",
"=",
"self",
".",
"_count_by_date",
"(",
"self",
".",
"resul... | takes the logfiles and produces an event summary matrix
date command result process source
20140421 9 40 178 9
20140423 0 0 6 0
20140424 19 1 47 19
20140425 24 0 117 24
... | [
"takes",
"the",
"logfiles",
"and",
"produces",
"an",
"event",
"summary",
"matrix",
"date",
"command",
"result",
"process",
"source",
"20140421",
"9",
"40",
"178",
"9",
"20140423",
"0",
"0",
"6",
"0",
"20140424",
"19",
"1",
"47",
"19",
"20140425",
"24",
"... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L227-L265 | train |
acutesoftware/AIKIF | aikif/cls_log.py | LogSummary._count_by_date | def _count_by_date(self, fname, all_dates):
"""
reads a logfile and returns a dictionary by date
showing the count of log entries
"""
if not os.path.isfile(fname):
return {}
d_log_sum = {}
with open(fname, "r") as raw_log:
for line in raw_l... | python | def _count_by_date(self, fname, all_dates):
"""
reads a logfile and returns a dictionary by date
showing the count of log entries
"""
if not os.path.isfile(fname):
return {}
d_log_sum = {}
with open(fname, "r") as raw_log:
for line in raw_l... | [
"def",
"_count_by_date",
"(",
"self",
",",
"fname",
",",
"all_dates",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"fname",
")",
":",
"return",
"{",
"}",
"d_log_sum",
"=",
"{",
"}",
"with",
"open",
"(",
"fname",
",",
"\"r\"",
")",
... | reads a logfile and returns a dictionary by date
showing the count of log entries | [
"reads",
"a",
"logfile",
"and",
"returns",
"a",
"dictionary",
"by",
"date",
"showing",
"the",
"count",
"of",
"log",
"entries"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L267-L284 | train |
acutesoftware/AIKIF | aikif/agents/agent_map_data.py | AgentMapDataFile.map_data | def map_data(self):
"""
provides a mapping from the CSV file to the
aikif data structures.
"""
with open(self.src_file, "r") as f:
for line in f:
cols = line.split(',')
print(cols) | python | def map_data(self):
"""
provides a mapping from the CSV file to the
aikif data structures.
"""
with open(self.src_file, "r") as f:
for line in f:
cols = line.split(',')
print(cols) | [
"def",
"map_data",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"src_file",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"cols",
"=",
"line",
".",
"split",
"(",
"','",
")",
"print",
"(",
"cols",
")"
] | provides a mapping from the CSV file to the
aikif data structures. | [
"provides",
"a",
"mapping",
"from",
"the",
"CSV",
"file",
"to",
"the",
"aikif",
"data",
"structures",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/agent_map_data.py#L29-L37 | train |
mpg-age-bioinformatics/AGEpy | AGEpy/blast.py | variablename | def variablename(var):
"""
Returns the string of a variable name.
"""
s=[tpl[0] for tpl in itertools.ifilter(lambda x: var is x[1], globals().items())]
s=s[0].upper()
return s | python | def variablename(var):
"""
Returns the string of a variable name.
"""
s=[tpl[0] for tpl in itertools.ifilter(lambda x: var is x[1], globals().items())]
s=s[0].upper()
return s | [
"def",
"variablename",
"(",
"var",
")",
":",
"s",
"=",
"[",
"tpl",
"[",
"0",
"]",
"for",
"tpl",
"in",
"itertools",
".",
"ifilter",
"(",
"lambda",
"x",
":",
"var",
"is",
"x",
"[",
"1",
"]",
",",
"globals",
"(",
")",
".",
"items",
"(",
")",
")"... | Returns the string of a variable name. | [
"Returns",
"the",
"string",
"of",
"a",
"variable",
"name",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/blast.py#L6-L12 | train |
mpg-age-bioinformatics/AGEpy | AGEpy/blast.py | BLASTquery | def BLASTquery(query,database,program,filter=None,\
format_type=None, expect=None,\
nucl_reward=None, nucl_penalty=None,\
gapcosts=None, matrix=None,\
hitlist_size=None, descriptions=None,\
alignments=None,\
ncbi_gi=None, threshol... | python | def BLASTquery(query,database,program,filter=None,\
format_type=None, expect=None,\
nucl_reward=None, nucl_penalty=None,\
gapcosts=None, matrix=None,\
hitlist_size=None, descriptions=None,\
alignments=None,\
ncbi_gi=None, threshol... | [
"def",
"BLASTquery",
"(",
"query",
",",
"database",
",",
"program",
",",
"filter",
"=",
"None",
",",
"format_type",
"=",
"None",
",",
"expect",
"=",
"None",
",",
"nucl_reward",
"=",
"None",
",",
"nucl_penalty",
"=",
"None",
",",
"gapcosts",
"=",
"None",
... | Performs a blast query online.
As in https://ncbi.github.io/blast-cloud/
:param query: Search query. Allowed values: Accession, GI, or FASTA.
:param database: BLAST database. Allowed values: nt, nr, refseq_rna, refseq_protein, swissprot, pdbaa, pdbnt
:param program: BLAST program. Allowed values: bla... | [
"Performs",
"a",
"blast",
"query",
"online",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/blast.py#L14-L94 | train |
mpg-age-bioinformatics/AGEpy | AGEpy/blast.py | BLASTcheck | def BLASTcheck(rid,baseURL="http://blast.ncbi.nlm.nih.gov"):
"""
Checks the status of a query.
:param rid: BLAST search request identifier. Allowed values: The Request ID (RID) returned when the search was submitted
:param baseURL: server url. Default=http://blast.ncbi.nlm.nih.gov
:returns status:... | python | def BLASTcheck(rid,baseURL="http://blast.ncbi.nlm.nih.gov"):
"""
Checks the status of a query.
:param rid: BLAST search request identifier. Allowed values: The Request ID (RID) returned when the search was submitted
:param baseURL: server url. Default=http://blast.ncbi.nlm.nih.gov
:returns status:... | [
"def",
"BLASTcheck",
"(",
"rid",
",",
"baseURL",
"=",
"\"http://blast.ncbi.nlm.nih.gov\"",
")",
":",
"URL",
"=",
"baseURL",
"+",
"\"/Blast.cgi?\"",
"URL",
"=",
"URL",
"+",
"\"FORMAT_OBJECT=SearchInfo&RID=\"",
"+",
"rid",
"+",
"\"&CMD=Get\"",
"response",
"=",
"requ... | Checks the status of a query.
:param rid: BLAST search request identifier. Allowed values: The Request ID (RID) returned when the search was submitted
:param baseURL: server url. Default=http://blast.ncbi.nlm.nih.gov
:returns status: status for the query.
:returns therearehist: yes or no for existing ... | [
"Checks",
"the",
"status",
"of",
"a",
"query",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/blast.py#L96-L121 | train |
mpg-age-bioinformatics/AGEpy | AGEpy/blast.py | BLASTresults | def BLASTresults(rid, format_type="Tabular", \
hitlist_size= None, alignments=None, \
ncbi_gi = None, format_object=None,\
baseURL="http://blast.ncbi.nlm.nih.gov"):
"""
Retrieves results for an RID.
:param rid: BLAST search request identifier. Allowed valu... | python | def BLASTresults(rid, format_type="Tabular", \
hitlist_size= None, alignments=None, \
ncbi_gi = None, format_object=None,\
baseURL="http://blast.ncbi.nlm.nih.gov"):
"""
Retrieves results for an RID.
:param rid: BLAST search request identifier. Allowed valu... | [
"def",
"BLASTresults",
"(",
"rid",
",",
"format_type",
"=",
"\"Tabular\"",
",",
"hitlist_size",
"=",
"None",
",",
"alignments",
"=",
"None",
",",
"ncbi_gi",
"=",
"None",
",",
"format_object",
"=",
"None",
",",
"baseURL",
"=",
"\"http://blast.ncbi.nlm.nih.gov\"",... | Retrieves results for an RID.
:param rid: BLAST search request identifier. Allowed values: The Request ID (RID) returned when the search was submitted
:param format_type: Report type. Allowed values: HTML, Text, XML, XML2, JSON2, or Tabular. Tabular is the default.
:param hitlist_size: Number of databases ... | [
"Retrieves",
"results",
"for",
"an",
"RID",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/blast.py#L123-L160 | train |
Nachtfeuer/pipeline | spline/tools/report/generator.py | generate_html | def generate_html(store):
"""
Generating HTML report.
Args:
store (Store): report data.
Returns:
str: rendered HTML template.
"""
spline = {
'version': VERSION,
'url': 'https://github.com/Nachtfeuer/pipeline',
'generated': datetime.now().strftime("%A, %d... | python | def generate_html(store):
"""
Generating HTML report.
Args:
store (Store): report data.
Returns:
str: rendered HTML template.
"""
spline = {
'version': VERSION,
'url': 'https://github.com/Nachtfeuer/pipeline',
'generated': datetime.now().strftime("%A, %d... | [
"def",
"generate_html",
"(",
"store",
")",
":",
"spline",
"=",
"{",
"'version'",
":",
"VERSION",
",",
"'url'",
":",
"'https://github.com/Nachtfeuer/pipeline'",
",",
"'generated'",
":",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"\"%A, %d. %B %Y - %I... | Generating HTML report.
Args:
store (Store): report data.
Returns:
str: rendered HTML template. | [
"Generating",
"HTML",
"report",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/generator.py#L26-L45 | train |
Nachtfeuer/pipeline | spline/tools/condition.py | TokensCompressor.__begin_of_list | def __begin_of_list(self, ast_token):
"""Handle begin of a list."""
self.list_level += 1
if self.list_level == 1:
self.final_ast_tokens.append(ast_token) | python | def __begin_of_list(self, ast_token):
"""Handle begin of a list."""
self.list_level += 1
if self.list_level == 1:
self.final_ast_tokens.append(ast_token) | [
"def",
"__begin_of_list",
"(",
"self",
",",
"ast_token",
")",
":",
"self",
".",
"list_level",
"+=",
"1",
"if",
"self",
".",
"list_level",
"==",
"1",
":",
"self",
".",
"final_ast_tokens",
".",
"append",
"(",
"ast_token",
")"
] | Handle begin of a list. | [
"Handle",
"begin",
"of",
"a",
"list",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L41-L45 | train |
Nachtfeuer/pipeline | spline/tools/condition.py | TokensCompressor.__end_of_list | def __end_of_list(self, ast_token):
"""Handle end of a list."""
self.list_level -= 1
if self.list_level == 0:
if self.list_entry is not None:
self.final_ast_tokens.append(self.list_entry)
self.list_entry = None
self.final_ast_tokens.append(... | python | def __end_of_list(self, ast_token):
"""Handle end of a list."""
self.list_level -= 1
if self.list_level == 0:
if self.list_entry is not None:
self.final_ast_tokens.append(self.list_entry)
self.list_entry = None
self.final_ast_tokens.append(... | [
"def",
"__end_of_list",
"(",
"self",
",",
"ast_token",
")",
":",
"self",
".",
"list_level",
"-=",
"1",
"if",
"self",
".",
"list_level",
"==",
"0",
":",
"if",
"self",
".",
"list_entry",
"is",
"not",
"None",
":",
"self",
".",
"final_ast_tokens",
".",
"ap... | Handle end of a list. | [
"Handle",
"end",
"of",
"a",
"list",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L47-L54 | train |
Nachtfeuer/pipeline | spline/tools/condition.py | TokensCompressor.__default | def __default(self, ast_token):
"""Handle tokens inside the list or outside the list."""
if self.list_level == 1:
if self.list_entry is None:
self.list_entry = ast_token
elif not isinstance(ast_token, type(self.list_entry)):
self.final_ast_tokens.a... | python | def __default(self, ast_token):
"""Handle tokens inside the list or outside the list."""
if self.list_level == 1:
if self.list_entry is None:
self.list_entry = ast_token
elif not isinstance(ast_token, type(self.list_entry)):
self.final_ast_tokens.a... | [
"def",
"__default",
"(",
"self",
",",
"ast_token",
")",
":",
"if",
"self",
".",
"list_level",
"==",
"1",
":",
"if",
"self",
".",
"list_entry",
"is",
"None",
":",
"self",
".",
"list_entry",
"=",
"ast_token",
"elif",
"not",
"isinstance",
"(",
"ast_token",
... | Handle tokens inside the list or outside the list. | [
"Handle",
"tokens",
"inside",
"the",
"list",
"or",
"outside",
"the",
"list",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L56-L64 | train |
Nachtfeuer/pipeline | spline/tools/condition.py | TokensCompressor.compress | def compress(self):
"""Main function of compression."""
for ast_token in self.ast_tokens:
if type(ast_token) in self.dispatcher: # pylint: disable=unidiomatic-typecheck
self.dispatcher[type(ast_token)](ast_token)
else:
self.dispatcher['default'](a... | python | def compress(self):
"""Main function of compression."""
for ast_token in self.ast_tokens:
if type(ast_token) in self.dispatcher: # pylint: disable=unidiomatic-typecheck
self.dispatcher[type(ast_token)](ast_token)
else:
self.dispatcher['default'](a... | [
"def",
"compress",
"(",
"self",
")",
":",
"for",
"ast_token",
"in",
"self",
".",
"ast_tokens",
":",
"if",
"type",
"(",
"ast_token",
")",
"in",
"self",
".",
"dispatcher",
":",
"self",
".",
"dispatcher",
"[",
"type",
"(",
"ast_token",
")",
"]",
"(",
"a... | Main function of compression. | [
"Main",
"function",
"of",
"compression",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L66-L72 | train |
Nachtfeuer/pipeline | spline/tools/condition.py | Condition.get_tokens | def get_tokens(condition):
"""
Get AST tokens for Python condition.
Returns:
list: list of AST tokens
"""
try:
ast_tokens = list(ast.walk(ast.parse(condition.strip())))
except SyntaxError as exception:
Logger.get_logger(__name__).error... | python | def get_tokens(condition):
"""
Get AST tokens for Python condition.
Returns:
list: list of AST tokens
"""
try:
ast_tokens = list(ast.walk(ast.parse(condition.strip())))
except SyntaxError as exception:
Logger.get_logger(__name__).error... | [
"def",
"get_tokens",
"(",
"condition",
")",
":",
"try",
":",
"ast_tokens",
"=",
"list",
"(",
"ast",
".",
"walk",
"(",
"ast",
".",
"parse",
"(",
"condition",
".",
"strip",
"(",
")",
")",
")",
")",
"except",
"SyntaxError",
"as",
"exception",
":",
"Logg... | Get AST tokens for Python condition.
Returns:
list: list of AST tokens | [
"Get",
"AST",
"tokens",
"for",
"Python",
"condition",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L129-L141 | train |
Nachtfeuer/pipeline | spline/tools/condition.py | Condition.match_tokens | def match_tokens(ast_tokens, ast_types):
"""
Verify that each token in order does match the expected types.
The list provided by `get_tokens` does have three more elements
at the beginning of the list which should be always the same
for a condition (Module and Expr). Those are a... | python | def match_tokens(ast_tokens, ast_types):
"""
Verify that each token in order does match the expected types.
The list provided by `get_tokens` does have three more elements
at the beginning of the list which should be always the same
for a condition (Module and Expr). Those are a... | [
"def",
"match_tokens",
"(",
"ast_tokens",
",",
"ast_types",
")",
":",
"ast_final_types",
"=",
"[",
"ast",
".",
"Module",
",",
"ast",
".",
"Expr",
"]",
"+",
"ast_types",
"return",
"all",
"(",
"isinstance",
"(",
"ast_token",
",",
"ast_type",
")",
"for",
"a... | Verify that each token in order does match the expected types.
The list provided by `get_tokens` does have three more elements
at the beginning of the list which should be always the same
for a condition (Module and Expr). Those are automatically
added first to the final list of expecte... | [
"Verify",
"that",
"each",
"token",
"in",
"order",
"does",
"match",
"the",
"expected",
"types",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L144-L167 | train |
Nachtfeuer/pipeline | spline/tools/condition.py | Condition.find_rule | def find_rule(condition):
"""
Find rule for given condition.
Args:
condition (str): Python condition as string.
Returns:
str, list, function: found rule name, list of AST tokens for condition
and verification function.
""... | python | def find_rule(condition):
"""
Find rule for given condition.
Args:
condition (str): Python condition as string.
Returns:
str, list, function: found rule name, list of AST tokens for condition
and verification function.
""... | [
"def",
"find_rule",
"(",
"condition",
")",
":",
"final_condition",
"=",
"re",
".",
"sub",
"(",
"'{{.*}}'",
",",
"'42'",
",",
"condition",
")",
"ast_tokens",
"=",
"Condition",
".",
"get_tokens",
"(",
"final_condition",
")",
"ast_compressed_tokens",
"=",
"Condit... | Find rule for given condition.
Args:
condition (str): Python condition as string.
Returns:
str, list, function: found rule name, list of AST tokens for condition
and verification function. | [
"Find",
"rule",
"for",
"given",
"condition",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L229-L253 | train |
Nachtfeuer/pipeline | spline/tools/condition.py | Condition.evaluate | def evaluate(condition):
"""
Evaluate simple condition.
>>> Condition.evaluate(' 2 == 2 ')
True
>>> Condition.evaluate(' not 2 == 2 ')
False
>>> Condition.evaluate(' not "abc" == "xyz" ')
True
>>> Condition.evaluate('2 in [2, 4, 6, 8... | python | def evaluate(condition):
"""
Evaluate simple condition.
>>> Condition.evaluate(' 2 == 2 ')
True
>>> Condition.evaluate(' not 2 == 2 ')
False
>>> Condition.evaluate(' not "abc" == "xyz" ')
True
>>> Condition.evaluate('2 in [2, 4, 6, 8... | [
"def",
"evaluate",
"(",
"condition",
")",
":",
"success",
"=",
"False",
"if",
"len",
"(",
"condition",
")",
">",
"0",
":",
"try",
":",
"rule_name",
",",
"ast_tokens",
",",
"evaluate_function",
"=",
"Condition",
".",
"find_rule",
"(",
"condition",
")",
"i... | Evaluate simple condition.
>>> Condition.evaluate(' 2 == 2 ')
True
>>> Condition.evaluate(' not 2 == 2 ')
False
>>> Condition.evaluate(' not "abc" == "xyz" ')
True
>>> Condition.evaluate('2 in [2, 4, 6, 8, 10]')
True
>>> Condition.ev... | [
"Evaluate",
"simple",
"condition",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L256-L293 | train |
acutesoftware/AIKIF | scripts/run.py | start_aikif | def start_aikif():
"""
starts the web interface and possibly other processes
"""
if sys.platform[0:3] == 'win':
os.system("start go_web_aikif.bat")
else:
os.system("../aikif/web_app/web_aikif.py")
import webbrowser
import time
time.sleep(1)
webbrowser... | python | def start_aikif():
"""
starts the web interface and possibly other processes
"""
if sys.platform[0:3] == 'win':
os.system("start go_web_aikif.bat")
else:
os.system("../aikif/web_app/web_aikif.py")
import webbrowser
import time
time.sleep(1)
webbrowser... | [
"def",
"start_aikif",
"(",
")",
":",
"if",
"sys",
".",
"platform",
"[",
"0",
":",
"3",
"]",
"==",
"'win'",
":",
"os",
".",
"system",
"(",
"\"start go_web_aikif.bat\"",
")",
"else",
":",
"os",
".",
"system",
"(",
"\"../aikif/web_app/web_aikif.py\"",
")",
... | starts the web interface and possibly other processes | [
"starts",
"the",
"web",
"interface",
"and",
"possibly",
"other",
"processes"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/run.py#L49-L60 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | get_creator_by_name | def get_creator_by_name(name):
"""
Get creator function by name.
Args:
name (str): name of the creator function.
Returns:
function: creater function.
"""
return {'docker(container)': Container.creator,
'shell': Bash.creator, 'docker(image)': Image.creator,
... | python | def get_creator_by_name(name):
"""
Get creator function by name.
Args:
name (str): name of the creator function.
Returns:
function: creater function.
"""
return {'docker(container)': Container.creator,
'shell': Bash.creator, 'docker(image)': Image.creator,
... | [
"def",
"get_creator_by_name",
"(",
"name",
")",
":",
"return",
"{",
"'docker(container)'",
":",
"Container",
".",
"creator",
",",
"'shell'",
":",
"Bash",
".",
"creator",
",",
"'docker(image)'",
":",
"Image",
".",
"creator",
",",
"'python'",
":",
"Script",
".... | Get creator function by name.
Args:
name (str): name of the creator function.
Returns:
function: creater function. | [
"Get",
"creator",
"function",
"by",
"name",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L36-L49 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | worker | def worker(data):
"""Running on shell via multiprocessing."""
creator = get_creator_by_name(data['creator'])
shell = creator(data['entry'],
ShellConfig(script=data['entry']['script'],
title=data['entry']['title'] if 'title' in data['entry'] else '',
... | python | def worker(data):
"""Running on shell via multiprocessing."""
creator = get_creator_by_name(data['creator'])
shell = creator(data['entry'],
ShellConfig(script=data['entry']['script'],
title=data['entry']['title'] if 'title' in data['entry'] else '',
... | [
"def",
"worker",
"(",
"data",
")",
":",
"creator",
"=",
"get_creator_by_name",
"(",
"data",
"[",
"'creator'",
"]",
")",
"shell",
"=",
"creator",
"(",
"data",
"[",
"'entry'",
"]",
",",
"ShellConfig",
"(",
"script",
"=",
"data",
"[",
"'entry'",
"]",
"[",... | Running on shell via multiprocessing. | [
"Running",
"on",
"shell",
"via",
"multiprocessing",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L52-L66 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.get_merged_env | def get_merged_env(self, include_os=False):
"""
Copying and merging environment variables.
Args:
include_os (bool): when true then include the environment variables (default: False)
Returns:
dict: environment variables as defined in the pipeline
... | python | def get_merged_env(self, include_os=False):
"""
Copying and merging environment variables.
Args:
include_os (bool): when true then include the environment variables (default: False)
Returns:
dict: environment variables as defined in the pipeline
... | [
"def",
"get_merged_env",
"(",
"self",
",",
"include_os",
"=",
"False",
")",
":",
"env",
"=",
"{",
"}",
"if",
"include_os",
":",
"env",
".",
"update",
"(",
"os",
".",
"environ",
".",
"copy",
"(",
")",
")",
"for",
"level",
"in",
"range",
"(",
"3",
... | Copying and merging environment variables.
Args:
include_os (bool): when true then include the environment variables (default: False)
Returns:
dict: environment variables as defined in the pipeline
(optional including system environment variables). | [
"Copying",
"and",
"merging",
"environment",
"variables",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L80-L96 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.prepare_shell_data | def prepare_shell_data(self, shells, key, entry):
"""Prepare one shell or docker task."""
if self.can_process_shell(entry):
if key in ['python']:
entry['type'] = key
if 'with' in entry and isinstance(entry['with'], str):
rendered_with = ast.litera... | python | def prepare_shell_data(self, shells, key, entry):
"""Prepare one shell or docker task."""
if self.can_process_shell(entry):
if key in ['python']:
entry['type'] = key
if 'with' in entry and isinstance(entry['with'], str):
rendered_with = ast.litera... | [
"def",
"prepare_shell_data",
"(",
"self",
",",
"shells",
",",
"key",
",",
"entry",
")",
":",
"if",
"self",
".",
"can_process_shell",
"(",
"entry",
")",
":",
"if",
"key",
"in",
"[",
"'python'",
"]",
":",
"entry",
"[",
"'type'",
"]",
"=",
"key",
"if",
... | Prepare one shell or docker task. | [
"Prepare",
"one",
"shell",
"or",
"docker",
"task",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L98-L127 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.process | def process(self, document):
"""Processing a group of tasks."""
self.logger.info("Processing group of tasks (parallel=%s)", self.get_parallel_mode())
self.pipeline.data.env_list[2] = {}
output, shells = [], []
result = Adapter({'success': True, 'output': []})
for task_en... | python | def process(self, document):
"""Processing a group of tasks."""
self.logger.info("Processing group of tasks (parallel=%s)", self.get_parallel_mode())
self.pipeline.data.env_list[2] = {}
output, shells = [], []
result = Adapter({'success': True, 'output': []})
for task_en... | [
"def",
"process",
"(",
"self",
",",
"document",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Processing group of tasks (parallel=%s)\"",
",",
"self",
".",
"get_parallel_mode",
"(",
")",
")",
"self",
".",
"pipeline",
".",
"data",
".",
"env_list",
"["... | Processing a group of tasks. | [
"Processing",
"a",
"group",
"of",
"tasks",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L135-L164 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.process_shells_parallel | def process_shells_parallel(self, shells):
"""Processing a list of shells parallel."""
output = []
success = True
with closing(multiprocessing.Pool(multiprocessing.cpu_count())) as pool:
for result in [Adapter(entry) for entry in pool.map(worker, [shell for shell in shells])]... | python | def process_shells_parallel(self, shells):
"""Processing a list of shells parallel."""
output = []
success = True
with closing(multiprocessing.Pool(multiprocessing.cpu_count())) as pool:
for result in [Adapter(entry) for entry in pool.map(worker, [shell for shell in shells])]... | [
"def",
"process_shells_parallel",
"(",
"self",
",",
"shells",
")",
":",
"output",
"=",
"[",
"]",
"success",
"=",
"True",
"with",
"closing",
"(",
"multiprocessing",
".",
"Pool",
"(",
"multiprocessing",
".",
"cpu_count",
"(",
")",
")",
")",
"as",
"pool",
"... | Processing a list of shells parallel. | [
"Processing",
"a",
"list",
"of",
"shells",
"parallel",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L166-L185 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.process_shells_ordered | def process_shells_ordered(self, shells):
"""Processing a list of shells one after the other."""
output = []
for shell in shells:
entry = shell['entry']
config = ShellConfig(script=entry['script'], title=entry['title'] if 'title' in entry else '',
... | python | def process_shells_ordered(self, shells):
"""Processing a list of shells one after the other."""
output = []
for shell in shells:
entry = shell['entry']
config = ShellConfig(script=entry['script'], title=entry['title'] if 'title' in entry else '',
... | [
"def",
"process_shells_ordered",
"(",
"self",
",",
"shells",
")",
":",
"output",
"=",
"[",
"]",
"for",
"shell",
"in",
"shells",
":",
"entry",
"=",
"shell",
"[",
"'entry'",
"]",
"config",
"=",
"ShellConfig",
"(",
"script",
"=",
"entry",
"[",
"'script'",
... | Processing a list of shells one after the other. | [
"Processing",
"a",
"list",
"of",
"shells",
"one",
"after",
"the",
"other",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L187-L202 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.process_shells | def process_shells(self, shells):
"""Processing a list of shells."""
result = {'success': True, 'output': []}
if self.parallel and len(shells) > 1:
result = self.process_shells_parallel(shells)
elif len(shells) > 0:
result = self.process_shells_ordered(shells)
... | python | def process_shells(self, shells):
"""Processing a list of shells."""
result = {'success': True, 'output': []}
if self.parallel and len(shells) > 1:
result = self.process_shells_parallel(shells)
elif len(shells) > 0:
result = self.process_shells_ordered(shells)
... | [
"def",
"process_shells",
"(",
"self",
",",
"shells",
")",
":",
"result",
"=",
"{",
"'success'",
":",
"True",
",",
"'output'",
":",
"[",
"]",
"}",
"if",
"self",
".",
"parallel",
"and",
"len",
"(",
"shells",
")",
">",
"1",
":",
"result",
"=",
"self",... | Processing a list of shells. | [
"Processing",
"a",
"list",
"of",
"shells",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L204-L211 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.process_shell | def process_shell(self, creator, entry, config):
"""Processing a shell entry."""
self.logger.info("Processing Bash code: start")
output = []
shell = creator(entry, config)
for line in shell.process():
output.append(line)
self.logger.info(" | %s", line)
... | python | def process_shell(self, creator, entry, config):
"""Processing a shell entry."""
self.logger.info("Processing Bash code: start")
output = []
shell = creator(entry, config)
for line in shell.process():
output.append(line)
self.logger.info(" | %s", line)
... | [
"def",
"process_shell",
"(",
"self",
",",
"creator",
",",
"entry",
",",
"config",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Processing Bash code: start\"",
")",
"output",
"=",
"[",
"]",
"shell",
"=",
"creator",
"(",
"entry",
",",
"config",
")... | Processing a shell entry. | [
"Processing",
"a",
"shell",
"entry",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L230-L249 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.run_cleanup | def run_cleanup(self, env, exit_code):
"""Run cleanup hook when configured."""
output = []
if self.pipeline.data.hooks and len(self.pipeline.data.hooks.cleanup) > 0:
env.update({'PIPELINE_RESULT': 'FAILURE'})
env.update({'PIPELINE_SHELL_EXIT_CODE': str(exit_code)})
... | python | def run_cleanup(self, env, exit_code):
"""Run cleanup hook when configured."""
output = []
if self.pipeline.data.hooks and len(self.pipeline.data.hooks.cleanup) > 0:
env.update({'PIPELINE_RESULT': 'FAILURE'})
env.update({'PIPELINE_SHELL_EXIT_CODE': str(exit_code)})
... | [
"def",
"run_cleanup",
"(",
"self",
",",
"env",
",",
"exit_code",
")",
":",
"output",
"=",
"[",
"]",
"if",
"self",
".",
"pipeline",
".",
"data",
".",
"hooks",
"and",
"len",
"(",
"self",
".",
"pipeline",
".",
"data",
".",
"hooks",
".",
"cleanup",
")"... | Run cleanup hook when configured. | [
"Run",
"cleanup",
"hook",
"when",
"configured",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L251-L267 | train |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.__handle_variable | def __handle_variable(self, shell_entry, output):
"""
Saving output for configured variable name.
Args:
shell_entry(dict): shell based configuration (shell, docker container or Python).
output: list of strings representing output of last shell
"""
if 'var... | python | def __handle_variable(self, shell_entry, output):
"""
Saving output for configured variable name.
Args:
shell_entry(dict): shell based configuration (shell, docker container or Python).
output: list of strings representing output of last shell
"""
if 'var... | [
"def",
"__handle_variable",
"(",
"self",
",",
"shell_entry",
",",
"output",
")",
":",
"if",
"'variable'",
"in",
"shell_entry",
":",
"variable_name",
"=",
"shell_entry",
"[",
"'variable'",
"]",
"self",
".",
"pipeline",
".",
"variables",
"[",
"variable_name",
"]... | Saving output for configured variable name.
Args:
shell_entry(dict): shell based configuration (shell, docker container or Python).
output: list of strings representing output of last shell | [
"Saving",
"output",
"for",
"configured",
"variable",
"name",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L269-L279 | train |
acutesoftware/AIKIF | scripts/examples/finance_example.py | main | def main():
"""
This is the main body of the process that does the work.
Summary:
- load the raw data
- read in rules list
- create log events for AIKIF according to rules [map]
- create new facts / reports based on rules [report]
OUTPUT =
AIKIF mapping : Date_of_... | python | def main():
"""
This is the main body of the process that does the work.
Summary:
- load the raw data
- read in rules list
- create log events for AIKIF according to rules [map]
- create new facts / reports based on rules [report]
OUTPUT =
AIKIF mapping : Date_of_... | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"'AIKIF example: Processing Finance data\\n'",
")",
"data",
"=",
"read_bank_statements",
"(",
"'your_statement.csv'",
")",
"print",
"(",
"data",
")",
"maps",
"=",
"load_column_maps",
"(",
")",
"rules",
"=",
"load_rules",... | This is the main body of the process that does the work.
Summary:
- load the raw data
- read in rules list
- create log events for AIKIF according to rules [map]
- create new facts / reports based on rules [report]
OUTPUT =
AIKIF mapping : Date_of_transaction => event
... | [
"This",
"is",
"the",
"main",
"body",
"of",
"the",
"process",
"that",
"does",
"the",
"work",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/finance_example.py#L25-L61 | train |
HackerEarth/he-sdk-python | hackerearth/parameters.py | BaseAPIParameters._clean_params | def _clean_params(self, params):
"""Removes parameters whose values are set to None.
"""
clean_params = {}
for key, value in params.iteritems():
if value is not None:
clean_params[key] = value
return clean_params | python | def _clean_params(self, params):
"""Removes parameters whose values are set to None.
"""
clean_params = {}
for key, value in params.iteritems():
if value is not None:
clean_params[key] = value
return clean_params | [
"def",
"_clean_params",
"(",
"self",
",",
"params",
")",
":",
"clean_params",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"params",
".",
"iteritems",
"(",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"clean_params",
"[",
"key",
"]",
"=",
... | Removes parameters whose values are set to None. | [
"Removes",
"parameters",
"whose",
"values",
"are",
"set",
"to",
"None",
"."
] | ca718afaf70a4239af1adf09ee248a076864b5fe | https://github.com/HackerEarth/he-sdk-python/blob/ca718afaf70a4239af1adf09ee248a076864b5fe/hackerearth/parameters.py#L48-L56 | train |
OpenHydrology/floodestimation | floodestimation/entities.py | Catchment.distance_to | def distance_to(self, other_catchment):
"""
Returns the distance between the centroids of two catchments in kilometers.
:param other_catchment: Catchment to calculate distance to
:type other_catchment: :class:`.Catchment`
:return: Distance between the catchments in km.
:... | python | def distance_to(self, other_catchment):
"""
Returns the distance between the centroids of two catchments in kilometers.
:param other_catchment: Catchment to calculate distance to
:type other_catchment: :class:`.Catchment`
:return: Distance between the catchments in km.
:... | [
"def",
"distance_to",
"(",
"self",
",",
"other_catchment",
")",
":",
"try",
":",
"if",
"self",
".",
"country",
"==",
"other_catchment",
".",
"country",
":",
"try",
":",
"return",
"0.001",
"*",
"hypot",
"(",
"self",
".",
"descriptors",
".",
"centroid_ngr",
... | Returns the distance between the centroids of two catchments in kilometers.
:param other_catchment: Catchment to calculate distance to
:type other_catchment: :class:`.Catchment`
:return: Distance between the catchments in km.
:rtype: float | [
"Returns",
"the",
"distance",
"between",
"the",
"centroids",
"of",
"two",
"catchments",
"in",
"kilometers",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/entities.py#L137-L158 | train |
OpenHydrology/floodestimation | floodestimation/entities.py | Descriptors.urbext | def urbext(self, year):
"""
Estimate the `urbext2000` parameter for a given year assuming a nation-wide urbanisation curve.
Methodology source: eqn 5.5, report FD1919/TR
:param year: Year to provide estimate for
:type year: float
:return: Urban extent parameter
... | python | def urbext(self, year):
"""
Estimate the `urbext2000` parameter for a given year assuming a nation-wide urbanisation curve.
Methodology source: eqn 5.5, report FD1919/TR
:param year: Year to provide estimate for
:type year: float
:return: Urban extent parameter
... | [
"def",
"urbext",
"(",
"self",
",",
"year",
")",
":",
"urban_expansion",
"=",
"0.7851",
"+",
"0.2124",
"*",
"atan",
"(",
"(",
"year",
"-",
"1967.5",
")",
"/",
"20.331792998",
")",
"try",
":",
"return",
"self",
".",
"catchment",
".",
"descriptors",
".",
... | Estimate the `urbext2000` parameter for a given year assuming a nation-wide urbanisation curve.
Methodology source: eqn 5.5, report FD1919/TR
:param year: Year to provide estimate for
:type year: float
:return: Urban extent parameter
:rtype: float | [
"Estimate",
"the",
"urbext2000",
"parameter",
"for",
"a",
"given",
"year",
"assuming",
"a",
"nation",
"-",
"wide",
"urbanisation",
"curve",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/entities.py#L273-L291 | train |
OpenHydrology/floodestimation | floodestimation/entities.py | PotDataset.continuous_periods | def continuous_periods(self):
"""
Return a list of continuous data periods by removing the data gaps from the overall record.
"""
result = []
# For the first period
start_date = self.start_date
for gap in self.pot_data_gaps:
end_date = gap.start_date ... | python | def continuous_periods(self):
"""
Return a list of continuous data periods by removing the data gaps from the overall record.
"""
result = []
# For the first period
start_date = self.start_date
for gap in self.pot_data_gaps:
end_date = gap.start_date ... | [
"def",
"continuous_periods",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"start_date",
"=",
"self",
".",
"start_date",
"for",
"gap",
"in",
"self",
".",
"pot_data_gaps",
":",
"end_date",
"=",
"gap",
".",
"start_date",
"-",
"timedelta",
"(",
"days",
"=... | Return a list of continuous data periods by removing the data gaps from the overall record. | [
"Return",
"a",
"list",
"of",
"continuous",
"data",
"periods",
"by",
"removing",
"the",
"data",
"gaps",
"from",
"the",
"overall",
"record",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/entities.py#L401-L418 | train |
Nachtfeuer/pipeline | spline/tools/memfiles.py | InMemoryFiles.add_path | def add_path(self, path, path_filter=None):
"""
Adding all files from given path to the object.
Args:
path (str): valid, existing directory
"""
for root, _, files in os.walk(path):
for filename in files:
full_path_and_filename = os.path.jo... | python | def add_path(self, path, path_filter=None):
"""
Adding all files from given path to the object.
Args:
path (str): valid, existing directory
"""
for root, _, files in os.walk(path):
for filename in files:
full_path_and_filename = os.path.jo... | [
"def",
"add_path",
"(",
"self",
",",
"path",
",",
"path_filter",
"=",
"None",
")",
":",
"for",
"root",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"for",
"filename",
"in",
"files",
":",
"full_path_and_filename",
"=",
"os",... | Adding all files from given path to the object.
Args:
path (str): valid, existing directory | [
"Adding",
"all",
"files",
"from",
"given",
"path",
"to",
"the",
"object",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/memfiles.py#L42-L55 | train |
Nachtfeuer/pipeline | spline/tools/memfiles.py | InMemoryFiles.from_json | def from_json(data):
"""
Convert JSON into a in memory file storage.
Args:
data (str): valid JSON with path and filenames and
the base64 encoding of the file content.
Returns:
InMemoryFiles: in memory file storage
"""
memf... | python | def from_json(data):
"""
Convert JSON into a in memory file storage.
Args:
data (str): valid JSON with path and filenames and
the base64 encoding of the file content.
Returns:
InMemoryFiles: in memory file storage
"""
memf... | [
"def",
"from_json",
"(",
"data",
")",
":",
"memfiles",
"=",
"InMemoryFiles",
"(",
")",
"memfiles",
".",
"files",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"return",
"memfiles"
] | Convert JSON into a in memory file storage.
Args:
data (str): valid JSON with path and filenames and
the base64 encoding of the file content.
Returns:
InMemoryFiles: in memory file storage | [
"Convert",
"JSON",
"into",
"a",
"in",
"memory",
"file",
"storage",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/memfiles.py#L84-L97 | train |
acutesoftware/AIKIF | aikif/toolbox/file_tools.py | delete_file | def delete_file(f, ignore_errors=False):
"""
delete a single file
"""
try:
os.remove(f)
except Exception as ex:
if ignore_errors:
return
print('ERROR deleting file ' + str(ex)) | python | def delete_file(f, ignore_errors=False):
"""
delete a single file
"""
try:
os.remove(f)
except Exception as ex:
if ignore_errors:
return
print('ERROR deleting file ' + str(ex)) | [
"def",
"delete_file",
"(",
"f",
",",
"ignore_errors",
"=",
"False",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"f",
")",
"except",
"Exception",
"as",
"ex",
":",
"if",
"ignore_errors",
":",
"return",
"print",
"(",
"'ERROR deleting file '",
"+",
"str"... | delete a single file | [
"delete",
"a",
"single",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/file_tools.py#L36-L45 | train |
acutesoftware/AIKIF | aikif/toolbox/file_tools.py | delete_files_in_folder | def delete_files_in_folder(fldr):
"""
delete all files in folder 'fldr'
"""
fl = glob.glob(fldr + os.sep + '*.*')
for f in fl:
delete_file(f, True) | python | def delete_files_in_folder(fldr):
"""
delete all files in folder 'fldr'
"""
fl = glob.glob(fldr + os.sep + '*.*')
for f in fl:
delete_file(f, True) | [
"def",
"delete_files_in_folder",
"(",
"fldr",
")",
":",
"fl",
"=",
"glob",
".",
"glob",
"(",
"fldr",
"+",
"os",
".",
"sep",
"+",
"'*.*'",
")",
"for",
"f",
"in",
"fl",
":",
"delete_file",
"(",
"f",
",",
"True",
")"
] | delete all files in folder 'fldr' | [
"delete",
"all",
"files",
"in",
"folder",
"fldr"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/file_tools.py#L47-L53 | train |
acutesoftware/AIKIF | aikif/toolbox/file_tools.py | copy_file | def copy_file(src, dest):
"""
copy single file
"""
try:
shutil.copy2(src , dest)
except Exception as ex:
print('ERROR copying file' + str(ex)) | python | def copy_file(src, dest):
"""
copy single file
"""
try:
shutil.copy2(src , dest)
except Exception as ex:
print('ERROR copying file' + str(ex)) | [
"def",
"copy_file",
"(",
"src",
",",
"dest",
")",
":",
"try",
":",
"shutil",
".",
"copy2",
"(",
"src",
",",
"dest",
")",
"except",
"Exception",
"as",
"ex",
":",
"print",
"(",
"'ERROR copying file'",
"+",
"str",
"(",
"ex",
")",
")"
] | copy single file | [
"copy",
"single",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/file_tools.py#L55-L62 | train |
acutesoftware/AIKIF | aikif/toolbox/file_tools.py | copy_files_to_folder | def copy_files_to_folder(src, dest, xtn='*.txt'):
"""
copies all the files from src to dest folder
"""
try:
all_files = glob.glob(os.path.join(src,xtn))
for f in all_files:
copy_file(f, dest)
except Exception as ex:
print('ERROR copy_files_to_folder - ' + str(ex)) | python | def copy_files_to_folder(src, dest, xtn='*.txt'):
"""
copies all the files from src to dest folder
"""
try:
all_files = glob.glob(os.path.join(src,xtn))
for f in all_files:
copy_file(f, dest)
except Exception as ex:
print('ERROR copy_files_to_folder - ' + str(ex)) | [
"def",
"copy_files_to_folder",
"(",
"src",
",",
"dest",
",",
"xtn",
"=",
"'*.txt'",
")",
":",
"try",
":",
"all_files",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"src",
",",
"xtn",
")",
")",
"for",
"f",
"in",
"all_files",
... | copies all the files from src to dest folder | [
"copies",
"all",
"the",
"files",
"from",
"src",
"to",
"dest",
"folder"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/file_tools.py#L68-L78 | train |
acutesoftware/AIKIF | scripts/install_data.py | main | def main():
"""
script to setup folder structures for AIKIF
and prepare data tables.
"""
print('\n\n /------- AIKIF Installation --------\\')
print(' | s. show current setup |')
print(' | f. setup folder structures |')
print(' | c. create sample data |')
... | python | def main():
"""
script to setup folder structures for AIKIF
and prepare data tables.
"""
print('\n\n /------- AIKIF Installation --------\\')
print(' | s. show current setup |')
print(' | f. setup folder structures |')
print(' | c. create sample data |')
... | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"'\\n\\n /------- AIKIF Installation --------\\\\'",
")",
"print",
"(",
"' | s. show current setup |'",
")",
"print",
"(",
"' | f. setup folder structures |'",
")",
"print",
"(",
"' | c. create sample data ... | script to setup folder structures for AIKIF
and prepare data tables. | [
"script",
"to",
"setup",
"folder",
"structures",
"for",
"AIKIF",
"and",
"prepare",
"data",
"tables",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/install_data.py#L8-L31 | train |
acutesoftware/AIKIF | aikif/ontology/cyc_extract.py | load_graph_from_rdf | def load_graph_from_rdf(fname):
""" reads an RDF file into a graph """
print("reading RDF from " + fname + "....")
store = Graph()
store.parse(fname, format="n3")
print("Loaded " + str(len(store)) + " tuples")
return store | python | def load_graph_from_rdf(fname):
""" reads an RDF file into a graph """
print("reading RDF from " + fname + "....")
store = Graph()
store.parse(fname, format="n3")
print("Loaded " + str(len(store)) + " tuples")
return store | [
"def",
"load_graph_from_rdf",
"(",
"fname",
")",
":",
"print",
"(",
"\"reading RDF from \"",
"+",
"fname",
"+",
"\"....\"",
")",
"store",
"=",
"Graph",
"(",
")",
"store",
".",
"parse",
"(",
"fname",
",",
"format",
"=",
"\"n3\"",
")",
"print",
"(",
"\"Loa... | reads an RDF file into a graph | [
"reads",
"an",
"RDF",
"file",
"into",
"a",
"graph"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/cyc_extract.py#L20-L26 | train |
acutesoftware/AIKIF | aikif/ontology/cyc_extract.py | show_graph_summary | def show_graph_summary(g):
""" display sample data from a graph """
sample_data = []
print("list(g[RDFS.Class]) = " + str(len(list(g[RDFS.Class]))))
# Get Subject Lists
num_subj = 0
for subj in g.subjects(RDF.type):
num_subj += 1
if num_subj < 5:
sample_data.append("s... | python | def show_graph_summary(g):
""" display sample data from a graph """
sample_data = []
print("list(g[RDFS.Class]) = " + str(len(list(g[RDFS.Class]))))
# Get Subject Lists
num_subj = 0
for subj in g.subjects(RDF.type):
num_subj += 1
if num_subj < 5:
sample_data.append("s... | [
"def",
"show_graph_summary",
"(",
"g",
")",
":",
"sample_data",
"=",
"[",
"]",
"print",
"(",
"\"list(g[RDFS.Class]) = \"",
"+",
"str",
"(",
"len",
"(",
"list",
"(",
"g",
"[",
"RDFS",
".",
"Class",
"]",
")",
")",
")",
")",
"num_subj",
"=",
"0",
"for",... | display sample data from a graph | [
"display",
"sample",
"data",
"from",
"a",
"graph"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/cyc_extract.py#L28-L54 | train |
acutesoftware/AIKIF | aikif/ontology/cyc_extract.py | export | def export(g, csv_fname):
""" export a graph to CSV for simpler viewing """
with open(csv_fname, "w") as f:
num_tuples = 0
f.write('"num","subject","predicate","object"\n')
for subj, pred, obj in g:
num_tuples += 1
f.write('"' + str(num_tuples) + '",')
... | python | def export(g, csv_fname):
""" export a graph to CSV for simpler viewing """
with open(csv_fname, "w") as f:
num_tuples = 0
f.write('"num","subject","predicate","object"\n')
for subj, pred, obj in g:
num_tuples += 1
f.write('"' + str(num_tuples) + '",')
... | [
"def",
"export",
"(",
"g",
",",
"csv_fname",
")",
":",
"with",
"open",
"(",
"csv_fname",
",",
"\"w\"",
")",
"as",
"f",
":",
"num_tuples",
"=",
"0",
"f",
".",
"write",
"(",
"'\"num\",\"subject\",\"predicate\",\"object\"\\n'",
")",
"for",
"subj",
",",
"pred"... | export a graph to CSV for simpler viewing | [
"export",
"a",
"graph",
"to",
"CSV",
"for",
"simpler",
"viewing"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/cyc_extract.py#L56-L67 | train |
acutesoftware/AIKIF | aikif/ontology/cyc_extract.py | get_string_from_rdf | def get_string_from_rdf(src):
""" extracts the real content from an RDF info object """
res = src.split("/") #[:-1]
return "".join([l.replace('"', '""') for l in res[len(res) - 1]]) | python | def get_string_from_rdf(src):
""" extracts the real content from an RDF info object """
res = src.split("/") #[:-1]
return "".join([l.replace('"', '""') for l in res[len(res) - 1]]) | [
"def",
"get_string_from_rdf",
"(",
"src",
")",
":",
"res",
"=",
"src",
".",
"split",
"(",
"\"/\"",
")",
"return",
"\"\"",
".",
"join",
"(",
"[",
"l",
".",
"replace",
"(",
"'\"'",
",",
"'\"\"'",
")",
"for",
"l",
"in",
"res",
"[",
"len",
"(",
"res"... | extracts the real content from an RDF info object | [
"extracts",
"the",
"real",
"content",
"from",
"an",
"RDF",
"info",
"object"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/cyc_extract.py#L69-L72 | train |
acutesoftware/AIKIF | aikif/ontology/cyc_extract.py | create_sample_file | def create_sample_file(ip, op, num_lines):
""" make a short version of an RDF file """
with open(ip, "rb") as f:
with open(op, "wb") as fout:
for _ in range(num_lines):
fout.write(f.readline() ) | python | def create_sample_file(ip, op, num_lines):
""" make a short version of an RDF file """
with open(ip, "rb") as f:
with open(op, "wb") as fout:
for _ in range(num_lines):
fout.write(f.readline() ) | [
"def",
"create_sample_file",
"(",
"ip",
",",
"op",
",",
"num_lines",
")",
":",
"with",
"open",
"(",
"ip",
",",
"\"rb\"",
")",
"as",
"f",
":",
"with",
"open",
"(",
"op",
",",
"\"wb\"",
")",
"as",
"fout",
":",
"for",
"_",
"in",
"range",
"(",
"num_l... | make a short version of an RDF file | [
"make",
"a",
"short",
"version",
"of",
"an",
"RDF",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/cyc_extract.py#L75-L80 | train |
Nachtfeuer/pipeline | spline/tools/query.py | Select.flatten | def flatten(*sequence):
"""Flatten nested sequences into one."""
result = []
for entry in sequence:
if isinstance(entry, list):
result += Select.flatten(*entry)
elif isinstance(entry, tuple):
result += Select.flatten(*entry)
els... | python | def flatten(*sequence):
"""Flatten nested sequences into one."""
result = []
for entry in sequence:
if isinstance(entry, list):
result += Select.flatten(*entry)
elif isinstance(entry, tuple):
result += Select.flatten(*entry)
els... | [
"def",
"flatten",
"(",
"*",
"sequence",
")",
":",
"result",
"=",
"[",
"]",
"for",
"entry",
"in",
"sequence",
":",
"if",
"isinstance",
"(",
"entry",
",",
"list",
")",
":",
"result",
"+=",
"Select",
".",
"flatten",
"(",
"*",
"entry",
")",
"elif",
"is... | Flatten nested sequences into one. | [
"Flatten",
"nested",
"sequences",
"into",
"one",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/query.py#L42-L52 | train |
Nachtfeuer/pipeline | spline/tools/query.py | Select.build | def build(self):
"""Do the query."""
result = []
for entry in self.sequence:
ignore = False
for filter_function in self.filter_functions:
if not filter_function(entry):
ignore = True
break
if not ignore:
... | python | def build(self):
"""Do the query."""
result = []
for entry in self.sequence:
ignore = False
for filter_function in self.filter_functions:
if not filter_function(entry):
ignore = True
break
if not ignore:
... | [
"def",
"build",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"entry",
"in",
"self",
".",
"sequence",
":",
"ignore",
"=",
"False",
"for",
"filter_function",
"in",
"self",
".",
"filter_functions",
":",
"if",
"not",
"filter_function",
"(",
"entry"... | Do the query. | [
"Do",
"the",
"query",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/query.py#L64-L78 | train |
acutesoftware/AIKIF | aikif/toolbox/zip_tools.py | extract_all | def extract_all(zipfile, dest_folder):
"""
reads the zip file, determines compression
and unzips recursively until source files
are extracted
"""
z = ZipFile(zipfile)
print(z)
z.extract(dest_folder) | python | def extract_all(zipfile, dest_folder):
"""
reads the zip file, determines compression
and unzips recursively until source files
are extracted
"""
z = ZipFile(zipfile)
print(z)
z.extract(dest_folder) | [
"def",
"extract_all",
"(",
"zipfile",
",",
"dest_folder",
")",
":",
"z",
"=",
"ZipFile",
"(",
"zipfile",
")",
"print",
"(",
"z",
")",
"z",
".",
"extract",
"(",
"dest_folder",
")"
] | reads the zip file, determines compression
and unzips recursively until source files
are extracted | [
"reads",
"the",
"zip",
"file",
"determines",
"compression",
"and",
"unzips",
"recursively",
"until",
"source",
"files",
"are",
"extracted"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/zip_tools.py#L11-L19 | train |
acutesoftware/AIKIF | aikif/toolbox/zip_tools.py | create_zip_from_file | def create_zip_from_file(zip_file, fname):
"""
add a file to the archive
"""
with zipfile.ZipFile(zip_file, 'w') as myzip:
myzip.write(fname) | python | def create_zip_from_file(zip_file, fname):
"""
add a file to the archive
"""
with zipfile.ZipFile(zip_file, 'w') as myzip:
myzip.write(fname) | [
"def",
"create_zip_from_file",
"(",
"zip_file",
",",
"fname",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"zip_file",
",",
"'w'",
")",
"as",
"myzip",
":",
"myzip",
".",
"write",
"(",
"fname",
")"
] | add a file to the archive | [
"add",
"a",
"file",
"to",
"the",
"archive"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/zip_tools.py#L21-L26 | train |
acutesoftware/AIKIF | aikif/toolbox/zip_tools.py | create_zip_from_folder | def create_zip_from_folder(zip_file, fldr, mode="r"):
"""
add all the files from the folder fldr
to the archive
"""
#print('zip from folder - adding folder : ', fldr)
zipf = zipfile.ZipFile(zip_file, 'w')
for root, dirs, files in os.walk(fldr):
for file in files:
fullname... | python | def create_zip_from_folder(zip_file, fldr, mode="r"):
"""
add all the files from the folder fldr
to the archive
"""
#print('zip from folder - adding folder : ', fldr)
zipf = zipfile.ZipFile(zip_file, 'w')
for root, dirs, files in os.walk(fldr):
for file in files:
fullname... | [
"def",
"create_zip_from_folder",
"(",
"zip_file",
",",
"fldr",
",",
"mode",
"=",
"\"r\"",
")",
":",
"zipf",
"=",
"zipfile",
".",
"ZipFile",
"(",
"zip_file",
",",
"'w'",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"fld... | add all the files from the folder fldr
to the archive | [
"add",
"all",
"the",
"files",
"from",
"the",
"folder",
"fldr",
"to",
"the",
"archive"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/zip_tools.py#L38-L52 | train |
nocarryr/python-dispatch | pydispatch/aioutils.py | AioWeakMethodContainer.add_method | def add_method(self, loop, callback):
"""Add a coroutine function
Args:
loop: The :class:`event loop <asyncio.BaseEventLoop>` instance
on which to schedule callbacks
callback: The :term:`coroutine function` to add
"""
f, obj = get_method_vars(call... | python | def add_method(self, loop, callback):
"""Add a coroutine function
Args:
loop: The :class:`event loop <asyncio.BaseEventLoop>` instance
on which to schedule callbacks
callback: The :term:`coroutine function` to add
"""
f, obj = get_method_vars(call... | [
"def",
"add_method",
"(",
"self",
",",
"loop",
",",
"callback",
")",
":",
"f",
",",
"obj",
"=",
"get_method_vars",
"(",
"callback",
")",
"wrkey",
"=",
"(",
"f",
",",
"id",
"(",
"obj",
")",
")",
"self",
"[",
"wrkey",
"]",
"=",
"obj",
"self",
".",
... | Add a coroutine function
Args:
loop: The :class:`event loop <asyncio.BaseEventLoop>` instance
on which to schedule callbacks
callback: The :term:`coroutine function` to add | [
"Add",
"a",
"coroutine",
"function"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/aioutils.py#L229-L240 | train |
nocarryr/python-dispatch | pydispatch/aioutils.py | AioWeakMethodContainer.iter_methods | def iter_methods(self):
"""Iterate over stored coroutine functions
Yields:
Stored :term:`coroutine function` objects
.. seealso:: :meth:`pydispatch.utils.WeakMethodContainer.iter_instances`
"""
for wrkey, obj in self.iter_instances():
f, obj_id = wrkey
... | python | def iter_methods(self):
"""Iterate over stored coroutine functions
Yields:
Stored :term:`coroutine function` objects
.. seealso:: :meth:`pydispatch.utils.WeakMethodContainer.iter_instances`
"""
for wrkey, obj in self.iter_instances():
f, obj_id = wrkey
... | [
"def",
"iter_methods",
"(",
"self",
")",
":",
"for",
"wrkey",
",",
"obj",
"in",
"self",
".",
"iter_instances",
"(",
")",
":",
"f",
",",
"obj_id",
"=",
"wrkey",
"loop",
"=",
"self",
".",
"event_loop_map",
"[",
"wrkey",
"]",
"m",
"=",
"getattr",
"(",
... | Iterate over stored coroutine functions
Yields:
Stored :term:`coroutine function` objects
.. seealso:: :meth:`pydispatch.utils.WeakMethodContainer.iter_instances` | [
"Iterate",
"over",
"stored",
"coroutine",
"functions"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/aioutils.py#L248-L260 | train |
nocarryr/python-dispatch | pydispatch/aioutils.py | AioWeakMethodContainer.submit_coroutine | def submit_coroutine(self, coro, loop):
"""Schedule and await a coroutine on the specified loop
The coroutine is wrapped and scheduled using
:func:`asyncio.run_coroutine_threadsafe`. While the coroutine is
"awaited", the result is not available as method returns immediately.
Ar... | python | def submit_coroutine(self, coro, loop):
"""Schedule and await a coroutine on the specified loop
The coroutine is wrapped and scheduled using
:func:`asyncio.run_coroutine_threadsafe`. While the coroutine is
"awaited", the result is not available as method returns immediately.
Ar... | [
"def",
"submit_coroutine",
"(",
"self",
",",
"coro",
",",
"loop",
")",
":",
"async",
"def",
"_do_call",
"(",
"_coro",
")",
":",
"with",
"_IterationGuard",
"(",
"self",
")",
":",
"await",
"_coro",
"asyncio",
".",
"run_coroutine_threadsafe",
"(",
"_do_call",
... | Schedule and await a coroutine on the specified loop
The coroutine is wrapped and scheduled using
:func:`asyncio.run_coroutine_threadsafe`. While the coroutine is
"awaited", the result is not available as method returns immediately.
Args:
coro: The :term:`coroutine` to sche... | [
"Schedule",
"and",
"await",
"a",
"coroutine",
"on",
"the",
"specified",
"loop"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/aioutils.py#L264-L283 | train |
acutesoftware/AIKIF | aikif/lib/cls_file.py | File.launch | def launch(self):
""" launch a file - used for starting html pages """
#os.system(self.fullname) # gives permission denied seeing it needs to be chmod +x
import subprocess
try:
retcode = subprocess.call(self.fullname, shell=True)
if retcode < 0:
pr... | python | def launch(self):
""" launch a file - used for starting html pages """
#os.system(self.fullname) # gives permission denied seeing it needs to be chmod +x
import subprocess
try:
retcode = subprocess.call(self.fullname, shell=True)
if retcode < 0:
pr... | [
"def",
"launch",
"(",
"self",
")",
":",
"import",
"subprocess",
"try",
":",
"retcode",
"=",
"subprocess",
".",
"call",
"(",
"self",
".",
"fullname",
",",
"shell",
"=",
"True",
")",
"if",
"retcode",
"<",
"0",
":",
"print",
"(",
"\"Child was terminated by ... | launch a file - used for starting html pages | [
"launch",
"a",
"file",
"-",
"used",
"for",
"starting",
"html",
"pages"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_file.py#L57-L71 | train |
acutesoftware/AIKIF | aikif/lib/cls_file.py | File.delete | def delete(self):
""" delete a file, don't really care if it doesn't exist """
if self.fullname != "":
try:
os.remove(self.fullname)
except IOError:
print("Cant delete ",self.fullname) | python | def delete(self):
""" delete a file, don't really care if it doesn't exist """
if self.fullname != "":
try:
os.remove(self.fullname)
except IOError:
print("Cant delete ",self.fullname) | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"fullname",
"!=",
"\"\"",
":",
"try",
":",
"os",
".",
"remove",
"(",
"self",
".",
"fullname",
")",
"except",
"IOError",
":",
"print",
"(",
"\"Cant delete \"",
",",
"self",
".",
"fullname",
")... | delete a file, don't really care if it doesn't exist | [
"delete",
"a",
"file",
"don",
"t",
"really",
"care",
"if",
"it",
"doesn",
"t",
"exist"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_file.py#L76-L82 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.