repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
TaurusOlson/fntools | fntools/fntools.py | find | def find(fn, record):
"""Apply a function on the record and return the corresponding new record
:param fn: a function
:param record: a dictionary
:returns: a dictionary
>>> find(max, {'Terry': 30, 'Graham': 35, 'John': 27})
{'Graham': 35}
"""
values_result = fn(record.values())
ke... | python | def find(fn, record):
"""Apply a function on the record and return the corresponding new record
:param fn: a function
:param record: a dictionary
:returns: a dictionary
>>> find(max, {'Terry': 30, 'Graham': 35, 'John': 27})
{'Graham': 35}
"""
values_result = fn(record.values())
ke... | [
"def",
"find",
"(",
"fn",
",",
"record",
")",
":",
"values_result",
"=",
"fn",
"(",
"record",
".",
"values",
"(",
")",
")",
"keys_result",
"=",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"record",
".",
"items",
"(",
")",
"if",
"v",
"==",
"values_resul... | Apply a function on the record and return the corresponding new record
:param fn: a function
:param record: a dictionary
:returns: a dictionary
>>> find(max, {'Terry': 30, 'Graham': 35, 'John': 27})
{'Graham': 35} | [
"Apply",
"a",
"function",
"on",
"the",
"record",
"and",
"return",
"the",
"corresponding",
"new",
"record"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L595-L608 |
TaurusOlson/fntools | fntools/fntools.py | remove | def remove(coll, value):
"""Remove all the occurrences of a given value
:param coll: a collection
:param value: the value to remove
:returns: a list
>>> data = ('NA', 0, 1, 'NA', 1, 2, 3, 'NA', 5)
>>> remove(data, 'NA')
(0, 1, 1, 2, 3, 5)
"""
coll_class = coll.__class__
return... | python | def remove(coll, value):
"""Remove all the occurrences of a given value
:param coll: a collection
:param value: the value to remove
:returns: a list
>>> data = ('NA', 0, 1, 'NA', 1, 2, 3, 'NA', 5)
>>> remove(data, 'NA')
(0, 1, 1, 2, 3, 5)
"""
coll_class = coll.__class__
return... | [
"def",
"remove",
"(",
"coll",
",",
"value",
")",
":",
"coll_class",
"=",
"coll",
".",
"__class__",
"return",
"coll_class",
"(",
"x",
"for",
"x",
"in",
"coll",
"if",
"x",
"!=",
"value",
")"
] | Remove all the occurrences of a given value
:param coll: a collection
:param value: the value to remove
:returns: a list
>>> data = ('NA', 0, 1, 'NA', 1, 2, 3, 'NA', 5)
>>> remove(data, 'NA')
(0, 1, 1, 2, 3, 5) | [
"Remove",
"all",
"the",
"occurrences",
"of",
"a",
"given",
"value"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L611-L624 |
TaurusOlson/fntools | fntools/fntools.py | are_in | def are_in(items, collection):
"""Return True for each item in the collection
:param items: a sub-collection
:param collection: a collection
:returns: a list of booleans
>>> are_in(['Terry', 'James'], ['Terry', 'John', 'Eric'])
[True, False]
"""
if not isinstance(items, (list, tuple))... | python | def are_in(items, collection):
"""Return True for each item in the collection
:param items: a sub-collection
:param collection: a collection
:returns: a list of booleans
>>> are_in(['Terry', 'James'], ['Terry', 'John', 'Eric'])
[True, False]
"""
if not isinstance(items, (list, tuple))... | [
"def",
"are_in",
"(",
"items",
",",
"collection",
")",
":",
"if",
"not",
"isinstance",
"(",
"items",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"items",
"=",
"(",
"items",
",",
")",
"return",
"map",
"(",
"lambda",
"x",
":",
"x",
"in",
"collec... | Return True for each item in the collection
:param items: a sub-collection
:param collection: a collection
:returns: a list of booleans
>>> are_in(['Terry', 'James'], ['Terry', 'John', 'Eric'])
[True, False] | [
"Return",
"True",
"for",
"each",
"item",
"in",
"the",
"collection"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L646-L659 |
TaurusOlson/fntools | fntools/fntools.py | monotony | def monotony(seq):
"""Determine the monotony of a sequence
:param seq: a sequence
:returns: 1 if the sequence is sorted (increasing)
:returns: 0 if it is not sorted
:returns: -1 if it is sorted in reverse order (decreasing)
>>> monotony([1, 2, 3])
1
>>> monotony([1, 3, 2])
0
>... | python | def monotony(seq):
"""Determine the monotony of a sequence
:param seq: a sequence
:returns: 1 if the sequence is sorted (increasing)
:returns: 0 if it is not sorted
:returns: -1 if it is sorted in reverse order (decreasing)
>>> monotony([1, 2, 3])
1
>>> monotony([1, 3, 2])
0
>... | [
"def",
"monotony",
"(",
"seq",
")",
":",
"if",
"seq",
"==",
"sorted",
"(",
"seq",
")",
":",
"return",
"1",
"elif",
"seq",
"==",
"list",
"(",
"reversed",
"(",
"sorted",
"(",
"seq",
")",
")",
")",
":",
"return",
"-",
"1",
"else",
":",
"return",
"... | Determine the monotony of a sequence
:param seq: a sequence
:returns: 1 if the sequence is sorted (increasing)
:returns: 0 if it is not sorted
:returns: -1 if it is sorted in reverse order (decreasing)
>>> monotony([1, 2, 3])
1
>>> monotony([1, 3, 2])
0
>>> monotony([3, 2, 1])
... | [
"Determine",
"the",
"monotony",
"of",
"a",
"sequence"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L698-L720 |
TaurusOlson/fntools | fntools/fntools.py | attributes | def attributes(data):
"""Return all the non callable and non special attributes of the input data
:param data: an object
:returns: a list
>>> class table:
... def __init__(self, name, rows, cols):
... self.name = name
... self.rows = rows
... self.cols = col... | python | def attributes(data):
"""Return all the non callable and non special attributes of the input data
:param data: an object
:returns: a list
>>> class table:
... def __init__(self, name, rows, cols):
... self.name = name
... self.rows = rows
... self.cols = col... | [
"def",
"attributes",
"(",
"data",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"dir",
"(",
"data",
")",
"if",
"not",
"callable",
"(",
"x",
")",
"and",
"not",
"x",
".",
"startswith",
"(",
"'__'",
")",
"]"
] | Return all the non callable and non special attributes of the input data
:param data: an object
:returns: a list
>>> class table:
... def __init__(self, name, rows, cols):
... self.name = name
... self.rows = rows
... self.cols = cols
>>> t = table('people'... | [
"Return",
"all",
"the",
"non",
"callable",
"and",
"non",
"special",
"attributes",
"of",
"the",
"input",
"data"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L723-L740 |
TaurusOlson/fntools | fntools/fntools.py | dfilter | def dfilter(fn, record):
"""filter for a directory
:param fn: A predicate function
:param record: a dict
:returns: a dict
>>> odd = lambda x: x % 2 != 0
>>> dfilter(odd, {'Terry': 30, 'Graham': 35, 'John': 27})
{'John': 27, 'Graham': 35}
"""
return dict([(k, v) for k, v in record.... | python | def dfilter(fn, record):
"""filter for a directory
:param fn: A predicate function
:param record: a dict
:returns: a dict
>>> odd = lambda x: x % 2 != 0
>>> dfilter(odd, {'Terry': 30, 'Graham': 35, 'John': 27})
{'John': 27, 'Graham': 35}
"""
return dict([(k, v) for k, v in record.... | [
"def",
"dfilter",
"(",
"fn",
",",
"record",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"record",
".",
"items",
"(",
")",
"if",
"fn",
"(",
"v",
")",
"]",
")"
] | filter for a directory
:param fn: A predicate function
:param record: a dict
:returns: a dict
>>> odd = lambda x: x % 2 != 0
>>> dfilter(odd, {'Terry': 30, 'Graham': 35, 'John': 27})
{'John': 27, 'Graham': 35} | [
"filter",
"for",
"a",
"directory"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L760-L772 |
TaurusOlson/fntools | fntools/fntools.py | _filter_occurrences | def _filter_occurrences(count, relat_op):
"""Filter the occurrences with respect to the selected relational operators"""
# Filter the occurrences equal (or not equal) to a given value
if "eq" in relat_op:
count = dfilter(lambda x: x == relat_op["eq"], count)
elif "ne" in relat_op:
count ... | python | def _filter_occurrences(count, relat_op):
"""Filter the occurrences with respect to the selected relational operators"""
# Filter the occurrences equal (or not equal) to a given value
if "eq" in relat_op:
count = dfilter(lambda x: x == relat_op["eq"], count)
elif "ne" in relat_op:
count ... | [
"def",
"_filter_occurrences",
"(",
"count",
",",
"relat_op",
")",
":",
"# Filter the occurrences equal (or not equal) to a given value",
"if",
"\"eq\"",
"in",
"relat_op",
":",
"count",
"=",
"dfilter",
"(",
"lambda",
"x",
":",
"x",
"==",
"relat_op",
"[",
"\"eq\"",
... | Filter the occurrences with respect to the selected relational operators | [
"Filter",
"the",
"occurrences",
"with",
"respect",
"to",
"the",
"selected",
"relational",
"operators"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L776-L795 |
TaurusOlson/fntools | fntools/fntools.py | occurrences | def occurrences(coll, value=None, **options):
"""Return the occurrences of the elements in the collection
:param coll: a collection
:param value: a value in the collection
:param options:
an optional keyword used as a criterion to filter the
values in the collection
:returns: the f... | python | def occurrences(coll, value=None, **options):
"""Return the occurrences of the elements in the collection
:param coll: a collection
:param value: a value in the collection
:param options:
an optional keyword used as a criterion to filter the
values in the collection
:returns: the f... | [
"def",
"occurrences",
"(",
"coll",
",",
"value",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"count",
"=",
"{",
"}",
"for",
"element",
"in",
"coll",
":",
"count",
"[",
"element",
"]",
"=",
"count",
".",
"get",
"(",
"element",
",",
"0",
")",
... | Return the occurrences of the elements in the collection
:param coll: a collection
:param value: a value in the collection
:param options:
an optional keyword used as a criterion to filter the
values in the collection
:returns: the frequency of the values in the collection as a diction... | [
"Return",
"the",
"occurrences",
"of",
"the",
"elements",
"in",
"the",
"collection"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L798-L833 |
TaurusOlson/fntools | fntools/fntools.py | indexof | def indexof(coll, item, start=0, default=None):
"""Return the index of the item in the collection
:param coll: iterable
:param item: scalar
:param start: (optional) The start index
:default: The default value of the index if the item is not in the collection
:returns: idx -- The index of the i... | python | def indexof(coll, item, start=0, default=None):
"""Return the index of the item in the collection
:param coll: iterable
:param item: scalar
:param start: (optional) The start index
:default: The default value of the index if the item is not in the collection
:returns: idx -- The index of the i... | [
"def",
"indexof",
"(",
"coll",
",",
"item",
",",
"start",
"=",
"0",
",",
"default",
"=",
"None",
")",
":",
"if",
"item",
"in",
"coll",
"[",
"start",
":",
"]",
":",
"return",
"list",
"(",
"coll",
")",
".",
"index",
"(",
"item",
",",
"start",
")"... | Return the index of the item in the collection
:param coll: iterable
:param item: scalar
:param start: (optional) The start index
:default: The default value of the index if the item is not in the collection
:returns: idx -- The index of the item in the collection
>>> monties = ['Eric', 'John... | [
"Return",
"the",
"index",
"of",
"the",
"item",
"in",
"the",
"collection"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L836-L860 |
TaurusOlson/fntools | fntools/fntools.py | indexesof | def indexesof(coll, item):
"""Return all the indexes of the item in the collection
:param coll: the collection
:param item: a value
:returns: a list of indexes
>>> monties = ['Eric', 'John', 'Terry', 'Terry', 'Graham', 'Mickael']
>>> indexesof(monties, 'Terry')
[2, 3]
"""
return [... | python | def indexesof(coll, item):
"""Return all the indexes of the item in the collection
:param coll: the collection
:param item: a value
:returns: a list of indexes
>>> monties = ['Eric', 'John', 'Terry', 'Terry', 'Graham', 'Mickael']
>>> indexesof(monties, 'Terry')
[2, 3]
"""
return [... | [
"def",
"indexesof",
"(",
"coll",
",",
"item",
")",
":",
"return",
"[",
"indexof",
"(",
"coll",
",",
"item",
",",
"i",
")",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"coll",
")",
")",
"if",
"coll",
"[",
"i",
"]",
"==",
"item",
"]"
] | Return all the indexes of the item in the collection
:param coll: the collection
:param item: a value
:returns: a list of indexes
>>> monties = ['Eric', 'John', 'Terry', 'Terry', 'Graham', 'Mickael']
>>> indexesof(monties, 'Terry')
[2, 3] | [
"Return",
"all",
"the",
"indexes",
"of",
"the",
"item",
"in",
"the",
"collection"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L863-L875 |
TaurusOlson/fntools | fntools/fntools.py | count | def count(fn, coll):
"""Return the count of True values returned by the predicate function applied to the
collection
:param fn: a predicate function
:param coll: a collection
:returns: an integer
>>> count(lambda x: x % 2 == 0, [11, 22, 31, 24, 15])
2
"""
return len([x for x in co... | python | def count(fn, coll):
"""Return the count of True values returned by the predicate function applied to the
collection
:param fn: a predicate function
:param coll: a collection
:returns: an integer
>>> count(lambda x: x % 2 == 0, [11, 22, 31, 24, 15])
2
"""
return len([x for x in co... | [
"def",
"count",
"(",
"fn",
",",
"coll",
")",
":",
"return",
"len",
"(",
"[",
"x",
"for",
"x",
"in",
"coll",
"if",
"fn",
"(",
"x",
")",
"is",
"True",
"]",
")"
] | Return the count of True values returned by the predicate function applied to the
collection
:param fn: a predicate function
:param coll: a collection
:returns: an integer
>>> count(lambda x: x % 2 == 0, [11, 22, 31, 24, 15])
2 | [
"Return",
"the",
"count",
"of",
"True",
"values",
"returned",
"by",
"the",
"predicate",
"function",
"applied",
"to",
"the",
"collection"
] | train | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L878-L890 |
shaunduncan/helga-icanhazascii | helga_icanhazascii.py | icanhazascii | def icanhazascii(client, channel, nick, message, found):
"""
A plugin for generating showing ascii artz
"""
global FLOOD_RATE, LAST_USED
now = time.time()
if channel in LAST_USED and (now - LAST_USED[channel]) < FLOOD_RATE:
return
LAST_USED[channel] = now
return found | python | def icanhazascii(client, channel, nick, message, found):
"""
A plugin for generating showing ascii artz
"""
global FLOOD_RATE, LAST_USED
now = time.time()
if channel in LAST_USED and (now - LAST_USED[channel]) < FLOOD_RATE:
return
LAST_USED[channel] = now
return found | [
"def",
"icanhazascii",
"(",
"client",
",",
"channel",
",",
"nick",
",",
"message",
",",
"found",
")",
":",
"global",
"FLOOD_RATE",
",",
"LAST_USED",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"channel",
"in",
"LAST_USED",
"and",
"(",
"now",
"-",
... | A plugin for generating showing ascii artz | [
"A",
"plugin",
"for",
"generating",
"showing",
"ascii",
"artz"
] | train | https://github.com/shaunduncan/helga-icanhazascii/blob/a69d63232186d6b0e6c6ac72935cee906eb359b1/helga_icanhazascii.py#L113-L124 |
xsleonard/wsgisubdomain | wsgisubdomain.py | SubdomainDispatcher.get_application | def get_application(self, environ):
""" Retrieve an application for a wsgi environ
:param environ: The environ object sent by wsgi to an application
"""
host = self._get_host(environ)
subdomain = self._extract_subdomain(host)
return self._get_application(subdomain) | python | def get_application(self, environ):
""" Retrieve an application for a wsgi environ
:param environ: The environ object sent by wsgi to an application
"""
host = self._get_host(environ)
subdomain = self._extract_subdomain(host)
return self._get_application(subdomain) | [
"def",
"get_application",
"(",
"self",
",",
"environ",
")",
":",
"host",
"=",
"self",
".",
"_get_host",
"(",
"environ",
")",
"subdomain",
"=",
"self",
".",
"_extract_subdomain",
"(",
"host",
")",
"return",
"self",
".",
"_get_application",
"(",
"subdomain",
... | Retrieve an application for a wsgi environ
:param environ: The environ object sent by wsgi to an application | [
"Retrieve",
"an",
"application",
"for",
"a",
"wsgi",
"environ"
] | train | https://github.com/xsleonard/wsgisubdomain/blob/394c705a9e39cf4e4e1af2551ed0ed79d2c070f3/wsgisubdomain.py#L37-L44 |
xsleonard/wsgisubdomain | wsgisubdomain.py | SubdomainDispatcher._get_application | def _get_application(self, subdomain):
""" Return a WSGI application for subdomain. The subdomain is
passed to the create_application constructor as a keyword argument.
:param subdomain: Subdomain to get or create an application with
"""
with self.lock:
app = self.i... | python | def _get_application(self, subdomain):
""" Return a WSGI application for subdomain. The subdomain is
passed to the create_application constructor as a keyword argument.
:param subdomain: Subdomain to get or create an application with
"""
with self.lock:
app = self.i... | [
"def",
"_get_application",
"(",
"self",
",",
"subdomain",
")",
":",
"with",
"self",
".",
"lock",
":",
"app",
"=",
"self",
".",
"instances",
".",
"get",
"(",
"subdomain",
")",
"if",
"app",
"is",
"None",
":",
"app",
"=",
"self",
".",
"create_application"... | Return a WSGI application for subdomain. The subdomain is
passed to the create_application constructor as a keyword argument.
:param subdomain: Subdomain to get or create an application with | [
"Return",
"a",
"WSGI",
"application",
"for",
"subdomain",
".",
"The",
"subdomain",
"is",
"passed",
"to",
"the",
"create_application",
"constructor",
"as",
"a",
"keyword",
"argument",
"."
] | train | https://github.com/xsleonard/wsgisubdomain/blob/394c705a9e39cf4e4e1af2551ed0ed79d2c070f3/wsgisubdomain.py#L46-L57 |
xsleonard/wsgisubdomain | wsgisubdomain.py | SubdomainDispatcher._extract_subdomain | def _extract_subdomain(host):
""" Returns a subdomain from a host. This host is typically the
HTTP_HOST request envvar. If the host is an IP address, `None` is
returned
:param host: Request's target host
"""
host = host.split(':')[0]
# If the host is an IP addre... | python | def _extract_subdomain(host):
""" Returns a subdomain from a host. This host is typically the
HTTP_HOST request envvar. If the host is an IP address, `None` is
returned
:param host: Request's target host
"""
host = host.split(':')[0]
# If the host is an IP addre... | [
"def",
"_extract_subdomain",
"(",
"host",
")",
":",
"host",
"=",
"host",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
"# If the host is an IP address, there is no subdomain to extract",
"try",
":",
"# Check if the host is an ip address",
"socket",
".",
"inet_aton",
"... | Returns a subdomain from a host. This host is typically the
HTTP_HOST request envvar. If the host is an IP address, `None` is
returned
:param host: Request's target host | [
"Returns",
"a",
"subdomain",
"from",
"a",
"host",
".",
"This",
"host",
"is",
"typically",
"the",
"HTTP_HOST",
"request",
"envvar",
".",
"If",
"the",
"host",
"is",
"an",
"IP",
"address",
"None",
"is",
"returned"
] | train | https://github.com/xsleonard/wsgisubdomain/blob/394c705a9e39cf4e4e1af2551ed0ed79d2c070f3/wsgisubdomain.py#L60-L74 |
mattrobenolt/python-casscache | casscache.py | Client._val_to_store_info | def _val_to_store_info(self, val):
"""
Transform val to a storable representation,
returning a tuple of the flags, the length of the new value, and the new value itself.
"""
if isinstance(val, str):
return val, 0
elif isinstance(val, int):
return "... | python | def _val_to_store_info(self, val):
"""
Transform val to a storable representation,
returning a tuple of the flags, the length of the new value, and the new value itself.
"""
if isinstance(val, str):
return val, 0
elif isinstance(val, int):
return "... | [
"def",
"_val_to_store_info",
"(",
"self",
",",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"str",
")",
":",
"return",
"val",
",",
"0",
"elif",
"isinstance",
"(",
"val",
",",
"int",
")",
":",
"return",
"\"%d\"",
"%",
"val",
",",
"Client",
... | Transform val to a storable representation,
returning a tuple of the flags, the length of the new value, and the new value itself. | [
"Transform",
"val",
"to",
"a",
"storable",
"representation",
"returning",
"a",
"tuple",
"of",
"the",
"flags",
"the",
"length",
"of",
"the",
"new",
"value",
"and",
"the",
"new",
"value",
"itself",
"."
] | train | https://github.com/mattrobenolt/python-casscache/blob/71b7388d233aa6e2e1682b92736abe1bb1c12045/casscache.py#L167-L178 |
nicktgr15/sac | sac/cli/wav_editor.py | WavEditor.are_labels_overlapping | def are_labels_overlapping(label1, label2):
"""
non-overlap cases
|---------| lbl1
|--------| lbl2
|---------| lbl1
|---------| lbl2
:param label1:
:param label2:
:return:
"""
if (
... | python | def are_labels_overlapping(label1, label2):
"""
non-overlap cases
|---------| lbl1
|--------| lbl2
|---------| lbl1
|---------| lbl2
:param label1:
:param label2:
:return:
"""
if (
... | [
"def",
"are_labels_overlapping",
"(",
"label1",
",",
"label2",
")",
":",
"if",
"(",
"label2",
".",
"start_seconds",
">",
"label1",
".",
"end_seconds",
"and",
"label2",
".",
"start_seconds",
">",
"label1",
".",
"start_seconds",
"and",
"label2",
".",
"end_second... | non-overlap cases
|---------| lbl1
|--------| lbl2
|---------| lbl1
|---------| lbl2
:param label1:
:param label2:
:return: | [
"non",
"-",
"overlap",
"cases"
] | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/cli/wav_editor.py#L72-L99 |
jkenlooper/chill | src/chill/app.py | multiple_directory_files_loader | def multiple_directory_files_loader(*args):
"""
Loads all the files in each directory as values in a dict with the key
being the relative file path of the directory. Updates the value if
subsequent file paths are the same.
"""
d = dict()
def load_files(folder):
for (dirpath, dirnam... | python | def multiple_directory_files_loader(*args):
"""
Loads all the files in each directory as values in a dict with the key
being the relative file path of the directory. Updates the value if
subsequent file paths are the same.
"""
d = dict()
def load_files(folder):
for (dirpath, dirnam... | [
"def",
"multiple_directory_files_loader",
"(",
"*",
"args",
")",
":",
"d",
"=",
"dict",
"(",
")",
"def",
"load_files",
"(",
"folder",
")",
":",
"for",
"(",
"dirpath",
",",
"dirnames",
",",
"filenames",
")",
"in",
"os",
".",
"walk",
"(",
"folder",
")",
... | Loads all the files in each directory as values in a dict with the key
being the relative file path of the directory. Updates the value if
subsequent file paths are the same. | [
"Loads",
"all",
"the",
"files",
"in",
"each",
"directory",
"as",
"values",
"in",
"a",
"dict",
"with",
"the",
"key",
"being",
"the",
"relative",
"file",
"path",
"of",
"the",
"directory",
".",
"Updates",
"the",
"value",
"if",
"subsequent",
"file",
"paths",
... | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/app.py#L67-L87 |
jkenlooper/chill | src/chill/app.py | make_app | def make_app(config=None, **kw):
"factory to create the app"
app = ChillFlask('chill')
if config:
config_file = config if config[0] == os.sep else os.path.join(os.getcwd(), config)
app.config.from_pyfile(config_file)
app.config.update(kw)
cache.init_app(app)
# Set the freezer... | python | def make_app(config=None, **kw):
"factory to create the app"
app = ChillFlask('chill')
if config:
config_file = config if config[0] == os.sep else os.path.join(os.getcwd(), config)
app.config.from_pyfile(config_file)
app.config.update(kw)
cache.init_app(app)
# Set the freezer... | [
"def",
"make_app",
"(",
"config",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"app",
"=",
"ChillFlask",
"(",
"'chill'",
")",
"if",
"config",
":",
"config_file",
"=",
"config",
"if",
"config",
"[",
"0",
"]",
"==",
"os",
".",
"sep",
"else",
"os",
"... | factory to create the app | [
"factory",
"to",
"create",
"the",
"app"
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/app.py#L89-L241 |
jkenlooper/chill | src/chill/app.py | ChillFlask.send_root_file | def send_root_file(self, filename):
"""
Function used to send static files from the root of the domain.
"""
cache_timeout = self.get_send_file_max_age(filename)
return send_from_directory(self.config['ROOT_FOLDER'], filename,
cache_timeout=cache... | python | def send_root_file(self, filename):
"""
Function used to send static files from the root of the domain.
"""
cache_timeout = self.get_send_file_max_age(filename)
return send_from_directory(self.config['ROOT_FOLDER'], filename,
cache_timeout=cache... | [
"def",
"send_root_file",
"(",
"self",
",",
"filename",
")",
":",
"cache_timeout",
"=",
"self",
".",
"get_send_file_max_age",
"(",
"filename",
")",
"return",
"send_from_directory",
"(",
"self",
".",
"config",
"[",
"'ROOT_FOLDER'",
"]",
",",
"filename",
",",
"ca... | Function used to send static files from the root of the domain. | [
"Function",
"used",
"to",
"send",
"static",
"files",
"from",
"the",
"root",
"of",
"the",
"domain",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/app.py#L20-L26 |
jkenlooper/chill | src/chill/app.py | ChillFlask.send_media_file | def send_media_file(self, filename):
"""
Function used to send media files from the media folder to the browser.
"""
cache_timeout = self.get_send_file_max_age(filename)
return send_from_directory(self.config['MEDIA_FOLDER'], filename,
cache_tim... | python | def send_media_file(self, filename):
"""
Function used to send media files from the media folder to the browser.
"""
cache_timeout = self.get_send_file_max_age(filename)
return send_from_directory(self.config['MEDIA_FOLDER'], filename,
cache_tim... | [
"def",
"send_media_file",
"(",
"self",
",",
"filename",
")",
":",
"cache_timeout",
"=",
"self",
".",
"get_send_file_max_age",
"(",
"filename",
")",
"return",
"send_from_directory",
"(",
"self",
".",
"config",
"[",
"'MEDIA_FOLDER'",
"]",
",",
"filename",
",",
"... | Function used to send media files from the media folder to the browser. | [
"Function",
"used",
"to",
"send",
"media",
"files",
"from",
"the",
"media",
"folder",
"to",
"the",
"browser",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/app.py#L28-L34 |
jkenlooper/chill | src/chill/app.py | ChillFlask.send_theme_file | def send_theme_file(self, filename):
"""
Function used to send static theme files from the theme folder to the browser.
"""
cache_timeout = self.get_send_file_max_age(filename)
return send_from_directory(self.config['THEME_STATIC_FOLDER'], filename,
... | python | def send_theme_file(self, filename):
"""
Function used to send static theme files from the theme folder to the browser.
"""
cache_timeout = self.get_send_file_max_age(filename)
return send_from_directory(self.config['THEME_STATIC_FOLDER'], filename,
... | [
"def",
"send_theme_file",
"(",
"self",
",",
"filename",
")",
":",
"cache_timeout",
"=",
"self",
".",
"get_send_file_max_age",
"(",
"filename",
")",
"return",
"send_from_directory",
"(",
"self",
".",
"config",
"[",
"'THEME_STATIC_FOLDER'",
"]",
",",
"filename",
"... | Function used to send static theme files from the theme folder to the browser. | [
"Function",
"used",
"to",
"send",
"static",
"theme",
"files",
"from",
"the",
"theme",
"folder",
"to",
"the",
"browser",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/app.py#L36-L42 |
jut-io/jut-python-tools | jut/common.py | info | def info(message, *args, **kwargs):
"""
write a message to stdout
"""
if 'end' in kwargs:
end = kwargs['end']
else:
end = '\n'
if len(args) == 0:
sys.stdout.write(message)
else:
sys.stdout.write(message % args)
sys.stdout.write(end)
sys.stdout.flush(... | python | def info(message, *args, **kwargs):
"""
write a message to stdout
"""
if 'end' in kwargs:
end = kwargs['end']
else:
end = '\n'
if len(args) == 0:
sys.stdout.write(message)
else:
sys.stdout.write(message % args)
sys.stdout.write(end)
sys.stdout.flush(... | [
"def",
"info",
"(",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'end'",
"in",
"kwargs",
":",
"end",
"=",
"kwargs",
"[",
"'end'",
"]",
"else",
":",
"end",
"=",
"'\\n'",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
... | write a message to stdout | [
"write",
"a",
"message",
"to",
"stdout"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/common.py#L9-L24 |
jut-io/jut-python-tools | jut/common.py | error | def error(message, *args, **kwargs):
"""
write a message to stderr
"""
if 'end' in kwargs:
end = kwargs['end']
else:
end = '\n'
if len(args) == 0:
sys.stderr.write(message)
else:
sys.stderr.write(message % args)
sys.stderr.write(end)
sys.stderr.flush... | python | def error(message, *args, **kwargs):
"""
write a message to stderr
"""
if 'end' in kwargs:
end = kwargs['end']
else:
end = '\n'
if len(args) == 0:
sys.stderr.write(message)
else:
sys.stderr.write(message % args)
sys.stderr.write(end)
sys.stderr.flush... | [
"def",
"error",
"(",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'end'",
"in",
"kwargs",
":",
"end",
"=",
"kwargs",
"[",
"'end'",
"]",
"else",
":",
"end",
"=",
"'\\n'",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
... | write a message to stderr | [
"write",
"a",
"message",
"to",
"stderr"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/common.py#L27-L42 |
jut-io/jut-python-tools | jut/common.py | debug | def debug(message, *args, **kwargs):
"""
debug output goes to stderr so you can still redirect the stdout to a file
or another program. Controlled by the JUT_DEBUG environment variable being
present
"""
if 'end' in kwargs:
end = kwargs['end']
else:
end = '\n'
if DEBUG: ... | python | def debug(message, *args, **kwargs):
"""
debug output goes to stderr so you can still redirect the stdout to a file
or another program. Controlled by the JUT_DEBUG environment variable being
present
"""
if 'end' in kwargs:
end = kwargs['end']
else:
end = '\n'
if DEBUG: ... | [
"def",
"debug",
"(",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'end'",
"in",
"kwargs",
":",
"end",
"=",
"kwargs",
"[",
"'end'",
"]",
"else",
":",
"end",
"=",
"'\\n'",
"if",
"DEBUG",
":",
"if",
"len",
"(",
"args",
")... | debug output goes to stderr so you can still redirect the stdout to a file
or another program. Controlled by the JUT_DEBUG environment variable being
present | [
"debug",
"output",
"goes",
"to",
"stderr",
"so",
"you",
"can",
"still",
"redirect",
"the",
"stdout",
"to",
"a",
"file",
"or",
"another",
"program",
".",
"Controlled",
"by",
"the",
"JUT_DEBUG",
"environment",
"variable",
"being",
"present"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/common.py#L45-L64 |
klmitch/workq | workq.py | WorkQueue.add | def add(self, item):
"""
Add an item to the work queue.
:param item: The work item to add. An item may be of any
type; however, if it is not hashable, then the
work queue must either be initialized with
``unique`` set to ``False``,... | python | def add(self, item):
"""
Add an item to the work queue.
:param item: The work item to add. An item may be of any
type; however, if it is not hashable, then the
work queue must either be initialized with
``unique`` set to ``False``,... | [
"def",
"add",
"(",
"self",
",",
"item",
")",
":",
"# Are we to uniquify work items?",
"if",
"self",
".",
"_unique",
":",
"key",
"=",
"self",
".",
"_key",
"(",
"item",
")",
"if",
"self",
".",
"_key",
"else",
"item",
"# If it already has been added to the queue,... | Add an item to the work queue.
:param item: The work item to add. An item may be of any
type; however, if it is not hashable, then the
work queue must either be initialized with
``unique`` set to ``False``, or a ``key``
callab... | [
"Add",
"an",
"item",
"to",
"the",
"work",
"queue",
"."
] | train | https://github.com/klmitch/workq/blob/6b26c7546947bd0b0c98d78cf4653411a1d09c55/workq.py#L96-L122 |
rorr73/LifeSOSpy | lifesospy/enums.py | IntEnumEx.has_value | def has_value(cls, value: int) -> bool:
"""True if specified value exists in int enum; otherwise, False."""
return any(value == item.value for item in cls) | python | def has_value(cls, value: int) -> bool:
"""True if specified value exists in int enum; otherwise, False."""
return any(value == item.value for item in cls) | [
"def",
"has_value",
"(",
"cls",
",",
"value",
":",
"int",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"value",
"==",
"item",
".",
"value",
"for",
"item",
"in",
"cls",
")"
] | True if specified value exists in int enum; otherwise, False. | [
"True",
"if",
"specified",
"value",
"exists",
"in",
"int",
"enum",
";",
"otherwise",
"False",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/enums.py#L20-L22 |
rorr73/LifeSOSpy | lifesospy/enums.py | IntEnumEx.parse_name | def parse_name(cls, name: str, default: T = None) -> T:
"""Parse specified name for IntEnum; return default if not found."""
if not name:
return default
name = name.lower()
return next((item for item in cls if name == item.name.lower()), default) | python | def parse_name(cls, name: str, default: T = None) -> T:
"""Parse specified name for IntEnum; return default if not found."""
if not name:
return default
name = name.lower()
return next((item for item in cls if name == item.name.lower()), default) | [
"def",
"parse_name",
"(",
"cls",
",",
"name",
":",
"str",
",",
"default",
":",
"T",
"=",
"None",
")",
"->",
"T",
":",
"if",
"not",
"name",
":",
"return",
"default",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"return",
"next",
"(",
"(",
"item",
... | Parse specified name for IntEnum; return default if not found. | [
"Parse",
"specified",
"name",
"for",
"IntEnum",
";",
"return",
"default",
"if",
"not",
"found",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/enums.py#L25-L30 |
rorr73/LifeSOSpy | lifesospy/enums.py | IntEnumEx.parse_value | def parse_value(cls, value: int, default: T = None) -> T:
"""Parse specified value for IntEnum; return default if not found."""
return next((item for item in cls if value == item.value), default) | python | def parse_value(cls, value: int, default: T = None) -> T:
"""Parse specified value for IntEnum; return default if not found."""
return next((item for item in cls if value == item.value), default) | [
"def",
"parse_value",
"(",
"cls",
",",
"value",
":",
"int",
",",
"default",
":",
"T",
"=",
"None",
")",
"->",
"T",
":",
"return",
"next",
"(",
"(",
"item",
"for",
"item",
"in",
"cls",
"if",
"value",
"==",
"item",
".",
"value",
")",
",",
"default"... | Parse specified value for IntEnum; return default if not found. | [
"Parse",
"specified",
"value",
"for",
"IntEnum",
";",
"return",
"default",
"if",
"not",
"found",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/enums.py#L33-L35 |
rorr73/LifeSOSpy | lifesospy/enums.py | IntFlagEx.parse_names | def parse_names(cls, names: List[str]) -> T:
"""Parse specified names for IntEnum; return default if not found."""
value = 0
iterable = cls # type: Iterable
for name in names:
name = name.lower()
flag = next((item for item in iterable if name == item.name.lower()... | python | def parse_names(cls, names: List[str]) -> T:
"""Parse specified names for IntEnum; return default if not found."""
value = 0
iterable = cls # type: Iterable
for name in names:
name = name.lower()
flag = next((item for item in iterable if name == item.name.lower()... | [
"def",
"parse_names",
"(",
"cls",
",",
"names",
":",
"List",
"[",
"str",
"]",
")",
"->",
"T",
":",
"value",
"=",
"0",
"iterable",
"=",
"cls",
"# type: Iterable",
"for",
"name",
"in",
"names",
":",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"flag"... | Parse specified names for IntEnum; return default if not found. | [
"Parse",
"specified",
"names",
"for",
"IntEnum",
";",
"return",
"default",
"if",
"not",
"found",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/enums.py#L46-L57 |
mbr/sshkeys | sshkeys/__init__.py | Key._extract_options | def _extract_options(line):
r'''Given a line as it would appear in the authorized_keys file,
return an OrderedDict of options, and the remainder of a line as a
string.
>>> Key._extract_options(r'no-pty,command="sh" ssh-rsa AAAAB3NzaC1yc2EAAA...OFy5Lwc8Lo+Jk=')
(OrderedDict([('no... | python | def _extract_options(line):
r'''Given a line as it would appear in the authorized_keys file,
return an OrderedDict of options, and the remainder of a line as a
string.
>>> Key._extract_options(r'no-pty,command="sh" ssh-rsa AAAAB3NzaC1yc2EAAA...OFy5Lwc8Lo+Jk=')
(OrderedDict([('no... | [
"def",
"_extract_options",
"(",
"line",
")",
":",
"options",
"=",
"OrderedDict",
"(",
"{",
"}",
")",
"quoted",
"=",
"False",
"escaped",
"=",
"False",
"option_name",
"=",
"''",
"option_val",
"=",
"None",
"key_without_options",
"=",
"''",
"in_options",
"=",
... | r'''Given a line as it would appear in the authorized_keys file,
return an OrderedDict of options, and the remainder of a line as a
string.
>>> Key._extract_options(r'no-pty,command="sh" ssh-rsa AAAAB3NzaC1yc2EAAA...OFy5Lwc8Lo+Jk=')
(OrderedDict([('no-pty', True), ('command', 'sh')]), '... | [
"r",
"Given",
"a",
"line",
"as",
"it",
"would",
"appear",
"in",
"the",
"authorized_keys",
"file",
"return",
"an",
"OrderedDict",
"of",
"options",
"and",
"the",
"remainder",
"of",
"a",
"line",
"as",
"a",
"string",
"."
] | train | https://github.com/mbr/sshkeys/blob/d62e46fcc5e677827ad7f0663ab3b2f99fe564a0/sshkeys/__init__.py#L59-L138 |
mbr/sshkeys | sshkeys/__init__.py | Key.from_pubkey_line | def from_pubkey_line(cls, line):
"""Generate Key instance from a a string. Raise ValueError if string is
malformed"""
options, key_without_options = cls._extract_options(line)
if key_without_options == '':
raise ValueError("Empty key")
# the key (with options stripped... | python | def from_pubkey_line(cls, line):
"""Generate Key instance from a a string. Raise ValueError if string is
malformed"""
options, key_without_options = cls._extract_options(line)
if key_without_options == '':
raise ValueError("Empty key")
# the key (with options stripped... | [
"def",
"from_pubkey_line",
"(",
"cls",
",",
"line",
")",
":",
"options",
",",
"key_without_options",
"=",
"cls",
".",
"_extract_options",
"(",
"line",
")",
"if",
"key_without_options",
"==",
"''",
":",
"raise",
"ValueError",
"(",
"\"Empty key\"",
")",
"# the k... | Generate Key instance from a a string. Raise ValueError if string is
malformed | [
"Generate",
"Key",
"instance",
"from",
"a",
"a",
"string",
".",
"Raise",
"ValueError",
"if",
"string",
"is",
"malformed"
] | train | https://github.com/mbr/sshkeys/blob/d62e46fcc5e677827ad7f0663ab3b2f99fe564a0/sshkeys/__init__.py#L141-L175 |
mbr/sshkeys | sshkeys/__init__.py | Key.from_pubkey_file | def from_pubkey_file(cls, file):
"""Generate a Key instance from a file. Raise ValueError is key is
malformed"""
if hasattr(file, 'read'):
return cls.from_pubkey_line(file.read())
return cls.from_pubkey_line(open(file).read()) | python | def from_pubkey_file(cls, file):
"""Generate a Key instance from a file. Raise ValueError is key is
malformed"""
if hasattr(file, 'read'):
return cls.from_pubkey_line(file.read())
return cls.from_pubkey_line(open(file).read()) | [
"def",
"from_pubkey_file",
"(",
"cls",
",",
"file",
")",
":",
"if",
"hasattr",
"(",
"file",
",",
"'read'",
")",
":",
"return",
"cls",
".",
"from_pubkey_line",
"(",
"file",
".",
"read",
"(",
")",
")",
"return",
"cls",
".",
"from_pubkey_line",
"(",
"open... | Generate a Key instance from a file. Raise ValueError is key is
malformed | [
"Generate",
"a",
"Key",
"instance",
"from",
"a",
"file",
".",
"Raise",
"ValueError",
"is",
"key",
"is",
"malformed"
] | train | https://github.com/mbr/sshkeys/blob/d62e46fcc5e677827ad7f0663ab3b2f99fe564a0/sshkeys/__init__.py#L178-L184 |
blubberdiblub/eztemplate | eztemplate/engines/__init__.py | _init | def _init():
"""Dynamically import engines that initialize successfully."""
import importlib
import os
import re
filenames = os.listdir(os.path.dirname(__file__))
module_names = set()
for filename in filenames:
match = re.match(r'^(?P<name>[A-Z_a-z]\w*)\.py[co]?$', filename)
... | python | def _init():
"""Dynamically import engines that initialize successfully."""
import importlib
import os
import re
filenames = os.listdir(os.path.dirname(__file__))
module_names = set()
for filename in filenames:
match = re.match(r'^(?P<name>[A-Z_a-z]\w*)\.py[co]?$', filename)
... | [
"def",
"_init",
"(",
")",
":",
"import",
"importlib",
"import",
"os",
"import",
"re",
"filenames",
"=",
"os",
".",
"listdir",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"module_names",
"=",
"set",
"(",
")",
"for",
"filename",
... | Dynamically import engines that initialize successfully. | [
"Dynamically",
"import",
"engines",
"that",
"initialize",
"successfully",
"."
] | train | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/__init__.py#L113-L149 |
blubberdiblub/eztemplate | eztemplate/engines/__init__.py | Engine.str | def str(self, value, tolerant=False, limit=1000, seen=frozenset()):
"""Transform value into a representation suitable for substitution."""
if value is None:
if tolerant:
return ""
raise ValueError("value is None")
if isinstance(value, (bool, numbers.Numb... | python | def str(self, value, tolerant=False, limit=1000, seen=frozenset()):
"""Transform value into a representation suitable for substitution."""
if value is None:
if tolerant:
return ""
raise ValueError("value is None")
if isinstance(value, (bool, numbers.Numb... | [
"def",
"str",
"(",
"self",
",",
"value",
",",
"tolerant",
"=",
"False",
",",
"limit",
"=",
"1000",
",",
"seen",
"=",
"frozenset",
"(",
")",
")",
":",
"if",
"value",
"is",
"None",
":",
"if",
"tolerant",
":",
"return",
"\"\"",
"raise",
"ValueError",
... | Transform value into a representation suitable for substitution. | [
"Transform",
"value",
"into",
"a",
"representation",
"suitable",
"for",
"substitution",
"."
] | train | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/__init__.py#L35-L103 |
databuild/databuild | databuild/adapters/locmem/models.py | LocMemSheet._match | def _match(self, doc, where):
"""Return True if 'doc' matches the 'where' condition."""
assert isinstance(where, dict), "where is not a dictionary"
assert isinstance(doc, dict), "doc is not a dictionary"
try:
return all([doc[k] == v for k, v in where.items()])
except ... | python | def _match(self, doc, where):
"""Return True if 'doc' matches the 'where' condition."""
assert isinstance(where, dict), "where is not a dictionary"
assert isinstance(doc, dict), "doc is not a dictionary"
try:
return all([doc[k] == v for k, v in where.items()])
except ... | [
"def",
"_match",
"(",
"self",
",",
"doc",
",",
"where",
")",
":",
"assert",
"isinstance",
"(",
"where",
",",
"dict",
")",
",",
"\"where is not a dictionary\"",
"assert",
"isinstance",
"(",
"doc",
",",
"dict",
")",
",",
"\"doc is not a dictionary\"",
"try",
"... | Return True if 'doc' matches the 'where' condition. | [
"Return",
"True",
"if",
"doc",
"matches",
"the",
"where",
"condition",
"."
] | train | https://github.com/databuild/databuild/blob/4c8ee04fad1748f5b966753057ac05efbc289b10/databuild/adapters/locmem/models.py#L24-L31 |
zeaphoo/budoc | budoc/pydoc.py | import_module | def import_module(module_name):
"""
Imports a module. A single point of truth for importing modules to
be documented by `pydoc`. In particular, it makes sure that the top
module in `module_name` can be imported by using only the paths in
`pydoc.import_path`.
If a module has already been importe... | python | def import_module(module_name):
"""
Imports a module. A single point of truth for importing modules to
be documented by `pydoc`. In particular, it makes sure that the top
module in `module_name` can be imported by using only the paths in
`pydoc.import_path`.
If a module has already been importe... | [
"def",
"import_module",
"(",
"module_name",
")",
":",
"if",
"import_path",
"!=",
"sys",
".",
"path",
":",
"# Such a kludge. Only restrict imports if the `import_path` has",
"# been changed. We don't want to always restrict imports, since",
"# providing a path to `imp.find_module` stops... | Imports a module. A single point of truth for importing modules to
be documented by `pydoc`. In particular, it makes sure that the top
module in `module_name` can be imported by using only the paths in
`pydoc.import_path`.
If a module has already been imported, then its corresponding entry
in `sys.... | [
"Imports",
"a",
"module",
".",
"A",
"single",
"point",
"of",
"truth",
"for",
"importing",
"modules",
"to",
"be",
"documented",
"by",
"pydoc",
".",
"In",
"particular",
"it",
"makes",
"sure",
"that",
"the",
"top",
"module",
"in",
"module_name",
"can",
"be",
... | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L26-L59 |
zeaphoo/budoc | budoc/pydoc.py | _safe_import | def _safe_import(module_name):
"""
A function for safely importing `module_name`, where errors are
suppressed and `stdout` and `stderr` are redirected to a null
device. The obligation is on the caller to close `stdin` in order
to avoid impolite modules from blocking on `stdin` when imported.
"""... | python | def _safe_import(module_name):
"""
A function for safely importing `module_name`, where errors are
suppressed and `stdout` and `stderr` are redirected to a null
device. The obligation is on the caller to close `stdin` in order
to avoid impolite modules from blocking on `stdin` when imported.
"""... | [
"def",
"_safe_import",
"(",
"module_name",
")",
":",
"class",
"_Null",
"(",
"object",
")",
":",
"def",
"write",
"(",
"self",
",",
"*",
"_",
")",
":",
"pass",
"sout",
",",
"serr",
"=",
"sys",
".",
"stdout",
",",
"sys",
".",
"stderr",
"sys",
".",
"... | A function for safely importing `module_name`, where errors are
suppressed and `stdout` and `stderr` are redirected to a null
device. The obligation is on the caller to close `stdin` in order
to avoid impolite modules from blocking on `stdin` when imported. | [
"A",
"function",
"for",
"safely",
"importing",
"module_name",
"where",
"errors",
"are",
"suppressed",
"and",
"stdout",
"and",
"stderr",
"are",
"redirected",
"to",
"a",
"null",
"device",
".",
"The",
"obligation",
"is",
"on",
"the",
"caller",
"to",
"close",
"s... | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L80-L98 |
zeaphoo/budoc | budoc/pydoc.py | _var_docstrings | def _var_docstrings(tree, module, cls=None, init=False):
"""
Extracts variable docstrings given `tree` as the abstract syntax,
`module` as a `pydoc.Module` containing `tree` and an option `cls`
as a `pydoc.Class` corresponding to the tree. In particular, `cls`
should be specified when extracting doc... | python | def _var_docstrings(tree, module, cls=None, init=False):
"""
Extracts variable docstrings given `tree` as the abstract syntax,
`module` as a `pydoc.Module` containing `tree` and an option `cls`
as a `pydoc.Class` corresponding to the tree. In particular, `cls`
should be specified when extracting doc... | [
"def",
"_var_docstrings",
"(",
"tree",
",",
"module",
",",
"cls",
"=",
"None",
",",
"init",
"=",
"False",
")",
":",
"vs",
"=",
"{",
"}",
"children",
"=",
"list",
"(",
"ast",
".",
"iter_child_nodes",
"(",
"tree",
")",
")",
"for",
"i",
",",
"child",
... | Extracts variable docstrings given `tree` as the abstract syntax,
`module` as a `pydoc.Module` containing `tree` and an option `cls`
as a `pydoc.Class` corresponding to the tree. In particular, `cls`
should be specified when extracting docstrings from a class or an
`__init__` method. Finally, `init` sho... | [
"Extracts",
"variable",
"docstrings",
"given",
"tree",
"as",
"the",
"abstract",
"syntax",
"module",
"as",
"a",
"pydoc",
".",
"Module",
"containing",
"tree",
"and",
"an",
"option",
"cls",
"as",
"a",
"pydoc",
".",
"Class",
"corresponding",
"to",
"the",
"tree",... | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L101-L137 |
zeaphoo/budoc | budoc/pydoc.py | Module.mro | def mro(self, cls):
"""
Returns a method resolution list of documentation objects
for `cls`, which must be a documentation object.
The list will contain objects belonging to `pydoc.Class` or
`pydoc.External`. Objects belonging to the former are exported
classes either in... | python | def mro(self, cls):
"""
Returns a method resolution list of documentation objects
for `cls`, which must be a documentation object.
The list will contain objects belonging to `pydoc.Class` or
`pydoc.External`. Objects belonging to the former are exported
classes either in... | [
"def",
"mro",
"(",
"self",
",",
"cls",
")",
":",
"ups",
"=",
"inspect",
".",
"getmro",
"(",
"cls",
".",
"cls",
")",
"return",
"list",
"(",
"map",
"(",
"lambda",
"c",
":",
"self",
".",
"find_class",
"(",
"c",
")",
",",
"ups",
")",
")"
] | Returns a method resolution list of documentation objects
for `cls`, which must be a documentation object.
The list will contain objects belonging to `pydoc.Class` or
`pydoc.External`. Objects belonging to the former are exported
classes either in this module or in one of its sub-module... | [
"Returns",
"a",
"method",
"resolution",
"list",
"of",
"documentation",
"objects",
"for",
"cls",
"which",
"must",
"be",
"a",
"documentation",
"object",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L400-L410 |
zeaphoo/budoc | budoc/pydoc.py | Module.descendents | def descendents(self, cls):
"""
Returns a descendent list of documentation objects for `cls`,
which must be a documentation object.
The list will contain objects belonging to `pydoc.Class` or
`pydoc.External`. Objects belonging to the former are exported
classes either i... | python | def descendents(self, cls):
"""
Returns a descendent list of documentation objects for `cls`,
which must be a documentation object.
The list will contain objects belonging to `pydoc.Class` or
`pydoc.External`. Objects belonging to the former are exported
classes either i... | [
"def",
"descendents",
"(",
"self",
",",
"cls",
")",
":",
"if",
"cls",
".",
"cls",
"==",
"type",
"or",
"not",
"hasattr",
"(",
"cls",
".",
"cls",
",",
"'__subclasses__'",
")",
":",
"# Is this right?",
"return",
"[",
"]",
"downs",
"=",
"cls",
".",
"cls"... | Returns a descendent list of documentation objects for `cls`,
which must be a documentation object.
The list will contain objects belonging to `pydoc.Class` or
`pydoc.External`. Objects belonging to the former are exported
classes either in this module or in one of its sub-modules. | [
"Returns",
"a",
"descendent",
"list",
"of",
"documentation",
"objects",
"for",
"cls",
"which",
"must",
"be",
"a",
"documentation",
"object",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L412-L426 |
zeaphoo/budoc | budoc/pydoc.py | Module.find_class | def find_class(self, cls):
"""
Given a Python `cls` object, try to find it in this module
or in any of the exported identifiers of the submodules.
"""
for doc_cls in self.classes():
if cls is doc_cls.cls:
return doc_cls
for module in self.submo... | python | def find_class(self, cls):
"""
Given a Python `cls` object, try to find it in this module
or in any of the exported identifiers of the submodules.
"""
for doc_cls in self.classes():
if cls is doc_cls.cls:
return doc_cls
for module in self.submo... | [
"def",
"find_class",
"(",
"self",
",",
"cls",
")",
":",
"for",
"doc_cls",
"in",
"self",
".",
"classes",
"(",
")",
":",
"if",
"cls",
"is",
"doc_cls",
".",
"cls",
":",
"return",
"doc_cls",
"for",
"module",
"in",
"self",
".",
"submodules",
"(",
")",
"... | Given a Python `cls` object, try to find it in this module
or in any of the exported identifiers of the submodules. | [
"Given",
"a",
"Python",
"cls",
"object",
"try",
"to",
"find",
"it",
"in",
"this",
"module",
"or",
"in",
"any",
"of",
"the",
"exported",
"identifiers",
"of",
"the",
"submodules",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L440-L452 |
zeaphoo/budoc | budoc/pydoc.py | Module.find_ident | def find_ident(self, name):
"""
Searches this module and **all** of its sub-modules for an
identifier with name `name` in its list of exported
identifiers according to `pydoc`. Note that unexported
sub-modules are searched.
A bare identifier (without `.` separators) will... | python | def find_ident(self, name):
"""
Searches this module and **all** of its sub-modules for an
identifier with name `name` in its list of exported
identifiers according to `pydoc`. Note that unexported
sub-modules are searched.
A bare identifier (without `.` separators) will... | [
"def",
"find_ident",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"refdoc",
":",
"return",
"self",
".",
"refdoc",
"[",
"name",
"]",
"for",
"module",
"in",
"self",
".",
"submodules",
"(",
")",
":",
"o",
"=",
"module",
".",
... | Searches this module and **all** of its sub-modules for an
identifier with name `name` in its list of exported
identifiers according to `pydoc`. Note that unexported
sub-modules are searched.
A bare identifier (without `.` separators) will only be checked
for in this module.
... | [
"Searches",
"this",
"module",
"and",
"**",
"all",
"**",
"of",
"its",
"sub",
"-",
"modules",
"for",
"an",
"identifier",
"with",
"name",
"name",
"in",
"its",
"list",
"of",
"exported",
"identifiers",
"according",
"to",
"pydoc",
".",
"Note",
"that",
"unexporte... | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L454-L474 |
zeaphoo/budoc | budoc/pydoc.py | Module.variables | def variables(self):
"""
Returns all documented module level variables in the module
sorted alphabetically as a list of `pydoc.Variable`.
"""
p = lambda o: isinstance(o, Variable) and self._docfilter(o)
return sorted(filter(p, self.doc.values())) | python | def variables(self):
"""
Returns all documented module level variables in the module
sorted alphabetically as a list of `pydoc.Variable`.
"""
p = lambda o: isinstance(o, Variable) and self._docfilter(o)
return sorted(filter(p, self.doc.values())) | [
"def",
"variables",
"(",
"self",
")",
":",
"p",
"=",
"lambda",
"o",
":",
"isinstance",
"(",
"o",
",",
"Variable",
")",
"and",
"self",
".",
"_docfilter",
"(",
"o",
")",
"return",
"sorted",
"(",
"filter",
"(",
"p",
",",
"self",
".",
"doc",
".",
"va... | Returns all documented module level variables in the module
sorted alphabetically as a list of `pydoc.Variable`. | [
"Returns",
"all",
"documented",
"module",
"level",
"variables",
"in",
"the",
"module",
"sorted",
"alphabetically",
"as",
"a",
"list",
"of",
"pydoc",
".",
"Variable",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L476-L482 |
zeaphoo/budoc | budoc/pydoc.py | Module.classes | def classes(self):
"""
Returns all documented module level classes in the module
sorted alphabetically as a list of `pydoc.Class`.
"""
p = lambda o: isinstance(o, Class) and self._docfilter(o)
return sorted(filter(p, self.doc.values())) | python | def classes(self):
"""
Returns all documented module level classes in the module
sorted alphabetically as a list of `pydoc.Class`.
"""
p = lambda o: isinstance(o, Class) and self._docfilter(o)
return sorted(filter(p, self.doc.values())) | [
"def",
"classes",
"(",
"self",
")",
":",
"p",
"=",
"lambda",
"o",
":",
"isinstance",
"(",
"o",
",",
"Class",
")",
"and",
"self",
".",
"_docfilter",
"(",
"o",
")",
"return",
"sorted",
"(",
"filter",
"(",
"p",
",",
"self",
".",
"doc",
".",
"values"... | Returns all documented module level classes in the module
sorted alphabetically as a list of `pydoc.Class`. | [
"Returns",
"all",
"documented",
"module",
"level",
"classes",
"in",
"the",
"module",
"sorted",
"alphabetically",
"as",
"a",
"list",
"of",
"pydoc",
".",
"Class",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L484-L490 |
zeaphoo/budoc | budoc/pydoc.py | Module.functions | def functions(self):
"""
Returns all documented module level functions in the module
sorted alphabetically as a list of `pydoc.Function`.
"""
p = lambda o: isinstance(o, Function) and self._docfilter(o)
return sorted(filter(p, self.doc.values())) | python | def functions(self):
"""
Returns all documented module level functions in the module
sorted alphabetically as a list of `pydoc.Function`.
"""
p = lambda o: isinstance(o, Function) and self._docfilter(o)
return sorted(filter(p, self.doc.values())) | [
"def",
"functions",
"(",
"self",
")",
":",
"p",
"=",
"lambda",
"o",
":",
"isinstance",
"(",
"o",
",",
"Function",
")",
"and",
"self",
".",
"_docfilter",
"(",
"o",
")",
"return",
"sorted",
"(",
"filter",
"(",
"p",
",",
"self",
".",
"doc",
".",
"va... | Returns all documented module level functions in the module
sorted alphabetically as a list of `pydoc.Function`. | [
"Returns",
"all",
"documented",
"module",
"level",
"functions",
"in",
"the",
"module",
"sorted",
"alphabetically",
"as",
"a",
"list",
"of",
"pydoc",
".",
"Function",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L492-L498 |
zeaphoo/budoc | budoc/pydoc.py | Module.submodules | def submodules(self):
"""
Returns all documented sub-modules in the module sorted
alphabetically as a list of `pydoc.Module`.
"""
p = lambda o: isinstance(o, Module) and self._docfilter(o)
return sorted(filter(p, self.doc.values())) | python | def submodules(self):
"""
Returns all documented sub-modules in the module sorted
alphabetically as a list of `pydoc.Module`.
"""
p = lambda o: isinstance(o, Module) and self._docfilter(o)
return sorted(filter(p, self.doc.values())) | [
"def",
"submodules",
"(",
"self",
")",
":",
"p",
"=",
"lambda",
"o",
":",
"isinstance",
"(",
"o",
",",
"Module",
")",
"and",
"self",
".",
"_docfilter",
"(",
"o",
")",
"return",
"sorted",
"(",
"filter",
"(",
"p",
",",
"self",
".",
"doc",
".",
"val... | Returns all documented sub-modules in the module sorted
alphabetically as a list of `pydoc.Module`. | [
"Returns",
"all",
"documented",
"sub",
"-",
"modules",
"in",
"the",
"module",
"sorted",
"alphabetically",
"as",
"a",
"list",
"of",
"pydoc",
".",
"Module",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L500-L506 |
zeaphoo/budoc | budoc/pydoc.py | Module.is_submodule | def is_submodule(self, name):
"""
Returns `True` if and only if `name` starts with the full
import path of `self` and has length at least one greater than
`len(self.name)`.
"""
return self.name != name and name.startswith(self.name) | python | def is_submodule(self, name):
"""
Returns `True` if and only if `name` starts with the full
import path of `self` and has length at least one greater than
`len(self.name)`.
"""
return self.name != name and name.startswith(self.name) | [
"def",
"is_submodule",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"name",
"!=",
"name",
"and",
"name",
".",
"startswith",
"(",
"self",
".",
"name",
")"
] | Returns `True` if and only if `name` starts with the full
import path of `self` and has length at least one greater than
`len(self.name)`. | [
"Returns",
"True",
"if",
"and",
"only",
"if",
"name",
"starts",
"with",
"the",
"full",
"import",
"path",
"of",
"self",
"and",
"has",
"length",
"at",
"least",
"one",
"greater",
"than",
"len",
"(",
"self",
".",
"name",
")",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L508-L514 |
zeaphoo/budoc | budoc/pydoc.py | Module.__is_exported | def __is_exported(self, name, module):
"""
Returns `True` if and only if `pydoc` considers `name` to be
a public identifier for this module where `name` was defined
in the Python module `module`.
If this module has an `__all__` attribute, then `name` is
considered to be ... | python | def __is_exported(self, name, module):
"""
Returns `True` if and only if `pydoc` considers `name` to be
a public identifier for this module where `name` was defined
in the Python module `module`.
If this module has an `__all__` attribute, then `name` is
considered to be ... | [
"def",
"__is_exported",
"(",
"self",
",",
"name",
",",
"module",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"module",
",",
"'__all__'",
")",
":",
"return",
"name",
"in",
"self",
".",
"module",
".",
"__all__",
"if",
"not",
"_is_exported",
"(",
"name",... | Returns `True` if and only if `pydoc` considers `name` to be
a public identifier for this module where `name` was defined
in the Python module `module`.
If this module has an `__all__` attribute, then `name` is
considered to be exported if and only if it is a member of
this modu... | [
"Returns",
"True",
"if",
"and",
"only",
"if",
"pydoc",
"considers",
"name",
"to",
"be",
"a",
"public",
"identifier",
"for",
"this",
"module",
"where",
"name",
"was",
"defined",
"in",
"the",
"Python",
"module",
"module",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L516-L541 |
zeaphoo/budoc | budoc/pydoc.py | Module.__public_objs | def __public_objs(self):
"""
Returns a dictionary mapping a public identifier name to a
Python object.
"""
members = dict(inspect.getmembers(self.module))
return dict([(name, obj)
for name, obj in members.items()
if self.__is_expo... | python | def __public_objs(self):
"""
Returns a dictionary mapping a public identifier name to a
Python object.
"""
members = dict(inspect.getmembers(self.module))
return dict([(name, obj)
for name, obj in members.items()
if self.__is_expo... | [
"def",
"__public_objs",
"(",
"self",
")",
":",
"members",
"=",
"dict",
"(",
"inspect",
".",
"getmembers",
"(",
"self",
".",
"module",
")",
")",
"return",
"dict",
"(",
"[",
"(",
"name",
",",
"obj",
")",
"for",
"name",
",",
"obj",
"in",
"members",
".... | Returns a dictionary mapping a public identifier name to a
Python object. | [
"Returns",
"a",
"dictionary",
"mapping",
"a",
"public",
"identifier",
"name",
"to",
"a",
"Python",
"object",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L543-L551 |
zeaphoo/budoc | budoc/pydoc.py | Module.__new_submodule | def __new_submodule(self, name, obj):
"""
Create a new submodule documentation object for this `obj`,
which must by a Python module object and pass along any
settings in this module.
"""
# Forcefully set the module name so that it is always the absolute
# import p... | python | def __new_submodule(self, name, obj):
"""
Create a new submodule documentation object for this `obj`,
which must by a Python module object and pass along any
settings in this module.
"""
# Forcefully set the module name so that it is always the absolute
# import p... | [
"def",
"__new_submodule",
"(",
"self",
",",
"name",
",",
"obj",
")",
":",
"# Forcefully set the module name so that it is always the absolute",
"# import path. We can't rely on `obj.__name__`, since it doesn't",
"# necessarily correspond to the public exported name of the module.",
"obj",
... | Create a new submodule documentation object for this `obj`,
which must by a Python module object and pass along any
settings in this module. | [
"Create",
"a",
"new",
"submodule",
"documentation",
"object",
"for",
"this",
"obj",
"which",
"must",
"by",
"a",
"Python",
"module",
"object",
"and",
"pass",
"along",
"any",
"settings",
"in",
"this",
"module",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L553-L565 |
zeaphoo/budoc | budoc/pydoc.py | Class.class_variables | def class_variables(self):
"""
Returns all documented class variables in the class, sorted
alphabetically as a list of `pydoc.Variable`.
"""
p = lambda o: isinstance(o, Variable) and self.module._docfilter(o)
return filter(p, self.doc.values()) | python | def class_variables(self):
"""
Returns all documented class variables in the class, sorted
alphabetically as a list of `pydoc.Variable`.
"""
p = lambda o: isinstance(o, Variable) and self.module._docfilter(o)
return filter(p, self.doc.values()) | [
"def",
"class_variables",
"(",
"self",
")",
":",
"p",
"=",
"lambda",
"o",
":",
"isinstance",
"(",
"o",
",",
"Variable",
")",
"and",
"self",
".",
"module",
".",
"_docfilter",
"(",
"o",
")",
"return",
"filter",
"(",
"p",
",",
"self",
".",
"doc",
".",... | Returns all documented class variables in the class, sorted
alphabetically as a list of `pydoc.Variable`. | [
"Returns",
"all",
"documented",
"class",
"variables",
"in",
"the",
"class",
"sorted",
"alphabetically",
"as",
"a",
"list",
"of",
"pydoc",
".",
"Variable",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L645-L651 |
zeaphoo/budoc | budoc/pydoc.py | Class.instance_variables | def instance_variables(self):
"""
Returns all instance variables in the class, sorted
alphabetically as a list of `pydoc.Variable`. Instance variables
are attributes of `self` defined in a class's `__init__`
method.
"""
p = lambda o: isinstance(o, Variable) and se... | python | def instance_variables(self):
"""
Returns all instance variables in the class, sorted
alphabetically as a list of `pydoc.Variable`. Instance variables
are attributes of `self` defined in a class's `__init__`
method.
"""
p = lambda o: isinstance(o, Variable) and se... | [
"def",
"instance_variables",
"(",
"self",
")",
":",
"p",
"=",
"lambda",
"o",
":",
"isinstance",
"(",
"o",
",",
"Variable",
")",
"and",
"self",
".",
"module",
".",
"_docfilter",
"(",
"o",
")",
"return",
"filter",
"(",
"p",
",",
"self",
".",
"doc_init"... | Returns all instance variables in the class, sorted
alphabetically as a list of `pydoc.Variable`. Instance variables
are attributes of `self` defined in a class's `__init__`
method. | [
"Returns",
"all",
"instance",
"variables",
"in",
"the",
"class",
"sorted",
"alphabetically",
"as",
"a",
"list",
"of",
"pydoc",
".",
"Variable",
".",
"Instance",
"variables",
"are",
"attributes",
"of",
"self",
"defined",
"in",
"a",
"class",
"s",
"__init__",
"... | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L653-L661 |
zeaphoo/budoc | budoc/pydoc.py | Class.methods | def methods(self):
"""
Returns all documented methods as `pydoc.Function` objects in
the class, sorted alphabetically with `__init__` always coming
first.
Unfortunately, this also includes class methods.
"""
p = lambda o: (isinstance(o, Function)
... | python | def methods(self):
"""
Returns all documented methods as `pydoc.Function` objects in
the class, sorted alphabetically with `__init__` always coming
first.
Unfortunately, this also includes class methods.
"""
p = lambda o: (isinstance(o, Function)
... | [
"def",
"methods",
"(",
"self",
")",
":",
"p",
"=",
"lambda",
"o",
":",
"(",
"isinstance",
"(",
"o",
",",
"Function",
")",
"and",
"o",
".",
"method",
"and",
"self",
".",
"module",
".",
"_docfilter",
"(",
"o",
")",
")",
"return",
"filter",
"(",
"p"... | Returns all documented methods as `pydoc.Function` objects in
the class, sorted alphabetically with `__init__` always coming
first.
Unfortunately, this also includes class methods. | [
"Returns",
"all",
"documented",
"methods",
"as",
"pydoc",
".",
"Function",
"objects",
"in",
"the",
"class",
"sorted",
"alphabetically",
"with",
"__init__",
"always",
"coming",
"first",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L663-L674 |
zeaphoo/budoc | budoc/pydoc.py | Class._fill_inheritance | def _fill_inheritance(self):
"""
Traverses this class's ancestor list and attempts to fill in
missing documentation from its ancestor's documentation.
The first pass connects variables, methods and functions with
their inherited couterparts. (The templates will decide how to
... | python | def _fill_inheritance(self):
"""
Traverses this class's ancestor list and attempts to fill in
missing documentation from its ancestor's documentation.
The first pass connects variables, methods and functions with
their inherited couterparts. (The templates will decide how to
... | [
"def",
"_fill_inheritance",
"(",
"self",
")",
":",
"mro",
"=",
"filter",
"(",
"lambda",
"c",
":",
"c",
"!=",
"self",
"and",
"isinstance",
"(",
"c",
",",
"Class",
")",
",",
"self",
".",
"module",
".",
"mro",
"(",
"self",
")",
")",
"def",
"search",
... | Traverses this class's ancestor list and attempts to fill in
missing documentation from its ancestor's documentation.
The first pass connects variables, methods and functions with
their inherited couterparts. (The templates will decide how to
display docstrings.) The second pass attempt... | [
"Traverses",
"this",
"class",
"s",
"ancestor",
"list",
"and",
"attempts",
"to",
"fill",
"in",
"missing",
"documentation",
"from",
"its",
"ancestor",
"s",
"documentation",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L694-L728 |
zeaphoo/budoc | budoc/pydoc.py | Class.__public_objs | def __public_objs(self):
"""
Returns a dictionary mapping a public identifier name to a
Python object. This counts the `__init__` method as being
public.
"""
_budoc = getattr(self.module.module, '__budoc__', {})
def forced_out(name):
return _budoc.get... | python | def __public_objs(self):
"""
Returns a dictionary mapping a public identifier name to a
Python object. This counts the `__init__` method as being
public.
"""
_budoc = getattr(self.module.module, '__budoc__', {})
def forced_out(name):
return _budoc.get... | [
"def",
"__public_objs",
"(",
"self",
")",
":",
"_budoc",
"=",
"getattr",
"(",
"self",
".",
"module",
".",
"module",
",",
"'__budoc__'",
",",
"{",
"}",
")",
"def",
"forced_out",
"(",
"name",
")",
":",
"return",
"_budoc",
".",
"get",
"(",
"'%s.%s'",
"%... | Returns a dictionary mapping a public identifier name to a
Python object. This counts the `__init__` method as being
public. | [
"Returns",
"a",
"dictionary",
"mapping",
"a",
"public",
"identifier",
"name",
"to",
"a",
"Python",
"object",
".",
"This",
"counts",
"the",
"__init__",
"method",
"as",
"being",
"public",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L730-L746 |
zeaphoo/budoc | budoc/pydoc.py | Function.params | def params(self):
"""
Returns a list where each element is a nicely formatted
parameter of this function. This includes argument lists,
keyword arguments and default values.
"""
def fmt_param(el):
if isinstance(el, str) or isinstance(el, unicode):
... | python | def params(self):
"""
Returns a list where each element is a nicely formatted
parameter of this function. This includes argument lists,
keyword arguments and default values.
"""
def fmt_param(el):
if isinstance(el, str) or isinstance(el, unicode):
... | [
"def",
"params",
"(",
"self",
")",
":",
"def",
"fmt_param",
"(",
"el",
")",
":",
"if",
"isinstance",
"(",
"el",
",",
"str",
")",
"or",
"isinstance",
"(",
"el",
",",
"unicode",
")",
":",
"return",
"el",
"else",
":",
"return",
"'(%s)'",
"%",
"(",
"... | Returns a list where each element is a nicely formatted
parameter of this function. This includes argument lists,
keyword arguments and default values. | [
"Returns",
"a",
"list",
"where",
"each",
"element",
"is",
"a",
"nicely",
"formatted",
"parameter",
"of",
"this",
"function",
".",
"This",
"includes",
"argument",
"lists",
"keyword",
"arguments",
"and",
"default",
"values",
"."
] | train | https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L802-L844 |
thomasvandoren/bugzscout-py | bugzscout/ext/cli.py | _defaults | def _defaults():
"""Returns a dict of default args from the environment, which can be
overridden by command line args.
"""
d = {}
d['url'] = os.environ.get('BUGZSCOUT_URL')
d['user'] = os.environ.get('BUGZSCOUT_USER')
d['project'] = os.environ.get('BUGZSCOUT_PROJECT')
d['area'] = os.envi... | python | def _defaults():
"""Returns a dict of default args from the environment, which can be
overridden by command line args.
"""
d = {}
d['url'] = os.environ.get('BUGZSCOUT_URL')
d['user'] = os.environ.get('BUGZSCOUT_USER')
d['project'] = os.environ.get('BUGZSCOUT_PROJECT')
d['area'] = os.envi... | [
"def",
"_defaults",
"(",
")",
":",
"d",
"=",
"{",
"}",
"d",
"[",
"'url'",
"]",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'BUGZSCOUT_URL'",
")",
"d",
"[",
"'user'",
"]",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'BUGZSCOUT_USER'",
")",
"d",
... | Returns a dict of default args from the environment, which can be
overridden by command line args. | [
"Returns",
"a",
"dict",
"of",
"default",
"args",
"from",
"the",
"environment",
"which",
"can",
"be",
"overridden",
"by",
"command",
"line",
"args",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/bugzscout/ext/cli.py#L30-L39 |
thomasvandoren/bugzscout-py | bugzscout/ext/cli.py | _from_args | def _from_args(args):
"""Factory method to create a new instance from command line args.
:param args: instance of :class:`argparse.Namespace`
"""
return bugzscout.BugzScout(args.url, args.user, args.project, args.area) | python | def _from_args(args):
"""Factory method to create a new instance from command line args.
:param args: instance of :class:`argparse.Namespace`
"""
return bugzscout.BugzScout(args.url, args.user, args.project, args.area) | [
"def",
"_from_args",
"(",
"args",
")",
":",
"return",
"bugzscout",
".",
"BugzScout",
"(",
"args",
".",
"url",
",",
"args",
".",
"user",
",",
"args",
".",
"project",
",",
"args",
".",
"area",
")"
] | Factory method to create a new instance from command line args.
:param args: instance of :class:`argparse.Namespace` | [
"Factory",
"method",
"to",
"create",
"a",
"new",
"instance",
"from",
"command",
"line",
"args",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/bugzscout/ext/cli.py#L42-L47 |
thomasvandoren/bugzscout-py | bugzscout/ext/cli.py | _init_logging | def _init_logging(verbose):
"""Enable logging o stream."""
hdlr = logging.StreamHandler()
hdlr.setFormatter(logging.Formatter(
'%(asctime)s [%(levelname)s] [%(module)s] %(message)s'))
LOG.addHandler(hdlr)
if verbose:
LOG.setLevel(logging.DEBUG)
LOG.debug('Verbose output enabl... | python | def _init_logging(verbose):
"""Enable logging o stream."""
hdlr = logging.StreamHandler()
hdlr.setFormatter(logging.Formatter(
'%(asctime)s [%(levelname)s] [%(module)s] %(message)s'))
LOG.addHandler(hdlr)
if verbose:
LOG.setLevel(logging.DEBUG)
LOG.debug('Verbose output enabl... | [
"def",
"_init_logging",
"(",
"verbose",
")",
":",
"hdlr",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"hdlr",
".",
"setFormatter",
"(",
"logging",
".",
"Formatter",
"(",
"'%(asctime)s [%(levelname)s] [%(module)s] %(message)s'",
")",
")",
"LOG",
".",
"addHandle... | Enable logging o stream. | [
"Enable",
"logging",
"o",
"stream",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/bugzscout/ext/cli.py#L50-L60 |
thomasvandoren/bugzscout-py | bugzscout/ext/cli.py | _parse_args | def _parse_args():
"""Parse and return command line arguments."""
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=_CliFormatter)
parser.add_argument('-v', '--verbose', action='store_true',
help='Enable verbose output.')
fb_group = parser.ad... | python | def _parse_args():
"""Parse and return command line arguments."""
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=_CliFormatter)
parser.add_argument('-v', '--verbose', action='store_true',
help='Enable verbose output.')
fb_group = parser.ad... | [
"def",
"_parse_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
",",
"formatter_class",
"=",
"_CliFormatter",
")",
"parser",
".",
"add_argument",
"(",
"'-v'",
",",
"'--verbose'",
",",
"action",
"=",
... | Parse and return command line arguments. | [
"Parse",
"and",
"return",
"command",
"line",
"arguments",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/bugzscout/ext/cli.py#L63-L94 |
thomasvandoren/bugzscout-py | bugzscout/ext/cli.py | main | def main():
"""Create a new instance and publish an error from command line args.
There is a console script for invoking this function from the command
line directly.
"""
args = _parse_args()
_init_logging(args.verbose)
client = _from_args(args)
client.submit_error(args.description, arg... | python | def main():
"""Create a new instance and publish an error from command line args.
There is a console script for invoking this function from the command
line directly.
"""
args = _parse_args()
_init_logging(args.verbose)
client = _from_args(args)
client.submit_error(args.description, arg... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"_parse_args",
"(",
")",
"_init_logging",
"(",
"args",
".",
"verbose",
")",
"client",
"=",
"_from_args",
"(",
"args",
")",
"client",
".",
"submit_error",
"(",
"args",
".",
"description",
",",
"args",
".",
"ext... | Create a new instance and publish an error from command line args.
There is a console script for invoking this function from the command
line directly. | [
"Create",
"a",
"new",
"instance",
"and",
"publish",
"an",
"error",
"from",
"command",
"line",
"args",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/bugzscout/ext/cli.py#L97-L107 |
ryanjdillon/pyotelem | pyotelem/plots/plotdsp.py | plot_lf_hf | def plot_lf_hf(x, xlf, xhf, title=''):
'''Plot original signal, low-pass filtered, and high-pass filtered signals
Args
----
x: ndarray
Signal data array
xlf: ndarray
Low-pass filtered signal
xhf: ndarray
High-pass filtered signal
title: str
Main title of plot... | python | def plot_lf_hf(x, xlf, xhf, title=''):
'''Plot original signal, low-pass filtered, and high-pass filtered signals
Args
----
x: ndarray
Signal data array
xlf: ndarray
Low-pass filtered signal
xhf: ndarray
High-pass filtered signal
title: str
Main title of plot... | [
"def",
"plot_lf_hf",
"(",
"x",
",",
"xlf",
",",
"xhf",
",",
"title",
"=",
"''",
")",
":",
"from",
".",
"import",
"plotutils",
"fig",
",",
"(",
"ax1",
",",
"ax2",
",",
"ax3",
")",
"=",
"plt",
".",
"subplots",
"(",
"3",
",",
"1",
",",
"sharex",
... | Plot original signal, low-pass filtered, and high-pass filtered signals
Args
----
x: ndarray
Signal data array
xlf: ndarray
Low-pass filtered signal
xhf: ndarray
High-pass filtered signal
title: str
Main title of plot | [
"Plot",
"original",
"signal",
"low",
"-",
"pass",
"filtered",
"and",
"high",
"-",
"pass",
"filtered",
"signals"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdsp.py#L10-L66 |
ryanjdillon/pyotelem | pyotelem/plots/plotdsp.py | plot_acc_pry_depth | def plot_acc_pry_depth(A_g_lf, A_g_hf, pry_deg, depths, glide_mask=None):
'''Plot the acceleration with the pitch, roll, and heading
Args
----
A_g_lf: ndarray
Low-pass filtered calibration accelerometer signal
A_g_hf: ndarray
High-pass filtered calibration accelerometer signal
p... | python | def plot_acc_pry_depth(A_g_lf, A_g_hf, pry_deg, depths, glide_mask=None):
'''Plot the acceleration with the pitch, roll, and heading
Args
----
A_g_lf: ndarray
Low-pass filtered calibration accelerometer signal
A_g_hf: ndarray
High-pass filtered calibration accelerometer signal
p... | [
"def",
"plot_acc_pry_depth",
"(",
"A_g_lf",
",",
"A_g_hf",
",",
"pry_deg",
",",
"depths",
",",
"glide_mask",
"=",
"None",
")",
":",
"import",
"numpy",
"fig",
",",
"(",
"ax1",
",",
"ax2",
",",
"ax3",
")",
"=",
"plt",
".",
"subplots",
"(",
"3",
",",
... | Plot the acceleration with the pitch, roll, and heading
Args
----
A_g_lf: ndarray
Low-pass filtered calibration accelerometer signal
A_g_hf: ndarray
High-pass filtered calibration accelerometer signal
pry_deg: ndarray
Pitch roll and heading in degrees
depths: ndarray
... | [
"Plot",
"the",
"acceleration",
"with",
"the",
"pitch",
"roll",
"and",
"heading"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdsp.py#L69-L108 |
ryanjdillon/pyotelem | pyotelem/plots/plotdsp.py | plot_welch_peaks | def plot_welch_peaks(f, S, peak_loc=None, title=''):
'''Plot welch PSD with peaks as scatter points
Args
----
f: ndarray
Array of frequencies produced with PSD
S: ndarray
Array of powers produced with PSD
peak_loc: ndarray
Indices of peak locations in signal
title: s... | python | def plot_welch_peaks(f, S, peak_loc=None, title=''):
'''Plot welch PSD with peaks as scatter points
Args
----
f: ndarray
Array of frequencies produced with PSD
S: ndarray
Array of powers produced with PSD
peak_loc: ndarray
Indices of peak locations in signal
title: s... | [
"def",
"plot_welch_peaks",
"(",
"f",
",",
"S",
",",
"peak_loc",
"=",
"None",
",",
"title",
"=",
"''",
")",
":",
"plt",
".",
"plot",
"(",
"f",
",",
"S",
",",
"linewidth",
"=",
"_linewidth",
")",
"plt",
".",
"title",
"(",
"title",
")",
"plt",
".",
... | Plot welch PSD with peaks as scatter points
Args
----
f: ndarray
Array of frequencies produced with PSD
S: ndarray
Array of powers produced with PSD
peak_loc: ndarray
Indices of peak locations in signal
title: str
Main title for plot | [
"Plot",
"welch",
"PSD",
"with",
"peaks",
"as",
"scatter",
"points"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdsp.py#L111-L136 |
ryanjdillon/pyotelem | pyotelem/plots/plotdsp.py | plot_fft | def plot_fft(f, S, dt):
'''Plot fft
Args
----
f: ndarray
Array of frequencies produced with PSD
S: ndarray
Array of powers produced with PSD
dt: ndarray
Sampling rate of sensor
'''
import numpy
xf = numpy.linspace(0.0, 1/(2.0*dt), N/2)
plt.plot(xf, 2.0/N... | python | def plot_fft(f, S, dt):
'''Plot fft
Args
----
f: ndarray
Array of frequencies produced with PSD
S: ndarray
Array of powers produced with PSD
dt: ndarray
Sampling rate of sensor
'''
import numpy
xf = numpy.linspace(0.0, 1/(2.0*dt), N/2)
plt.plot(xf, 2.0/N... | [
"def",
"plot_fft",
"(",
"f",
",",
"S",
",",
"dt",
")",
":",
"import",
"numpy",
"xf",
"=",
"numpy",
".",
"linspace",
"(",
"0.0",
",",
"1",
"/",
"(",
"2.0",
"*",
"dt",
")",
",",
"N",
"/",
"2",
")",
"plt",
".",
"plot",
"(",
"xf",
",",
"2.0",
... | Plot fft
Args
----
f: ndarray
Array of frequencies produced with PSD
S: ndarray
Array of powers produced with PSD
dt: ndarray
Sampling rate of sensor | [
"Plot",
"fft"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdsp.py#L139-L157 |
ryanjdillon/pyotelem | pyotelem/plots/plotdsp.py | plot_welch_perdiogram | def plot_welch_perdiogram(x, fs, nperseg):
'''Plot Welch perdiogram
Args
----
x: ndarray
Signal array
fs: float
Sampling frequency
nperseg: float
Length of each data segment in PSD
'''
import scipy.signal
import numpy
# Generate a test signal, a 2 Vrms s... | python | def plot_welch_perdiogram(x, fs, nperseg):
'''Plot Welch perdiogram
Args
----
x: ndarray
Signal array
fs: float
Sampling frequency
nperseg: float
Length of each data segment in PSD
'''
import scipy.signal
import numpy
# Generate a test signal, a 2 Vrms s... | [
"def",
"plot_welch_perdiogram",
"(",
"x",
",",
"fs",
",",
"nperseg",
")",
":",
"import",
"scipy",
".",
"signal",
"import",
"numpy",
"# Generate a test signal, a 2 Vrms sine wave at 1234 Hz, corrupted by",
"# 0.001V**2/Hz of white noise sampled at 10 kHz.",
"N",
"=",
"len",
... | Plot Welch perdiogram
Args
----
x: ndarray
Signal array
fs: float
Sampling frequency
nperseg: float
Length of each data segment in PSD | [
"Plot",
"Welch",
"perdiogram"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdsp.py#L160-L203 |
ryanjdillon/pyotelem | pyotelem/plots/plotdsp.py | plot_data_filter | def plot_data_filter(data, data_f, b, a, cutoff, fs):
'''Plot frequency response and filter overlay for butter filtered data
Args
----
data: ndarray
Signal array
data_f: float
Signal sampling rate
b: array_like
Numerator of a linear filter
a: array_like
Denom... | python | def plot_data_filter(data, data_f, b, a, cutoff, fs):
'''Plot frequency response and filter overlay for butter filtered data
Args
----
data: ndarray
Signal array
data_f: float
Signal sampling rate
b: array_like
Numerator of a linear filter
a: array_like
Denom... | [
"def",
"plot_data_filter",
"(",
"data",
",",
"data_f",
",",
"b",
",",
"a",
",",
"cutoff",
",",
"fs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"numpy",
"import",
"scipy",
".",
"signal",
"n",
"=",
"len",
"(",
"data",
")",... | Plot frequency response and filter overlay for butter filtered data
Args
----
data: ndarray
Signal array
data_f: float
Signal sampling rate
b: array_like
Numerator of a linear filter
a: array_like
Denominator of a linear filter
cutoff: float
Cutoff fr... | [
"Plot",
"frequency",
"response",
"and",
"filter",
"overlay",
"for",
"butter",
"filtered",
"data"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotdsp.py#L206-L258 |
Krokop/python-xmlstats | xmlstats/__init__.py | XMLStats._build_url | def _build_url(self, host, sport, method, id, format, parameters):
"""
build url from args
"""
path = "/".join(filter(None, (sport, method, id)))
url = "https://" + host + "/" + path + "." + format
if parameters:
paramstring = urllib.parse.urlencode(parame... | python | def _build_url(self, host, sport, method, id, format, parameters):
"""
build url from args
"""
path = "/".join(filter(None, (sport, method, id)))
url = "https://" + host + "/" + path + "." + format
if parameters:
paramstring = urllib.parse.urlencode(parame... | [
"def",
"_build_url",
"(",
"self",
",",
"host",
",",
"sport",
",",
"method",
",",
"id",
",",
"format",
",",
"parameters",
")",
":",
"path",
"=",
"\"/\"",
".",
"join",
"(",
"filter",
"(",
"None",
",",
"(",
"sport",
",",
"method",
",",
"id",
")",
")... | build url from args | [
"build",
"url",
"from",
"args"
] | train | https://github.com/Krokop/python-xmlstats/blob/d3ec60f09bdee71bbeaac8992ff792b5ebbdd704/xmlstats/__init__.py#L78-L87 |
Krokop/python-xmlstats | xmlstats/__init__.py | XMLStats.get_teams | def get_teams(self):
""" Return json current roster of team """
return self.make_request(host="erikberg.com", sport='nba',
method="teams", id=None,
format="json",
parameters={}) | python | def get_teams(self):
""" Return json current roster of team """
return self.make_request(host="erikberg.com", sport='nba',
method="teams", id=None,
format="json",
parameters={}) | [
"def",
"get_teams",
"(",
"self",
")",
":",
"return",
"self",
".",
"make_request",
"(",
"host",
"=",
"\"erikberg.com\"",
",",
"sport",
"=",
"'nba'",
",",
"method",
"=",
"\"teams\"",
",",
"id",
"=",
"None",
",",
"format",
"=",
"\"json\"",
",",
"parameters"... | Return json current roster of team | [
"Return",
"json",
"current",
"roster",
"of",
"team"
] | train | https://github.com/Krokop/python-xmlstats/blob/d3ec60f09bdee71bbeaac8992ff792b5ebbdd704/xmlstats/__init__.py#L89-L94 |
ryanjdillon/pyotelem | pyotelem/dynamics.py | prh | def prh(ax, ay, az):
'''Calculate the pitch, roll and heading for triaxial movement signalsi
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
pitch: ndarray
... | python | def prh(ax, ay, az):
'''Calculate the pitch, roll and heading for triaxial movement signalsi
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
pitch: ndarray
... | [
"def",
"prh",
"(",
"ax",
",",
"ay",
",",
"az",
")",
":",
"p",
"=",
"pitch",
"(",
"ax",
",",
"ay",
",",
"az",
")",
"r",
"=",
"roll",
"(",
"ax",
",",
"ay",
",",
"az",
")",
"y",
"=",
"yaw",
"(",
"ax",
",",
"ay",
",",
"az",
")",
"#from dtag... | Calculate the pitch, roll and heading for triaxial movement signalsi
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
pitch: ndarray
Pitch angle in radians
... | [
"Calculate",
"the",
"pitch",
"roll",
"and",
"heading",
"for",
"triaxial",
"movement",
"signalsi"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dynamics.py#L2-L31 |
ryanjdillon/pyotelem | pyotelem/dynamics.py | pitch | def pitch(ax, ay, az):
'''Angle of x-axis relative to ground (theta)
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
pitch: ndarray
Pitch angle in radians
... | python | def pitch(ax, ay, az):
'''Angle of x-axis relative to ground (theta)
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
pitch: ndarray
Pitch angle in radians
... | [
"def",
"pitch",
"(",
"ax",
",",
"ay",
",",
"az",
")",
":",
"import",
"numpy",
"# arctan2 not needed here to cover all quadrants, just for consistency",
"return",
"numpy",
".",
"arctan",
"(",
"ax",
",",
"numpy",
".",
"sqrt",
"(",
"ay",
"**",
"2",
"+",
"az",
"... | Angle of x-axis relative to ground (theta)
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
pitch: ndarray
Pitch angle in radians | [
"Angle",
"of",
"x",
"-",
"axis",
"relative",
"to",
"ground",
"(",
"theta",
")"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dynamics.py#L34-L53 |
ryanjdillon/pyotelem | pyotelem/dynamics.py | absdeg | def absdeg(deg):
'''Change from signed degrees to 0-180 or 0-360 ranges
deg: ndarray
Movement data in pitch, roll, yaw (degrees)
Returns
-------
deg_abs: ndarray
Movement translated from -180:180/-90:90 degrees to 0:360/0:180 degrees
Example
-------
deg = numpy.array([... | python | def absdeg(deg):
'''Change from signed degrees to 0-180 or 0-360 ranges
deg: ndarray
Movement data in pitch, roll, yaw (degrees)
Returns
-------
deg_abs: ndarray
Movement translated from -180:180/-90:90 degrees to 0:360/0:180 degrees
Example
-------
deg = numpy.array([... | [
"def",
"absdeg",
"(",
"deg",
")",
":",
"import",
"numpy",
"d",
"=",
"numpy",
".",
"copy",
"(",
"deg",
")",
"if",
"numpy",
".",
"max",
"(",
"numpy",
".",
"abs",
"(",
"deg",
")",
")",
">",
"90.0",
":",
"d",
"[",
"deg",
"<",
"0",
"]",
"=",
"36... | Change from signed degrees to 0-180 or 0-360 ranges
deg: ndarray
Movement data in pitch, roll, yaw (degrees)
Returns
-------
deg_abs: ndarray
Movement translated from -180:180/-90:90 degrees to 0:360/0:180 degrees
Example
-------
deg = numpy.array([-170, -120, 0, 90])
... | [
"Change",
"from",
"signed",
"degrees",
"to",
"0",
"-",
"180",
"or",
"0",
"-",
"360",
"ranges"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dynamics.py#L100-L125 |
ryanjdillon/pyotelem | pyotelem/dynamics.py | acceleration_magnitude | def acceleration_magnitude(ax, ay, az):
'''Cacluate the magnitude of 3D acceleration
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
acc_mag: ndarray
Magni... | python | def acceleration_magnitude(ax, ay, az):
'''Cacluate the magnitude of 3D acceleration
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
acc_mag: ndarray
Magni... | [
"def",
"acceleration_magnitude",
"(",
"ax",
",",
"ay",
",",
"az",
")",
":",
"import",
"numpy",
"return",
"numpy",
".",
"sqrt",
"(",
"ax",
"**",
"2",
"+",
"ay",
"**",
"2",
"+",
"az",
"**",
"2",
")"
] | Cacluate the magnitude of 3D acceleration
Args
----
ax: ndarray
x-axis acceleration values
ay: ndarray
y-axis acceleration values
az: ndarray
z-axis acceleration values
Returns
-------
acc_mag: ndarray
Magnitude of acceleration from combined acceleration... | [
"Cacluate",
"the",
"magnitude",
"of",
"3D",
"acceleration"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dynamics.py#L128-L148 |
Othernet-Project/conz | conz/console.py | Console.pstd | def pstd(self, *args, **kwargs):
""" Console to STDOUT """
kwargs['file'] = self.out
self.print(*args, **kwargs)
sys.stdout.flush() | python | def pstd(self, *args, **kwargs):
""" Console to STDOUT """
kwargs['file'] = self.out
self.print(*args, **kwargs)
sys.stdout.flush() | [
"def",
"pstd",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'file'",
"]",
"=",
"self",
".",
"out",
"self",
".",
"print",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"sys",
".",
"stdout",
".",
"flush",
... | Console to STDOUT | [
"Console",
"to",
"STDOUT"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L67-L71 |
Othernet-Project/conz | conz/console.py | Console.perr | def perr(self, *args, **kwargs):
""" Console to STERR """
kwargs['file'] = self.err
self.print(*args, **kwargs)
sys.stderr.flush() | python | def perr(self, *args, **kwargs):
""" Console to STERR """
kwargs['file'] = self.err
self.print(*args, **kwargs)
sys.stderr.flush() | [
"def",
"perr",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'file'",
"]",
"=",
"self",
".",
"err",
"self",
".",
"print",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"sys",
".",
"stderr",
".",
"flush",
... | Console to STERR | [
"Console",
"to",
"STERR"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L73-L77 |
Othernet-Project/conz | conz/console.py | Console.pok | def pok(self, val, ok='OK'):
""" Print val: OK in green on STDOUT """
self.pstd(self.color.green('{}: {}'.format(val, ok))) | python | def pok(self, val, ok='OK'):
""" Print val: OK in green on STDOUT """
self.pstd(self.color.green('{}: {}'.format(val, ok))) | [
"def",
"pok",
"(",
"self",
",",
"val",
",",
"ok",
"=",
"'OK'",
")",
":",
"self",
".",
"pstd",
"(",
"self",
".",
"color",
".",
"green",
"(",
"'{}: {}'",
".",
"format",
"(",
"val",
",",
"ok",
")",
")",
")"
] | Print val: OK in green on STDOUT | [
"Print",
"val",
":",
"OK",
"in",
"green",
"on",
"STDOUT"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L79-L81 |
Othernet-Project/conz | conz/console.py | Console.png | def png(self, val, ng='ERR'):
""" Print val: ERR in red on STDOUT """
self.pstd(self.color.red('{}: {}'.format(val, ng))) | python | def png(self, val, ng='ERR'):
""" Print val: ERR in red on STDOUT """
self.pstd(self.color.red('{}: {}'.format(val, ng))) | [
"def",
"png",
"(",
"self",
",",
"val",
",",
"ng",
"=",
"'ERR'",
")",
":",
"self",
".",
"pstd",
"(",
"self",
".",
"color",
".",
"red",
"(",
"'{}: {}'",
".",
"format",
"(",
"val",
",",
"ng",
")",
")",
")"
] | Print val: ERR in red on STDOUT | [
"Print",
"val",
":",
"ERR",
"in",
"red",
"on",
"STDOUT"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L83-L85 |
Othernet-Project/conz | conz/console.py | Console.pwa | def pwa(self, val, wa='WARN'):
""" Print val: WARN in yellow on STDOUT """
self.pstd(self.color.yellow('{}: {}'.format(val, wa))) | python | def pwa(self, val, wa='WARN'):
""" Print val: WARN in yellow on STDOUT """
self.pstd(self.color.yellow('{}: {}'.format(val, wa))) | [
"def",
"pwa",
"(",
"self",
",",
"val",
",",
"wa",
"=",
"'WARN'",
")",
":",
"self",
".",
"pstd",
"(",
"self",
".",
"color",
".",
"yellow",
"(",
"'{}: {}'",
".",
"format",
"(",
"val",
",",
"wa",
")",
")",
")"
] | Print val: WARN in yellow on STDOUT | [
"Print",
"val",
":",
"WARN",
"in",
"yellow",
"on",
"STDOUT"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L87-L89 |
Othernet-Project/conz | conz/console.py | Console.pverb | def pverb(self, *args, **kwargs):
""" Console verbose message to STDOUT """
if not self.verbose:
return
self.pstd(*args, **kwargs) | python | def pverb(self, *args, **kwargs):
""" Console verbose message to STDOUT """
if not self.verbose:
return
self.pstd(*args, **kwargs) | [
"def",
"pverb",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"verbose",
":",
"return",
"self",
".",
"pstd",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Console verbose message to STDOUT | [
"Console",
"verbose",
"message",
"to",
"STDOUT"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L95-L99 |
Othernet-Project/conz | conz/console.py | Console.read | def read(self, prompt='', clean=lambda x: x):
""" Display a prompt and ask user for input
A function to clean the user input can be passed as ``clean`` argument.
This function takes a single value, which is the string user entered,
and returns a cleaned value. Default is a pass-through ... | python | def read(self, prompt='', clean=lambda x: x):
""" Display a prompt and ask user for input
A function to clean the user input can be passed as ``clean`` argument.
This function takes a single value, which is the string user entered,
and returns a cleaned value. Default is a pass-through ... | [
"def",
"read",
"(",
"self",
",",
"prompt",
"=",
"''",
",",
"clean",
"=",
"lambda",
"x",
":",
"x",
")",
":",
"ans",
"=",
"read",
"(",
"prompt",
"+",
"' '",
")",
"return",
"clean",
"(",
"ans",
")"
] | Display a prompt and ask user for input
A function to clean the user input can be passed as ``clean`` argument.
This function takes a single value, which is the string user entered,
and returns a cleaned value. Default is a pass-through function, which
is an equivalent of::
... | [
"Display",
"a",
"prompt",
"and",
"ask",
"user",
"for",
"input"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L104-L116 |
Othernet-Project/conz | conz/console.py | Console.rvpl | def rvpl(self, prompt, error='Entered value is invalid', intro=None,
validator=lambda x: x != '', clean=lambda x: x.strip(),
strict=True, default=None):
""" Start a read-validate-print loop
The RVPL will read the user input, validate it, and loop until the
entered valu... | python | def rvpl(self, prompt, error='Entered value is invalid', intro=None,
validator=lambda x: x != '', clean=lambda x: x.strip(),
strict=True, default=None):
""" Start a read-validate-print loop
The RVPL will read the user input, validate it, and loop until the
entered valu... | [
"def",
"rvpl",
"(",
"self",
",",
"prompt",
",",
"error",
"=",
"'Entered value is invalid'",
",",
"intro",
"=",
"None",
",",
"validator",
"=",
"lambda",
"x",
":",
"x",
"!=",
"''",
",",
"clean",
"=",
"lambda",
"x",
":",
"x",
".",
"strip",
"(",
")",
"... | Start a read-validate-print loop
The RVPL will read the user input, validate it, and loop until the
entered value passes the validation, then return it.
Error message can be customized using the ``error`` argument. If the
value is a callable, it will be called with the value and it wil... | [
"Start",
"a",
"read",
"-",
"validate",
"-",
"print",
"loop"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L118-L150 |
Othernet-Project/conz | conz/console.py | Console.yesno | def yesno(self, prompt, error='Please type either y or n', intro=None,
default=None):
""" Ask user for yes or no answer
The prompt will include a typical '(y/n):' at the end. Depending on
whether ``default`` was specified, this may also be '(Y/n):' or
'(y/N):'.
Th... | python | def yesno(self, prompt, error='Please type either y or n', intro=None,
default=None):
""" Ask user for yes or no answer
The prompt will include a typical '(y/n):' at the end. Depending on
whether ``default`` was specified, this may also be '(Y/n):' or
'(y/N):'.
Th... | [
"def",
"yesno",
"(",
"self",
",",
"prompt",
",",
"error",
"=",
"'Please type either y or n'",
",",
"intro",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
"is",
"None",
":",
"prompt",
"+=",
"' (y/n):'",
"else",
":",
"if",
"default",... | Ask user for yes or no answer
The prompt will include a typical '(y/n):' at the end. Depending on
whether ``default`` was specified, this may also be '(Y/n):' or
'(y/N):'.
The ``default`` argument can be ``True`` or ``False``, with meaning of
'yes' and 'no' respectively. Defaul... | [
"Ask",
"user",
"for",
"yes",
"or",
"no",
"answer"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L152-L181 |
Othernet-Project/conz | conz/console.py | Console.menu | def menu(self, choices, prompt='Please choose from the provided options:',
error='Invalid choice', intro=None, strict=True, default=None,
numerator=lambda x: [i + 1 for i in range(x)],
formatter=lambda x, y: '{0:>3}) {1}'.format(x, y),
clean=utils.safeint):
""... | python | def menu(self, choices, prompt='Please choose from the provided options:',
error='Invalid choice', intro=None, strict=True, default=None,
numerator=lambda x: [i + 1 for i in range(x)],
formatter=lambda x, y: '{0:>3}) {1}'.format(x, y),
clean=utils.safeint):
""... | [
"def",
"menu",
"(",
"self",
",",
"choices",
",",
"prompt",
"=",
"'Please choose from the provided options:'",
",",
"error",
"=",
"'Invalid choice'",
",",
"intro",
"=",
"None",
",",
"strict",
"=",
"True",
",",
"default",
"=",
"None",
",",
"numerator",
"=",
"l... | Print a menu
The choices must be an iterable of two-tuples where the first value is
the value of the menu item, and the second is the label for that
matches the value.
The menu will be printed with numeric choices. For example::
1) foo
2) bar
Formattin... | [
"Print",
"a",
"menu"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L183-L239 |
Othernet-Project/conz | conz/console.py | Console.readpipe | def readpipe(self, chunk=None):
""" Return iterator that iterates over STDIN line by line
If ``chunk`` is set to a positive non-zero integer value, then the
reads are performed in chunks of that many lines, and returned as a
list. Otherwise the lines are returned one by one.
"""... | python | def readpipe(self, chunk=None):
""" Return iterator that iterates over STDIN line by line
If ``chunk`` is set to a positive non-zero integer value, then the
reads are performed in chunks of that many lines, and returned as a
list. Otherwise the lines are returned one by one.
"""... | [
"def",
"readpipe",
"(",
"self",
",",
"chunk",
"=",
"None",
")",
":",
"read",
"=",
"[",
"]",
"while",
"True",
":",
"l",
"=",
"sys",
".",
"stdin",
".",
"readline",
"(",
")",
"if",
"not",
"l",
":",
"if",
"read",
":",
"yield",
"read",
"return",
"re... | Return iterator that iterates over STDIN line by line
If ``chunk`` is set to a positive non-zero integer value, then the
reads are performed in chunks of that many lines, and returned as a
list. Otherwise the lines are returned one by one. | [
"Return",
"iterator",
"that",
"iterates",
"over",
"STDIN",
"line",
"by",
"line"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L241-L261 |
Othernet-Project/conz | conz/console.py | Console.error | def error(self, msg='Program error: {err}', exit=None):
""" Error handler factory
This function takes a message with optional ``{err}`` placeholder and
returns a function that takes an exception object, prints the error
message to STDERR and optionally quits.
If no message is s... | python | def error(self, msg='Program error: {err}', exit=None):
""" Error handler factory
This function takes a message with optional ``{err}`` placeholder and
returns a function that takes an exception object, prints the error
message to STDERR and optionally quits.
If no message is s... | [
"def",
"error",
"(",
"self",
",",
"msg",
"=",
"'Program error: {err}'",
",",
"exit",
"=",
"None",
")",
":",
"def",
"handler",
"(",
"exc",
")",
":",
"if",
"msg",
":",
"self",
".",
"perr",
"(",
"msg",
".",
"format",
"(",
"err",
"=",
"exc",
")",
")"... | Error handler factory
This function takes a message with optional ``{err}`` placeholder and
returns a function that takes an exception object, prints the error
message to STDERR and optionally quits.
If no message is supplied (e.g., passing ``None`` or ``False`` or empty
string... | [
"Error",
"handler",
"factory"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L282-L304 |
Othernet-Project/conz | conz/console.py | Console.progress | def progress(self, msg, onerror=None, sep='...', end='DONE', abrt='FAIL',
prog='.', excs=(Exception,), reraise=True):
""" Context manager for handling interactive prog indication
This context manager streamlines presenting banners and prog
indicators. To start the prog, pass ``... | python | def progress(self, msg, onerror=None, sep='...', end='DONE', abrt='FAIL',
prog='.', excs=(Exception,), reraise=True):
""" Context manager for handling interactive prog indication
This context manager streamlines presenting banners and prog
indicators. To start the prog, pass ``... | [
"def",
"progress",
"(",
"self",
",",
"msg",
",",
"onerror",
"=",
"None",
",",
"sep",
"=",
"'...'",
",",
"end",
"=",
"'DONE'",
",",
"abrt",
"=",
"'FAIL'",
",",
"prog",
"=",
"'.'",
",",
"excs",
"=",
"(",
"Exception",
",",
")",
",",
"reraise",
"=",
... | Context manager for handling interactive prog indication
This context manager streamlines presenting banners and prog
indicators. To start the prog, pass ``msg`` argument as a start
message. For example::
printer = Console(verbose=True)
with printer.progress('Checking f... | [
"Context",
"manager",
"for",
"handling",
"interactive",
"prog",
"indication"
] | train | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L307-L369 |
daknuett/py_register_machine2 | core/processor.py | RegisterInterface.add_register | def add_register(self, register):
"""
.. _add_register:
Adds the Register_ ``register`` to the interface.
Will raise a SetupError_ if the interface is locked (because it is running) or if
there is already a Register with the name of the new Register or if
the number of Registers would exceed the size of t... | python | def add_register(self, register):
"""
.. _add_register:
Adds the Register_ ``register`` to the interface.
Will raise a SetupError_ if the interface is locked (because it is running) or if
there is already a Register with the name of the new Register or if
the number of Registers would exceed the size of t... | [
"def",
"add_register",
"(",
"self",
",",
"register",
")",
":",
"if",
"(",
"self",
".",
"_lock",
")",
":",
"raise",
"SetupError",
"(",
"\"RegisterInterface is already running, no changes to the register layout can be performed\"",
")",
"if",
"(",
"len",
"(",
"self",
... | .. _add_register:
Adds the Register_ ``register`` to the interface.
Will raise a SetupError_ if the interface is locked (because it is running) or if
there is already a Register with the name of the new Register or if
the number of Registers would exceed the size of the interface.
Returns the index of the ... | [
"..",
"_add_register",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L38-L58 |
daknuett/py_register_machine2 | core/processor.py | RegisterInterface.write | def write(self, name_or_index, word):
"""
Write a word in the Register with the name ``name_or_index`` or with the index ``name_or_index``.
``name_or_index`` hat to be either ``str`` or ``int``. If the type of ``name_or_index``
is wrong an AttributeError will be raised.
If there is no Register with the speci... | python | def write(self, name_or_index, word):
"""
Write a word in the Register with the name ``name_or_index`` or with the index ``name_or_index``.
``name_or_index`` hat to be either ``str`` or ``int``. If the type of ``name_or_index``
is wrong an AttributeError will be raised.
If there is no Register with the speci... | [
"def",
"write",
"(",
"self",
",",
"name_or_index",
",",
"word",
")",
":",
"if",
"(",
"isinstance",
"(",
"name_or_index",
",",
"str",
")",
")",
":",
"if",
"(",
"name_or_index",
"in",
"self",
".",
"registers_by_name",
")",
":",
"self",
".",
"registers_by_n... | Write a word in the Register with the name ``name_or_index`` or with the index ``name_or_index``.
``name_or_index`` hat to be either ``str`` or ``int``. If the type of ``name_or_index``
is wrong an AttributeError will be raised.
If there is no Register with the specified name or index, a NameError will be raised... | [
"Write",
"a",
"word",
"in",
"the",
"Register",
"with",
"the",
"name",
"name_or_index",
"or",
"with",
"the",
"index",
"name_or_index",
".",
"name_or_index",
"hat",
"to",
"be",
"either",
"str",
"or",
"int",
".",
"If",
"the",
"type",
"of",
"name_or_index",
"i... | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L60-L79 |
daknuett/py_register_machine2 | core/processor.py | Processor.en_dis_able_interrupts | def en_dis_able_interrupts(self, mask):
"""
This callback might be used by a Register to enable/disable Interrupts.
``mask`` is an ``int``, the Interrupts are bits in this mask, the first registered interrupt
has the bit ``(1 << 0)``, the n-th Interrupt the bit ``(1 << (n - 1))``.
If the bit is cleared (``0`... | python | def en_dis_able_interrupts(self, mask):
"""
This callback might be used by a Register to enable/disable Interrupts.
``mask`` is an ``int``, the Interrupts are bits in this mask, the first registered interrupt
has the bit ``(1 << 0)``, the n-th Interrupt the bit ``(1 << (n - 1))``.
If the bit is cleared (``0`... | [
"def",
"en_dis_able_interrupts",
"(",
"self",
",",
"mask",
")",
":",
"for",
"shift",
",",
"interrupt",
"in",
"enumerate",
"(",
"self",
".",
"interrupts",
")",
":",
"if",
"(",
"mask",
"&",
"(",
"1",
"<<",
"shift",
")",
")",
":",
"interrupt",
".",
"ena... | This callback might be used by a Register to enable/disable Interrupts.
``mask`` is an ``int``, the Interrupts are bits in this mask, the first registered interrupt
has the bit ``(1 << 0)``, the n-th Interrupt the bit ``(1 << (n - 1))``.
If the bit is cleared (``0``) the Interrupt will be disabled. | [
"This",
"callback",
"might",
"be",
"used",
"by",
"a",
"Register",
"to",
"enable",
"/",
"disable",
"Interrupts",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L198-L210 |
daknuett/py_register_machine2 | core/processor.py | Processor.add_interrupt | def add_interrupt(self, interrupt):
"""
Adds the interrupt to the internal interrupt storage ``self.interrupts`` and
registers the interrupt address in the internal constants.
"""
self.interrupts.append(interrupt)
self.constants[interrupt.name] = interrupt.address | python | def add_interrupt(self, interrupt):
"""
Adds the interrupt to the internal interrupt storage ``self.interrupts`` and
registers the interrupt address in the internal constants.
"""
self.interrupts.append(interrupt)
self.constants[interrupt.name] = interrupt.address | [
"def",
"add_interrupt",
"(",
"self",
",",
"interrupt",
")",
":",
"self",
".",
"interrupts",
".",
"append",
"(",
"interrupt",
")",
"self",
".",
"constants",
"[",
"interrupt",
".",
"name",
"]",
"=",
"interrupt",
".",
"address"
] | Adds the interrupt to the internal interrupt storage ``self.interrupts`` and
registers the interrupt address in the internal constants. | [
"Adds",
"the",
"interrupt",
"to",
"the",
"internal",
"interrupt",
"storage",
"self",
".",
"interrupts",
"and",
"registers",
"the",
"interrupt",
"address",
"in",
"the",
"internal",
"constants",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L211-L217 |
daknuett/py_register_machine2 | core/processor.py | Processor.interrupt | def interrupt(self, address):
"""
Interrupts the Processor and forces him to jump to ``address``.
If ``push_pc`` is enabled this will push the PC to the stack.
"""
if(self.push_pc):
self.memory_bus.write_word(self.sp, self.pc)
self._set_sp(self.sp - 1)
self._set_pc(address) | python | def interrupt(self, address):
"""
Interrupts the Processor and forces him to jump to ``address``.
If ``push_pc`` is enabled this will push the PC to the stack.
"""
if(self.push_pc):
self.memory_bus.write_word(self.sp, self.pc)
self._set_sp(self.sp - 1)
self._set_pc(address) | [
"def",
"interrupt",
"(",
"self",
",",
"address",
")",
":",
"if",
"(",
"self",
".",
"push_pc",
")",
":",
"self",
".",
"memory_bus",
".",
"write_word",
"(",
"self",
".",
"sp",
",",
"self",
".",
"pc",
")",
"self",
".",
"_set_sp",
"(",
"self",
".",
"... | Interrupts the Processor and forces him to jump to ``address``.
If ``push_pc`` is enabled this will push the PC to the stack. | [
"Interrupts",
"the",
"Processor",
"and",
"forces",
"him",
"to",
"jump",
"to",
"address",
".",
"If",
"push_pc",
"is",
"enabled",
"this",
"will",
"push",
"the",
"PC",
"to",
"the",
"stack",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L218-L226 |
daknuett/py_register_machine2 | core/processor.py | Processor.setup_done | def setup_done(self):
"""
.. _setup_done:
Finish the setup of the Processor.
This should be the last call before the Processor is used.
Sets the `internal constants`_ (used by the assembler) and
sets the Stack Pointer to RAMEND_HIGH, if there is a RAM attached.
If there is no RAM attached, SP will stay... | python | def setup_done(self):
"""
.. _setup_done:
Finish the setup of the Processor.
This should be the last call before the Processor is used.
Sets the `internal constants`_ (used by the assembler) and
sets the Stack Pointer to RAMEND_HIGH, if there is a RAM attached.
If there is no RAM attached, SP will stay... | [
"def",
"setup_done",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"memory_bus",
".",
"device_count",
"(",
")",
"<",
"1",
")",
":",
"raise",
"SetupError",
"(",
"\"At least a ROM device has to be attached.\"",
")",
"rom",
"=",
"self",
".",
"memory_bus",
".",... | .. _setup_done:
Finish the setup of the Processor.
This should be the last call before the Processor is used.
Sets the `internal constants`_ (used by the assembler) and
sets the Stack Pointer to RAMEND_HIGH, if there is a RAM attached.
If there is no RAM attached, SP will stay ``0``.
If there is a RAM a... | [
"..",
"_setup_done",
":",
"Finish",
"the",
"setup",
"of",
"the",
"Processor",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L259-L290 |
daknuett/py_register_machine2 | core/processor.py | Processor.reset | def reset(self):
"""
Resets the control registers of the Processor_(PC_, ECR_ and SP_)
"""
rom = self.memory_bus.devices[0]
if(self.memory_bus.device_count() > 1):
ram = self.memory_bus.devices[1]
self._set_sp(rom.size + ram.size - 1)
self._set_pc(0)
self._set_ecr(0)
self.cycles = 0 | python | def reset(self):
"""
Resets the control registers of the Processor_(PC_, ECR_ and SP_)
"""
rom = self.memory_bus.devices[0]
if(self.memory_bus.device_count() > 1):
ram = self.memory_bus.devices[1]
self._set_sp(rom.size + ram.size - 1)
self._set_pc(0)
self._set_ecr(0)
self.cycles = 0 | [
"def",
"reset",
"(",
"self",
")",
":",
"rom",
"=",
"self",
".",
"memory_bus",
".",
"devices",
"[",
"0",
"]",
"if",
"(",
"self",
".",
"memory_bus",
".",
"device_count",
"(",
")",
">",
"1",
")",
":",
"ram",
"=",
"self",
".",
"memory_bus",
".",
"dev... | Resets the control registers of the Processor_(PC_, ECR_ and SP_) | [
"Resets",
"the",
"control",
"registers",
"of",
"the",
"Processor_",
"(",
"PC_",
"ECR_",
"and",
"SP_",
")"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L291-L301 |
daknuett/py_register_machine2 | core/processor.py | Processor.register_command | def register_command(self, command):
"""
.. _register_command:
Register a Command in the Processor,
the Command can now be executed by the Processor.
"""
if(command.opcode() in self.commands_by_opcode):
raise SetupError("Command with opcode {}(mnemonic: {}) already registered".format(command.opcode(), c... | python | def register_command(self, command):
"""
.. _register_command:
Register a Command in the Processor,
the Command can now be executed by the Processor.
"""
if(command.opcode() in self.commands_by_opcode):
raise SetupError("Command with opcode {}(mnemonic: {}) already registered".format(command.opcode(), c... | [
"def",
"register_command",
"(",
"self",
",",
"command",
")",
":",
"if",
"(",
"command",
".",
"opcode",
"(",
")",
"in",
"self",
".",
"commands_by_opcode",
")",
":",
"raise",
"SetupError",
"(",
"\"Command with opcode {}(mnemonic: {}) already registered\"",
".",
"for... | .. _register_command:
Register a Command in the Processor,
the Command can now be executed by the Processor. | [
"..",
"_register_command",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L319-L331 |
daknuett/py_register_machine2 | core/processor.py | Processor.do_cycle | def do_cycle(self):
"""
.. _do_cycle:
Run one clock cycle of the Processor_,
works according to processor_phases_.
Then all ``on_cycle_callbacks`` are executed and the internal Registers are updated.
If ``f_cpu`` is set and the execution took not long enough,
``do_cycle`` will wait until the right time... | python | def do_cycle(self):
"""
.. _do_cycle:
Run one clock cycle of the Processor_,
works according to processor_phases_.
Then all ``on_cycle_callbacks`` are executed and the internal Registers are updated.
If ``f_cpu`` is set and the execution took not long enough,
``do_cycle`` will wait until the right time... | [
"def",
"do_cycle",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"f_cpu",
"!=",
"None",
")",
":",
"if",
"(",
"self",
".",
"last_cycle",
"==",
"None",
")",
":",
"self",
".",
"last_cycle",
"=",
"time",
".",
"time",
"(",
")",
"opcode",
"=",
"self",... | .. _do_cycle:
Run one clock cycle of the Processor_,
works according to processor_phases_.
Then all ``on_cycle_callbacks`` are executed and the internal Registers are updated.
If ``f_cpu`` is set and the execution took not long enough,
``do_cycle`` will wait until the right time for the next cycle.
If `... | [
"..",
"_do_cycle",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L358-L401 |
jamieleshaw/lurklib | lurklib/core.py | _Core.find | def find(self, haystack, needle):
"""
Finds needle in haystack.
If needle is found return True, if not return False.
Required arguments:
* haystack - Text to search in.
* needle - Text to search for.
"""
try:
qstatus = haystack.find(needle)
... | python | def find(self, haystack, needle):
"""
Finds needle in haystack.
If needle is found return True, if not return False.
Required arguments:
* haystack - Text to search in.
* needle - Text to search for.
"""
try:
qstatus = haystack.find(needle)
... | [
"def",
"find",
"(",
"self",
",",
"haystack",
",",
"needle",
")",
":",
"try",
":",
"qstatus",
"=",
"haystack",
".",
"find",
"(",
"needle",
")",
"except",
"AttributeError",
":",
"if",
"needle",
"in",
"haystack",
":",
"return",
"True",
"else",
":",
"retur... | Finds needle in haystack.
If needle is found return True, if not return False.
Required arguments:
* haystack - Text to search in.
* needle - Text to search for. | [
"Finds",
"needle",
"in",
"haystack",
".",
"If",
"needle",
"is",
"found",
"return",
"True",
"if",
"not",
"return",
"False",
".",
"Required",
"arguments",
":",
"*",
"haystack",
"-",
"Text",
"to",
"search",
"in",
".",
"*",
"needle",
"-",
"Text",
"to",
"se... | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L83-L101 |
jamieleshaw/lurklib | lurklib/core.py | _Core.send | def send(self, msg, error_check=False):
"""
Send a raw string with the CR-LF appended to it.
Required arguments:
* msg - Message to send.
Optional arguments:
* error_check=False - Check for errors.
If an error is found the relevant exception will be raised.
... | python | def send(self, msg, error_check=False):
"""
Send a raw string with the CR-LF appended to it.
Required arguments:
* msg - Message to send.
Optional arguments:
* error_check=False - Check for errors.
If an error is found the relevant exception will be raised.
... | [
"def",
"send",
"(",
"self",
",",
"msg",
",",
"error_check",
"=",
"False",
")",
":",
"with",
"self",
".",
"lock",
":",
"msg",
"=",
"msg",
".",
"replace",
"(",
"'\\r'",
",",
"'\\\\r'",
")",
".",
"replace",
"(",
"'\\n'",
",",
"'\\\\n'",
")",
"+",
"s... | Send a raw string with the CR-LF appended to it.
Required arguments:
* msg - Message to send.
Optional arguments:
* error_check=False - Check for errors.
If an error is found the relevant exception will be raised. | [
"Send",
"a",
"raw",
"string",
"with",
"the",
"CR",
"-",
"LF",
"appended",
"to",
"it",
".",
"Required",
"arguments",
":",
"*",
"msg",
"-",
"Message",
"to",
"send",
".",
"Optional",
"arguments",
":",
"*",
"error_check",
"=",
"False",
"-",
"Check",
"for",... | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L103-L123 |
jamieleshaw/lurklib | lurklib/core.py | _Core._mcon | def _mcon(self):
""" Buffer IRC data and handle PING/PONG. """
with self.lock:
sdata = ' '
while sdata[-1] != self._crlf[-1]:
if sdata == ' ':
sdata = ''
try:
sdata = sdata + \
self._socke... | python | def _mcon(self):
""" Buffer IRC data and handle PING/PONG. """
with self.lock:
sdata = ' '
while sdata[-1] != self._crlf[-1]:
if sdata == ' ':
sdata = ''
try:
sdata = sdata + \
self._socke... | [
"def",
"_mcon",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"sdata",
"=",
"' '",
"while",
"sdata",
"[",
"-",
"1",
"]",
"!=",
"self",
".",
"_crlf",
"[",
"-",
"1",
"]",
":",
"if",
"sdata",
"==",
"' '",
":",
"sdata",
"=",
"''",
"try... | Buffer IRC data and handle PING/PONG. | [
"Buffer",
"IRC",
"data",
"and",
"handle",
"PING",
"/",
"PONG",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L125-L144 |
jamieleshaw/lurklib | lurklib/core.py | _Core._raw_recv | def _raw_recv(self):
""" Return the next available IRC message in the buffer. """
with self.lock:
if self._index >= len(self._buffer):
self._mcon()
if self._index >= 199:
self._resetbuffer()
self._mcon()
msg = self._buff... | python | def _raw_recv(self):
""" Return the next available IRC message in the buffer. """
with self.lock:
if self._index >= len(self._buffer):
self._mcon()
if self._index >= 199:
self._resetbuffer()
self._mcon()
msg = self._buff... | [
"def",
"_raw_recv",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"_index",
">=",
"len",
"(",
"self",
".",
"_buffer",
")",
":",
"self",
".",
"_mcon",
"(",
")",
"if",
"self",
".",
"_index",
">=",
"199",
":",
"self",
... | Return the next available IRC message in the buffer. | [
"Return",
"the",
"next",
"available",
"IRC",
"message",
"in",
"the",
"buffer",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L146-L164 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.