repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
cthoyt/onto2nx | src/onto2nx/ontospy/core/utils.py | entityTriples | def entityTriples(rdfGraph, anEntity, excludeProps=False, excludeBNodes=False,
orderProps=[RDF, RDFS, OWL.OWLNS, DC.DCNS]):
"""
Returns the pred-obj for any given resource, excluding selected ones..
Sorting: by default results are sorted alphabetically and according to namespaces: [RDF, R... | python | def entityTriples(rdfGraph, anEntity, excludeProps=False, excludeBNodes=False,
orderProps=[RDF, RDFS, OWL.OWLNS, DC.DCNS]):
"""
Returns the pred-obj for any given resource, excluding selected ones..
Sorting: by default results are sorted alphabetically and according to namespaces: [RDF, R... | [
"def",
"entityTriples",
"(",
"rdfGraph",
",",
"anEntity",
",",
"excludeProps",
"=",
"False",
",",
"excludeBNodes",
"=",
"False",
",",
"orderProps",
"=",
"[",
"RDF",
",",
"RDFS",
",",
"OWL",
".",
"OWLNS",
",",
"DC",
".",
"DCNS",
"]",
")",
":",
"temp",
... | Returns the pred-obj for any given resource, excluding selected ones..
Sorting: by default results are sorted alphabetically and according to namespaces: [RDF, RDFS, OWL.OWLNS, DC.DCNS] | [
"Returns",
"the",
"pred",
"-",
"obj",
"for",
"any",
"given",
"resource",
"excluding",
"selected",
"ones",
".."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/utils.py#L560-L591 |
SetBased/py-etlt | etlt/helper/Type2CondenseHelper.py | Type2CondenseHelper._distinct | def _distinct(row1, row2):
"""
Returns a list of distinct (or none overlapping) intervals if two intervals are overlapping. Returns None if
the two intervals are none overlapping. The list can have 2 or 3 intervals.
:param tuple[int,int] row1: The first interval.
:param tuple[in... | python | def _distinct(row1, row2):
"""
Returns a list of distinct (or none overlapping) intervals if two intervals are overlapping. Returns None if
the two intervals are none overlapping. The list can have 2 or 3 intervals.
:param tuple[int,int] row1: The first interval.
:param tuple[in... | [
"def",
"_distinct",
"(",
"row1",
",",
"row2",
")",
":",
"relation",
"=",
"Allen",
".",
"relation",
"(",
"row1",
"[",
"0",
"]",
",",
"row1",
"[",
"1",
"]",
",",
"row2",
"[",
"0",
"]",
",",
"row2",
"[",
"1",
"]",
")",
"if",
"relation",
"is",
"N... | Returns a list of distinct (or none overlapping) intervals if two intervals are overlapping. Returns None if
the two intervals are none overlapping. The list can have 2 or 3 intervals.
:param tuple[int,int] row1: The first interval.
:param tuple[int,int] row2: The second interval.
:rty... | [
"Returns",
"a",
"list",
"of",
"distinct",
"(",
"or",
"none",
"overlapping",
")",
"intervals",
"if",
"two",
"intervals",
"are",
"overlapping",
".",
"Returns",
"None",
"if",
"the",
"two",
"intervals",
"are",
"none",
"overlapping",
".",
"The",
"list",
"can",
... | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2CondenseHelper.py#L23-L105 |
SetBased/py-etlt | etlt/helper/Type2CondenseHelper.py | Type2CondenseHelper._add_interval | def _add_interval(all_intervals, new_interval):
"""
Adds a new interval to a set of none overlapping intervals.
:param set[(int,int)] all_intervals: The set of distinct intervals.
:param (int,int) new_interval: The new interval.
"""
intervals = None
old_interval ... | python | def _add_interval(all_intervals, new_interval):
"""
Adds a new interval to a set of none overlapping intervals.
:param set[(int,int)] all_intervals: The set of distinct intervals.
:param (int,int) new_interval: The new interval.
"""
intervals = None
old_interval ... | [
"def",
"_add_interval",
"(",
"all_intervals",
",",
"new_interval",
")",
":",
"intervals",
"=",
"None",
"old_interval",
"=",
"None",
"for",
"old_interval",
"in",
"all_intervals",
":",
"intervals",
"=",
"Type2CondenseHelper",
".",
"_distinct",
"(",
"new_interval",
"... | Adds a new interval to a set of none overlapping intervals.
:param set[(int,int)] all_intervals: The set of distinct intervals.
:param (int,int) new_interval: The new interval. | [
"Adds",
"a",
"new",
"interval",
"to",
"a",
"set",
"of",
"none",
"overlapping",
"intervals",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2CondenseHelper.py#L109-L129 |
SetBased/py-etlt | etlt/helper/Type2CondenseHelper.py | Type2CondenseHelper._derive_distinct_intervals | def _derive_distinct_intervals(self, rows):
"""
Returns the set of distinct intervals in a row set.
:param list[dict[str,T]] rows: The rows set.
:rtype: set[(int,int)]
"""
ret = set()
for row in rows:
self._add_interval(ret, (row[self._key_start_date... | python | def _derive_distinct_intervals(self, rows):
"""
Returns the set of distinct intervals in a row set.
:param list[dict[str,T]] rows: The rows set.
:rtype: set[(int,int)]
"""
ret = set()
for row in rows:
self._add_interval(ret, (row[self._key_start_date... | [
"def",
"_derive_distinct_intervals",
"(",
"self",
",",
"rows",
")",
":",
"ret",
"=",
"set",
"(",
")",
"for",
"row",
"in",
"rows",
":",
"self",
".",
"_add_interval",
"(",
"ret",
",",
"(",
"row",
"[",
"self",
".",
"_key_start_date",
"]",
",",
"row",
"[... | Returns the set of distinct intervals in a row set.
:param list[dict[str,T]] rows: The rows set.
:rtype: set[(int,int)] | [
"Returns",
"the",
"set",
"of",
"distinct",
"intervals",
"in",
"a",
"row",
"set",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2CondenseHelper.py#L132-L144 |
SetBased/py-etlt | etlt/helper/Type2CondenseHelper.py | Type2CondenseHelper.condense | def condense(self):
"""
Condense the data set to the distinct intervals based on the pseudo key.
"""
for pseudo_key, rows in self._rows.items():
tmp1 = []
intervals = sorted(self._derive_distinct_intervals(rows))
for interval in intervals:
... | python | def condense(self):
"""
Condense the data set to the distinct intervals based on the pseudo key.
"""
for pseudo_key, rows in self._rows.items():
tmp1 = []
intervals = sorted(self._derive_distinct_intervals(rows))
for interval in intervals:
... | [
"def",
"condense",
"(",
"self",
")",
":",
"for",
"pseudo_key",
",",
"rows",
"in",
"self",
".",
"_rows",
".",
"items",
"(",
")",
":",
"tmp1",
"=",
"[",
"]",
"intervals",
"=",
"sorted",
"(",
"self",
".",
"_derive_distinct_intervals",
"(",
"rows",
")",
... | Condense the data set to the distinct intervals based on the pseudo key. | [
"Condense",
"the",
"data",
"set",
"to",
"the",
"distinct",
"intervals",
"based",
"on",
"the",
"pseudo",
"key",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2CondenseHelper.py#L147-L160 |
fhcrc/nestly | nestly/scripts/nestrun.py | _terminate_procs | def _terminate_procs(procs):
"""
Terminate all processes in the process dictionary
"""
logging.warn("Stopping all remaining processes")
for proc, g in procs.values():
logging.debug("[%s] SIGTERM", proc.pid)
try:
proc.terminate()
except OSError as e:
# ... | python | def _terminate_procs(procs):
"""
Terminate all processes in the process dictionary
"""
logging.warn("Stopping all remaining processes")
for proc, g in procs.values():
logging.debug("[%s] SIGTERM", proc.pid)
try:
proc.terminate()
except OSError as e:
# ... | [
"def",
"_terminate_procs",
"(",
"procs",
")",
":",
"logging",
".",
"warn",
"(",
"\"Stopping all remaining processes\"",
")",
"for",
"proc",
",",
"g",
"in",
"procs",
".",
"values",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"\"[%s] SIGTERM\"",
",",
"proc",
... | Terminate all processes in the process dictionary | [
"Terminate",
"all",
"processes",
"in",
"the",
"process",
"dictionary"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L27-L40 |
fhcrc/nestly | nestly/scripts/nestrun.py | write_summary | def write_summary(all_procs, summary_file):
"""
Write a summary of all run processes to summary_file in tab-delimited
format.
"""
if not summary_file:
return
with summary_file:
writer = csv.writer(summary_file, delimiter='\t', lineterminator='\n')
writer.writerow(('direc... | python | def write_summary(all_procs, summary_file):
"""
Write a summary of all run processes to summary_file in tab-delimited
format.
"""
if not summary_file:
return
with summary_file:
writer = csv.writer(summary_file, delimiter='\t', lineterminator='\n')
writer.writerow(('direc... | [
"def",
"write_summary",
"(",
"all_procs",
",",
"summary_file",
")",
":",
"if",
"not",
"summary_file",
":",
"return",
"with",
"summary_file",
":",
"writer",
"=",
"csv",
".",
"writer",
"(",
"summary_file",
",",
"delimiter",
"=",
"'\\t'",
",",
"lineterminator",
... | Write a summary of all run processes to summary_file in tab-delimited
format. | [
"Write",
"a",
"summary",
"of",
"all",
"run",
"processes",
"to",
"summary_file",
"in",
"tab",
"-",
"delimited",
"format",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L138-L152 |
fhcrc/nestly | nestly/scripts/nestrun.py | template_subs_file | def template_subs_file(in_file, out_fobj, d):
"""
Substitute template arguments in in_file from variables in d, write the
result to out_fobj.
"""
with open(in_file, 'r') as in_fobj:
for line in in_fobj:
out_fobj.write(line.format(**d)) | python | def template_subs_file(in_file, out_fobj, d):
"""
Substitute template arguments in in_file from variables in d, write the
result to out_fobj.
"""
with open(in_file, 'r') as in_fobj:
for line in in_fobj:
out_fobj.write(line.format(**d)) | [
"def",
"template_subs_file",
"(",
"in_file",
",",
"out_fobj",
",",
"d",
")",
":",
"with",
"open",
"(",
"in_file",
",",
"'r'",
")",
"as",
"in_fobj",
":",
"for",
"line",
"in",
"in_fobj",
":",
"out_fobj",
".",
"write",
"(",
"line",
".",
"format",
"(",
"... | Substitute template arguments in in_file from variables in d, write the
result to out_fobj. | [
"Substitute",
"template",
"arguments",
"in",
"in_file",
"from",
"variables",
"in",
"d",
"write",
"the",
"result",
"to",
"out_fobj",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L155-L162 |
fhcrc/nestly | nestly/scripts/nestrun.py | worker | def worker(data, json_file):
"""
Handle parameter substitution and execute command as child process.
"""
# PERHAPS TODO: Support either full or relative paths.
with open(json_file) as fp:
d = json.load(fp)
json_directory = os.path.dirname(json_file)
def p(*parts):
return os.p... | python | def worker(data, json_file):
"""
Handle parameter substitution and execute command as child process.
"""
# PERHAPS TODO: Support either full or relative paths.
with open(json_file) as fp:
d = json.load(fp)
json_directory = os.path.dirname(json_file)
def p(*parts):
return os.p... | [
"def",
"worker",
"(",
"data",
",",
"json_file",
")",
":",
"# PERHAPS TODO: Support either full or relative paths.",
"with",
"open",
"(",
"json_file",
")",
"as",
"fp",
":",
"d",
"=",
"json",
".",
"load",
"(",
"fp",
")",
"json_directory",
"=",
"os",
".",
"path... | Handle parameter substitution and execute command as child process. | [
"Handle",
"parameter",
"substitution",
"and",
"execute",
"command",
"as",
"child",
"process",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L212-L279 |
fhcrc/nestly | nestly/scripts/nestrun.py | extant_file | def extant_file(x):
"""
'Type' for argparse - checks that file exists but does not open.
"""
if not os.path.exists(x):
raise argparse.ArgumentError("{0} does not exist".format(x))
return x | python | def extant_file(x):
"""
'Type' for argparse - checks that file exists but does not open.
"""
if not os.path.exists(x):
raise argparse.ArgumentError("{0} does not exist".format(x))
return x | [
"def",
"extant_file",
"(",
"x",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"x",
")",
":",
"raise",
"argparse",
".",
"ArgumentError",
"(",
"\"{0} does not exist\"",
".",
"format",
"(",
"x",
")",
")",
"return",
"x"
] | 'Type' for argparse - checks that file exists but does not open. | [
"Type",
"for",
"argparse",
"-",
"checks",
"that",
"file",
"exists",
"but",
"does",
"not",
"open",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L282-L288 |
fhcrc/nestly | nestly/scripts/nestrun.py | parse_arguments | def parse_arguments():
"""
Grab options and json files.
"""
max_procs = MAX_PROCS
dry_run = DRY_RUN
logging.basicConfig(level=logging.INFO, stream=sys.stdout,
format='%(asctime)s * %(levelname)s * %(message)s')
parser = argparse.ArgumentParser(description="""nestrun ... | python | def parse_arguments():
"""
Grab options and json files.
"""
max_procs = MAX_PROCS
dry_run = DRY_RUN
logging.basicConfig(level=logging.INFO, stream=sys.stdout,
format='%(asctime)s * %(levelname)s * %(message)s')
parser = argparse.ArgumentParser(description="""nestrun ... | [
"def",
"parse_arguments",
"(",
")",
":",
"max_procs",
"=",
"MAX_PROCS",
"dry_run",
"=",
"DRY_RUN",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
",",
"stream",
"=",
"sys",
".",
"stdout",
",",
"format",
"=",
"'%(asctime)s * %(level... | Grab options and json files. | [
"Grab",
"options",
"and",
"json",
"files",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L291-L379 |
fhcrc/nestly | nestly/scripts/nestrun.py | NestlyProcess.complete | def complete(self, return_code):
"""
Mark the process as complete with provided return_code
"""
self.return_code = return_code
self.status = 'COMPLETE' if not return_code else 'FAILED'
self.end_time = datetime.datetime.now() | python | def complete(self, return_code):
"""
Mark the process as complete with provided return_code
"""
self.return_code = return_code
self.status = 'COMPLETE' if not return_code else 'FAILED'
self.end_time = datetime.datetime.now() | [
"def",
"complete",
"(",
"self",
",",
"return_code",
")",
":",
"self",
".",
"return_code",
"=",
"return_code",
"self",
".",
"status",
"=",
"'COMPLETE'",
"if",
"not",
"return_code",
"else",
"'FAILED'",
"self",
".",
"end_time",
"=",
"datetime",
".",
"datetime",... | Mark the process as complete with provided return_code | [
"Mark",
"the",
"process",
"as",
"complete",
"with",
"provided",
"return_code"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L186-L192 |
fhcrc/nestly | nestly/scripts/nestrun.py | NestlyProcess.log_tail | def log_tail(self, nlines=10):
"""
Return the last ``nlines`` lines of the log file
"""
log_path = os.path.join(self.working_dir, self.log_name)
with open(log_path) as fp:
d = collections.deque(maxlen=nlines)
d.extend(fp)
return ''.join(d) | python | def log_tail(self, nlines=10):
"""
Return the last ``nlines`` lines of the log file
"""
log_path = os.path.join(self.working_dir, self.log_name)
with open(log_path) as fp:
d = collections.deque(maxlen=nlines)
d.extend(fp)
return ''.join(d) | [
"def",
"log_tail",
"(",
"self",
",",
"nlines",
"=",
"10",
")",
":",
"log_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"self",
".",
"log_name",
")",
"with",
"open",
"(",
"log_path",
")",
"as",
"fp",
":",
"d",
"... | Return the last ``nlines`` lines of the log file | [
"Return",
"the",
"last",
"nlines",
"lines",
"of",
"the",
"log",
"file"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L201-L209 |
shaiguitar/snowclient.py | snowclient/client.py | Client.list | def list(self,table, **kparams):
"""
get a collection of records by table name.
returns a collection of SnowRecord obj.
"""
records = self.api.list(table, **kparams)
return records | python | def list(self,table, **kparams):
"""
get a collection of records by table name.
returns a collection of SnowRecord obj.
"""
records = self.api.list(table, **kparams)
return records | [
"def",
"list",
"(",
"self",
",",
"table",
",",
"*",
"*",
"kparams",
")",
":",
"records",
"=",
"self",
".",
"api",
".",
"list",
"(",
"table",
",",
"*",
"*",
"kparams",
")",
"return",
"records"
] | get a collection of records by table name.
returns a collection of SnowRecord obj. | [
"get",
"a",
"collection",
"of",
"records",
"by",
"table",
"name",
".",
"returns",
"a",
"collection",
"of",
"SnowRecord",
"obj",
"."
] | train | https://github.com/shaiguitar/snowclient.py/blob/6bb513576d3b37612a7a4da225140d134f3e1c82/snowclient/client.py#L10-L16 |
shaiguitar/snowclient.py | snowclient/client.py | Client.get | def get(self,table, sys_id):
"""
get a single record by table name and sys_id
returns a SnowRecord obj.
"""
record = self.api.get(table, sys_id)
return record | python | def get(self,table, sys_id):
"""
get a single record by table name and sys_id
returns a SnowRecord obj.
"""
record = self.api.get(table, sys_id)
return record | [
"def",
"get",
"(",
"self",
",",
"table",
",",
"sys_id",
")",
":",
"record",
"=",
"self",
".",
"api",
".",
"get",
"(",
"table",
",",
"sys_id",
")",
"return",
"record"
] | get a single record by table name and sys_id
returns a SnowRecord obj. | [
"get",
"a",
"single",
"record",
"by",
"table",
"name",
"and",
"sys_id",
"returns",
"a",
"SnowRecord",
"obj",
"."
] | train | https://github.com/shaiguitar/snowclient.py/blob/6bb513576d3b37612a7a4da225140d134f3e1c82/snowclient/client.py#L18-L24 |
shaiguitar/snowclient.py | snowclient/client.py | Client.update | def update(self,table, sys_id, **kparams):
"""
update a record via table api, kparams being the dict of PUT params to update.
returns a SnowRecord obj.
"""
record = self.api.update(table, sys_id, **kparams)
return record | python | def update(self,table, sys_id, **kparams):
"""
update a record via table api, kparams being the dict of PUT params to update.
returns a SnowRecord obj.
"""
record = self.api.update(table, sys_id, **kparams)
return record | [
"def",
"update",
"(",
"self",
",",
"table",
",",
"sys_id",
",",
"*",
"*",
"kparams",
")",
":",
"record",
"=",
"self",
".",
"api",
".",
"update",
"(",
"table",
",",
"sys_id",
",",
"*",
"*",
"kparams",
")",
"return",
"record"
] | update a record via table api, kparams being the dict of PUT params to update.
returns a SnowRecord obj. | [
"update",
"a",
"record",
"via",
"table",
"api",
"kparams",
"being",
"the",
"dict",
"of",
"PUT",
"params",
"to",
"update",
".",
"returns",
"a",
"SnowRecord",
"obj",
"."
] | train | https://github.com/shaiguitar/snowclient.py/blob/6bb513576d3b37612a7a4da225140d134f3e1c82/snowclient/client.py#L26-L32 |
yatiml/yatiml | yatiml/representers.py | Representer.__sweeten | def __sweeten(self, dumper: 'Dumper', class_: Type, node: Node) -> None:
"""Applies the user's yatiml_sweeten() function(s), if any.
Sweetening is done for the base classes first, then for the \
derived classes, down the hierarchy to the class we're \
constructing.
Args:
... | python | def __sweeten(self, dumper: 'Dumper', class_: Type, node: Node) -> None:
"""Applies the user's yatiml_sweeten() function(s), if any.
Sweetening is done for the base classes first, then for the \
derived classes, down the hierarchy to the class we're \
constructing.
Args:
... | [
"def",
"__sweeten",
"(",
"self",
",",
"dumper",
":",
"'Dumper'",
",",
"class_",
":",
"Type",
",",
"node",
":",
"Node",
")",
"->",
"None",
":",
"for",
"base_class",
"in",
"class_",
".",
"__bases__",
":",
"if",
"base_class",
"in",
"dumper",
".",
"yaml_re... | Applies the user's yatiml_sweeten() function(s), if any.
Sweetening is done for the base classes first, then for the \
derived classes, down the hierarchy to the class we're \
constructing.
Args:
dumper: The dumper that is dumping this object.
class_: The type o... | [
"Applies",
"the",
"user",
"s",
"yatiml_sweeten",
"()",
"function",
"(",
"s",
")",
"if",
"any",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/representers.py#L80-L98 |
henzk/django-productline | django_productline/startup.py | select_product | def select_product():
"""
binds the frozen context the selected features
should be called only once - calls after the first call have
no effect
"""
global _product_selected
if _product_selected:
# tss already bound ... ignore
return
_product_selected = True
from dja... | python | def select_product():
"""
binds the frozen context the selected features
should be called only once - calls after the first call have
no effect
"""
global _product_selected
if _product_selected:
# tss already bound ... ignore
return
_product_selected = True
from dja... | [
"def",
"select_product",
"(",
")",
":",
"global",
"_product_selected",
"if",
"_product_selected",
":",
"# tss already bound ... ignore",
"return",
"_product_selected",
"=",
"True",
"from",
"django_productline",
"import",
"context",
",",
"template",
"featuremonkey",
".",
... | binds the frozen context the selected features
should be called only once - calls after the first call have
no effect | [
"binds",
"the",
"frozen",
"context",
"the",
"selected",
"features"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/startup.py#L15-L59 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/entities.py | RDF_Entity.serialize | def serialize(self, format="turtle"):
""" xml, n3, turtle, nt, pretty-xml, trix are built in"""
if self.triples:
if not self.rdfgraph:
self._buildGraph()
return self.rdfgraph.serialize(format=format)
else:
return None | python | def serialize(self, format="turtle"):
""" xml, n3, turtle, nt, pretty-xml, trix are built in"""
if self.triples:
if not self.rdfgraph:
self._buildGraph()
return self.rdfgraph.serialize(format=format)
else:
return None | [
"def",
"serialize",
"(",
"self",
",",
"format",
"=",
"\"turtle\"",
")",
":",
"if",
"self",
".",
"triples",
":",
"if",
"not",
"self",
".",
"rdfgraph",
":",
"self",
".",
"_buildGraph",
"(",
")",
"return",
"self",
".",
"rdfgraph",
".",
"serialize",
"(",
... | xml, n3, turtle, nt, pretty-xml, trix are built in | [
"xml",
"n3",
"turtle",
"nt",
"pretty",
"-",
"xml",
"trix",
"are",
"built",
"in"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/entities.py#L49-L56 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/entities.py | RDF_Entity.bestLabel | def bestLabel(self, prefLanguage="en", qname_allowed=True, quotes=True):
"""
facility for extrating the best available label for an entity
..This checks RFDS.label, SKOS.prefLabel and finally the qname local component
"""
test = self.getValuesForProperty(rdflib.RDFS.label)
... | python | def bestLabel(self, prefLanguage="en", qname_allowed=True, quotes=True):
"""
facility for extrating the best available label for an entity
..This checks RFDS.label, SKOS.prefLabel and finally the qname local component
"""
test = self.getValuesForProperty(rdflib.RDFS.label)
... | [
"def",
"bestLabel",
"(",
"self",
",",
"prefLanguage",
"=",
"\"en\"",
",",
"qname_allowed",
"=",
"True",
",",
"quotes",
"=",
"True",
")",
":",
"test",
"=",
"self",
".",
"getValuesForProperty",
"(",
"rdflib",
".",
"RDFS",
".",
"label",
")",
"out",
"=",
"... | facility for extrating the best available label for an entity
..This checks RFDS.label, SKOS.prefLabel and finally the qname local component | [
"facility",
"for",
"extrating",
"the",
"best",
"available",
"label",
"for",
"an",
"entity"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/entities.py#L135-L158 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/entities.py | RDF_Entity.bestDescription | def bestDescription(self, prefLanguage="en"):
"""
facility for extrating the best available description for an entity
..This checks RFDS.label, SKOS.prefLabel and finally the qname local component
"""
test_preds = [rdflib.RDFS.comment, rdflib.namespace.DCTERMS.description, rdfl... | python | def bestDescription(self, prefLanguage="en"):
"""
facility for extrating the best available description for an entity
..This checks RFDS.label, SKOS.prefLabel and finally the qname local component
"""
test_preds = [rdflib.RDFS.comment, rdflib.namespace.DCTERMS.description, rdfl... | [
"def",
"bestDescription",
"(",
"self",
",",
"prefLanguage",
"=",
"\"en\"",
")",
":",
"test_preds",
"=",
"[",
"rdflib",
".",
"RDFS",
".",
"comment",
",",
"rdflib",
".",
"namespace",
".",
"DCTERMS",
".",
"description",
",",
"rdflib",
".",
"namespace",
".",
... | facility for extrating the best available description for an entity
..This checks RFDS.label, SKOS.prefLabel and finally the qname local component | [
"facility",
"for",
"extrating",
"the",
"best",
"available",
"description",
"for",
"an",
"entity"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/entities.py#L160-L174 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/entities.py | Ontology.stats | def stats(self):
""" shotcut to pull out useful info for interactive use """
printDebug("Classes.....: %d" % len(self.classes))
printDebug("Properties..: %d" % len(self.properties)) | python | def stats(self):
""" shotcut to pull out useful info for interactive use """
printDebug("Classes.....: %d" % len(self.classes))
printDebug("Properties..: %d" % len(self.properties)) | [
"def",
"stats",
"(",
"self",
")",
":",
"printDebug",
"(",
"\"Classes.....: %d\"",
"%",
"len",
"(",
"self",
".",
"classes",
")",
")",
"printDebug",
"(",
"\"Properties..: %d\"",
"%",
"len",
"(",
"self",
".",
"properties",
")",
")"
] | shotcut to pull out useful info for interactive use | [
"shotcut",
"to",
"pull",
"out",
"useful",
"info",
"for",
"interactive",
"use"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/entities.py#L214-L217 |
exa-analytics/exa | exa/util/utility.py | mkp | def mkp(*args, **kwargs):
"""
Generate a directory path, and create it if requested.
.. code-block:: Python
filepath = mkp('base', 'folder', 'file')
dirpath = mkp('root', 'path', 'folder', mk=True)
Args:
\*args: File or directory path segments to be concatenated
mk (bo... | python | def mkp(*args, **kwargs):
"""
Generate a directory path, and create it if requested.
.. code-block:: Python
filepath = mkp('base', 'folder', 'file')
dirpath = mkp('root', 'path', 'folder', mk=True)
Args:
\*args: File or directory path segments to be concatenated
mk (bo... | [
"def",
"mkp",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"mk",
"=",
"kwargs",
".",
"pop",
"(",
"'mk'",
",",
"False",
")",
"path",
"=",
"os",
".",
"sep",
".",
"join",
"(",
"list",
"(",
"args",
")",
")",
"if",
"mk",
":",
"while",
"s... | Generate a directory path, and create it if requested.
.. code-block:: Python
filepath = mkp('base', 'folder', 'file')
dirpath = mkp('root', 'path', 'folder', mk=True)
Args:
\*args: File or directory path segments to be concatenated
mk (bool): Make the directory (if it doesn't... | [
"Generate",
"a",
"directory",
"path",
"and",
"create",
"it",
"if",
"requested",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/util/utility.py#L27-L52 |
exa-analytics/exa | exa/util/utility.py | convert_bytes | def convert_bytes(value):
"""
Reduces bytes to more convenient units (i.e. KiB, GiB, TiB, etc.).
Args:
values (int): Value in Bytes
Returns:
tup (tuple): Tuple of value, unit (e.g. (10, 'MiB'))
"""
n = np.rint(len(str(value))/4).astype(int)
return value/(1024**n), sizes[n] | python | def convert_bytes(value):
"""
Reduces bytes to more convenient units (i.e. KiB, GiB, TiB, etc.).
Args:
values (int): Value in Bytes
Returns:
tup (tuple): Tuple of value, unit (e.g. (10, 'MiB'))
"""
n = np.rint(len(str(value))/4).astype(int)
return value/(1024**n), sizes[n] | [
"def",
"convert_bytes",
"(",
"value",
")",
":",
"n",
"=",
"np",
".",
"rint",
"(",
"len",
"(",
"str",
"(",
"value",
")",
")",
"/",
"4",
")",
".",
"astype",
"(",
"int",
")",
"return",
"value",
"/",
"(",
"1024",
"**",
"n",
")",
",",
"sizes",
"["... | Reduces bytes to more convenient units (i.e. KiB, GiB, TiB, etc.).
Args:
values (int): Value in Bytes
Returns:
tup (tuple): Tuple of value, unit (e.g. (10, 'MiB')) | [
"Reduces",
"bytes",
"to",
"more",
"convenient",
"units",
"(",
"i",
".",
"e",
".",
"KiB",
"GiB",
"TiB",
"etc",
".",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/util/utility.py#L55-L66 |
exa-analytics/exa | exa/util/utility.py | get_internal_modules | def get_internal_modules(key='exa'):
"""
Get a list of modules belonging to the given package.
Args:
key (str): Package or library name (e.g. "exa")
"""
key += '.'
return [v for k, v in sys.modules.items() if k.startswith(key)] | python | def get_internal_modules(key='exa'):
"""
Get a list of modules belonging to the given package.
Args:
key (str): Package or library name (e.g. "exa")
"""
key += '.'
return [v for k, v in sys.modules.items() if k.startswith(key)] | [
"def",
"get_internal_modules",
"(",
"key",
"=",
"'exa'",
")",
":",
"key",
"+=",
"'.'",
"return",
"[",
"v",
"for",
"k",
",",
"v",
"in",
"sys",
".",
"modules",
".",
"items",
"(",
")",
"if",
"k",
".",
"startswith",
"(",
"key",
")",
"]"
] | Get a list of modules belonging to the given package.
Args:
key (str): Package or library name (e.g. "exa") | [
"Get",
"a",
"list",
"of",
"modules",
"belonging",
"to",
"the",
"given",
"package",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/util/utility.py#L69-L77 |
shimpe/pyvectortween | vectortween/ParametricAnimation.py | ParametricAnimation.make_frame | def make_frame(self, frame, birthframe, startframe, stopframe, deathframe, noiseframe=None):
"""
animation happens between startframe and stopframe
the value is None before aliveframe, and after deathframe
* if aliveframe is not specified it defaults to startframe
* if deathfra... | python | def make_frame(self, frame, birthframe, startframe, stopframe, deathframe, noiseframe=None):
"""
animation happens between startframe and stopframe
the value is None before aliveframe, and after deathframe
* if aliveframe is not specified it defaults to startframe
* if deathfra... | [
"def",
"make_frame",
"(",
"self",
",",
"frame",
",",
"birthframe",
",",
"startframe",
",",
"stopframe",
",",
"deathframe",
",",
"noiseframe",
"=",
"None",
")",
":",
"if",
"birthframe",
"is",
"None",
":",
"birthframe",
"=",
"startframe",
"if",
"deathframe",
... | animation happens between startframe and stopframe
the value is None before aliveframe, and after deathframe
* if aliveframe is not specified it defaults to startframe
* if deathframe is not specified it defaults to stopframe
initial value is held from aliveframe to startframe
... | [
"animation",
"happens",
"between",
"startframe",
"and",
"stopframe",
"the",
"value",
"is",
"None",
"before",
"aliveframe",
"and",
"after",
"deathframe",
"*",
"if",
"aliveframe",
"is",
"not",
"specified",
"it",
"defaults",
"to",
"startframe",
"*",
"if",
"deathfra... | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/ParametricAnimation.py#L95-L130 |
dlancer/django-crispy-contact-form | contact_form/helpers.py | get_user_ip | def get_user_ip(request):
"""Return user ip
:param request: Django request object
:return: user ip
"""
ip = get_real_ip(request)
if ip is None:
ip = get_ip(request)
if ip is None:
ip = '127.0.0.1'
return ip | python | def get_user_ip(request):
"""Return user ip
:param request: Django request object
:return: user ip
"""
ip = get_real_ip(request)
if ip is None:
ip = get_ip(request)
if ip is None:
ip = '127.0.0.1'
return ip | [
"def",
"get_user_ip",
"(",
"request",
")",
":",
"ip",
"=",
"get_real_ip",
"(",
"request",
")",
"if",
"ip",
"is",
"None",
":",
"ip",
"=",
"get_ip",
"(",
"request",
")",
"if",
"ip",
"is",
"None",
":",
"ip",
"=",
"'127.0.0.1'",
"return",
"ip"
] | Return user ip
:param request: Django request object
:return: user ip | [
"Return",
"user",
"ip"
] | train | https://github.com/dlancer/django-crispy-contact-form/blob/3d422556add5aea3607344a034779c214f84da04/contact_form/helpers.py#L8-L19 |
ionelmc/python-cogen | examples/cogen-chat/ChatApp/chatapp/config/environment.py | load_environment | def load_environment(global_conf, app_conf):
"""Configure the Pylons environment via the ``pylons.config``
object
"""
# Pylons paths
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
paths = dict(root=root,
controllers=os.path.join(root, 'controllers'),
... | python | def load_environment(global_conf, app_conf):
"""Configure the Pylons environment via the ``pylons.config``
object
"""
# Pylons paths
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
paths = dict(root=root,
controllers=os.path.join(root, 'controllers'),
... | [
"def",
"load_environment",
"(",
"global_conf",
",",
"app_conf",
")",
":",
"# Pylons paths\r",
"root",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
")"... | Configure the Pylons environment via the ``pylons.config``
object | [
"Configure",
"the",
"Pylons",
"environment",
"via",
"the",
"pylons",
".",
"config",
"object"
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-chat/ChatApp/chatapp/config/environment.py#L10-L34 |
DavidMStraub/ckmutil | ckmutil/diag.py | msvd | def msvd(m):
"""Modified singular value decomposition.
Returns U, S, V where Udagger M V = diag(S) and the singular values
are sorted in ascending order (small to large).
"""
u, s, vdgr = np.linalg.svd(m)
order = s.argsort()
# reverse the n first columns of u
s = s[order]
u= u[:,order]
vdgr = vdgr[... | python | def msvd(m):
"""Modified singular value decomposition.
Returns U, S, V where Udagger M V = diag(S) and the singular values
are sorted in ascending order (small to large).
"""
u, s, vdgr = np.linalg.svd(m)
order = s.argsort()
# reverse the n first columns of u
s = s[order]
u= u[:,order]
vdgr = vdgr[... | [
"def",
"msvd",
"(",
"m",
")",
":",
"u",
",",
"s",
",",
"vdgr",
"=",
"np",
".",
"linalg",
".",
"svd",
"(",
"m",
")",
"order",
"=",
"s",
".",
"argsort",
"(",
")",
"# reverse the n first columns of u",
"s",
"=",
"s",
"[",
"order",
"]",
"u",
"=",
"... | Modified singular value decomposition.
Returns U, S, V where Udagger M V = diag(S) and the singular values
are sorted in ascending order (small to large). | [
"Modified",
"singular",
"value",
"decomposition",
"."
] | train | https://github.com/DavidMStraub/ckmutil/blob/b6e9cf368c18f2dbc7c8a6ce01242c2f5b58207a/ckmutil/diag.py#L5-L17 |
DavidMStraub/ckmutil | ckmutil/diag.py | mtakfac | def mtakfac(m):
"""Modified Takagi factorization of a (complex) symmetric matrix.
Returns U, S where U^T M U = diag(S) and the singular values
are sorted in ascending order (small to large).
"""
u, s, v = msvd(np.asarray(m, dtype=complex))
f = np.sqrt(u.conj().T @ v.conj())
w = v @ f
return w, s | python | def mtakfac(m):
"""Modified Takagi factorization of a (complex) symmetric matrix.
Returns U, S where U^T M U = diag(S) and the singular values
are sorted in ascending order (small to large).
"""
u, s, v = msvd(np.asarray(m, dtype=complex))
f = np.sqrt(u.conj().T @ v.conj())
w = v @ f
return w, s | [
"def",
"mtakfac",
"(",
"m",
")",
":",
"u",
",",
"s",
",",
"v",
"=",
"msvd",
"(",
"np",
".",
"asarray",
"(",
"m",
",",
"dtype",
"=",
"complex",
")",
")",
"f",
"=",
"np",
".",
"sqrt",
"(",
"u",
".",
"conj",
"(",
")",
".",
"T",
"@",
"v",
"... | Modified Takagi factorization of a (complex) symmetric matrix.
Returns U, S where U^T M U = diag(S) and the singular values
are sorted in ascending order (small to large). | [
"Modified",
"Takagi",
"factorization",
"of",
"a",
"(",
"complex",
")",
"symmetric",
"matrix",
"."
] | train | https://github.com/DavidMStraub/ckmutil/blob/b6e9cf368c18f2dbc7c8a6ce01242c2f5b58207a/ckmutil/diag.py#L20-L29 |
pycrest/PyCrest | pycrest/eve.py | APIConnection._parse_parameters | def _parse_parameters(self, resource, params):
'''Creates a dictionary from query_string and `params`
Transforms the `?key=value&...` to a {'key': 'value'} and adds
(or overwrites if already present) the value with the dictionary in
`params`.
'''
# remove params from res... | python | def _parse_parameters(self, resource, params):
'''Creates a dictionary from query_string and `params`
Transforms the `?key=value&...` to a {'key': 'value'} and adds
(or overwrites if already present) the value with the dictionary in
`params`.
'''
# remove params from res... | [
"def",
"_parse_parameters",
"(",
"self",
",",
"resource",
",",
"params",
")",
":",
"# remove params from resource URI (needed for paginated stuff)",
"parsed_uri",
"=",
"urlparse",
"(",
"resource",
")",
"qs",
"=",
"parsed_uri",
".",
"query",
"resource",
"=",
"urlunpars... | Creates a dictionary from query_string and `params`
Transforms the `?key=value&...` to a {'key': 'value'} and adds
(or overwrites if already present) the value with the dictionary in
`params`. | [
"Creates",
"a",
"dictionary",
"from",
"query_string",
"and",
"params"
] | train | https://github.com/pycrest/PyCrest/blob/5c43899b5a0c6fda7a6441233a571bd04fa6b82f/pycrest/eve.py#L69-L87 |
moonso/vcftoolbox | vcftoolbox/parse_variant.py | get_variant_dict | def get_variant_dict(variant_line, header_line=None):
"""Parse a variant line
Split a variant line and map the fields on the header columns
Args:
variant_line (str): A vcf variant line
header_line (list): A list with the header columns
Returns:
... | python | def get_variant_dict(variant_line, header_line=None):
"""Parse a variant line
Split a variant line and map the fields on the header columns
Args:
variant_line (str): A vcf variant line
header_line (list): A list with the header columns
Returns:
... | [
"def",
"get_variant_dict",
"(",
"variant_line",
",",
"header_line",
"=",
"None",
")",
":",
"if",
"not",
"header_line",
":",
"logger",
".",
"debug",
"(",
"\"No header line, use only first 8 mandatory fields\"",
")",
"header_line",
"=",
"[",
"'CHROM'",
",",
"'POS'",
... | Parse a variant line
Split a variant line and map the fields on the header columns
Args:
variant_line (str): A vcf variant line
header_line (list): A list with the header columns
Returns:
variant_dict (dict): A variant dictionary | [
"Parse",
"a",
"variant",
"line",
"Split",
"a",
"variant",
"line",
"and",
"map",
"the",
"fields",
"on",
"the",
"header",
"columns",
"Args",
":",
"variant_line",
"(",
"str",
")",
":",
"A",
"vcf",
"variant",
"line",
"header_line",
"(",
"list",
")",
":",
"... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/parse_variant.py#L7-L32 |
moonso/vcftoolbox | vcftoolbox/parse_variant.py | get_info_dict | def get_info_dict(info_line):
"""Parse a info field of a variant
Make a dictionary from the info field of a vcf variant.
Keys are the info keys and values are the raw strings from the vcf
If the field only have a key (no value), value of infodict is True.
Args:
... | python | def get_info_dict(info_line):
"""Parse a info field of a variant
Make a dictionary from the info field of a vcf variant.
Keys are the info keys and values are the raw strings from the vcf
If the field only have a key (no value), value of infodict is True.
Args:
... | [
"def",
"get_info_dict",
"(",
"info_line",
")",
":",
"variant_info",
"=",
"{",
"}",
"for",
"raw_info",
"in",
"info_line",
".",
"split",
"(",
"';'",
")",
":",
"splitted_info",
"=",
"raw_info",
".",
"split",
"(",
"'='",
")",
"if",
"len",
"(",
"splitted_info... | Parse a info field of a variant
Make a dictionary from the info field of a vcf variant.
Keys are the info keys and values are the raw strings from the vcf
If the field only have a key (no value), value of infodict is True.
Args:
info_line (str): The info fie... | [
"Parse",
"a",
"info",
"field",
"of",
"a",
"variant",
"Make",
"a",
"dictionary",
"from",
"the",
"info",
"field",
"of",
"a",
"vcf",
"variant",
".",
"Keys",
"are",
"the",
"info",
"keys",
"and",
"values",
"are",
"the",
"raw",
"strings",
"from",
"the",
"vcf... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/parse_variant.py#L34-L55 |
moonso/vcftoolbox | vcftoolbox/parse_variant.py | get_variant_id | def get_variant_id(variant_dict=None, variant_line=None):
"""Build a variant id
The variant id is a string made of CHROM_POS_REF_ALT
Args:
variant_dict (dict): A variant dictionary
Returns:
variant_id (str)
"""
if variant_dict:
... | python | def get_variant_id(variant_dict=None, variant_line=None):
"""Build a variant id
The variant id is a string made of CHROM_POS_REF_ALT
Args:
variant_dict (dict): A variant dictionary
Returns:
variant_id (str)
"""
if variant_dict:
... | [
"def",
"get_variant_id",
"(",
"variant_dict",
"=",
"None",
",",
"variant_line",
"=",
"None",
")",
":",
"if",
"variant_dict",
":",
"chrom",
"=",
"variant_dict",
"[",
"'CHROM'",
"]",
"position",
"=",
"variant_dict",
"[",
"'POS'",
"]",
"ref",
"=",
"variant_dict... | Build a variant id
The variant id is a string made of CHROM_POS_REF_ALT
Args:
variant_dict (dict): A variant dictionary
Returns:
variant_id (str) | [
"Build",
"a",
"variant",
"id",
"The",
"variant",
"id",
"is",
"a",
"string",
"made",
"of",
"CHROM_POS_REF_ALT",
"Args",
":",
"variant_dict",
"(",
"dict",
")",
":",
"A",
"variant",
"dictionary",
"Returns",
":",
"variant_id",
"(",
"str",
")"
] | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/parse_variant.py#L57-L88 |
moonso/vcftoolbox | vcftoolbox/parse_variant.py | get_vep_info | def get_vep_info(vep_string, vep_header):
"""Make the vep annotations into a dictionaries
A vep dictionary will have the vep column names as keys and
the vep annotations as values.
The dictionaries are stored in a list
Args:
vep_string (string): A string with the C... | python | def get_vep_info(vep_string, vep_header):
"""Make the vep annotations into a dictionaries
A vep dictionary will have the vep column names as keys and
the vep annotations as values.
The dictionaries are stored in a list
Args:
vep_string (string): A string with the C... | [
"def",
"get_vep_info",
"(",
"vep_string",
",",
"vep_header",
")",
":",
"vep_annotations",
"=",
"[",
"dict",
"(",
"zip",
"(",
"vep_header",
",",
"vep_annotation",
".",
"split",
"(",
"'|'",
")",
")",
")",
"for",
"vep_annotation",
"in",
"vep_string",
".",
"sp... | Make the vep annotations into a dictionaries
A vep dictionary will have the vep column names as keys and
the vep annotations as values.
The dictionaries are stored in a list
Args:
vep_string (string): A string with the CSQ annotation
vep_header (list): A li... | [
"Make",
"the",
"vep",
"annotations",
"into",
"a",
"dictionaries",
"A",
"vep",
"dictionary",
"will",
"have",
"the",
"vep",
"column",
"names",
"as",
"keys",
"and",
"the",
"vep",
"annotations",
"as",
"values",
".",
"The",
"dictionaries",
"are",
"stored",
"in",
... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/parse_variant.py#L90-L111 |
moonso/vcftoolbox | vcftoolbox/parse_variant.py | get_snpeff_info | def get_snpeff_info(snpeff_string, snpeff_header):
"""Make the vep annotations into a dictionaries
A snpeff dictionary will have the snpeff column names as keys and
the vep annotations as values.
The dictionaries are stored in a list.
One dictionary for each transcript.
... | python | def get_snpeff_info(snpeff_string, snpeff_header):
"""Make the vep annotations into a dictionaries
A snpeff dictionary will have the snpeff column names as keys and
the vep annotations as values.
The dictionaries are stored in a list.
One dictionary for each transcript.
... | [
"def",
"get_snpeff_info",
"(",
"snpeff_string",
",",
"snpeff_header",
")",
":",
"snpeff_annotations",
"=",
"[",
"dict",
"(",
"zip",
"(",
"snpeff_header",
",",
"snpeff_annotation",
".",
"split",
"(",
"'|'",
")",
")",
")",
"for",
"snpeff_annotation",
"in",
"snpe... | Make the vep annotations into a dictionaries
A snpeff dictionary will have the snpeff column names as keys and
the vep annotations as values.
The dictionaries are stored in a list.
One dictionary for each transcript.
Args:
snpeff_string (string): A string with... | [
"Make",
"the",
"vep",
"annotations",
"into",
"a",
"dictionaries",
"A",
"snpeff",
"dictionary",
"will",
"have",
"the",
"snpeff",
"column",
"names",
"as",
"keys",
"and",
"the",
"vep",
"annotations",
"as",
"values",
".",
"The",
"dictionaries",
"are",
"stored",
... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/parse_variant.py#L113-L135 |
ionelmc/python-cogen | cogen/core/proactors/kqueue_impl.py | KQueueProactor.run | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
kqueue timeout param is a integer number of nanoseconds (seconds/10**9).
"""
ptimeout = int(
timeout.days*86400... | python | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
kqueue timeout param is a integer number of nanoseconds (seconds/10**9).
"""
ptimeout = int(
timeout.days*86400... | [
"def",
"run",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"ptimeout",
"=",
"int",
"(",
"timeout",
".",
"days",
"*",
"86400000000000",
"+",
"timeout",
".",
"microseconds",
"*",
"1000",
"+",
"timeout",
".",
"seconds",
"*",
"1000000000",
"if",
"timeo... | Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
kqueue timeout param is a integer number of nanoseconds (seconds/10**9). | [
"Run",
"a",
"proactor",
"loop",
"and",
"return",
"new",
"socket",
"events",
".",
"Timeout",
"is",
"a",
"timedelta",
"object",
"0",
"if",
"active",
"coros",
"or",
"None",
".",
"kqueue",
"timeout",
"param",
"is",
"a",
"integer",
"number",
"of",
"nanoseconds"... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/kqueue_impl.py#L37-L76 |
duboviy/pybenchmark | pybenchmark/profile.py | profile | def profile(name='stats', _stats=stats):
"""Calculates a duration (wall clock time, not the CPU time) and a memory size."""
def _profile(function):
def __profile(*args, **kw):
start_time = timer()
start_memory = _get_memory_usage()
try:
return function... | python | def profile(name='stats', _stats=stats):
"""Calculates a duration (wall clock time, not the CPU time) and a memory size."""
def _profile(function):
def __profile(*args, **kw):
start_time = timer()
start_memory = _get_memory_usage()
try:
return function... | [
"def",
"profile",
"(",
"name",
"=",
"'stats'",
",",
"_stats",
"=",
"stats",
")",
":",
"def",
"_profile",
"(",
"function",
")",
":",
"def",
"__profile",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"start_time",
"=",
"timer",
"(",
")",
"start_me... | Calculates a duration (wall clock time, not the CPU time) and a memory size. | [
"Calculates",
"a",
"duration",
"(",
"wall",
"clock",
"time",
"not",
"the",
"CPU",
"time",
")",
"and",
"a",
"memory",
"size",
"."
] | train | https://github.com/duboviy/pybenchmark/blob/750841faebf89292ffcc5a6c15f9f909cf36fdb9/pybenchmark/profile.py#L17-L33 |
SetBased/py-etlt | etlt/condition/RegularExpressionCondition.py | RegularExpressionCondition.match | def match(self, row):
"""
Returns True if the field matches the regular expression of this simple condition. Returns False otherwise.
:param dict row: The row.
:rtype: bool
"""
if re.search(self._expression, row[self._field]):
return True
return Fal... | python | def match(self, row):
"""
Returns True if the field matches the regular expression of this simple condition. Returns False otherwise.
:param dict row: The row.
:rtype: bool
"""
if re.search(self._expression, row[self._field]):
return True
return Fal... | [
"def",
"match",
"(",
"self",
",",
"row",
")",
":",
"if",
"re",
".",
"search",
"(",
"self",
".",
"_expression",
",",
"row",
"[",
"self",
".",
"_field",
"]",
")",
":",
"return",
"True",
"return",
"False"
] | Returns True if the field matches the regular expression of this simple condition. Returns False otherwise.
:param dict row: The row.
:rtype: bool | [
"Returns",
"True",
"if",
"the",
"field",
"matches",
"the",
"regular",
"expression",
"of",
"this",
"simple",
"condition",
".",
"Returns",
"False",
"otherwise",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/condition/RegularExpressionCondition.py#L19-L30 |
sandipbgt/theastrologer | theastrologer/__init__.py | Horoscope._get_horoscope | def _get_horoscope(self, day='today'):
"""gets a horoscope from site html
:param day: day for which to get horoscope. Default is 'today'
:returns: dictionary of horoscope details
"""
if not is_valid_day(day):
raise HoroscopeException("Invalid day. Allowed days: [tod... | python | def _get_horoscope(self, day='today'):
"""gets a horoscope from site html
:param day: day for which to get horoscope. Default is 'today'
:returns: dictionary of horoscope details
"""
if not is_valid_day(day):
raise HoroscopeException("Invalid day. Allowed days: [tod... | [
"def",
"_get_horoscope",
"(",
"self",
",",
"day",
"=",
"'today'",
")",
":",
"if",
"not",
"is_valid_day",
"(",
"day",
")",
":",
"raise",
"HoroscopeException",
"(",
"\"Invalid day. Allowed days: [today|yesterday|tomorrow]\"",
")",
"horoscope",
"=",
"''",
".",
"join"... | gets a horoscope from site html
:param day: day for which to get horoscope. Default is 'today'
:returns: dictionary of horoscope details | [
"gets",
"a",
"horoscope",
"from",
"site",
"html"
] | train | https://github.com/sandipbgt/theastrologer/blob/bcf50234bf65ab26a29b11f19266c3d9052d4550/theastrologer/__init__.py#L76-L101 |
sandipbgt/theastrologer | theastrologer/__init__.py | Horoscope._get_horoscope_meta | def _get_horoscope_meta(self, day='today'):
"""gets a horoscope meta from site html
:param day: day for which to get horoscope meta. Default is 'today'
:returns: dictionary of horoscope mood details
"""
if not is_valid_day(day):
raise HoroscopeException("Invalid day... | python | def _get_horoscope_meta(self, day='today'):
"""gets a horoscope meta from site html
:param day: day for which to get horoscope meta. Default is 'today'
:returns: dictionary of horoscope mood details
"""
if not is_valid_day(day):
raise HoroscopeException("Invalid day... | [
"def",
"_get_horoscope_meta",
"(",
"self",
",",
"day",
"=",
"'today'",
")",
":",
"if",
"not",
"is_valid_day",
"(",
"day",
")",
":",
"raise",
"HoroscopeException",
"(",
"\"Invalid day. Allowed days: [today|yesterday|tomorrow]\"",
")",
"return",
"{",
"'intensity'",
":... | gets a horoscope meta from site html
:param day: day for which to get horoscope meta. Default is 'today'
:returns: dictionary of horoscope mood details | [
"gets",
"a",
"horoscope",
"meta",
"from",
"site",
"html"
] | train | https://github.com/sandipbgt/theastrologer/blob/bcf50234bf65ab26a29b11f19266c3d9052d4550/theastrologer/__init__.py#L103-L117 |
ionelmc/python-cogen | cogen/core/events.py | heapremove | def heapremove(heap,item):
"""
Removes item from heap.
(This function is missing from the standard heapq package.)
"""
i=heap.index(item)
lastelt=heap.pop()
if item==lastelt:
return
heap[i]=lastelt
heapq._siftup(heap,i)
if i:
heapq._siftdown(heap,0,i) | python | def heapremove(heap,item):
"""
Removes item from heap.
(This function is missing from the standard heapq package.)
"""
i=heap.index(item)
lastelt=heap.pop()
if item==lastelt:
return
heap[i]=lastelt
heapq._siftup(heap,i)
if i:
heapq._siftdown(heap,0,i) | [
"def",
"heapremove",
"(",
"heap",
",",
"item",
")",
":",
"i",
"=",
"heap",
".",
"index",
"(",
"item",
")",
"lastelt",
"=",
"heap",
".",
"pop",
"(",
")",
"if",
"item",
"==",
"lastelt",
":",
"return",
"heap",
"[",
"i",
"]",
"=",
"lastelt",
"heapq",... | Removes item from heap.
(This function is missing from the standard heapq package.) | [
"Removes",
"item",
"from",
"heap",
".",
"(",
"This",
"function",
"is",
"missing",
"from",
"the",
"standard",
"heapq",
"package",
".",
")"
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L89-L101 |
ionelmc/python-cogen | cogen/core/events.py | Operation.process | def process(self, sched, coro):
"""This is called when the operation is to be processed by the
scheduler. Code here works modifies the scheduler and it's usualy
very crafty. Subclasses usualy overwrite this method and call it from
the superclass."""
if self.prio == priorit... | python | def process(self, sched, coro):
"""This is called when the operation is to be processed by the
scheduler. Code here works modifies the scheduler and it's usualy
very crafty. Subclasses usualy overwrite this method and call it from
the superclass."""
if self.prio == priorit... | [
"def",
"process",
"(",
"self",
",",
"sched",
",",
"coro",
")",
":",
"if",
"self",
".",
"prio",
"==",
"priority",
".",
"DEFAULT",
":",
"self",
".",
"prio",
"=",
"sched",
".",
"default_priority"
] | This is called when the operation is to be processed by the
scheduler. Code here works modifies the scheduler and it's usualy
very crafty. Subclasses usualy overwrite this method and call it from
the superclass. | [
"This",
"is",
"called",
"when",
"the",
"operation",
"is",
"to",
"be",
"processed",
"by",
"the",
"scheduler",
".",
"Code",
"here",
"works",
"modifies",
"the",
"scheduler",
"and",
"it",
"s",
"usualy",
"very",
"crafty",
".",
"Subclasses",
"usualy",
"overwrite",... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L60-L67 |
ionelmc/python-cogen | cogen/core/events.py | TimedOperation.process | def process(self, sched, coro):
"""Add the timeout in the scheduler, check for defaults."""
super(TimedOperation, self).process(sched, coro)
if sched.default_timeout and not self.timeout:
self.set_timeout(sched.default_timeout)
if self.timeout and self.timeout != -1:
... | python | def process(self, sched, coro):
"""Add the timeout in the scheduler, check for defaults."""
super(TimedOperation, self).process(sched, coro)
if sched.default_timeout and not self.timeout:
self.set_timeout(sched.default_timeout)
if self.timeout and self.timeout != -1:
... | [
"def",
"process",
"(",
"self",
",",
"sched",
",",
"coro",
")",
":",
"super",
"(",
"TimedOperation",
",",
"self",
")",
".",
"process",
"(",
"sched",
",",
"coro",
")",
"if",
"sched",
".",
"default_timeout",
"and",
"not",
"self",
".",
"timeout",
":",
"s... | Add the timeout in the scheduler, check for defaults. | [
"Add",
"the",
"timeout",
"in",
"the",
"scheduler",
"check",
"for",
"defaults",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L144-L159 |
ionelmc/python-cogen | cogen/core/events.py | WaitForSignal.process | def process(self, sched, coro):
"""Add the calling coro in a waiting for signal queue."""
super(WaitForSignal, self).process(sched, coro)
waitlist = sched.sigwait[self.name]
waitlist.append((self, coro))
if self.name in sched.signals:
sig = sched.signals[self.na... | python | def process(self, sched, coro):
"""Add the calling coro in a waiting for signal queue."""
super(WaitForSignal, self).process(sched, coro)
waitlist = sched.sigwait[self.name]
waitlist.append((self, coro))
if self.name in sched.signals:
sig = sched.signals[self.na... | [
"def",
"process",
"(",
"self",
",",
"sched",
",",
"coro",
")",
":",
"super",
"(",
"WaitForSignal",
",",
"self",
")",
".",
"process",
"(",
"sched",
",",
"coro",
")",
"waitlist",
"=",
"sched",
".",
"sigwait",
"[",
"self",
".",
"name",
"]",
"waitlist",
... | Add the calling coro in a waiting for signal queue. | [
"Add",
"the",
"calling",
"coro",
"in",
"a",
"waiting",
"for",
"signal",
"queue",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L206-L216 |
ionelmc/python-cogen | cogen/core/events.py | WaitForSignal.cleanup | def cleanup(self, sched, coro):
"""Remove this coro from the waiting for signal queue."""
try:
sched.sigwait[self.name].remove((self, coro))
except ValueError:
pass
return True | python | def cleanup(self, sched, coro):
"""Remove this coro from the waiting for signal queue."""
try:
sched.sigwait[self.name].remove((self, coro))
except ValueError:
pass
return True | [
"def",
"cleanup",
"(",
"self",
",",
"sched",
",",
"coro",
")",
":",
"try",
":",
"sched",
".",
"sigwait",
"[",
"self",
".",
"name",
"]",
".",
"remove",
"(",
"(",
"self",
",",
"coro",
")",
")",
"except",
"ValueError",
":",
"pass",
"return",
"True"
] | Remove this coro from the waiting for signal queue. | [
"Remove",
"this",
"coro",
"from",
"the",
"waiting",
"for",
"signal",
"queue",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L222-L228 |
ionelmc/python-cogen | cogen/core/events.py | Signal.process | def process(self, sched, coro):
"""If there aren't enough coroutines waiting for the signal as the
recipicient param add the calling coro in another queue to be activated
later, otherwise activate the waiting coroutines."""
super(Signal, self).process(sched, coro)
self.resul... | python | def process(self, sched, coro):
"""If there aren't enough coroutines waiting for the signal as the
recipicient param add the calling coro in another queue to be activated
later, otherwise activate the waiting coroutines."""
super(Signal, self).process(sched, coro)
self.resul... | [
"def",
"process",
"(",
"self",
",",
"sched",
",",
"coro",
")",
":",
"super",
"(",
"Signal",
",",
"self",
")",
".",
"process",
"(",
"sched",
",",
"coro",
")",
"self",
".",
"result",
"=",
"len",
"(",
"sched",
".",
"sigwait",
"[",
"self",
".",
"name... | If there aren't enough coroutines waiting for the signal as the
recipicient param add the calling coro in another queue to be activated
later, otherwise activate the waiting coroutines. | [
"If",
"there",
"aren",
"t",
"enough",
"coroutines",
"waiting",
"for",
"the",
"signal",
"as",
"the",
"recipicient",
"param",
"add",
"the",
"calling",
"coro",
"in",
"another",
"queue",
"to",
"be",
"activated",
"later",
"otherwise",
"activate",
"the",
"waiting",
... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L272-L295 |
ionelmc/python-cogen | cogen/core/events.py | AddCoro.finalize | def finalize(self, sched):
"""Return a reference to the instance of the newly added coroutine."""
super(AddCoro, self).finalize(sched)
return self.result | python | def finalize(self, sched):
"""Return a reference to the instance of the newly added coroutine."""
super(AddCoro, self).finalize(sched)
return self.result | [
"def",
"finalize",
"(",
"self",
",",
"sched",
")",
":",
"super",
"(",
"AddCoro",
",",
"self",
")",
".",
"finalize",
"(",
"sched",
")",
"return",
"self",
".",
"result"
] | Return a reference to the instance of the newly added coroutine. | [
"Return",
"a",
"reference",
"to",
"the",
"instance",
"of",
"the",
"newly",
"added",
"coroutine",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L318-L321 |
ionelmc/python-cogen | cogen/core/events.py | AddCoro.process | def process(self, sched, coro):
"""Add the given coroutine in the scheduler."""
super(AddCoro, self).process(sched, coro)
self.result = sched.add(self.coro, self.args, self.kwargs, self.prio & priority.OP)
if self.prio & priority.CORO:
return self, coro
else:
... | python | def process(self, sched, coro):
"""Add the given coroutine in the scheduler."""
super(AddCoro, self).process(sched, coro)
self.result = sched.add(self.coro, self.args, self.kwargs, self.prio & priority.OP)
if self.prio & priority.CORO:
return self, coro
else:
... | [
"def",
"process",
"(",
"self",
",",
"sched",
",",
"coro",
")",
":",
"super",
"(",
"AddCoro",
",",
"self",
")",
".",
"process",
"(",
"sched",
",",
"coro",
")",
"self",
".",
"result",
"=",
"sched",
".",
"add",
"(",
"self",
".",
"coro",
",",
"self",... | Add the given coroutine in the scheduler. | [
"Add",
"the",
"given",
"coroutine",
"in",
"the",
"scheduler",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L323-L330 |
ionelmc/python-cogen | cogen/core/events.py | Join.process | def process(self, sched, coro):
"""Add the calling coroutine as a waiter in the coro we want to join.
Also, doesn't keep the called active (we'll be activated back when the
joined coro dies)."""
super(Join, self).process(sched, coro)
self.coro.add_waiter(coro) | python | def process(self, sched, coro):
"""Add the calling coroutine as a waiter in the coro we want to join.
Also, doesn't keep the called active (we'll be activated back when the
joined coro dies)."""
super(Join, self).process(sched, coro)
self.coro.add_waiter(coro) | [
"def",
"process",
"(",
"self",
",",
"sched",
",",
"coro",
")",
":",
"super",
"(",
"Join",
",",
"self",
")",
".",
"process",
"(",
"sched",
",",
"coro",
")",
"self",
".",
"coro",
".",
"add_waiter",
"(",
"coro",
")"
] | Add the calling coroutine as a waiter in the coro we want to join.
Also, doesn't keep the called active (we'll be activated back when the
joined coro dies). | [
"Add",
"the",
"calling",
"coroutine",
"as",
"a",
"waiter",
"in",
"the",
"coro",
"we",
"want",
"to",
"join",
".",
"Also",
"doesn",
"t",
"keep",
"the",
"called",
"active",
"(",
"we",
"ll",
"be",
"activated",
"back",
"when",
"the",
"joined",
"coro",
"dies... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L370-L375 |
shimpe/pyvectortween | vectortween/Animation.py | AbstractAnimation.curve_points | def curve_points(self, beginframe, endframe, framestep, birthframe, startframe, stopframe, deathframe,
filternone=False, noiseframe=None):
"""
returns a list of frames from startframe to stopframe, in steps of framestep
:param beginframe: first frame to include in list of po... | python | def curve_points(self, beginframe, endframe, framestep, birthframe, startframe, stopframe, deathframe,
filternone=False, noiseframe=None):
"""
returns a list of frames from startframe to stopframe, in steps of framestep
:param beginframe: first frame to include in list of po... | [
"def",
"curve_points",
"(",
"self",
",",
"beginframe",
",",
"endframe",
",",
"framestep",
",",
"birthframe",
",",
"startframe",
",",
"stopframe",
",",
"deathframe",
",",
"filternone",
"=",
"False",
",",
"noiseframe",
"=",
"None",
")",
":",
"return",
"None"
] | returns a list of frames from startframe to stopframe, in steps of framestep
:param beginframe: first frame to include in list of points
:param endframe: last frame to include in list of points
:param framestep: framestep, e.g. 0.01 means that the points will be calculated in timesteps of 0.01
... | [
"returns",
"a",
"list",
"of",
"frames",
"from",
"startframe",
"to",
"stopframe",
"in",
"steps",
"of",
"framestep",
":",
"param",
"beginframe",
":",
"first",
"frame",
"to",
"include",
"in",
"list",
"of",
"points",
":",
"param",
"endframe",
":",
"last",
"fra... | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/Animation.py#L24-L41 |
shimpe/pyvectortween | vectortween/Animation.py | Animation.curve_points | def curve_points(self, beginframe, endframe, framestep, birthframe, startframe, stopframe, deathframe,
filternone=True, noiseframe=None):
"""
returns a list of frames from startframe to stopframe, in steps of framestepj
warning: the list of points may include "None" elements... | python | def curve_points(self, beginframe, endframe, framestep, birthframe, startframe, stopframe, deathframe,
filternone=True, noiseframe=None):
"""
returns a list of frames from startframe to stopframe, in steps of framestepj
warning: the list of points may include "None" elements... | [
"def",
"curve_points",
"(",
"self",
",",
"beginframe",
",",
"endframe",
",",
"framestep",
",",
"birthframe",
",",
"startframe",
",",
"stopframe",
",",
"deathframe",
",",
"filternone",
"=",
"True",
",",
"noiseframe",
"=",
"None",
")",
":",
"if",
"endframe",
... | returns a list of frames from startframe to stopframe, in steps of framestepj
warning: the list of points may include "None" elements
:param beginframe: first frame to include in list of points
:param endframe: last frame to include in list of points
:param framestep: framestep
... | [
"returns",
"a",
"list",
"of",
"frames",
"from",
"startframe",
"to",
"stopframe",
"in",
"steps",
"of",
"framestepj",
"warning",
":",
"the",
"list",
"of",
"points",
"may",
"include",
"None",
"elements",
":",
"param",
"beginframe",
":",
"first",
"frame",
"to",
... | train | https://github.com/shimpe/pyvectortween/blob/aff071180474739060ec2d3102c39c8e73510988/vectortween/Animation.py#L62-L94 |
crypto101/merlyn | merlyn/multiplexing.py | addToStore | def addToStore(store, identifier, name):
"""Adds a persisted factory with given identifier and object name to
the given store.
This is intended to have the identifier and name partially
applied, so that a particular module with an exercise in it can
just have an ``addToStore`` function that remembe... | python | def addToStore(store, identifier, name):
"""Adds a persisted factory with given identifier and object name to
the given store.
This is intended to have the identifier and name partially
applied, so that a particular module with an exercise in it can
just have an ``addToStore`` function that remembe... | [
"def",
"addToStore",
"(",
"store",
",",
"identifier",
",",
"name",
")",
":",
"persistedFactory",
"=",
"store",
".",
"findOrCreate",
"(",
"_PersistedFactory",
",",
"identifier",
"=",
"identifier",
")",
"persistedFactory",
".",
"name",
"=",
"name",
"return",
"pe... | Adds a persisted factory with given identifier and object name to
the given store.
This is intended to have the identifier and name partially
applied, so that a particular module with an exercise in it can
just have an ``addToStore`` function that remembers it in the
store.
If a persisted fact... | [
"Adds",
"a",
"persisted",
"factory",
"with",
"given",
"identifier",
"and",
"object",
"name",
"to",
"the",
"given",
"store",
"."
] | train | https://github.com/crypto101/merlyn/blob/0f313210b9ea5385cc2e5b725dc766df9dc3284d/merlyn/multiplexing.py#L44-L59 |
kennknowles/python-rightarrow | rightarrow/parser.py | Parser.p_ty_funty_complex | def p_ty_funty_complex(self, p):
"ty : '(' maybe_arg_types ')' ARROW ty"
argument_types=p[2]
return_type=p[5]
# Check here whether too many kwarg or vararg types are present
# Each item in the list uses the dictionary encoding of tagged variants
arg_types = [argty['arg_t... | python | def p_ty_funty_complex(self, p):
"ty : '(' maybe_arg_types ')' ARROW ty"
argument_types=p[2]
return_type=p[5]
# Check here whether too many kwarg or vararg types are present
# Each item in the list uses the dictionary encoding of tagged variants
arg_types = [argty['arg_t... | [
"def",
"p_ty_funty_complex",
"(",
"self",
",",
"p",
")",
":",
"argument_types",
"=",
"p",
"[",
"2",
"]",
"return_type",
"=",
"p",
"[",
"5",
"]",
"# Check here whether too many kwarg or vararg types are present",
"# Each item in the list uses the dictionary encoding of tagge... | ty : '(' maybe_arg_types ')' ARROW ty | [
"ty",
":",
"(",
"maybe_arg_types",
")",
"ARROW",
"ty"
] | train | https://github.com/kennknowles/python-rightarrow/blob/86c83bde9d2fba6d54744eac9abedd1c248b7e73/rightarrow/parser.py#L80-L102 |
kennknowles/python-rightarrow | rightarrow/parser.py | Parser.p_object_ty | def p_object_ty(self, p):
"""
object_ty : OBJECT '(' ID ')'
| OBJECT '(' ID ',' obj_fields ')'
"""
field_types = {} if len(p) == 5 else p[5]
p[0] = Object(p[3], **field_types) | python | def p_object_ty(self, p):
"""
object_ty : OBJECT '(' ID ')'
| OBJECT '(' ID ',' obj_fields ')'
"""
field_types = {} if len(p) == 5 else p[5]
p[0] = Object(p[3], **field_types) | [
"def",
"p_object_ty",
"(",
"self",
",",
"p",
")",
":",
"field_types",
"=",
"{",
"}",
"if",
"len",
"(",
"p",
")",
"==",
"5",
"else",
"p",
"[",
"5",
"]",
"p",
"[",
"0",
"]",
"=",
"Object",
"(",
"p",
"[",
"3",
"]",
",",
"*",
"*",
"field_types"... | object_ty : OBJECT '(' ID ')'
| OBJECT '(' ID ',' obj_fields ')' | [
"object_ty",
":",
"OBJECT",
"(",
"ID",
")",
"|",
"OBJECT",
"(",
"ID",
"obj_fields",
")"
] | train | https://github.com/kennknowles/python-rightarrow/blob/86c83bde9d2fba6d54744eac9abedd1c248b7e73/rightarrow/parser.py#L161-L167 |
kennknowles/python-rightarrow | rightarrow/parser.py | Parser.p_obj_fields | def p_obj_fields(self, p):
"""
obj_fields : obj_fields ',' obj_field
| obj_field
"""
p[0] = dict([p[1]] if len(p) == 2 else p[1] + [p[3]]) | python | def p_obj_fields(self, p):
"""
obj_fields : obj_fields ',' obj_field
| obj_field
"""
p[0] = dict([p[1]] if len(p) == 2 else p[1] + [p[3]]) | [
"def",
"p_obj_fields",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"dict",
"(",
"[",
"p",
"[",
"1",
"]",
"]",
"if",
"len",
"(",
"p",
")",
"==",
"2",
"else",
"p",
"[",
"1",
"]",
"+",
"[",
"p",
"[",
"3",
"]",
"]",
")"
] | obj_fields : obj_fields ',' obj_field
| obj_field | [
"obj_fields",
":",
"obj_fields",
"obj_field",
"|",
"obj_field"
] | train | https://github.com/kennknowles/python-rightarrow/blob/86c83bde9d2fba6d54744eac9abedd1c248b7e73/rightarrow/parser.py#L169-L174 |
cthoyt/onto2nx | src/onto2nx/owl_xml.py | parse_owl_xml | def parse_owl_xml(url):
"""Downloads and parses an OWL resource in OWL/XML format using the :class:`OWLParser`.
:param str url: The URL to the OWL resource
:return: A directional graph representing the OWL document's hierarchy
:rtype: networkx.DiGraph
"""
res = download(url)
owl = OWLParser... | python | def parse_owl_xml(url):
"""Downloads and parses an OWL resource in OWL/XML format using the :class:`OWLParser`.
:param str url: The URL to the OWL resource
:return: A directional graph representing the OWL document's hierarchy
:rtype: networkx.DiGraph
"""
res = download(url)
owl = OWLParser... | [
"def",
"parse_owl_xml",
"(",
"url",
")",
":",
"res",
"=",
"download",
"(",
"url",
")",
"owl",
"=",
"OWLParser",
"(",
"content",
"=",
"res",
".",
"content",
")",
"return",
"owl"
] | Downloads and parses an OWL resource in OWL/XML format using the :class:`OWLParser`.
:param str url: The URL to the OWL resource
:return: A directional graph representing the OWL document's hierarchy
:rtype: networkx.DiGraph | [
"Downloads",
"and",
"parses",
"an",
"OWL",
"resource",
"in",
"OWL",
"/",
"XML",
"format",
"using",
"the",
":",
"class",
":",
"OWLParser",
"."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/owl_xml.py#L24-L33 |
justquick/django-native-tags | native_tags/contrib/generic_content.py | retrieve_object | def retrieve_object(model, *args, **kwargs):
"""
Retrieves a specific object from a given model by primary-key
lookup, and stores it in a context variable.
Syntax::
{% retrieve_object [app_name].[model_name] [lookup kwargs] as [varname] %}
Example::
{% retrieve_ob... | python | def retrieve_object(model, *args, **kwargs):
"""
Retrieves a specific object from a given model by primary-key
lookup, and stores it in a context variable.
Syntax::
{% retrieve_object [app_name].[model_name] [lookup kwargs] as [varname] %}
Example::
{% retrieve_ob... | [
"def",
"retrieve_object",
"(",
"model",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"kwargs",
".",
"update",
"(",
"{",
"'pk'",
":",
"args",
"[",
"0",
"]",
"}",
")",
"_model",
"=",
"_get_mo... | Retrieves a specific object from a given model by primary-key
lookup, and stores it in a context variable.
Syntax::
{% retrieve_object [app_name].[model_name] [lookup kwargs] as [varname] %}
Example::
{% retrieve_object flatpages.flatpage pk=12 as my_flat_page %} | [
"Retrieves",
"a",
"specific",
"object",
"from",
"a",
"given",
"model",
"by",
"primary",
"-",
"key",
"lookup",
"and",
"stores",
"it",
"in",
"a",
"context",
"variable",
".",
"Syntax",
"::",
"{",
"%",
"retrieve_object",
"[",
"app_name",
"]",
".",
"[",
"mode... | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/generic_content.py#L94-L114 |
ionelmc/python-cogen | cogen/core/proactors/iocp_impl.py | IOCPProactor.request_generic | def request_generic(self, act, coro, perform, complete):
"""
Performs an overlapped request (via `perform` callable) and saves
the token and the (`overlapped`, `perform`, `complete`) trio.
"""
overlapped = pywintypes.OVERLAPPED()
overlapped.object = act
sel... | python | def request_generic(self, act, coro, perform, complete):
"""
Performs an overlapped request (via `perform` callable) and saves
the token and the (`overlapped`, `perform`, `complete`) trio.
"""
overlapped = pywintypes.OVERLAPPED()
overlapped.object = act
sel... | [
"def",
"request_generic",
"(",
"self",
",",
"act",
",",
"coro",
",",
"perform",
",",
"complete",
")",
":",
"overlapped",
"=",
"pywintypes",
".",
"OVERLAPPED",
"(",
")",
"overlapped",
".",
"object",
"=",
"act",
"self",
".",
"add_token",
"(",
"act",
",",
... | Performs an overlapped request (via `perform` callable) and saves
the token and the (`overlapped`, `perform`, `complete`) trio. | [
"Performs",
"an",
"overlapped",
"request",
"(",
"via",
"perform",
"callable",
")",
"and",
"saves",
"the",
"token",
"and",
"the",
"(",
"overlapped",
"perform",
"complete",
")",
"trio",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/iocp_impl.py#L130-L148 |
ionelmc/python-cogen | cogen/core/proactors/iocp_impl.py | IOCPProactor.process_op | def process_op(self, rc, nbytes, overlap):
"""
Handles the possible completion or re-queueing if conditions haven't
been met (the `complete` callable returns false) of a overlapped request.
"""
act = overlap.object
overlap.object = None
if act in self.token... | python | def process_op(self, rc, nbytes, overlap):
"""
Handles the possible completion or re-queueing if conditions haven't
been met (the `complete` callable returns false) of a overlapped request.
"""
act = overlap.object
overlap.object = None
if act in self.token... | [
"def",
"process_op",
"(",
"self",
",",
"rc",
",",
"nbytes",
",",
"overlap",
")",
":",
"act",
"=",
"overlap",
".",
"object",
"overlap",
".",
"object",
"=",
"None",
"if",
"act",
"in",
"self",
".",
"tokens",
":",
"ol",
",",
"perform",
",",
"complete",
... | Handles the possible completion or re-queueing if conditions haven't
been met (the `complete` callable returns false) of a overlapped request. | [
"Handles",
"the",
"possible",
"completion",
"or",
"re",
"-",
"queueing",
"if",
"conditions",
"haven",
"t",
"been",
"met",
"(",
"the",
"complete",
"callable",
"returns",
"false",
")",
"of",
"a",
"overlapped",
"request",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/iocp_impl.py#L165-L203 |
ionelmc/python-cogen | cogen/core/proactors/iocp_impl.py | IOCPProactor.run | def run(self, timeout = 0):
"""
Calls GetQueuedCompletionStatus and handles completion via
IOCPProactor.process_op.
"""
# same resolution as epoll
ptimeout = int(
timeout.days * 86400000 +
timeout.microseconds / 1000 +
timeout.... | python | def run(self, timeout = 0):
"""
Calls GetQueuedCompletionStatus and handles completion via
IOCPProactor.process_op.
"""
# same resolution as epoll
ptimeout = int(
timeout.days * 86400000 +
timeout.microseconds / 1000 +
timeout.... | [
"def",
"run",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"# same resolution as epoll\r",
"ptimeout",
"=",
"int",
"(",
"timeout",
".",
"days",
"*",
"86400000",
"+",
"timeout",
".",
"microseconds",
"/",
"1000",
"+",
"timeout",
".",
"seconds",
"*",
"1... | Calls GetQueuedCompletionStatus and handles completion via
IOCPProactor.process_op. | [
"Calls",
"GetQueuedCompletionStatus",
"and",
"handles",
"completion",
"via",
"IOCPProactor",
".",
"process_op",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/iocp_impl.py#L205-L262 |
lucasem/ghmarkdown | ghmarkdown/ghmarkdown.py | html_from_markdown | def html_from_markdown(markdown):
""" Takes raw markdown, returns html result from GitHub api """
if login:
r = requests.get(gh_url+"/rate_limit", auth=login.auth())
if r.status_code >= 400:
if r.status_code != 401:
err = RequestError('Bad HTTP Status Code: %s' % r.s... | python | def html_from_markdown(markdown):
""" Takes raw markdown, returns html result from GitHub api """
if login:
r = requests.get(gh_url+"/rate_limit", auth=login.auth())
if r.status_code >= 400:
if r.status_code != 401:
err = RequestError('Bad HTTP Status Code: %s' % r.s... | [
"def",
"html_from_markdown",
"(",
"markdown",
")",
":",
"if",
"login",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"gh_url",
"+",
"\"/rate_limit\"",
",",
"auth",
"=",
"login",
".",
"auth",
"(",
")",
")",
"if",
"r",
".",
"status_code",
">=",
"400",
":... | Takes raw markdown, returns html result from GitHub api | [
"Takes",
"raw",
"markdown",
"returns",
"html",
"result",
"from",
"GitHub",
"api"
] | train | https://github.com/lucasem/ghmarkdown/blob/8e4c937c7f2dc45892ace4623a1354c0e5d63cb3/ghmarkdown/ghmarkdown.py#L57-L81 |
lucasem/ghmarkdown | ghmarkdown/ghmarkdown.py | standalone | def standalone(body):
""" Returns complete html document given markdown html """
with open(_ROOT + '/html.dat', 'r') as html_template:
head = html_title()
html = "".join(html_template.readlines()) \
.replace("{{HEAD}}", head) \
.replace("{{BODY}}", body)
... | python | def standalone(body):
""" Returns complete html document given markdown html """
with open(_ROOT + '/html.dat', 'r') as html_template:
head = html_title()
html = "".join(html_template.readlines()) \
.replace("{{HEAD}}", head) \
.replace("{{BODY}}", body)
... | [
"def",
"standalone",
"(",
"body",
")",
":",
"with",
"open",
"(",
"_ROOT",
"+",
"'/html.dat'",
",",
"'r'",
")",
"as",
"html_template",
":",
"head",
"=",
"html_title",
"(",
")",
"html",
"=",
"\"\"",
".",
"join",
"(",
"html_template",
".",
"readlines",
"(... | Returns complete html document given markdown html | [
"Returns",
"complete",
"html",
"document",
"given",
"markdown",
"html"
] | train | https://github.com/lucasem/ghmarkdown/blob/8e4c937c7f2dc45892ace4623a1354c0e5d63cb3/ghmarkdown/ghmarkdown.py#L84-L91 |
lucasem/ghmarkdown | ghmarkdown/ghmarkdown.py | run_server | def run_server(port=8000):
""" Runs server on port with html response """
from http.server import BaseHTTPRequestHandler, HTTPServer
class VerboseHTMLHandler(BaseHTTPRequestHandler):
def do_HEAD(s):
s.send_response(200)
s.send_header("Content-type", "text/html")
... | python | def run_server(port=8000):
""" Runs server on port with html response """
from http.server import BaseHTTPRequestHandler, HTTPServer
class VerboseHTMLHandler(BaseHTTPRequestHandler):
def do_HEAD(s):
s.send_response(200)
s.send_header("Content-type", "text/html")
... | [
"def",
"run_server",
"(",
"port",
"=",
"8000",
")",
":",
"from",
"http",
".",
"server",
"import",
"BaseHTTPRequestHandler",
",",
"HTTPServer",
"class",
"VerboseHTMLHandler",
"(",
"BaseHTTPRequestHandler",
")",
":",
"def",
"do_HEAD",
"(",
"s",
")",
":",
"s",
... | Runs server on port with html response | [
"Runs",
"server",
"on",
"port",
"with",
"html",
"response"
] | train | https://github.com/lucasem/ghmarkdown/blob/8e4c937c7f2dc45892ace4623a1354c0e5d63cb3/ghmarkdown/ghmarkdown.py#L110-L151 |
lucasem/ghmarkdown | ghmarkdown/ghmarkdown.py | rate_limit_info | def rate_limit_info():
""" Returns (requests_remaining, minutes_to_reset) """
import json
import time
r = requests.get(gh_url + "/rate_limit", auth=login.auth())
out = json.loads(r.text)
mins = (out["resources"]["core"]["reset"]-time.time())/60
return out["resources"]["core"]["remaining"], ... | python | def rate_limit_info():
""" Returns (requests_remaining, minutes_to_reset) """
import json
import time
r = requests.get(gh_url + "/rate_limit", auth=login.auth())
out = json.loads(r.text)
mins = (out["resources"]["core"]["reset"]-time.time())/60
return out["resources"]["core"]["remaining"], ... | [
"def",
"rate_limit_info",
"(",
")",
":",
"import",
"json",
"import",
"time",
"r",
"=",
"requests",
".",
"get",
"(",
"gh_url",
"+",
"\"/rate_limit\"",
",",
"auth",
"=",
"login",
".",
"auth",
"(",
")",
")",
"out",
"=",
"json",
".",
"loads",
"(",
"r",
... | Returns (requests_remaining, minutes_to_reset) | [
"Returns",
"(",
"requests_remaining",
"minutes_to_reset",
")"
] | train | https://github.com/lucasem/ghmarkdown/blob/8e4c937c7f2dc45892ace4623a1354c0e5d63cb3/ghmarkdown/ghmarkdown.py#L154-L162 |
klen/django-netauth | netauth/templatetags/netauth_tags.py | set | def set(parser, token):
"""
Usage:
{% set templ_tag var1 var2 ... key %}
{% set variable key %}
This tag save result of {% templ_tag var1 var2 ... %} to variable with name key,
Or will save value of variable to new variable with name key.
"""
bits = token.contents.spl... | python | def set(parser, token):
"""
Usage:
{% set templ_tag var1 var2 ... key %}
{% set variable key %}
This tag save result of {% templ_tag var1 var2 ... %} to variable with name key,
Or will save value of variable to new variable with name key.
"""
bits = token.contents.spl... | [
"def",
"set",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"contents",
".",
"split",
"(",
"' '",
")",
"[",
"1",
":",
"]",
"new_token",
"=",
"Token",
"(",
"TOKEN_BLOCK",
",",
"' '",
".",
"join",
"(",
"bits",
"[",
":",
"-",
"... | Usage:
{% set templ_tag var1 var2 ... key %}
{% set variable key %}
This tag save result of {% templ_tag var1 var2 ... %} to variable with name key,
Or will save value of variable to new variable with name key. | [
"Usage",
":",
"{",
"%",
"set",
"templ_tag",
"var1",
"var2",
"...",
"key",
"%",
"}",
"{",
"%",
"set",
"variable",
"key",
"%",
"}",
"This",
"tag",
"save",
"result",
"of",
"{",
"%",
"templ_tag",
"var1",
"var2",
"...",
"%",
"}",
"to",
"variable",
"with... | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/templatetags/netauth_tags.py#L34-L48 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | stringClade | def stringClade(taxrefs, name, at):
'''Return a Newick string from a list of TaxRefs'''
string = []
for ref in taxrefs:
# distance is the difference between the taxonomic level of the ref
# and the current level of the tree growth
d = float(at-ref.level)
# ensure no spaces i... | python | def stringClade(taxrefs, name, at):
'''Return a Newick string from a list of TaxRefs'''
string = []
for ref in taxrefs:
# distance is the difference between the taxonomic level of the ref
# and the current level of the tree growth
d = float(at-ref.level)
# ensure no spaces i... | [
"def",
"stringClade",
"(",
"taxrefs",
",",
"name",
",",
"at",
")",
":",
"string",
"=",
"[",
"]",
"for",
"ref",
"in",
"taxrefs",
":",
"# distance is the difference between the taxonomic level of the ref",
"# and the current level of the tree growth",
"d",
"=",
"float",
... | Return a Newick string from a list of TaxRefs | [
"Return",
"a",
"Newick",
"string",
"from",
"a",
"list",
"of",
"TaxRefs"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L192-L205 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | taxTree | def taxTree(taxdict):
"""Return taxonomic Newick tree"""
# the taxonomic dictionary holds the lineage of each ident in
# the same order as the taxonomy
# use hierarchy to construct a taxonomic tree
for rank in taxdict.taxonomy:
current_level = float(taxdict.taxonomy.index(rank))
# g... | python | def taxTree(taxdict):
"""Return taxonomic Newick tree"""
# the taxonomic dictionary holds the lineage of each ident in
# the same order as the taxonomy
# use hierarchy to construct a taxonomic tree
for rank in taxdict.taxonomy:
current_level = float(taxdict.taxonomy.index(rank))
# g... | [
"def",
"taxTree",
"(",
"taxdict",
")",
":",
"# the taxonomic dictionary holds the lineage of each ident in",
"# the same order as the taxonomy",
"# use hierarchy to construct a taxonomic tree",
"for",
"rank",
"in",
"taxdict",
".",
"taxonomy",
":",
"current_level",
"=",
"float",
... | Return taxonomic Newick tree | [
"Return",
"taxonomic",
"Newick",
"tree"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L208-L241 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | TaxRef.change | def change(self, ident, rank=None):
'''Change ident'''
self.ident = ident
if rank:
self.rank = rank
self.level = self._getLevel(rank, self.taxonomy)
# count changes made to instance
self.counter += 1 | python | def change(self, ident, rank=None):
'''Change ident'''
self.ident = ident
if rank:
self.rank = rank
self.level = self._getLevel(rank, self.taxonomy)
# count changes made to instance
self.counter += 1 | [
"def",
"change",
"(",
"self",
",",
"ident",
",",
"rank",
"=",
"None",
")",
":",
"self",
".",
"ident",
"=",
"ident",
"if",
"rank",
":",
"self",
".",
"rank",
"=",
"rank",
"self",
".",
"level",
"=",
"self",
".",
"_getLevel",
"(",
"rank",
",",
"self"... | Change ident | [
"Change",
"ident"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L35-L42 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | TaxDict._additional | def _additional(self, idents, kwargs):
'''Add additional data slots from **kwargs'''
if kwargs:
for name, value in list(kwargs.items()):
if not isinstance(value, list):
raise ValueError('Additional arguments must be lists of \
same length as idents')
... | python | def _additional(self, idents, kwargs):
'''Add additional data slots from **kwargs'''
if kwargs:
for name, value in list(kwargs.items()):
if not isinstance(value, list):
raise ValueError('Additional arguments must be lists of \
same length as idents')
... | [
"def",
"_additional",
"(",
"self",
",",
"idents",
",",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"for",
"name",
",",
"value",
"in",
"list",
"(",
"kwargs",
".",
"items",
"(",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"list",
")",
... | Add additional data slots from **kwargs | [
"Add",
"additional",
"data",
"slots",
"from",
"**",
"kwargs"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L122-L130 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | TaxDict._slice | def _slice(self, level):
'''Return list of tuples of ident and lineage ident for given level
(numbered rank)'''
if level >= len(self.taxonomy):
raise IndexError('Level greater than size of taxonomy')
res = []
for ident in sorted(list(self.keys())):
res.append((sel... | python | def _slice(self, level):
'''Return list of tuples of ident and lineage ident for given level
(numbered rank)'''
if level >= len(self.taxonomy):
raise IndexError('Level greater than size of taxonomy')
res = []
for ident in sorted(list(self.keys())):
res.append((sel... | [
"def",
"_slice",
"(",
"self",
",",
"level",
")",
":",
"if",
"level",
">=",
"len",
"(",
"self",
".",
"taxonomy",
")",
":",
"raise",
"IndexError",
"(",
"'Level greater than size of taxonomy'",
")",
"res",
"=",
"[",
"]",
"for",
"ident",
"in",
"sorted",
"(",... | Return list of tuples of ident and lineage ident for given level
(numbered rank) | [
"Return",
"list",
"of",
"tuples",
"of",
"ident",
"and",
"lineage",
"ident",
"for",
"given",
"level",
"(",
"numbered",
"rank",
")"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L132-L140 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | TaxDict._group | def _group(self, taxslice):
'''Return list of lists of idents grouped by shared rank'''
res = []
while taxslice:
taxref, lident = taxslice.pop()
if lident == '':
res.append(([taxref], lident))
else:
# identify idents in the same... | python | def _group(self, taxslice):
'''Return list of lists of idents grouped by shared rank'''
res = []
while taxslice:
taxref, lident = taxslice.pop()
if lident == '':
res.append(([taxref], lident))
else:
# identify idents in the same... | [
"def",
"_group",
"(",
"self",
",",
"taxslice",
")",
":",
"res",
"=",
"[",
"]",
"while",
"taxslice",
":",
"taxref",
",",
"lident",
"=",
"taxslice",
".",
"pop",
"(",
")",
"if",
"lident",
"==",
"''",
":",
"res",
".",
"append",
"(",
"(",
"[",
"taxref... | Return list of lists of idents grouped by shared rank | [
"Return",
"list",
"of",
"lists",
"of",
"idents",
"grouped",
"by",
"shared",
"rank"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L142-L160 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | TaxDict._hierarchy | def _hierarchy(self):
'''Generate dictionary of referenced idents grouped by shared rank'''
self.hierarchy = {}
for rank in self.taxonomy:
# extract lineage idents for this rank
taxslice = self._slice(level=self.taxonomy.index(rank))
# group idents by shared g... | python | def _hierarchy(self):
'''Generate dictionary of referenced idents grouped by shared rank'''
self.hierarchy = {}
for rank in self.taxonomy:
# extract lineage idents for this rank
taxslice = self._slice(level=self.taxonomy.index(rank))
# group idents by shared g... | [
"def",
"_hierarchy",
"(",
"self",
")",
":",
"self",
".",
"hierarchy",
"=",
"{",
"}",
"for",
"rank",
"in",
"self",
".",
"taxonomy",
":",
"# extract lineage idents for this rank",
"taxslice",
"=",
"self",
".",
"_slice",
"(",
"level",
"=",
"self",
".",
"taxon... | Generate dictionary of referenced idents grouped by shared rank | [
"Generate",
"dictionary",
"of",
"referenced",
"idents",
"grouped",
"by",
"shared",
"rank"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L162-L169 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/manip_tools.py | TaxDict._contextualise | def _contextualise(self):
'''Determine contextual idents (cidents)'''
# loop through hierarchy identifying unique lineages
# TODO: gain other contextual information, not just ident
deja_vues = []
for rank in reversed(self.taxonomy):
# return named clades -- '' are ign... | python | def _contextualise(self):
'''Determine contextual idents (cidents)'''
# loop through hierarchy identifying unique lineages
# TODO: gain other contextual information, not just ident
deja_vues = []
for rank in reversed(self.taxonomy):
# return named clades -- '' are ign... | [
"def",
"_contextualise",
"(",
"self",
")",
":",
"# loop through hierarchy identifying unique lineages",
"# TODO: gain other contextual information, not just ident",
"deja_vues",
"=",
"[",
"]",
"for",
"rank",
"in",
"reversed",
"(",
"self",
".",
"taxonomy",
")",
":",
"# ret... | Determine contextual idents (cidents) | [
"Determine",
"contextual",
"idents",
"(",
"cidents",
")"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/manip_tools.py#L171-L188 |
justquick/django-native-tags | native_tags/registry.py | Library.load_module | def load_module(self, module):
"""
Load a module string like django.contrib.markup.templatetags.markup into the registry
Iterates through the module looking for callables w/ attributes matching Native Tags
"""
if isinstance(module, basestring) and module.find('.') > -1:
... | python | def load_module(self, module):
"""
Load a module string like django.contrib.markup.templatetags.markup into the registry
Iterates through the module looking for callables w/ attributes matching Native Tags
"""
if isinstance(module, basestring) and module.find('.') > -1:
... | [
"def",
"load_module",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"basestring",
")",
"and",
"module",
".",
"find",
"(",
"'.'",
")",
">",
"-",
"1",
":",
"a",
"=",
"module",
".",
"split",
"(",
"'.'",
")",
"module",
... | Load a module string like django.contrib.markup.templatetags.markup into the registry
Iterates through the module looking for callables w/ attributes matching Native Tags | [
"Load",
"a",
"module",
"string",
"like",
"django",
".",
"contrib",
".",
"markup",
".",
"templatetags",
".",
"markup",
"into",
"the",
"registry",
"Iterates",
"through",
"the",
"module",
"looking",
"for",
"callables",
"w",
"/",
"attributes",
"matching",
"Native"... | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/registry.py#L58-L83 |
justquick/django-native-tags | native_tags/registry.py | Library.register | def register(self, bucket, name_or_func, func=None):
"""
Add a function to the registry by name
"""
assert bucket in self, 'Bucket %s is unknown' % bucket
if func is None and hasattr(name_or_func, '__name__'):
name = name_or_func.__name__
func = name_or_fu... | python | def register(self, bucket, name_or_func, func=None):
"""
Add a function to the registry by name
"""
assert bucket in self, 'Bucket %s is unknown' % bucket
if func is None and hasattr(name_or_func, '__name__'):
name = name_or_func.__name__
func = name_or_fu... | [
"def",
"register",
"(",
"self",
",",
"bucket",
",",
"name_or_func",
",",
"func",
"=",
"None",
")",
":",
"assert",
"bucket",
"in",
"self",
",",
"'Bucket %s is unknown'",
"%",
"bucket",
"if",
"func",
"is",
"None",
"and",
"hasattr",
"(",
"name_or_func",
",",
... | Add a function to the registry by name | [
"Add",
"a",
"function",
"to",
"the",
"registry",
"by",
"name"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/registry.py#L85-L98 |
justquick/django-native-tags | native_tags/registry.py | Library.unregister | def unregister(self, bucket, name):
"""
Remove the function from the registry by name
"""
assert bucket in self, 'Bucket %s is unknown' % bucket
if not name in self[bucket]:
raise NotRegistered('The function %s is not registered' % name)
del self[bucket][name] | python | def unregister(self, bucket, name):
"""
Remove the function from the registry by name
"""
assert bucket in self, 'Bucket %s is unknown' % bucket
if not name in self[bucket]:
raise NotRegistered('The function %s is not registered' % name)
del self[bucket][name] | [
"def",
"unregister",
"(",
"self",
",",
"bucket",
",",
"name",
")",
":",
"assert",
"bucket",
"in",
"self",
",",
"'Bucket %s is unknown'",
"%",
"bucket",
"if",
"not",
"name",
"in",
"self",
"[",
"bucket",
"]",
":",
"raise",
"NotRegistered",
"(",
"'The functio... | Remove the function from the registry by name | [
"Remove",
"the",
"function",
"from",
"the",
"registry",
"by",
"name"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/registry.py#L100-L107 |
justquick/django-native-tags | native_tags/registry.py | Library.get_doc | def get_doc(self, tag_name):
"Get documentation for the first tag matching the given name"
for tag,func in self.tags:
if tag.startswith(tag_name) and func.__doc__:
return func.__doc__ | python | def get_doc(self, tag_name):
"Get documentation for the first tag matching the given name"
for tag,func in self.tags:
if tag.startswith(tag_name) and func.__doc__:
return func.__doc__ | [
"def",
"get_doc",
"(",
"self",
",",
"tag_name",
")",
":",
"for",
"tag",
",",
"func",
"in",
"self",
".",
"tags",
":",
"if",
"tag",
".",
"startswith",
"(",
"tag_name",
")",
"and",
"func",
".",
"__doc__",
":",
"return",
"func",
".",
"__doc__"
] | Get documentation for the first tag matching the given name | [
"Get",
"documentation",
"for",
"the",
"first",
"tag",
"matching",
"the",
"given",
"name"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/registry.py#L121-L125 |
justquick/django-native-tags | native_tags/registry.py | Library.get_bucket | def get_bucket(self, name):
"Find out which bucket a given tag name is in"
for bucket in self:
for k,v in self[bucket].items():
if k == name:
return bucket | python | def get_bucket(self, name):
"Find out which bucket a given tag name is in"
for bucket in self:
for k,v in self[bucket].items():
if k == name:
return bucket | [
"def",
"get_bucket",
"(",
"self",
",",
"name",
")",
":",
"for",
"bucket",
"in",
"self",
":",
"for",
"k",
",",
"v",
"in",
"self",
"[",
"bucket",
"]",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"name",
":",
"return",
"bucket"
] | Find out which bucket a given tag name is in | [
"Find",
"out",
"which",
"bucket",
"a",
"given",
"tag",
"name",
"is",
"in"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/registry.py#L127-L132 |
justquick/django-native-tags | native_tags/registry.py | Library.get | def get(self, name):
"Get the first tag function matching the given name"
for bucket in self:
for k,v in self[bucket].items():
if k == name:
return v | python | def get(self, name):
"Get the first tag function matching the given name"
for bucket in self:
for k,v in self[bucket].items():
if k == name:
return v | [
"def",
"get",
"(",
"self",
",",
"name",
")",
":",
"for",
"bucket",
"in",
"self",
":",
"for",
"k",
",",
"v",
"in",
"self",
"[",
"bucket",
"]",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"name",
":",
"return",
"v"
] | Get the first tag function matching the given name | [
"Get",
"the",
"first",
"tag",
"function",
"matching",
"the",
"given",
"name"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/registry.py#L134-L139 |
justquick/django-native-tags | native_tags/registry.py | Library.tags | def tags(self):
"Iterate over all tags yielding (name, function)"
for bucket in self:
for k,v in self[bucket].items():
yield k,v | python | def tags(self):
"Iterate over all tags yielding (name, function)"
for bucket in self:
for k,v in self[bucket].items():
yield k,v | [
"def",
"tags",
"(",
"self",
")",
":",
"for",
"bucket",
"in",
"self",
":",
"for",
"k",
",",
"v",
"in",
"self",
"[",
"bucket",
"]",
".",
"items",
"(",
")",
":",
"yield",
"k",
",",
"v"
] | Iterate over all tags yielding (name, function) | [
"Iterate",
"over",
"all",
"tags",
"yielding",
"(",
"name",
"function",
")"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/registry.py#L141-L145 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | open_listing_page | def open_listing_page(trailing_part_of_url):
"""
Opens a BBC radio tracklisting page based on trailing part of url.
Returns a lxml ElementTree derived from that page.
trailing_part_of_url: a string, like the pid or e.g. pid/segments.inc
"""
base_url = 'http://www.bbc.co.uk/programmes/'
prin... | python | def open_listing_page(trailing_part_of_url):
"""
Opens a BBC radio tracklisting page based on trailing part of url.
Returns a lxml ElementTree derived from that page.
trailing_part_of_url: a string, like the pid or e.g. pid/segments.inc
"""
base_url = 'http://www.bbc.co.uk/programmes/'
prin... | [
"def",
"open_listing_page",
"(",
"trailing_part_of_url",
")",
":",
"base_url",
"=",
"'http://www.bbc.co.uk/programmes/'",
"print",
"(",
"\"Opening web page: \"",
"+",
"base_url",
"+",
"trailing_part_of_url",
")",
"try",
":",
"html",
"=",
"requests",
".",
"get",
"(",
... | Opens a BBC radio tracklisting page based on trailing part of url.
Returns a lxml ElementTree derived from that page.
trailing_part_of_url: a string, like the pid or e.g. pid/segments.inc | [
"Opens",
"a",
"BBC",
"radio",
"tracklisting",
"page",
"based",
"on",
"trailing",
"part",
"of",
"url",
".",
"Returns",
"a",
"lxml",
"ElementTree",
"derived",
"from",
"that",
"page",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L36-L58 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | get_programme_title | def get_programme_title(pid):
"""Take BBC programme ID as string; returns programme title as string."""
print("Extracting title and station...")
main_page_etree = open_listing_page(pid)
try:
title, = main_page_etree.xpath('//title/text()')
except ValueError:
title = ''
return tit... | python | def get_programme_title(pid):
"""Take BBC programme ID as string; returns programme title as string."""
print("Extracting title and station...")
main_page_etree = open_listing_page(pid)
try:
title, = main_page_etree.xpath('//title/text()')
except ValueError:
title = ''
return tit... | [
"def",
"get_programme_title",
"(",
"pid",
")",
":",
"print",
"(",
"\"Extracting title and station...\"",
")",
"main_page_etree",
"=",
"open_listing_page",
"(",
"pid",
")",
"try",
":",
"title",
",",
"=",
"main_page_etree",
".",
"xpath",
"(",
"'//title/text()'",
")"... | Take BBC programme ID as string; returns programme title as string. | [
"Take",
"BBC",
"programme",
"ID",
"as",
"string",
";",
"returns",
"programme",
"title",
"as",
"string",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L61-L69 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | get_broadcast_date | def get_broadcast_date(pid):
"""Take BBC pid (string); extract and return broadcast date as string."""
print("Extracting first broadcast date...")
broadcast_etree = open_listing_page(pid + '/broadcasts.inc')
original_broadcast_date, = broadcast_etree.xpath(
'(//div[@class="grid__inner"]//div'
... | python | def get_broadcast_date(pid):
"""Take BBC pid (string); extract and return broadcast date as string."""
print("Extracting first broadcast date...")
broadcast_etree = open_listing_page(pid + '/broadcasts.inc')
original_broadcast_date, = broadcast_etree.xpath(
'(//div[@class="grid__inner"]//div'
... | [
"def",
"get_broadcast_date",
"(",
"pid",
")",
":",
"print",
"(",
"\"Extracting first broadcast date...\"",
")",
"broadcast_etree",
"=",
"open_listing_page",
"(",
"pid",
"+",
"'/broadcasts.inc'",
")",
"original_broadcast_date",
",",
"=",
"broadcast_etree",
".",
"xpath",
... | Take BBC pid (string); extract and return broadcast date as string. | [
"Take",
"BBC",
"pid",
"(",
"string",
")",
";",
"extract",
"and",
"return",
"broadcast",
"date",
"as",
"string",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L72-L79 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | extract_listing | def extract_listing(pid):
"""Extract listing; return list of tuples (artist(s), title, label)."""
print("Extracting tracklisting...")
listing_etree = open_listing_page(pid + '/segments.inc')
track_divs = listing_etree.xpath('//div[@class="segment__track"]')
listing = []
for track_div in track_d... | python | def extract_listing(pid):
"""Extract listing; return list of tuples (artist(s), title, label)."""
print("Extracting tracklisting...")
listing_etree = open_listing_page(pid + '/segments.inc')
track_divs = listing_etree.xpath('//div[@class="segment__track"]')
listing = []
for track_div in track_d... | [
"def",
"extract_listing",
"(",
"pid",
")",
":",
"print",
"(",
"\"Extracting tracklisting...\"",
")",
"listing_etree",
"=",
"open_listing_page",
"(",
"pid",
"+",
"'/segments.inc'",
")",
"track_divs",
"=",
"listing_etree",
".",
"xpath",
"(",
"'//div[@class=\"segment__tr... | Extract listing; return list of tuples (artist(s), title, label). | [
"Extract",
"listing",
";",
"return",
"list",
"of",
"tuples",
"(",
"artist",
"(",
"s",
")",
"title",
"label",
")",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L82-L115 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | generate_output | def generate_output(listing, title, date):
"""
Returns a string containing a full tracklisting.
listing: list of (artist(s), track, record label) tuples
title: programme title
date: programme date
"""
listing_string = '{0}\n{1}\n\n'.format(title, date)
for entry in listing:
list... | python | def generate_output(listing, title, date):
"""
Returns a string containing a full tracklisting.
listing: list of (artist(s), track, record label) tuples
title: programme title
date: programme date
"""
listing_string = '{0}\n{1}\n\n'.format(title, date)
for entry in listing:
list... | [
"def",
"generate_output",
"(",
"listing",
",",
"title",
",",
"date",
")",
":",
"listing_string",
"=",
"'{0}\\n{1}\\n\\n'",
".",
"format",
"(",
"title",
",",
"date",
")",
"for",
"entry",
"in",
"listing",
":",
"listing_string",
"+=",
"'\\n'",
".",
"join",
"(... | Returns a string containing a full tracklisting.
listing: list of (artist(s), track, record label) tuples
title: programme title
date: programme date | [
"Returns",
"a",
"string",
"containing",
"a",
"full",
"tracklisting",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L118-L129 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | get_output_filename | def get_output_filename(args):
"""Returns a filename as string without an extension."""
# If filename and path provided, use these for output text file.
if args.directory is not None and args.fileprefix is not None:
path = args.directory
filename = args.fileprefix
output = os.path.jo... | python | def get_output_filename(args):
"""Returns a filename as string without an extension."""
# If filename and path provided, use these for output text file.
if args.directory is not None and args.fileprefix is not None:
path = args.directory
filename = args.fileprefix
output = os.path.jo... | [
"def",
"get_output_filename",
"(",
"args",
")",
":",
"# If filename and path provided, use these for output text file.",
"if",
"args",
".",
"directory",
"is",
"not",
"None",
"and",
"args",
".",
"fileprefix",
"is",
"not",
"None",
":",
"path",
"=",
"args",
".",
"dir... | Returns a filename as string without an extension. | [
"Returns",
"a",
"filename",
"as",
"string",
"without",
"an",
"extension",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L132-L144 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | write_listing_to_textfile | def write_listing_to_textfile(textfile, tracklisting):
"""Write tracklisting to a text file."""
with codecs.open(textfile, 'wb', 'utf-8') as text:
text.write(tracklisting) | python | def write_listing_to_textfile(textfile, tracklisting):
"""Write tracklisting to a text file."""
with codecs.open(textfile, 'wb', 'utf-8') as text:
text.write(tracklisting) | [
"def",
"write_listing_to_textfile",
"(",
"textfile",
",",
"tracklisting",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"textfile",
",",
"'wb'",
",",
"'utf-8'",
")",
"as",
"text",
":",
"text",
".",
"write",
"(",
"tracklisting",
")"
] | Write tracklisting to a text file. | [
"Write",
"tracklisting",
"to",
"a",
"text",
"file",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L147-L150 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | save_tag_to_audio_file | def save_tag_to_audio_file(audio_file, tracklisting):
"""
Saves tag to audio file.
"""
print("Trying to tag {}".format(audio_file))
f = mediafile.MediaFile(audio_file)
if not f.lyrics:
print("No tracklisting present. Creating lyrics tag.")
f.lyrics = 'Tracklisting' + '\n' + trac... | python | def save_tag_to_audio_file(audio_file, tracklisting):
"""
Saves tag to audio file.
"""
print("Trying to tag {}".format(audio_file))
f = mediafile.MediaFile(audio_file)
if not f.lyrics:
print("No tracklisting present. Creating lyrics tag.")
f.lyrics = 'Tracklisting' + '\n' + trac... | [
"def",
"save_tag_to_audio_file",
"(",
"audio_file",
",",
"tracklisting",
")",
":",
"print",
"(",
"\"Trying to tag {}\"",
".",
"format",
"(",
"audio_file",
")",
")",
"f",
"=",
"mediafile",
".",
"MediaFile",
"(",
"audio_file",
")",
"if",
"not",
"f",
".",
"lyri... | Saves tag to audio file. | [
"Saves",
"tag",
"to",
"audio",
"file",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L157-L175 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | tag_audio_file | def tag_audio_file(audio_file, tracklisting):
"""
Adds tracklisting as list to lyrics tag of audio file if not present.
Returns True if successful or not needed, False if tagging fails.
"""
try:
save_tag_to_audio_file(audio_file, tracklisting)
# TODO: is IOError required now or would the... | python | def tag_audio_file(audio_file, tracklisting):
"""
Adds tracklisting as list to lyrics tag of audio file if not present.
Returns True if successful or not needed, False if tagging fails.
"""
try:
save_tag_to_audio_file(audio_file, tracklisting)
# TODO: is IOError required now or would the... | [
"def",
"tag_audio_file",
"(",
"audio_file",
",",
"tracklisting",
")",
":",
"try",
":",
"save_tag_to_audio_file",
"(",
"audio_file",
",",
"tracklisting",
")",
"# TODO: is IOError required now or would the mediafile exception cover it?",
"except",
"(",
"IOError",
",",
"mediaf... | Adds tracklisting as list to lyrics tag of audio file if not present.
Returns True if successful or not needed, False if tagging fails. | [
"Adds",
"tracklisting",
"as",
"list",
"to",
"lyrics",
"tag",
"of",
"audio",
"file",
"if",
"not",
"present",
".",
"Returns",
"True",
"if",
"successful",
"or",
"not",
"needed",
"False",
"if",
"tagging",
"fails",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L178-L193 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | output_to_file | def output_to_file(filename, tracklisting, action):
"""
Produce requested output; either output text file, tag audio file or do
both.
filename: a string of path + filename without file extension
tracklisting: a string containing a tracklisting
action: 'tag', 'text' or 'both', from command line ... | python | def output_to_file(filename, tracklisting, action):
"""
Produce requested output; either output text file, tag audio file or do
both.
filename: a string of path + filename without file extension
tracklisting: a string containing a tracklisting
action: 'tag', 'text' or 'both', from command line ... | [
"def",
"output_to_file",
"(",
"filename",
",",
"tracklisting",
",",
"action",
")",
":",
"if",
"action",
"in",
"(",
"'tag'",
",",
"'both'",
")",
":",
"audio_tagged",
"=",
"tag_audio",
"(",
"filename",
",",
"tracklisting",
")",
"if",
"action",
"==",
"'both'"... | Produce requested output; either output text file, tag audio file or do
both.
filename: a string of path + filename without file extension
tracklisting: a string containing a tracklisting
action: 'tag', 'text' or 'both', from command line arguments | [
"Produce",
"requested",
"output",
";",
"either",
"output",
"text",
"file",
"tag",
"audio",
"file",
"or",
"do",
"both",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L196-L210 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | write_text | def write_text(filename, tracklisting):
"""Handle writing tracklisting to text."""
print("Saving text file.")
try:
write_listing_to_textfile(filename + '.txt', tracklisting)
except IOError:
# if all else fails, just print listing
print("Cannot write text file to path: {}".format(... | python | def write_text(filename, tracklisting):
"""Handle writing tracklisting to text."""
print("Saving text file.")
try:
write_listing_to_textfile(filename + '.txt', tracklisting)
except IOError:
# if all else fails, just print listing
print("Cannot write text file to path: {}".format(... | [
"def",
"write_text",
"(",
"filename",
",",
"tracklisting",
")",
":",
"print",
"(",
"\"Saving text file.\"",
")",
"try",
":",
"write_listing_to_textfile",
"(",
"filename",
"+",
"'.txt'",
",",
"tracklisting",
")",
"except",
"IOError",
":",
"# if all else fails, just p... | Handle writing tracklisting to text. | [
"Handle",
"writing",
"tracklisting",
"to",
"text",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L213-L224 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | tag_audio | def tag_audio(filename, tracklisting):
"""Return True if audio tagged successfully; handle tagging audio."""
# TODO: maybe actually glob for files, then try tagging if present?
if not(tag_audio_file(filename + '.m4a', tracklisting) or
tag_audio_file(filename + '.mp3', tracklisting)):
prin... | python | def tag_audio(filename, tracklisting):
"""Return True if audio tagged successfully; handle tagging audio."""
# TODO: maybe actually glob for files, then try tagging if present?
if not(tag_audio_file(filename + '.m4a', tracklisting) or
tag_audio_file(filename + '.mp3', tracklisting)):
prin... | [
"def",
"tag_audio",
"(",
"filename",
",",
"tracklisting",
")",
":",
"# TODO: maybe actually glob for files, then try tagging if present?",
"if",
"not",
"(",
"tag_audio_file",
"(",
"filename",
"+",
"'.m4a'",
",",
"tracklisting",
")",
"or",
"tag_audio_file",
"(",
"filenam... | Return True if audio tagged successfully; handle tagging audio. | [
"Return",
"True",
"if",
"audio",
"tagged",
"successfully",
";",
"handle",
"tagging",
"audio",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L227-L236 |
StevenMaude/bbc-radio-tracklisting-downloader | bbc_tracklist.py | main | def main():
"""Get a tracklisting, write to audio file or text."""
args = parse_arguments()
pid = args.pid
title = get_programme_title(pid)
broadcast_date = get_broadcast_date(pid)
listing = extract_listing(pid)
filename = get_output_filename(args)
tracklisting = generate_output(listing,... | python | def main():
"""Get a tracklisting, write to audio file or text."""
args = parse_arguments()
pid = args.pid
title = get_programme_title(pid)
broadcast_date = get_broadcast_date(pid)
listing = extract_listing(pid)
filename = get_output_filename(args)
tracklisting = generate_output(listing,... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"parse_arguments",
"(",
")",
"pid",
"=",
"args",
".",
"pid",
"title",
"=",
"get_programme_title",
"(",
"pid",
")",
"broadcast_date",
"=",
"get_broadcast_date",
"(",
"pid",
")",
"listing",
"=",
"extract_listing",
"... | Get a tracklisting, write to audio file or text. | [
"Get",
"a",
"tracklisting",
"write",
"to",
"audio",
"file",
"or",
"text",
"."
] | train | https://github.com/StevenMaude/bbc-radio-tracklisting-downloader/blob/9fe9096b4d889888f65756444e4fd71352b92458/bbc_tracklist.py#L239-L249 |
moonso/vcftoolbox | vcftoolbox/add_variant_information.py | replace_vcf_info | def replace_vcf_info(keyword, annotation, variant_line=None, variant_dict=None):
"""Replace the information of a info field of a vcf variant line or a
variant dict.
Arguments:
variant_line (str): A vcf formatted variant line
variant_dict (dict): A variant dictionary
keyword... | python | def replace_vcf_info(keyword, annotation, variant_line=None, variant_dict=None):
"""Replace the information of a info field of a vcf variant line or a
variant dict.
Arguments:
variant_line (str): A vcf formatted variant line
variant_dict (dict): A variant dictionary
keyword... | [
"def",
"replace_vcf_info",
"(",
"keyword",
",",
"annotation",
",",
"variant_line",
"=",
"None",
",",
"variant_dict",
"=",
"None",
")",
":",
"new_info",
"=",
"'{0}={1}'",
".",
"format",
"(",
"keyword",
",",
"annotation",
")",
"logger",
".",
"debug",
"(",
"\... | Replace the information of a info field of a vcf variant line or a
variant dict.
Arguments:
variant_line (str): A vcf formatted variant line
variant_dict (dict): A variant dictionary
keyword (str): The info field key
annotation (str): If the annotation is a key, value p... | [
"Replace",
"the",
"information",
"of",
"a",
"info",
"field",
"of",
"a",
"vcf",
"variant",
"line",
"or",
"a",
"variant",
"dict",
".",
"Arguments",
":",
"variant_line",
"(",
"str",
")",
":",
"A",
"vcf",
"formatted",
"variant",
"line",
"variant_dict",
"(",
... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/add_variant_information.py#L19-L79 |
moonso/vcftoolbox | vcftoolbox/add_variant_information.py | remove_vcf_info | def remove_vcf_info(keyword, variant_line=None, variant_dict=None):
"""Remove the information of a info field of a vcf variant line or a
variant dict.
Arguments:
variant_line (str): A vcf formatted variant line
variant_dict (dict): A variant dictionary
keyword (str): The in... | python | def remove_vcf_info(keyword, variant_line=None, variant_dict=None):
"""Remove the information of a info field of a vcf variant line or a
variant dict.
Arguments:
variant_line (str): A vcf formatted variant line
variant_dict (dict): A variant dictionary
keyword (str): The in... | [
"def",
"remove_vcf_info",
"(",
"keyword",
",",
"variant_line",
"=",
"None",
",",
"variant_dict",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"Removing variant information {0}\"",
".",
"format",
"(",
"keyword",
")",
")",
"fixed_variant",
"=",
"None",
... | Remove the information of a info field of a vcf variant line or a
variant dict.
Arguments:
variant_line (str): A vcf formatted variant line
variant_dict (dict): A variant dictionary
keyword (str): The info field key
Returns:
variant_line (str): A annotated vari... | [
"Remove",
"the",
"information",
"of",
"a",
"info",
"field",
"of",
"a",
"vcf",
"variant",
"line",
"or",
"a",
"variant",
"dict",
".",
"Arguments",
":",
"variant_line",
"(",
"str",
")",
":",
"A",
"vcf",
"formatted",
"variant",
"line",
"variant_dict",
"(",
"... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/add_variant_information.py#L81-L137 |
moonso/vcftoolbox | vcftoolbox/add_variant_information.py | add_vcf_info | def add_vcf_info(keyword, variant_line=None, variant_dict=None, annotation=None):
"""
Add information to the info field of a vcf variant line.
Arguments:
variant_line (str): A vcf formatted variant line
keyword (str): The info field key
annotation (str): If the annotation is a k... | python | def add_vcf_info(keyword, variant_line=None, variant_dict=None, annotation=None):
"""
Add information to the info field of a vcf variant line.
Arguments:
variant_line (str): A vcf formatted variant line
keyword (str): The info field key
annotation (str): If the annotation is a k... | [
"def",
"add_vcf_info",
"(",
"keyword",
",",
"variant_line",
"=",
"None",
",",
"variant_dict",
"=",
"None",
",",
"annotation",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"if",
"annotation",
":",
"new_info",
"=",... | Add information to the info field of a vcf variant line.
Arguments:
variant_line (str): A vcf formatted variant line
keyword (str): The info field key
annotation (str): If the annotation is a key, value pair
this is the string that represents the value
... | [
"Add",
"information",
"to",
"the",
"info",
"field",
"of",
"a",
"vcf",
"variant",
"line",
".",
"Arguments",
":",
"variant_line",
"(",
"str",
")",
":",
"A",
"vcf",
"formatted",
"variant",
"line",
"keyword",
"(",
"str",
")",
":",
"The",
"info",
"field",
"... | train | https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/add_variant_information.py#L140-L185 |
henzk/django-productline | django_productline/features/djpladmin/tasks.py | sync_auth_groups | def sync_auth_groups():
"""
Syncs auth groups according to settings.AUTH_GROUPS
:return:
"""
from django.conf import settings
from django.contrib.auth.models import Group, Permission
from django.db.models import Q
for data in settings.AUTH_GROUPS:
g1 = Group.objects.get_or_creat... | python | def sync_auth_groups():
"""
Syncs auth groups according to settings.AUTH_GROUPS
:return:
"""
from django.conf import settings
from django.contrib.auth.models import Group, Permission
from django.db.models import Q
for data in settings.AUTH_GROUPS:
g1 = Group.objects.get_or_creat... | [
"def",
"sync_auth_groups",
"(",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"models",
"import",
"Group",
",",
"Permission",
"from",
"django",
".",
"db",
".",
"models",
"import",
"Q",
... | Syncs auth groups according to settings.AUTH_GROUPS
:return: | [
"Syncs",
"auth",
"groups",
"according",
"to",
"settings",
".",
"AUTH_GROUPS",
":",
"return",
":"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/features/djpladmin/tasks.py#L8-L30 |
henzk/django-productline | django_productline/features/djpladmin/tasks.py | createsuperusers | def createsuperusers():
"""
Creates all superusers defined in settings.INITIAL_SUPERUSERS.
These superusers do not have any circles. They are plain superusers.
However you may want to signup yourself and make this new user a super user then.
"""
from django.contrib.auth import models as auth_mod... | python | def createsuperusers():
"""
Creates all superusers defined in settings.INITIAL_SUPERUSERS.
These superusers do not have any circles. They are plain superusers.
However you may want to signup yourself and make this new user a super user then.
"""
from django.contrib.auth import models as auth_mod... | [
"def",
"createsuperusers",
"(",
")",
":",
"from",
"django",
".",
"contrib",
".",
"auth",
"import",
"models",
"as",
"auth_models",
"from",
"django",
".",
"conf",
"import",
"settings",
"from",
"django",
".",
"core",
".",
"mail",
"import",
"send_mail",
"from",
... | Creates all superusers defined in settings.INITIAL_SUPERUSERS.
These superusers do not have any circles. They are plain superusers.
However you may want to signup yourself and make this new user a super user then. | [
"Creates",
"all",
"superusers",
"defined",
"in",
"settings",
".",
"INITIAL_SUPERUSERS",
".",
"These",
"superusers",
"do",
"not",
"have",
"any",
"circles",
".",
"They",
"are",
"plain",
"superusers",
".",
"However",
"you",
"may",
"want",
"to",
"signup",
"yoursel... | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/features/djpladmin/tasks.py#L49-L101 |
SetBased/py-etlt | etlt/Transformer.py | Transformer._log | def _log(message):
"""
Logs a message.
:param str message: The log message.
:rtype: None
"""
# @todo Replace with log package.
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + ' ' + str(message), flush=True) | python | def _log(message):
"""
Logs a message.
:param str message: The log message.
:rtype: None
"""
# @todo Replace with log package.
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + ' ' + str(message), flush=True) | [
"def",
"_log",
"(",
"message",
")",
":",
"# @todo Replace with log package.",
"print",
"(",
"time",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
",",
"time",
".",
"localtime",
"(",
")",
")",
"+",
"' '",
"+",
"str",
"(",
"message",
")",
",",
"flush",
"=",
... | Logs a message.
:param str message: The log message.
:rtype: None | [
"Logs",
"a",
"message",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/Transformer.py#L141-L150 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.