repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | split by multiple delimiters
|
acutesoftware/AIKIF | aikif/index.py | consolidate | def consolidate(ipFile, opFile):
"""
make a single index file with 1 record per word which shows the word, file and linenums
# storms, knowledge.csv - 3
# string, rawData.csv - 1
# structure, EVENT_SYSTEM-PC-FILE.CSV - 18, OBJECT_SYSTEM-PC-FILE.CSV - 4, sample-filelist-for-AIKIF.csv - 18... | python | def consolidate(ipFile, opFile):
"""
make a single index file with 1 record per word which shows the word, file and linenums
# storms, knowledge.csv - 3
# string, rawData.csv - 1
# structure, EVENT_SYSTEM-PC-FILE.CSV - 18, OBJECT_SYSTEM-PC-FILE.CSV - 4, sample-filelist-for-AIKIF.csv - 18... | [
"def",
"consolidate",
"(",
"ipFile",
",",
"opFile",
")",
":",
"curFile",
"=",
"''",
"curWord",
"=",
"''",
"curLineNums",
"=",
"''",
"indexedWords",
"=",
"{",
"}",
"with",
"open",
"(",
"ipFile",
",",
"\"r\"",
",",
"encoding",
"=",
"'utf-8'",
",",
"error... | make a single index file with 1 record per word which shows the word, file and linenums
# storms, knowledge.csv - 3
# string, rawData.csv - 1
# structure, EVENT_SYSTEM-PC-FILE.CSV - 18, OBJECT_SYSTEM-PC-FILE.CSV - 4, sample-filelist-for-AIKIF.csv - 18 18
# subgoal, goals.csv - 3 4 12 13 ... | [
"make",
"a",
"single",
"index",
"file",
"with",
"1",
"record",
"per",
"word",
"which",
"shows",
"the",
"word",
"file",
"and",
"linenums",
"#",
"storms",
"knowledge",
".",
"csv",
"-",
"3",
"#",
"string",
"rawData",
".",
"csv",
"-",
"1",
"#",
"structure"... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L194-L228 | train | consolidate the file with one index file per word which shows the word file and line number of the line. |
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 | Preparing and creating script. |
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 | converts and unknown type to string for display purposes. |
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 | Adds a watch point to the list of watch points that can be used in aggregation and extraction of the log session. |
acutesoftware/AIKIF | aikif/cls_log.py | Log.get_session_id | def get_session_id(self):
"""
get a unique id (shortish string) to allow simple aggregation
of log records from multiple sources. This id is used for the
life of the running program to allow extraction from all logs.
WARING - this can give duplicate sessions when 2 apps hit it
... | python | def get_session_id(self):
"""
get a unique id (shortish string) to allow simple aggregation
of log records from multiple sources. This id is used for the
life of the running program to allow extraction from all logs.
WARING - this can give duplicate sessions when 2 apps hit it
... | [
"def",
"get_session_id",
"(",
"self",
")",
":",
"max_session",
"=",
"'0'",
"try",
":",
"with",
"open",
"(",
"self",
".",
"log_folder",
"+",
"os",
".",
"sep",
"+",
"'_sessions.txt'",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"_",
"in",
"f",
":",
"txt"... | get a unique id (shortish string) to allow simple aggregation
of log records from multiple sources. This id is used for the
life of the running program to allow extraction from all logs.
WARING - this can give duplicate sessions when 2 apps hit it
at the same time. | [
"get",
"a",
"unique",
"id",
"(",
"shortish",
"string",
")",
"to",
"allow",
"simple",
"aggregation",
"of",
"log",
"records",
"from",
"multiple",
"sources",
".",
"This",
"id",
"is",
"used",
"for",
"the",
"life",
"of",
"the",
"running",
"program",
"to",
"al... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L64-L85 | train | get a unique id for the log record |
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",
"# a 2014 PC does about 100k calcs in a second (guess b... | 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 | estimate the complexity of the object based on product of parameters
|
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 | converts seconds to a string in terms of
seconds -> years to show complexity of algorithm
|
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 | Logs an entry to fname along with standard date and user details |
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 | record source file |
acutesoftware/AIKIF | aikif/cls_log.py | Log.record_process | def record_process(self, process, prg=''):
"""
log a process or program - log a physical program (.py, .bat, .exe)
"""
self._log(self.logFileProcess, force_to_string(process), prg) | python | def record_process(self, process, prg=''):
"""
log a process or program - log a physical program (.py, .bat, .exe)
"""
self._log(self.logFileProcess, force_to_string(process), prg) | [
"def",
"record_process",
"(",
"self",
",",
"process",
",",
"prg",
"=",
"''",
")",
":",
"self",
".",
"_log",
"(",
"self",
".",
"logFileProcess",
",",
"force_to_string",
"(",
"process",
")",
",",
"prg",
")"
] | log a process or program - log a physical program (.py, .bat, .exe) | [
"log",
"a",
"process",
"or",
"program",
"-",
"log",
"a",
"physical",
"program",
"(",
".",
"py",
".",
"bat",
".",
"exe",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L142-L146 | train | record a process or program |
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 | record the command passed |
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 | record the output of the command |
acutesoftware/AIKIF | aikif/cls_log.py | LogSummary.filter_by_program | def filter_by_program(self, prg, opFile):
"""
parse the log files and extract entries from all
logfiles to one file per program (program is the
2nd to last entry each logfile)
"""
log_1 = open(self.process_file, 'r')
log_2 = open(self.command_file, 'r')
... | python | def filter_by_program(self, prg, opFile):
"""
parse the log files and extract entries from all
logfiles to one file per program (program is the
2nd to last entry each logfile)
"""
log_1 = open(self.process_file, 'r')
log_2 = open(self.command_file, 'r')
... | [
"def",
"filter_by_program",
"(",
"self",
",",
"prg",
",",
"opFile",
")",
":",
"log_1",
"=",
"open",
"(",
"self",
".",
"process_file",
",",
"'r'",
")",
"log_2",
"=",
"open",
"(",
"self",
".",
"command_file",
",",
"'r'",
")",
"log_3",
"=",
"open",
"(",... | parse the log files and extract entries from all
logfiles to one file per program (program is the
2nd to last entry each logfile) | [
"parse",
"the",
"log",
"files",
"and",
"extract",
"entries",
"from",
"all",
"logfiles",
"to",
"one",
"file",
"per",
"program",
"(",
"program",
"is",
"the",
"2nd",
"to",
"last",
"entry",
"each",
"logfile",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_log.py#L186-L214 | train | Filter the log files by program. |
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 | read a logfile and return entries for a program
|
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 | Takes the logfiles and produces an event summary matrix for each log entry. |
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 | reads a logfile and returns a dictionary by date and count the log entries |
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 | provides a mapping from the CSV file to the aikif data structures. |
cox-labs/perseuspy | perseuspy/dependent_peptides.py | read_dependent_peptides | def read_dependent_peptides(filename):
""" read the dependent peptides table and extract localiztion information
:param filename: path to the 'allPeptides.txt' table.
:returns dep, localization: the dependent peptide table, localization information.
"""
df = (pd.read_perseus(filename, usecols=_cols)... | python | def read_dependent_peptides(filename):
""" read the dependent peptides table and extract localiztion information
:param filename: path to the 'allPeptides.txt' table.
:returns dep, localization: the dependent peptide table, localization information.
"""
df = (pd.read_perseus(filename, usecols=_cols)... | [
"def",
"read_dependent_peptides",
"(",
"filename",
")",
":",
"df",
"=",
"(",
"pd",
".",
"read_perseus",
"(",
"filename",
",",
"usecols",
"=",
"_cols",
")",
".",
"dropna",
"(",
"subset",
"=",
"[",
"'DP Ratio mod/base'",
"]",
")",
")",
"df",
"[",
"'DP Rati... | read the dependent peptides table and extract localiztion information
:param filename: path to the 'allPeptides.txt' table.
:returns dep, localization: the dependent peptide table, localization information. | [
"read",
"the",
"dependent",
"peptides",
"table",
"and",
"extract",
"localiztion",
"information",
":",
"param",
"filename",
":",
"path",
"to",
"the",
"allPeptides",
".",
"txt",
"table",
".",
":",
"returns",
"dep",
"localization",
":",
"the",
"dependent",
"pepti... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/dependent_peptides.py#L16-L27 | train | read the dependent peptides table and extract localiztion information |
cox-labs/perseuspy | perseuspy/dependent_peptides.py | _set_column_names | def _set_column_names(dep, exp):
""" rename the columns in the dependent peptides table from
the raw file to the corresponding {experiment}_{fraction}.
:param dep: dependent peptides table.
:param exp: experimental design table.
"""
colnames = exp['Experiment'].astype(str) + '_' + exp['Fraction'... | python | def _set_column_names(dep, exp):
""" rename the columns in the dependent peptides table from
the raw file to the corresponding {experiment}_{fraction}.
:param dep: dependent peptides table.
:param exp: experimental design table.
"""
colnames = exp['Experiment'].astype(str) + '_' + exp['Fraction'... | [
"def",
"_set_column_names",
"(",
"dep",
",",
"exp",
")",
":",
"colnames",
"=",
"exp",
"[",
"'Experiment'",
"]",
".",
"astype",
"(",
"str",
")",
"+",
"'_'",
"+",
"exp",
"[",
"'Fraction'",
"]",
".",
"astype",
"(",
"str",
")",
"file2col",
"=",
"dict",
... | rename the columns in the dependent peptides table from
the raw file to the corresponding {experiment}_{fraction}.
:param dep: dependent peptides table.
:param exp: experimental design table. | [
"rename",
"the",
"columns",
"in",
"the",
"dependent",
"peptides",
"table",
"from",
"the",
"raw",
"file",
"to",
"the",
"corresponding",
"{",
"experiment",
"}",
"_",
"{",
"fraction",
"}",
".",
":",
"param",
"dep",
":",
"dependent",
"peptides",
"table",
".",
... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/dependent_peptides.py#L29-L39 | train | rename the columns in the dependent peptides table from
the raw file to the corresponding experiment}_{fraction. |
cox-labs/perseuspy | perseuspy/dependent_peptides.py | count | def count(args):
""" count occurences in a list of lists
>>> count([['a','b'],['a']])
defaultdict(int, {'a' : 2, 'b' : 1})
"""
counts = defaultdict(int)
for arg in args:
for item in arg:
counts[item] = counts[item] + 1
return counts | python | def count(args):
""" count occurences in a list of lists
>>> count([['a','b'],['a']])
defaultdict(int, {'a' : 2, 'b' : 1})
"""
counts = defaultdict(int)
for arg in args:
for item in arg:
counts[item] = counts[item] + 1
return counts | [
"def",
"count",
"(",
"args",
")",
":",
"counts",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"arg",
"in",
"args",
":",
"for",
"item",
"in",
"arg",
":",
"counts",
"[",
"item",
"]",
"=",
"counts",
"[",
"item",
"]",
"+",
"1",
"return",
"counts"
] | count occurences in a list of lists
>>> count([['a','b'],['a']])
defaultdict(int, {'a' : 2, 'b' : 1}) | [
"count",
"occurences",
"in",
"a",
"list",
"of",
"lists",
">>>",
"count",
"(",
"[[",
"a",
"b",
"]",
"[",
"a",
"]]",
")",
"defaultdict",
"(",
"int",
"{",
"a",
":",
"2",
"b",
":",
"1",
"}",
")"
] | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/dependent_peptides.py#L42-L51 | train | count occurences in a list of lists
|
cox-labs/perseuspy | perseuspy/dependent_peptides.py | _count_localizations | def _count_localizations(df):
""" count the most likely localization for each depentent peptide.
:param df: allPeptides.txt table.
"""
grp = df.groupby(_index_columns)
counts = grp['DP AA'].apply(lambda x: count(x.str.split(';').values))
counts.index = counts.index.set_names('DP AA', level=4)
... | python | def _count_localizations(df):
""" count the most likely localization for each depentent peptide.
:param df: allPeptides.txt table.
"""
grp = df.groupby(_index_columns)
counts = grp['DP AA'].apply(lambda x: count(x.str.split(';').values))
counts.index = counts.index.set_names('DP AA', level=4)
... | [
"def",
"_count_localizations",
"(",
"df",
")",
":",
"grp",
"=",
"df",
".",
"groupby",
"(",
"_index_columns",
")",
"counts",
"=",
"grp",
"[",
"'DP AA'",
"]",
".",
"apply",
"(",
"lambda",
"x",
":",
"count",
"(",
"x",
".",
"str",
".",
"split",
"(",
"'... | count the most likely localization for each depentent peptide.
:param df: allPeptides.txt table. | [
"count",
"the",
"most",
"likely",
"localization",
"for",
"each",
"depentent",
"peptide",
".",
":",
"param",
"df",
":",
"allPeptides",
".",
"txt",
"table",
"."
] | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/dependent_peptides.py#L53-L62 | train | count the most likely localization for each depentent peptide. |
cox-labs/perseuspy | perseuspy/dependent_peptides.py | _frequent_localizations | def _frequent_localizations(df):
""" returns the most frequent localization for any dependent peptide.
In case of ties, preference is given to n-terminal modification which are
biologically more likely to occur
:param df: allPeptides.txt table.
"""
max_count = int(df['DP AA count'].max())
ma... | python | def _frequent_localizations(df):
""" returns the most frequent localization for any dependent peptide.
In case of ties, preference is given to n-terminal modification which are
biologically more likely to occur
:param df: allPeptides.txt table.
"""
max_count = int(df['DP AA count'].max())
ma... | [
"def",
"_frequent_localizations",
"(",
"df",
")",
":",
"max_count",
"=",
"int",
"(",
"df",
"[",
"'DP AA count'",
"]",
".",
"max",
"(",
")",
")",
"max_aa",
"=",
"set",
"(",
"df",
"[",
"df",
"[",
"'DP AA count'",
"]",
"==",
"max_count",
"]",
"[",
"'DP ... | returns the most frequent localization for any dependent peptide.
In case of ties, preference is given to n-terminal modification which are
biologically more likely to occur
:param df: allPeptides.txt table. | [
"returns",
"the",
"most",
"frequent",
"localization",
"for",
"any",
"dependent",
"peptide",
".",
"In",
"case",
"of",
"ties",
"preference",
"is",
"given",
"to",
"n",
"-",
"terminal",
"modification",
"which",
"are",
"biologically",
"more",
"likely",
"to",
"occur... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/dependent_peptides.py#L64-L77 | train | Returns the most frequent localization for any dependent peptide. |
cox-labs/perseuspy | perseuspy/dependent_peptides.py | run_dependent_peptides_from_parameters | def run_dependent_peptides_from_parameters(paramfile, outfile):
""" transform a allPeptides.txt and experimentalDesign.txt table
into the dependentPeptides.txt table written in outfile.
:param paramfile: Perseus parameters.xml including at least two FileParam
entries names 'allPeptides.txt' and 'experim... | python | def run_dependent_peptides_from_parameters(paramfile, outfile):
""" transform a allPeptides.txt and experimentalDesign.txt table
into the dependentPeptides.txt table written in outfile.
:param paramfile: Perseus parameters.xml including at least two FileParam
entries names 'allPeptides.txt' and 'experim... | [
"def",
"run_dependent_peptides_from_parameters",
"(",
"paramfile",
",",
"outfile",
")",
":",
"parameters",
"=",
"parse_parameters",
"(",
"paramfile",
")",
"allPeptides_file",
"=",
"fileParam",
"(",
"parameters",
",",
"'allPeptides.txt'",
")",
"rawFilesTable_file",
"=",
... | transform a allPeptides.txt and experimentalDesign.txt table
into the dependentPeptides.txt table written in outfile.
:param paramfile: Perseus parameters.xml including at least two FileParam
entries names 'allPeptides.txt' and 'experimentalDesign.txt'.
:param outfile: Path to the output file. | [
"transform",
"a",
"allPeptides",
".",
"txt",
"and",
"experimentalDesign",
".",
"txt",
"table",
"into",
"the",
"dependentPeptides",
".",
"txt",
"table",
"written",
"in",
"outfile",
".",
":",
"param",
"paramfile",
":",
"Perseus",
"parameters",
".",
"xml",
"inclu... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/dependent_peptides.py#L79-L89 | train | transform a allPeptides. txt and experimentalDesign. txt table
into the dependentPeptides. txt table written in outfile. |
cox-labs/perseuspy | perseuspy/dependent_peptides.py | run_dependent_peptides | def run_dependent_peptides(allPeptides_file, rawFilesTable_file, outfile):
""" transform a allPeptides.txt and experimentalDesign.txt table
into the dependentPeptides.txt table written in outfile.
:param allPeptides_file: MaxQuant 'allPeptides.txt' output table.
:param rawFilesTable_file: MaxQuant 'Raw ... | python | def run_dependent_peptides(allPeptides_file, rawFilesTable_file, outfile):
""" transform a allPeptides.txt and experimentalDesign.txt table
into the dependentPeptides.txt table written in outfile.
:param allPeptides_file: MaxQuant 'allPeptides.txt' output table.
:param rawFilesTable_file: MaxQuant 'Raw ... | [
"def",
"run_dependent_peptides",
"(",
"allPeptides_file",
",",
"rawFilesTable_file",
",",
"outfile",
")",
":",
"__dep",
",",
"localization",
"=",
"read_dependent_peptides",
"(",
"allPeptides_file",
")",
"exp",
"=",
"read_rawFilesTable",
"(",
"rawFilesTable_file",
")",
... | transform a allPeptides.txt and experimentalDesign.txt table
into the dependentPeptides.txt table written in outfile.
:param allPeptides_file: MaxQuant 'allPeptides.txt' output table.
:param rawFilesTable_file: MaxQuant 'Raw files'-tab table.
:param outfile: Path to the output file. | [
"transform",
"a",
"allPeptides",
".",
"txt",
"and",
"experimentalDesign",
".",
"txt",
"table",
"into",
"the",
"dependentPeptides",
".",
"txt",
"table",
"written",
"in",
"outfile",
".",
":",
"param",
"allPeptides_file",
":",
"MaxQuant",
"allPeptides",
".",
"txt",... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/dependent_peptides.py#L91-L103 | train | transform a allPeptides. txt and experimentalDesign. txt table
into the dependentPeptides. txt table written in outfile. |
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 | Returns the string of a variable name. |
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 | A BLAST query online. |
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 | Checks the status of a BLAST query. |
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 | Returns the results of a BLAST query for a given RID. |
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 | Generate HTML report. |
Nachtfeuer/pipeline | spline/tools/report/generator.py | generate | def generate(store, report_format, path):
"""
Generate file in defined format representing the report of pipeline(s).
Args:
store (Store): report data.
report_format (str): currently "html" is supported only.
path (str): path where to write the report to. Missing sub folders will be... | python | def generate(store, report_format, path):
"""
Generate file in defined format representing the report of pipeline(s).
Args:
store (Store): report data.
report_format (str): currently "html" is supported only.
path (str): path where to write the report to. Missing sub folders will be... | [
"def",
"generate",
"(",
"store",
",",
"report_format",
",",
"path",
")",
":",
"success",
"=",
"False",
"if",
"report_format",
"in",
"[",
"'html'",
"]",
":",
"rendered_content",
"=",
"{",
"'html'",
":",
"generate_html",
"}",
"[",
"report_format",
"]",
"(",
... | Generate file in defined format representing the report of pipeline(s).
Args:
store (Store): report data.
report_format (str): currently "html" is supported only.
path (str): path where to write the report to. Missing sub folders will be created. | [
"Generate",
"file",
"in",
"defined",
"format",
"representing",
"the",
"report",
"of",
"pipeline",
"(",
"s",
")",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/generator.py#L48-L73 | train | Generate a new file in defined format representing the report of pipeline(s. |
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 | Handle the beginning of a list. |
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 | Handle end of a list. |
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 | Handle tokens inside the list or outside the list. |
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",
":",
"# pylint: disable=unidiomatic-typecheck",
"self",
".",
"dispatcher",
"[",
"type",
... | Main function of compression. | [
"Main",
"function",
"of",
"compression",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L66-L72 | train | Main function of compression. |
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 | Get AST tokens for Python condition. |
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 | Verify that each token in order does match the expected types. |
Nachtfeuer/pipeline | spline/tools/condition.py | Condition.is_valid | def is_valid(condition):
"""
Verify condition (format).
>>> Condition.is_valid('{{ foo }} == 42')
True
>>> Condition.is_valid('"{{ foo }}" == 42')
False
>>> Condition.is_valid(' not "{{ foo }}" == "42" ')
True
>>> Condition.is_valid(' not {{ fo... | python | def is_valid(condition):
"""
Verify condition (format).
>>> Condition.is_valid('{{ foo }} == 42')
True
>>> Condition.is_valid('"{{ foo }}" == 42')
False
>>> Condition.is_valid(' not "{{ foo }}" == "42" ')
True
>>> Condition.is_valid(' not {{ fo... | [
"def",
"is_valid",
"(",
"condition",
")",
":",
"matched",
"=",
"False",
"if",
"len",
"(",
"condition",
")",
">",
"0",
":",
"final_condition",
"=",
"re",
".",
"sub",
"(",
"'{{.*}}'",
",",
"'42'",
",",
"condition",
")",
"ast_tokens",
"=",
"Condition",
".... | Verify condition (format).
>>> Condition.is_valid('{{ foo }} == 42')
True
>>> Condition.is_valid('"{{ foo }}" == 42')
False
>>> Condition.is_valid(' not "{{ foo }}" == "42" ')
True
>>> Condition.is_valid(' not {{ foo }} == 42 ')
True
>>> Condi... | [
"Verify",
"condition",
"(",
"format",
")",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L197-L226 | train | Verify condition and return True if it is valid. |
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 | Find rule for given condition. |
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 | Evaluate a condition and return True if it evaluates to True. |
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 | starts the web interface and possibly other processes |
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 | Get creator function by name. |
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 | This function runs on a single shell via multiprocessing. |
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 | Copying and merging environment variables. |
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 | Prepare one shell or docker task. |
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 | Processes a group of tasks. |
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 | Processes a list of shells in parallel. |
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 | Processing a list of shells one after the other. |
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 | Processing a list of shells. |
Nachtfeuer/pipeline | spline/components/tasks.py | Tasks.can_process_shell | def can_process_shell(self, entry):
""":return: True when shell can be executed."""
count = 0
condition = render(entry['when'], variables=self.pipeline.variables,
model=self.pipeline.model, env=self.get_merged_env(include_os=True))
if Condition.evaluate("" if ... | python | def can_process_shell(self, entry):
""":return: True when shell can be executed."""
count = 0
condition = render(entry['when'], variables=self.pipeline.variables,
model=self.pipeline.model, env=self.get_merged_env(include_os=True))
if Condition.evaluate("" if ... | [
"def",
"can_process_shell",
"(",
"self",
",",
"entry",
")",
":",
"count",
"=",
"0",
"condition",
"=",
"render",
"(",
"entry",
"[",
"'when'",
"]",
",",
"variables",
"=",
"self",
".",
"pipeline",
".",
"variables",
",",
"model",
"=",
"self",
".",
"pipelin... | :return: True when shell can be executed. | [
":",
"return",
":",
"True",
"when",
"shell",
"can",
"be",
"executed",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/tasks.py#L213-L228 | train | Returns True when shell can be executed. |
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 | Process a single shell entry. |
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 | Run cleanup hook when configured. |
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 | Handles the output of a variable name command. |
acutesoftware/AIKIF | aikif/environments/internet.py | Internet.create | def create(self, num_sites):
"""
Creates the environment
Code in Base class = self.log.record_process('enviroment.py', 'Creating environment - ' + self.name)
"""
super(Internet, self).create(num_sites)
#print('building websites')
for _ in range(0,num_sites):
... | python | def create(self, num_sites):
"""
Creates the environment
Code in Base class = self.log.record_process('enviroment.py', 'Creating environment - ' + self.name)
"""
super(Internet, self).create(num_sites)
#print('building websites')
for _ in range(0,num_sites):
... | [
"def",
"create",
"(",
"self",
",",
"num_sites",
")",
":",
"super",
"(",
"Internet",
",",
"self",
")",
".",
"create",
"(",
"num_sites",
")",
"#print('building websites')",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"num_sites",
")",
":",
"self",
".",
"we... | Creates the environment
Code in Base class = self.log.record_process('enviroment.py', 'Creating environment - ' + self.name) | [
"Creates",
"the",
"environment",
"Code",
"in",
"Base",
"class",
"=",
"self",
".",
"log",
".",
"record_process",
"(",
"enviroment",
".",
"py",
"Creating",
"environment",
"-",
"+",
"self",
".",
"name",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/internet.py#L34-L42 | train | Creates the environment and websites. |
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 | Removes parameters whose values are set to None. |
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 | Calculates the distance between the centroids of two catchments in kilometers. |
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",
")",
":",
"# Decimal places increased to ensure year 2000 corresponds with 1",
"urban_expansion",
"=",
"0.7851",
"+",
"0.2124",
"*",
"atan",
"(",
"(",
"year",
"-",
"1967.5",
")",
"/",
"20.331792998",
")",
"try",
":",
"r... | 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 | Estimate the urbext2000 parameter for a given year assuming a nation - wide urbanisation curve. |
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",
"=",
"[",
"]",
"# For the first period",
"start_date",
"=",
"self",
".",
"start_date",
"for",
"gap",
"in",
"self",
".",
"pot_data_gaps",
":",
"end_date",
"=",
"gap",
".",
"start_date",
"-",
"timed... | 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 | Return a list of continuous data periods by removing the data gaps from the overall record. |
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 | Adds all files from given path to the object. |
Nachtfeuer/pipeline | spline/tools/memfiles.py | InMemoryFiles.save | def save(self, path):
"""
Saving stored files at a given path (relative paths are added).
Args:
path (str): root path where to save the files.
"""
for relative_path_and_filename, content in self.files.items():
full_path_and_filename = os.path.join(path, r... | python | def save(self, path):
"""
Saving stored files at a given path (relative paths are added).
Args:
path (str): root path where to save the files.
"""
for relative_path_and_filename, content in self.files.items():
full_path_and_filename = os.path.join(path, r... | [
"def",
"save",
"(",
"self",
",",
"path",
")",
":",
"for",
"relative_path_and_filename",
",",
"content",
"in",
"self",
".",
"files",
".",
"items",
"(",
")",
":",
"full_path_and_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"relative_pa... | Saving stored files at a given path (relative paths are added).
Args:
path (str): root path where to save the files. | [
"Saving",
"stored",
"files",
"at",
"a",
"given",
"path",
"(",
"relative",
"paths",
"are",
"added",
")",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/memfiles.py#L57-L72 | train | Saves the contents of the files in the cache at a given path. |
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 | Convert JSON into a in memory file storage. |
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 | delete a single file |
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 | delete all files in folder freldr |
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 | copy a single file |
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 | Copy all the files from src to dest folder |
acutesoftware/AIKIF | aikif/toolbox/file_tools.py | copy_all_files_and_subfolders | def copy_all_files_and_subfolders(src, dest, base_path_ignore, xtn_list):
"""
file_tools.copy_all_files_and_subfolders(src, dest, backup_path, ['*.*'])
gets list of all subfolders and copies each file to
its own folder in 'dest' folder
paths, xtn, excluded, output_file_name = 'my_files.csv')
"""
ensure_dir(dest... | python | def copy_all_files_and_subfolders(src, dest, base_path_ignore, xtn_list):
"""
file_tools.copy_all_files_and_subfolders(src, dest, backup_path, ['*.*'])
gets list of all subfolders and copies each file to
its own folder in 'dest' folder
paths, xtn, excluded, output_file_name = 'my_files.csv')
"""
ensure_dir(dest... | [
"def",
"copy_all_files_and_subfolders",
"(",
"src",
",",
"dest",
",",
"base_path_ignore",
",",
"xtn_list",
")",
":",
"ensure_dir",
"(",
"dest",
")",
"fl",
"=",
"mod_fl",
".",
"FileList",
"(",
"[",
"src",
"]",
",",
"xtn_list",
",",
"exclude_folders",
",",
"... | file_tools.copy_all_files_and_subfolders(src, dest, backup_path, ['*.*'])
gets list of all subfolders and copies each file to
its own folder in 'dest' folder
paths, xtn, excluded, output_file_name = 'my_files.csv') | [
"file_tools",
".",
"copy_all_files_and_subfolders",
"(",
"src",
"dest",
"backup_path",
"[",
"*",
".",
"*",
"]",
")",
"gets",
"list",
"of",
"all",
"subfolders",
"and",
"copies",
"each",
"file",
"to",
"its",
"own",
"folder",
"in",
"dest",
"folder",
"paths",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/file_tools.py#L82-L98 | train | Copy all files and subfolders to a new folder. |
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 | reads an RDF file into a graph |
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",
"]",
")",
")",
")",
")",
"# Get Subject Lists",
"num_subj... | 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 | display sample data from a graph |
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 | export a graph to a CSV file for simpler viewing |
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",
"(",
"\"/\"",
")",
"#[:-1]",
"return",
"\"\"",
".",
"join",
"(",
"[",
"l",
".",
"replace",
"(",
"'\"'",
",",
"'\"\"'",
")",
"for",
"l",
"in",
"res",
"[",
"len",
... | 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 | extracts the real content from an RDF info object |
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 | create a sample file |
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 | Flatten nested sequences into one. |
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 | Build a list of all the entries in the sequence. |
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 | reads the zip file determines compression
and unzips recursively until all source files in the zip file are extracted recursively |
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 | create a zip file from a file |
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\"",
")",
":",
"#print('zip from folder - adding folder : ', fldr)",
"zipf",
"=",
"zipfile",
".",
"ZipFile",
"(",
"zip_file",
",",
"'w'",
")",
"for",
"root",
",",
"dirs",
",",
... | 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 | create a zip file from folder fldr |
acutesoftware/AIKIF | aikif/toolbox/zip_tools.py | ZipFile.extract | def extract(self, dest_fldr, password=''):
"""
unzip the file contents to the dest_folder
(create if it doesn't exist)
and then return the list of files extracted
"""
#print('extracting to ' + dest_fldr)
if self.type == 'ZIP':
self._extract_zip(dest_fl... | python | def extract(self, dest_fldr, password=''):
"""
unzip the file contents to the dest_folder
(create if it doesn't exist)
and then return the list of files extracted
"""
#print('extracting to ' + dest_fldr)
if self.type == 'ZIP':
self._extract_zip(dest_fl... | [
"def",
"extract",
"(",
"self",
",",
"dest_fldr",
",",
"password",
"=",
"''",
")",
":",
"#print('extracting to ' + dest_fldr)",
"if",
"self",
".",
"type",
"==",
"'ZIP'",
":",
"self",
".",
"_extract_zip",
"(",
"dest_fldr",
",",
"password",
")",
"elif",
"self",... | unzip the file contents to the dest_folder
(create if it doesn't exist)
and then return the list of files extracted | [
"unzip",
"the",
"file",
"contents",
"to",
"the",
"dest_folder",
"(",
"create",
"if",
"it",
"doesn",
"t",
"exist",
")",
"and",
"then",
"return",
"the",
"list",
"of",
"files",
"extracted"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/zip_tools.py#L97-L111 | train | extract the contents of the file to the dest_fldr |
acutesoftware/AIKIF | aikif/toolbox/zip_tools.py | ZipFile.get_file_named | def get_file_named(self, fldr, xtn):
"""
scans a directory for files like *.GZ or *.ZIP and returns
the filename of the first one found (should only be one of
each file here
"""
res = [] # list of Sample objects
for root, _, files in os.walk(fldr):
... | python | def get_file_named(self, fldr, xtn):
"""
scans a directory for files like *.GZ or *.ZIP and returns
the filename of the first one found (should only be one of
each file here
"""
res = [] # list of Sample objects
for root, _, files in os.walk(fldr):
... | [
"def",
"get_file_named",
"(",
"self",
",",
"fldr",
",",
"xtn",
")",
":",
"res",
"=",
"[",
"]",
"# list of Sample objects",
"for",
"root",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"fldr",
")",
":",
"for",
"basename",
"in",
"files",
":",
... | scans a directory for files like *.GZ or *.ZIP and returns
the filename of the first one found (should only be one of
each file here | [
"scans",
"a",
"directory",
"for",
"files",
"like",
"*",
".",
"GZ",
"or",
"*",
".",
"ZIP",
"and",
"returns",
"the",
"filename",
"of",
"the",
"first",
"one",
"found",
"(",
"should",
"only",
"be",
"one",
"of",
"each",
"file",
"here"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/zip_tools.py#L113-L129 | train | returns the filename of the first file that matches xtn |
nocarryr/python-dispatch | pydispatch/aioutils.py | AioSimpleLock.acquire | def acquire(self, blocking=True, timeout=-1):
"""Acquire the :attr:`lock`
Args:
blocking (bool): See :meth:`threading.Lock.acquire`
timeout (float): See :meth:`threading.Lock.acquire`
Returns:
bool: :obj:`True` if the lock was acquired, otherwise :obj:`False... | python | def acquire(self, blocking=True, timeout=-1):
"""Acquire the :attr:`lock`
Args:
blocking (bool): See :meth:`threading.Lock.acquire`
timeout (float): See :meth:`threading.Lock.acquire`
Returns:
bool: :obj:`True` if the lock was acquired, otherwise :obj:`False... | [
"def",
"acquire",
"(",
"self",
",",
"blocking",
"=",
"True",
",",
"timeout",
"=",
"-",
"1",
")",
":",
"result",
"=",
"self",
".",
"lock",
".",
"acquire",
"(",
"blocking",
",",
"timeout",
")",
"return",
"result"
] | Acquire the :attr:`lock`
Args:
blocking (bool): See :meth:`threading.Lock.acquire`
timeout (float): See :meth:`threading.Lock.acquire`
Returns:
bool: :obj:`True` if the lock was acquired, otherwise :obj:`False` | [
"Acquire",
"the",
":",
"attr",
":",
"lock"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/aioutils.py#L61-L73 | train | Acquire the lock. |
nocarryr/python-dispatch | pydispatch/aioutils.py | AioSimpleLock.acquire_async | async def acquire_async(self):
"""Acquire the :attr:`lock` asynchronously
"""
r = self.acquire(blocking=False)
while not r:
await asyncio.sleep(.01)
r = self.acquire(blocking=False) | python | async def acquire_async(self):
"""Acquire the :attr:`lock` asynchronously
"""
r = self.acquire(blocking=False)
while not r:
await asyncio.sleep(.01)
r = self.acquire(blocking=False) | [
"async",
"def",
"acquire_async",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"acquire",
"(",
"blocking",
"=",
"False",
")",
"while",
"not",
"r",
":",
"await",
"asyncio",
".",
"sleep",
"(",
".01",
")",
"r",
"=",
"self",
".",
"acquire",
"(",
"block... | Acquire the :attr:`lock` asynchronously | [
"Acquire",
"the",
":",
"attr",
":",
"lock",
"asynchronously"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/aioutils.py#L83-L90 | train | Acquire the lock asynchronously. |
nocarryr/python-dispatch | pydispatch/aioutils.py | AioEventWaiter.trigger | def trigger(self, *args, **kwargs):
"""Called on event emission and notifies the :meth:`wait` method
Called by :class:`AioEventWaiters` when the
:class:`~pydispatch.dispatch.Event` instance is dispatched.
Positional and keyword arguments are stored as instance attributes for
us... | python | def trigger(self, *args, **kwargs):
"""Called on event emission and notifies the :meth:`wait` method
Called by :class:`AioEventWaiters` when the
:class:`~pydispatch.dispatch.Event` instance is dispatched.
Positional and keyword arguments are stored as instance attributes for
us... | [
"def",
"trigger",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"args",
"=",
"args",
"self",
".",
"kwargs",
"=",
"kwargs",
"self",
".",
"aio_event",
".",
"set",
"(",
")"
] | Called on event emission and notifies the :meth:`wait` method
Called by :class:`AioEventWaiters` when the
:class:`~pydispatch.dispatch.Event` instance is dispatched.
Positional and keyword arguments are stored as instance attributes for
use in the :meth:`wait` method and :attr:`aio_eve... | [
"Called",
"on",
"event",
"emission",
"and",
"notifies",
"the",
":",
"meth",
":",
"wait",
"method"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/aioutils.py#L118-L129 | train | Called on event emission and notifies the AioEventWaiters when the event is dispatched. |
nocarryr/python-dispatch | pydispatch/aioutils.py | AioEventWaiters.add_waiter | async def add_waiter(self):
"""Add a :class:`AioEventWaiter` to the :attr:`waiters` container
The event loop to use for :attr:`AioEventWaiter.loop` is found in the
current context using :func:`asyncio.get_event_loop`
Returns:
waiter: The created :class:`AioEventWaiter` inst... | python | async def add_waiter(self):
"""Add a :class:`AioEventWaiter` to the :attr:`waiters` container
The event loop to use for :attr:`AioEventWaiter.loop` is found in the
current context using :func:`asyncio.get_event_loop`
Returns:
waiter: The created :class:`AioEventWaiter` inst... | [
"async",
"def",
"add_waiter",
"(",
"self",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"async",
"with",
"self",
".",
"lock",
":",
"waiter",
"=",
"AioEventWaiter",
"(",
"loop",
")",
"self",
".",
"waiters",
".",
"add",
"(",
"waiter... | Add a :class:`AioEventWaiter` to the :attr:`waiters` container
The event loop to use for :attr:`AioEventWaiter.loop` is found in the
current context using :func:`asyncio.get_event_loop`
Returns:
waiter: The created :class:`AioEventWaiter` instance | [
"Add",
"a",
":",
"class",
":",
"AioEventWaiter",
"to",
"the",
":",
"attr",
":",
"waiters",
"container"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/aioutils.py#L162-L176 | train | Add a new AioEventWaiter to the list of waiters. |
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 | Add a coroutine function to the event loop. |
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 | Iterate over stored coroutine functions
Used by the event loop. |
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 | Schedule and await a coroutine on the specified loop. |
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",
")",
":",
"#os.system(self.fullname) # gives permission denied seeing it needs to be chmod +x",
"import",
"subprocess",
"try",
":",
"retcode",
"=",
"subprocess",
".",
"call",
"(",
"self",
".",
"fullname",
",",
"shell",
"=",
"True",
")",
... | 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 | launch a file - used for starting html pages |
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 | delete a file |
acutesoftware/AIKIF | aikif/lib/cls_file.py | TextFile.count_lines_in_file | def count_lines_in_file(self, fname=''):
""" you wont believe what this method does """
i = 0
if fname == '':
fname = self.fullname
try:
#with open(fname, encoding="utf8") as f:
with codecs.open(fname, "r",encoding='utf8', errors='ignore') as f:
... | python | def count_lines_in_file(self, fname=''):
""" you wont believe what this method does """
i = 0
if fname == '':
fname = self.fullname
try:
#with open(fname, encoding="utf8") as f:
with codecs.open(fname, "r",encoding='utf8', errors='ignore') as f:
... | [
"def",
"count_lines_in_file",
"(",
"self",
",",
"fname",
"=",
"''",
")",
":",
"i",
"=",
"0",
"if",
"fname",
"==",
"''",
":",
"fname",
"=",
"self",
".",
"fullname",
"try",
":",
"#with open(fname, encoding=\"utf8\") as f:",
"with",
"codecs",
".",
"open",
"("... | you wont believe what this method does | [
"you",
"wont",
"believe",
"what",
"this",
"method",
"does"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_file.py#L109-L122 | train | count the number of lines in a file |
acutesoftware/AIKIF | aikif/lib/cls_file.py | TextFile.count_lines_of_code | def count_lines_of_code(self, fname=''):
""" counts non blank lines """
if fname == '':
fname = self.fullname
loc = 0
try:
with open(fname) as f:
for l in f:
if l.strip() != '':
loc += 1
r... | python | def count_lines_of_code(self, fname=''):
""" counts non blank lines """
if fname == '':
fname = self.fullname
loc = 0
try:
with open(fname) as f:
for l in f:
if l.strip() != '':
loc += 1
r... | [
"def",
"count_lines_of_code",
"(",
"self",
",",
"fname",
"=",
"''",
")",
":",
"if",
"fname",
"==",
"''",
":",
"fname",
"=",
"self",
".",
"fullname",
"loc",
"=",
"0",
"try",
":",
"with",
"open",
"(",
"fname",
")",
"as",
"f",
":",
"for",
"l",
"in",... | counts non blank lines | [
"counts",
"non",
"blank",
"lines"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_file.py#L124-L137 | train | count the number of lines of code in a file |
acutesoftware/AIKIF | aikif/lib/cls_file.py | TextFile.get_file_sample | def get_file_sample(self, numLines=10):
""" retrieve a sample of the file """
res = ''
try:
with open(self.fullname, 'r') as f:
for line_num, line in enumerate(f):
res += str(line_num).zfill(5) + ' ' + line
if line_num >= numLi... | python | def get_file_sample(self, numLines=10):
""" retrieve a sample of the file """
res = ''
try:
with open(self.fullname, 'r') as f:
for line_num, line in enumerate(f):
res += str(line_num).zfill(5) + ' ' + line
if line_num >= numLi... | [
"def",
"get_file_sample",
"(",
"self",
",",
"numLines",
"=",
"10",
")",
":",
"res",
"=",
"''",
"try",
":",
"with",
"open",
"(",
"self",
".",
"fullname",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line_num",
",",
"line",
"in",
"enumerate",
"(",
"f",
... | retrieve a sample of the file | [
"retrieve",
"a",
"sample",
"of",
"the",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_file.py#L140-L152 | train | retrieve a sample of the file |
acutesoftware/AIKIF | aikif/lib/cls_file.py | TextFile.append_text | def append_text(self, txt):
""" adds a line of text to a file """
with open(self.fullname, "a") as myfile:
myfile.write(txt) | python | def append_text(self, txt):
""" adds a line of text to a file """
with open(self.fullname, "a") as myfile:
myfile.write(txt) | [
"def",
"append_text",
"(",
"self",
",",
"txt",
")",
":",
"with",
"open",
"(",
"self",
".",
"fullname",
",",
"\"a\"",
")",
"as",
"myfile",
":",
"myfile",
".",
"write",
"(",
"txt",
")"
] | adds a line of text to a file | [
"adds",
"a",
"line",
"of",
"text",
"to",
"a",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_file.py#L155-L158 | train | appends a line of text to a file |
acutesoftware/AIKIF | aikif/lib/cls_file.py | TextFile.load_file_to_string | def load_file_to_string(self):
""" load a file to a string """
try:
with open(self.fullname, 'r') as f:
txt = f.read()
return txt
except IOError:
return '' | python | def load_file_to_string(self):
""" load a file to a string """
try:
with open(self.fullname, 'r') as f:
txt = f.read()
return txt
except IOError:
return '' | [
"def",
"load_file_to_string",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"fullname",
",",
"'r'",
")",
"as",
"f",
":",
"txt",
"=",
"f",
".",
"read",
"(",
")",
"return",
"txt",
"except",
"IOError",
":",
"return",
"''"
] | load a file to a string | [
"load",
"a",
"file",
"to",
"a",
"string"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_file.py#L172-L179 | train | load a file to a string |
acutesoftware/AIKIF | aikif/lib/cls_file.py | TextFile.load_file_to_list | def load_file_to_list(self):
""" load a file to a list """
lst = []
try:
with open(self.fullname, 'r') as f:
for line in f:
lst.append(line)
return lst
except IOError:
return lst | python | def load_file_to_list(self):
""" load a file to a list """
lst = []
try:
with open(self.fullname, 'r') as f:
for line in f:
lst.append(line)
return lst
except IOError:
return lst | [
"def",
"load_file_to_list",
"(",
"self",
")",
":",
"lst",
"=",
"[",
"]",
"try",
":",
"with",
"open",
"(",
"self",
".",
"fullname",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"lst",
".",
"append",
"(",
"line",
")",
"return",
... | load a file to a list | [
"load",
"a",
"file",
"to",
"a",
"list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_file.py#L181-L190 | train | load a file to a list |
acutesoftware/AIKIF | aikif/web_app/page_programs.py | get_program_list | def get_program_list():
"""
get a HTML formatted view of all Python programs
in all subfolders of AIKIF, including imports and
lists of functions and classes
"""
colList = ['FileName','FileSize','Functions', 'Imports']
txt = '<TABLE width=90% border=0>'
txt += format_file_table_header(c... | python | def get_program_list():
"""
get a HTML formatted view of all Python programs
in all subfolders of AIKIF, including imports and
lists of functions and classes
"""
colList = ['FileName','FileSize','Functions', 'Imports']
txt = '<TABLE width=90% border=0>'
txt += format_file_table_header(c... | [
"def",
"get_program_list",
"(",
")",
":",
"colList",
"=",
"[",
"'FileName'",
",",
"'FileSize'",
",",
"'Functions'",
",",
"'Imports'",
"]",
"txt",
"=",
"'<TABLE width=90% border=0>'",
"txt",
"+=",
"format_file_table_header",
"(",
"colList",
")",
"fl",
"=",
"web",... | get a HTML formatted view of all Python programs
in all subfolders of AIKIF, including imports and
lists of functions and classes | [
"get",
"a",
"HTML",
"formatted",
"view",
"of",
"all",
"Python",
"programs",
"in",
"all",
"subfolders",
"of",
"AIKIF",
"including",
"imports",
"and",
"lists",
"of",
"functions",
"and",
"classes"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_programs.py#L32-L49 | train | get a HTML formatted view of all Python programs in AIKIF |
acutesoftware/AIKIF | aikif/web_app/page_programs.py | get_subfolder | def get_subfolder(txt):
"""
extracts a displayable subfolder name from full filename
"""
root_folder = os.sep + 'aikif' + os.sep
ndx = txt.find(root_folder, 1)
return txt[ndx:].replace('__init__.py', '') | python | def get_subfolder(txt):
"""
extracts a displayable subfolder name from full filename
"""
root_folder = os.sep + 'aikif' + os.sep
ndx = txt.find(root_folder, 1)
return txt[ndx:].replace('__init__.py', '') | [
"def",
"get_subfolder",
"(",
"txt",
")",
":",
"root_folder",
"=",
"os",
".",
"sep",
"+",
"'aikif'",
"+",
"os",
".",
"sep",
"ndx",
"=",
"txt",
".",
"find",
"(",
"root_folder",
",",
"1",
")",
"return",
"txt",
"[",
"ndx",
":",
"]",
".",
"replace",
"... | extracts a displayable subfolder name from full filename | [
"extracts",
"a",
"displayable",
"subfolder",
"name",
"from",
"full",
"filename"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_programs.py#L51-L57 | train | extracts a displayable subfolder name from full filename |
acutesoftware/AIKIF | aikif/web_app/page_programs.py | get_functions | def get_functions(fname):
""" get a list of functions from a Python program """
txt = ''
with open(fname, 'r') as f:
for line in f:
if line.strip()[0:4] == 'def ':
txt += '<PRE>' + strip_text_after_string(strip_text_after_string(line, '#')[4:], ':') + '</PRE>\n'
... | python | def get_functions(fname):
""" get a list of functions from a Python program """
txt = ''
with open(fname, 'r') as f:
for line in f:
if line.strip()[0:4] == 'def ':
txt += '<PRE>' + strip_text_after_string(strip_text_after_string(line, '#')[4:], ':') + '</PRE>\n'
... | [
"def",
"get_functions",
"(",
"fname",
")",
":",
"txt",
"=",
"''",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
"strip",
"(",
")",
"[",
"0",
":",
"4",
"]",
"==",
"'def '",
":"... | get a list of functions from a Python program | [
"get",
"a",
"list",
"of",
"functions",
"from",
"a",
"Python",
"program"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_programs.py#L95-L104 | train | get a list of functions from a Python program |
acutesoftware/AIKIF | aikif/web_app/page_programs.py | strip_text_after_string | def strip_text_after_string(txt, junk):
""" used to strip any poorly documented comments at the end of function defs """
if junk in txt:
return txt[:txt.find(junk)]
else:
return txt | python | def strip_text_after_string(txt, junk):
""" used to strip any poorly documented comments at the end of function defs """
if junk in txt:
return txt[:txt.find(junk)]
else:
return txt | [
"def",
"strip_text_after_string",
"(",
"txt",
",",
"junk",
")",
":",
"if",
"junk",
"in",
"txt",
":",
"return",
"txt",
"[",
":",
"txt",
".",
"find",
"(",
"junk",
")",
"]",
"else",
":",
"return",
"txt"
] | used to strip any poorly documented comments at the end of function defs | [
"used",
"to",
"strip",
"any",
"poorly",
"documented",
"comments",
"at",
"the",
"end",
"of",
"function",
"defs"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_programs.py#L106-L111 | train | used to strip any poorly documented comments at the end of function defs |
acutesoftware/AIKIF | aikif/web_app/page_programs.py | get_imports | def get_imports(fname):
""" get a list of imports from a Python program """
txt = ''
with open(fname, 'r') as f:
for line in f:
if line[0:6] == 'import':
txt += '<PRE>' + strip_text_after_string(line[7:], ' as ') + '</PRE>\n'
return txt + '<BR>' | python | def get_imports(fname):
""" get a list of imports from a Python program """
txt = ''
with open(fname, 'r') as f:
for line in f:
if line[0:6] == 'import':
txt += '<PRE>' + strip_text_after_string(line[7:], ' as ') + '</PRE>\n'
return txt + '<BR>' | [
"def",
"get_imports",
"(",
"fname",
")",
":",
"txt",
"=",
"''",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
"[",
"0",
":",
"6",
"]",
"==",
"'import'",
":",
"txt",
"+=",
"'<PRE>'",
... | get a list of imports from a Python program | [
"get",
"a",
"list",
"of",
"imports",
"from",
"a",
"Python",
"program"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_programs.py#L113-L120 | train | get a list of imports from a Python program |
acutesoftware/AIKIF | aikif/agents/learn/dummy_learn_1.py | main | def main(arg1=55, arg2='test', arg3=None):
"""
This is a sample program to show how a learning agent can
be logged using AIKIF.
The idea is that this main function is your algorithm, which
will run until it finds a successful result. The result is
returned and the time taken is logged.
... | python | def main(arg1=55, arg2='test', arg3=None):
"""
This is a sample program to show how a learning agent can
be logged using AIKIF.
The idea is that this main function is your algorithm, which
will run until it finds a successful result. The result is
returned and the time taken is logged.
... | [
"def",
"main",
"(",
"arg1",
"=",
"55",
",",
"arg2",
"=",
"'test'",
",",
"arg3",
"=",
"None",
")",
":",
"print",
"(",
"'Starting dummy AI algorithm with :'",
",",
"arg1",
",",
"arg2",
",",
"arg3",
")",
"if",
"arg3",
"is",
"None",
":",
"arg3",
"=",
"["... | This is a sample program to show how a learning agent can
be logged using AIKIF.
The idea is that this main function is your algorithm, which
will run until it finds a successful result. The result is
returned and the time taken is logged.
There can optionally be have additional functions
... | [
"This",
"is",
"a",
"sample",
"program",
"to",
"show",
"how",
"a",
"learning",
"agent",
"can",
"be",
"logged",
"using",
"AIKIF",
".",
"The",
"idea",
"is",
"that",
"this",
"main",
"function",
"is",
"your",
"algorithm",
"which",
"will",
"run",
"until",
"it"... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/learn/dummy_learn_1.py#L5-L23 | train | This is the main function that is used to run the AIKIF AI. It is a sample program that can be used to run the AIKIF AIKIF. |
acutesoftware/AIKIF | aikif/dataTools/if_redis.py | redis_server.get | def get(self, key):
""" get a set of keys from redis """
res = self.connection.get(key)
print(res)
return res | python | def get(self, key):
""" get a set of keys from redis """
res = self.connection.get(key)
print(res)
return res | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"res",
"=",
"self",
".",
"connection",
".",
"get",
"(",
"key",
")",
"print",
"(",
"res",
")",
"return",
"res"
] | get a set of keys from redis | [
"get",
"a",
"set",
"of",
"keys",
"from",
"redis"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/if_redis.py#L108-L112 | train | get a set of keys from redis |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.