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 |
|---|---|---|---|---|---|---|---|---|---|---|
4Kaylum/Brickfront | brickfront/client.py | Client.getReviews | def getReviews(self, setID):
'''
Get the reviews for a set.
:param str setID: The ID of the set you want to get the reviews of.
:returns: A list of reviews.
:rtype: List[:class:`brickfront.review.Review`]
.. warning:: An empty list will be returned if there are no review... | python | def getReviews(self, setID):
'''
Get the reviews for a set.
:param str setID: The ID of the set you want to get the reviews of.
:returns: A list of reviews.
:rtype: List[:class:`brickfront.review.Review`]
.. warning:: An empty list will be returned if there are no review... | [
"def",
"getReviews",
"(",
"self",
",",
"setID",
")",
":",
"params",
"=",
"{",
"'apiKey'",
":",
"self",
".",
"apiKey",
",",
"'setID'",
":",
"setID",
"}",
"url",
"=",
"Client",
".",
"ENDPOINT",
".",
"format",
"(",
"'getReviews'",
")",
"returned",
"=",
... | Get the reviews for a set.
:param str setID: The ID of the set you want to get the reviews of.
:returns: A list of reviews.
:rtype: List[:class:`brickfront.review.Review`]
.. warning:: An empty list will be returned if there are no reviews, or if the set ID is invalid. | [
"Get",
"the",
"reviews",
"for",
"a",
"set",
"."
] | train | https://github.com/4Kaylum/Brickfront/blob/9545f2183249862b077677d48fcfb9b4bfe1f87d/brickfront/client.py#L224-L244 |
arteymix/benchpy | benchpy/__init__.py | benchmarked.results | def results(cls, function, group=None):
"""
Returns a numpy nparray representing the benchmark results of a function
in a group.
"""
return numpy.array(cls._results[group][function]) | python | def results(cls, function, group=None):
"""
Returns a numpy nparray representing the benchmark results of a function
in a group.
"""
return numpy.array(cls._results[group][function]) | [
"def",
"results",
"(",
"cls",
",",
"function",
",",
"group",
"=",
"None",
")",
":",
"return",
"numpy",
".",
"array",
"(",
"cls",
".",
"_results",
"[",
"group",
"]",
"[",
"function",
"]",
")"
] | Returns a numpy nparray representing the benchmark results of a function
in a group. | [
"Returns",
"a",
"numpy",
"nparray",
"representing",
"the",
"benchmark",
"results",
"of",
"a",
"function",
"in",
"a",
"group",
"."
] | train | https://github.com/arteymix/benchpy/blob/3b5d949ec2e71541997923b1c7fcc67b634a9264/benchpy/__init__.py#L38-L43 |
arteymix/benchpy | benchpy/__init__.py | benchmarked.statistics | def statistics(cls, function, group=None):
"""
Compute statistics (average, max, median, minimun and sum) from _results
into a dictionary of numpy array.
"""
benchmark = cls.results(function, group)
results = {}
for name, stat in {'avg': numpy.average, 'max': nump... | python | def statistics(cls, function, group=None):
"""
Compute statistics (average, max, median, minimun and sum) from _results
into a dictionary of numpy array.
"""
benchmark = cls.results(function, group)
results = {}
for name, stat in {'avg': numpy.average, 'max': nump... | [
"def",
"statistics",
"(",
"cls",
",",
"function",
",",
"group",
"=",
"None",
")",
":",
"benchmark",
"=",
"cls",
".",
"results",
"(",
"function",
",",
"group",
")",
"results",
"=",
"{",
"}",
"for",
"name",
",",
"stat",
"in",
"{",
"'avg'",
":",
"nump... | Compute statistics (average, max, median, minimun and sum) from _results
into a dictionary of numpy array. | [
"Compute",
"statistics",
"(",
"average",
"max",
"median",
"minimun",
"and",
"sum",
")",
"from",
"_results",
"into",
"a",
"dictionary",
"of",
"numpy",
"array",
"."
] | train | https://github.com/arteymix/benchpy/blob/3b5d949ec2e71541997923b1c7fcc67b634a9264/benchpy/__init__.py#L46-L55 |
b3j0f/annotation | b3j0f/annotation/oop.py | Mixin.mixin_class | def mixin_class(target, cls):
"""Mix cls content in target."""
for name, field in getmembers(cls):
Mixin.mixin(target, field, name) | python | def mixin_class(target, cls):
"""Mix cls content in target."""
for name, field in getmembers(cls):
Mixin.mixin(target, field, name) | [
"def",
"mixin_class",
"(",
"target",
",",
"cls",
")",
":",
"for",
"name",
",",
"field",
"in",
"getmembers",
"(",
"cls",
")",
":",
"Mixin",
".",
"mixin",
"(",
"target",
",",
"field",
",",
"name",
")"
] | Mix cls content in target. | [
"Mix",
"cls",
"content",
"in",
"target",
"."
] | train | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/oop.py#L144-L148 |
b3j0f/annotation | b3j0f/annotation/oop.py | Mixin.mixin_function_or_method | def mixin_function_or_method(target, routine, name=None, isbound=False):
"""Mixin a routine into the target.
:param routine: routine to mix in target.
:param str name: mixin name. Routine name by default.
:param bool isbound: If True (False by default), the mixin result is a
... | python | def mixin_function_or_method(target, routine, name=None, isbound=False):
"""Mixin a routine into the target.
:param routine: routine to mix in target.
:param str name: mixin name. Routine name by default.
:param bool isbound: If True (False by default), the mixin result is a
... | [
"def",
"mixin_function_or_method",
"(",
"target",
",",
"routine",
",",
"name",
"=",
"None",
",",
"isbound",
"=",
"False",
")",
":",
"function",
"=",
"None",
"if",
"isfunction",
"(",
"routine",
")",
":",
"function",
"=",
"routine",
"elif",
"ismethod",
"(",
... | Mixin a routine into the target.
:param routine: routine to mix in target.
:param str name: mixin name. Routine name by default.
:param bool isbound: If True (False by default), the mixin result is a
bound method to target. | [
"Mixin",
"a",
"routine",
"into",
"the",
"target",
"."
] | train | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/oop.py#L151-L194 |
b3j0f/annotation | b3j0f/annotation/oop.py | Mixin.mixin | def mixin(target, resource, name=None):
"""Do the correct mixin depending on the type of input resource.
- Method or Function: mixin_function_or_method.
- class: mixin_class.
- other: set_mixin.
And returns the result of the choosen method (one or a list of mixins).
"""... | python | def mixin(target, resource, name=None):
"""Do the correct mixin depending on the type of input resource.
- Method or Function: mixin_function_or_method.
- class: mixin_class.
- other: set_mixin.
And returns the result of the choosen method (one or a list of mixins).
"""... | [
"def",
"mixin",
"(",
"target",
",",
"resource",
",",
"name",
"=",
"None",
")",
":",
"result",
"=",
"None",
"if",
"ismethod",
"(",
"resource",
")",
"or",
"isfunction",
"(",
"resource",
")",
":",
"result",
"=",
"Mixin",
".",
"mixin_function_or_method",
"("... | Do the correct mixin depending on the type of input resource.
- Method or Function: mixin_function_or_method.
- class: mixin_class.
- other: set_mixin.
And returns the result of the choosen method (one or a list of mixins). | [
"Do",
"the",
"correct",
"mixin",
"depending",
"on",
"the",
"type",
"of",
"input",
"resource",
"."
] | train | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/oop.py#L197-L227 |
b3j0f/annotation | b3j0f/annotation/oop.py | Mixin.get_mixedins_by_name | def get_mixedins_by_name(target):
"""Get a set of couple (name, field) of target mixedin."""
result = getattr(target, Mixin.__MIXEDIN_KEY__, None)
if result is None:
result = dict()
setattr(target, Mixin.__MIXEDIN_KEY__, result)
return result | python | def get_mixedins_by_name(target):
"""Get a set of couple (name, field) of target mixedin."""
result = getattr(target, Mixin.__MIXEDIN_KEY__, None)
if result is None:
result = dict()
setattr(target, Mixin.__MIXEDIN_KEY__, result)
return result | [
"def",
"get_mixedins_by_name",
"(",
"target",
")",
":",
"result",
"=",
"getattr",
"(",
"target",
",",
"Mixin",
".",
"__MIXEDIN_KEY__",
",",
"None",
")",
"if",
"result",
"is",
"None",
":",
"result",
"=",
"dict",
"(",
")",
"setattr",
"(",
"target",
",",
... | Get a set of couple (name, field) of target mixedin. | [
"Get",
"a",
"set",
"of",
"couple",
"(",
"name",
"field",
")",
"of",
"target",
"mixedin",
"."
] | train | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/oop.py#L230-L239 |
b3j0f/annotation | b3j0f/annotation/oop.py | Mixin.set_mixin | def set_mixin(target, resource, name=None, override=True):
"""Set a resource and returns the mixed one in target content or
Mixin.__NEW_CONTENT_KEY__ if resource name didn't exist in target.
:param str name: target content item to mix with the resource.
:param bool override: If True (de... | python | def set_mixin(target, resource, name=None, override=True):
"""Set a resource and returns the mixed one in target content or
Mixin.__NEW_CONTENT_KEY__ if resource name didn't exist in target.
:param str name: target content item to mix with the resource.
:param bool override: If True (de... | [
"def",
"set_mixin",
"(",
"target",
",",
"resource",
",",
"name",
"=",
"None",
",",
"override",
"=",
"True",
")",
":",
"if",
"name",
"is",
"None",
"and",
"not",
"hasattr",
"(",
"resource",
",",
"'__name__'",
")",
":",
"raise",
"Mixin",
".",
"MixInError"... | Set a resource and returns the mixed one in target content or
Mixin.__NEW_CONTENT_KEY__ if resource name didn't exist in target.
:param str name: target content item to mix with the resource.
:param bool override: If True (default) permits to replace an old
resource by the new one. | [
"Set",
"a",
"resource",
"and",
"returns",
"the",
"mixed",
"one",
"in",
"target",
"content",
"or",
"Mixin",
".",
"__NEW_CONTENT_KEY__",
"if",
"resource",
"name",
"didn",
"t",
"exist",
"in",
"target",
"."
] | train | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/oop.py#L242-L288 |
b3j0f/annotation | b3j0f/annotation/oop.py | Mixin.remove_mixin | def remove_mixin(target, name, mixedin=None, replace=True):
"""Remove a mixin with name (and reference) from targetand returns the
replaced one or None.
:param mixedin: a mixedin value or the last defined mixedin if is None
(by default).
:param bool replace: If True (default... | python | def remove_mixin(target, name, mixedin=None, replace=True):
"""Remove a mixin with name (and reference) from targetand returns the
replaced one or None.
:param mixedin: a mixedin value or the last defined mixedin if is None
(by default).
:param bool replace: If True (default... | [
"def",
"remove_mixin",
"(",
"target",
",",
"name",
",",
"mixedin",
"=",
"None",
",",
"replace",
"=",
"True",
")",
":",
"try",
":",
"result",
"=",
"getattr",
"(",
"target",
",",
"name",
")",
"except",
"AttributeError",
":",
"raise",
"Mixin",
".",
"MixIn... | Remove a mixin with name (and reference) from targetand returns the
replaced one or None.
:param mixedin: a mixedin value or the last defined mixedin if is None
(by default).
:param bool replace: If True (default), the removed mixedin replaces
the current mixin. | [
"Remove",
"a",
"mixin",
"with",
"name",
"(",
"and",
"reference",
")",
"from",
"targetand",
"returns",
"the",
"replaced",
"one",
"or",
"None",
"."
] | train | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/oop.py#L291-L360 |
b3j0f/annotation | b3j0f/annotation/oop.py | Mixin.remove_mixins | def remove_mixins(target):
"""Tries to get back target in a no mixin consistent state.
"""
mixedins_by_name = Mixin.get_mixedins_by_name(target).copy()
for _name in mixedins_by_name: # for all named mixins
while True: # remove all mixins named _name
try:
... | python | def remove_mixins(target):
"""Tries to get back target in a no mixin consistent state.
"""
mixedins_by_name = Mixin.get_mixedins_by_name(target).copy()
for _name in mixedins_by_name: # for all named mixins
while True: # remove all mixins named _name
try:
... | [
"def",
"remove_mixins",
"(",
"target",
")",
":",
"mixedins_by_name",
"=",
"Mixin",
".",
"get_mixedins_by_name",
"(",
"target",
")",
".",
"copy",
"(",
")",
"for",
"_name",
"in",
"mixedins_by_name",
":",
"# for all named mixins",
"while",
"True",
":",
"# remove al... | Tries to get back target in a no mixin consistent state. | [
"Tries",
"to",
"get",
"back",
"target",
"in",
"a",
"no",
"mixin",
"consistent",
"state",
"."
] | train | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/oop.py#L363-L374 |
edeposit/edeposit.amqp.storage | bin/edeposit_storage_server.py | error403 | def error403(error):
"""
Custom 403 page.
"""
tb = error.traceback
if isinstance(tb, dict) and "name" in tb and "uuid" in tb:
return SimpleTemplate(PRIVATE_ACCESS_MSG).render(
name=error.traceback["name"],
uuid=error.traceback["uuid"]
)
return "Access de... | python | def error403(error):
"""
Custom 403 page.
"""
tb = error.traceback
if isinstance(tb, dict) and "name" in tb and "uuid" in tb:
return SimpleTemplate(PRIVATE_ACCESS_MSG).render(
name=error.traceback["name"],
uuid=error.traceback["uuid"]
)
return "Access de... | [
"def",
"error403",
"(",
"error",
")",
":",
"tb",
"=",
"error",
".",
"traceback",
"if",
"isinstance",
"(",
"tb",
",",
"dict",
")",
"and",
"\"name\"",
"in",
"tb",
"and",
"\"uuid\"",
"in",
"tb",
":",
"return",
"SimpleTemplate",
"(",
"PRIVATE_ACCESS_MSG",
")... | Custom 403 page. | [
"Custom",
"403",
"page",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/bin/edeposit_storage_server.py#L251-L263 |
edeposit/edeposit.amqp.storage | bin/edeposit_storage_server.py | fetch_by_uuid | def fetch_by_uuid(uuid):
"""
Serve publications by UUID.
"""
# fetch all - private and public - publications
all_pubs = [
pub
for pub in search_publications(DBPublication(uuid=uuid))
]
if not all_pubs:
abort(404, "Dokument s UUID '%s' není dostupný." % (uuid))
p... | python | def fetch_by_uuid(uuid):
"""
Serve publications by UUID.
"""
# fetch all - private and public - publications
all_pubs = [
pub
for pub in search_publications(DBPublication(uuid=uuid))
]
if not all_pubs:
abort(404, "Dokument s UUID '%s' není dostupný." % (uuid))
p... | [
"def",
"fetch_by_uuid",
"(",
"uuid",
")",
":",
"# fetch all - private and public - publications",
"all_pubs",
"=",
"[",
"pub",
"for",
"pub",
"in",
"search_publications",
"(",
"DBPublication",
"(",
"uuid",
"=",
"uuid",
")",
")",
"]",
"if",
"not",
"all_pubs",
":",... | Serve publications by UUID. | [
"Serve",
"publications",
"by",
"UUID",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/bin/edeposit_storage_server.py#L267-L324 |
edeposit/edeposit.amqp.storage | bin/edeposit_storage_server.py | render_trees | def render_trees(trees, path_composer):
"""
Render list of `trees` to HTML.
Args:
trees (list): List of :class:`.Tree`.
path_composer (fn reference): Function used to compose paths from UUID.
Look at :func:`.compose_tree_path` from :mod:`.web_tools`.
Returns:
str: H... | python | def render_trees(trees, path_composer):
"""
Render list of `trees` to HTML.
Args:
trees (list): List of :class:`.Tree`.
path_composer (fn reference): Function used to compose paths from UUID.
Look at :func:`.compose_tree_path` from :mod:`.web_tools`.
Returns:
str: H... | [
"def",
"render_trees",
"(",
"trees",
",",
"path_composer",
")",
":",
"trees",
"=",
"list",
"(",
"trees",
")",
"# by default, this is set",
"def",
"create_pub_cache",
"(",
"trees",
")",
":",
"\"\"\"\n Create uuid -> DBPublication cache from all uuid's linked from `tre... | Render list of `trees` to HTML.
Args:
trees (list): List of :class:`.Tree`.
path_composer (fn reference): Function used to compose paths from UUID.
Look at :func:`.compose_tree_path` from :mod:`.web_tools`.
Returns:
str: HTML representation of trees. | [
"Render",
"list",
"of",
"trees",
"to",
"HTML",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/bin/edeposit_storage_server.py#L327-L404 |
edeposit/edeposit.amqp.storage | bin/edeposit_storage_server.py | show_periodical_tree_by_issn | def show_periodical_tree_by_issn(issn):
"""
Render tree using ISSN.
"""
trees = tree_handler().trees_by_issn(issn)
if not trees:
abort(404, "Dokument s ISSN '%s' není dostupný." % issn)
return render_trees(
trees,
partial(web_tools.compose_tree_path, issn=True)
) | python | def show_periodical_tree_by_issn(issn):
"""
Render tree using ISSN.
"""
trees = tree_handler().trees_by_issn(issn)
if not trees:
abort(404, "Dokument s ISSN '%s' není dostupný." % issn)
return render_trees(
trees,
partial(web_tools.compose_tree_path, issn=True)
) | [
"def",
"show_periodical_tree_by_issn",
"(",
"issn",
")",
":",
"trees",
"=",
"tree_handler",
"(",
")",
".",
"trees_by_issn",
"(",
"issn",
")",
"if",
"not",
"trees",
":",
"abort",
"(",
"404",
",",
"\"Dokument s ISSN '%s' není dostupný.\" %",
"i",
"sn)",
"",
"ret... | Render tree using ISSN. | [
"Render",
"tree",
"using",
"ISSN",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/bin/edeposit_storage_server.py#L408-L420 |
edeposit/edeposit.amqp.storage | bin/edeposit_storage_server.py | show_periodical_tree_by_path | def show_periodical_tree_by_path(path):
"""
Render tree using it's path.
"""
path = unquote_plus(path)
trees = tree_handler().trees_by_path(path)
if not trees:
path = path.decode("utf-8")
abort(404, "Dokument s názvem '%s' není dostupný." % path)
return render_trees(
... | python | def show_periodical_tree_by_path(path):
"""
Render tree using it's path.
"""
path = unquote_plus(path)
trees = tree_handler().trees_by_path(path)
if not trees:
path = path.decode("utf-8")
abort(404, "Dokument s názvem '%s' není dostupný." % path)
return render_trees(
... | [
"def",
"show_periodical_tree_by_path",
"(",
"path",
")",
":",
"path",
"=",
"unquote_plus",
"(",
"path",
")",
"trees",
"=",
"tree_handler",
"(",
")",
".",
"trees_by_path",
"(",
"path",
")",
"if",
"not",
"trees",
":",
"path",
"=",
"path",
".",
"decode",
"(... | Render tree using it's path. | [
"Render",
"tree",
"using",
"it",
"s",
"path",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/bin/edeposit_storage_server.py#L424-L438 |
edeposit/edeposit.amqp.storage | bin/edeposit_storage_server.py | list_publications | def list_publications():
"""
Return list of all publications in basic graphic HTML render.
"""
publications = search_publications(
DBPublication(is_public=True)
)
return SimpleTemplate(INDEX_TEMPLATE).render(
publications=publications,
compose_path=web_tools.compose_path... | python | def list_publications():
"""
Return list of all publications in basic graphic HTML render.
"""
publications = search_publications(
DBPublication(is_public=True)
)
return SimpleTemplate(INDEX_TEMPLATE).render(
publications=publications,
compose_path=web_tools.compose_path... | [
"def",
"list_publications",
"(",
")",
":",
"publications",
"=",
"search_publications",
"(",
"DBPublication",
"(",
"is_public",
"=",
"True",
")",
")",
"return",
"SimpleTemplate",
"(",
"INDEX_TEMPLATE",
")",
".",
"render",
"(",
"publications",
"=",
"publications",
... | Return list of all publications in basic graphic HTML render. | [
"Return",
"list",
"of",
"all",
"publications",
"in",
"basic",
"graphic",
"HTML",
"render",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/bin/edeposit_storage_server.py#L441-L453 |
edeposit/edeposit.amqp.storage | bin/edeposit_storage_server.py | check_auth | def check_auth(username, password):
"""
This function is used to check `username` and `password` in case that
:attr:`.settings.PRIVATE_INDEX` is set to ``True`` (default is ``False``).
"""
return (username == settings.PRIVATE_INDEX_USERNAME and
settings.PRIVATE_INDEX_PASSWORD and
... | python | def check_auth(username, password):
"""
This function is used to check `username` and `password` in case that
:attr:`.settings.PRIVATE_INDEX` is set to ``True`` (default is ``False``).
"""
return (username == settings.PRIVATE_INDEX_USERNAME and
settings.PRIVATE_INDEX_PASSWORD and
... | [
"def",
"check_auth",
"(",
"username",
",",
"password",
")",
":",
"return",
"(",
"username",
"==",
"settings",
".",
"PRIVATE_INDEX_USERNAME",
"and",
"settings",
".",
"PRIVATE_INDEX_PASSWORD",
"and",
"password",
"==",
"settings",
".",
"PRIVATE_INDEX_PASSWORD",
")"
] | This function is used to check `username` and `password` in case that
:attr:`.settings.PRIVATE_INDEX` is set to ``True`` (default is ``False``). | [
"This",
"function",
"is",
"used",
"to",
"check",
"username",
"and",
"password",
"in",
"case",
"that",
":",
"attr",
":",
".",
"settings",
".",
"PRIVATE_INDEX",
"is",
"set",
"to",
"True",
"(",
"default",
"is",
"False",
")",
"."
] | train | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/bin/edeposit_storage_server.py#L456-L463 |
roaet/eh | eh/mdv/markdownviewer.py | make_sample | def make_sample():
""" Generate the theme roller sample markdown """
if md_sample:
# user has set another:
return md_sample
_md = []
for hl in range(1, 7): _md.append('#' * hl + ' ' + 'Header %s' % hl)
this = open(__file__).read().split('"""', 3)[2].splitlines()[:10]
_md.append('... | python | def make_sample():
""" Generate the theme roller sample markdown """
if md_sample:
# user has set another:
return md_sample
_md = []
for hl in range(1, 7): _md.append('#' * hl + ' ' + 'Header %s' % hl)
this = open(__file__).read().split('"""', 3)[2].splitlines()[:10]
_md.append('... | [
"def",
"make_sample",
"(",
")",
":",
"if",
"md_sample",
":",
"# user has set another:",
"return",
"md_sample",
"_md",
"=",
"[",
"]",
"for",
"hl",
"in",
"range",
"(",
"1",
",",
"7",
")",
":",
"_md",
".",
"append",
"(",
"'#'",
"*",
"hl",
"+",
"' '",
... | Generate the theme roller sample markdown | [
"Generate",
"the",
"theme",
"roller",
"sample",
"markdown"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L189-L207 |
roaet/eh | eh/mdv/markdownviewer.py | set_theme | def set_theme(theme=None, for_code=None):
""" set md and code theme """
try:
if theme == 'default':
return
theme = theme or os.environ.get('AXC_THEME', 'random')
# all the themes from here:
themes = read_themes()
if theme == 'random':
rand = randin... | python | def set_theme(theme=None, for_code=None):
""" set md and code theme """
try:
if theme == 'default':
return
theme = theme or os.environ.get('AXC_THEME', 'random')
# all the themes from here:
themes = read_themes()
if theme == 'random':
rand = randin... | [
"def",
"set_theme",
"(",
"theme",
"=",
"None",
",",
"for_code",
"=",
"None",
")",
":",
"try",
":",
"if",
"theme",
"==",
"'default'",
":",
"return",
"theme",
"=",
"theme",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"'AXC_THEME'",
",",
"'random'",
")... | set md and code theme | [
"set",
"md",
"and",
"code",
"theme"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L236-L268 |
roaet/eh | eh/mdv/markdownviewer.py | style_ansi | def style_ansi(raw_code, lang=None):
""" actual code hilite """
lexer = 0
if lang:
try:
lexer = get_lexer_by_name(lang)
except ValueError:
print col(R, 'Lexer for %s not found' % lang)
lexer = None
if not lexer:
try:
if guess_lexer:
... | python | def style_ansi(raw_code, lang=None):
""" actual code hilite """
lexer = 0
if lang:
try:
lexer = get_lexer_by_name(lang)
except ValueError:
print col(R, 'Lexer for %s not found' % lang)
lexer = None
if not lexer:
try:
if guess_lexer:
... | [
"def",
"style_ansi",
"(",
"raw_code",
",",
"lang",
"=",
"None",
")",
":",
"lexer",
"=",
"0",
"if",
"lang",
":",
"try",
":",
"lexer",
"=",
"get_lexer_by_name",
"(",
"lang",
")",
"except",
"ValueError",
":",
"print",
"col",
"(",
"R",
",",
"'Lexer for %s ... | actual code hilite | [
"actual",
"code",
"hilite"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L271-L298 |
roaet/eh | eh/mdv/markdownviewer.py | col | def col(s, c, bg=0, no_reset=0):
"""
print col('foo', 124) -> red 'foo' on the terminal
c = color, s the value to colorize """
reset = reset_col
if no_reset:
reset = ''
for _strt, _end, _col in ((code_start, code_end, H2),
(stng_start, stng_end, H2),
... | python | def col(s, c, bg=0, no_reset=0):
"""
print col('foo', 124) -> red 'foo' on the terminal
c = color, s the value to colorize """
reset = reset_col
if no_reset:
reset = ''
for _strt, _end, _col in ((code_start, code_end, H2),
(stng_start, stng_end, H2),
... | [
"def",
"col",
"(",
"s",
",",
"c",
",",
"bg",
"=",
"0",
",",
"no_reset",
"=",
"0",
")",
":",
"reset",
"=",
"reset_col",
"if",
"no_reset",
":",
"reset",
"=",
"''",
"for",
"_strt",
",",
"_end",
",",
"_col",
"in",
"(",
"(",
"code_start",
",",
"code... | print col('foo', 124) -> red 'foo' on the terminal
c = color, s the value to colorize | [
"print",
"col",
"(",
"foo",
"124",
")",
"-",
">",
"red",
"foo",
"on",
"the",
"terminal",
"c",
"=",
"color",
"s",
"the",
"value",
"to",
"colorize"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L305-L324 |
roaet/eh | eh/mdv/markdownviewer.py | rewrap | def rewrap(el, t, ind, pref):
""" Reasonably smart rewrapping checking punctuations """
global term_columns
cols = term_columns - len(ind + pref)
if el.tag == 'code' or len(t) <= cols:
return t
# wrapping:
# we want to keep existing linebreaks after punctuation
# marks. the others we... | python | def rewrap(el, t, ind, pref):
""" Reasonably smart rewrapping checking punctuations """
global term_columns
cols = term_columns - len(ind + pref)
if el.tag == 'code' or len(t) <= cols:
return t
# wrapping:
# we want to keep existing linebreaks after punctuation
# marks. the others we... | [
"def",
"rewrap",
"(",
"el",
",",
"t",
",",
"ind",
",",
"pref",
")",
":",
"global",
"term_columns",
"cols",
"=",
"term_columns",
"-",
"len",
"(",
"ind",
"+",
"pref",
")",
"if",
"el",
".",
"tag",
"==",
"'code'",
"or",
"len",
"(",
"t",
")",
"<=",
... | Reasonably smart rewrapping checking punctuations | [
"Reasonably",
"smart",
"rewrapping",
"checking",
"punctuations"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L402-L439 |
roaet/eh | eh/mdv/markdownviewer.py | split_blocks | def split_blocks(text_block, w, cols, part_fmter=None):
""" splits while multiline blocks vertically (for large tables) """
ts = []
for line in text_block.splitlines():
parts = []
# make equal len:
line = line.ljust(w, ' ')
# first part full width, others a bit indented:
... | python | def split_blocks(text_block, w, cols, part_fmter=None):
""" splits while multiline blocks vertically (for large tables) """
ts = []
for line in text_block.splitlines():
parts = []
# make equal len:
line = line.ljust(w, ' ')
# first part full width, others a bit indented:
... | [
"def",
"split_blocks",
"(",
"text_block",
",",
"w",
",",
"cols",
",",
"part_fmter",
"=",
"None",
")",
":",
"ts",
"=",
"[",
"]",
"for",
"line",
"in",
"text_block",
".",
"splitlines",
"(",
")",
":",
"parts",
"=",
"[",
"]",
"# make equal len:",
"line",
... | splits while multiline blocks vertically (for large tables) | [
"splits",
"while",
"multiline",
"blocks",
"vertically",
"(",
"for",
"large",
"tables",
")"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L444-L472 |
roaet/eh | eh/mdv/markdownviewer.py | set_hr_widths | def set_hr_widths(result):
"""
We want the hrs indented by hirarchy...
A bit 2 much effort to calc, maybe just fixed with 10
style seps would have been enough visually:
◈────────────◈
"""
# set all hrs to max width of text:
mw = 0
hrs = []
if not hr_marker in result:
retu... | python | def set_hr_widths(result):
"""
We want the hrs indented by hirarchy...
A bit 2 much effort to calc, maybe just fixed with 10
style seps would have been enough visually:
◈────────────◈
"""
# set all hrs to max width of text:
mw = 0
hrs = []
if not hr_marker in result:
retu... | [
"def",
"set_hr_widths",
"(",
"result",
")",
":",
"# set all hrs to max width of text:",
"mw",
"=",
"0",
"hrs",
"=",
"[",
"]",
"if",
"not",
"hr_marker",
"in",
"result",
":",
"return",
"result",
"for",
"line",
"in",
"result",
".",
"splitlines",
"(",
")",
":"... | We want the hrs indented by hirarchy...
A bit 2 much effort to calc, maybe just fixed with 10
style seps would have been enough visually:
◈────────────◈ | [
"We",
"want",
"the",
"hrs",
"indented",
"by",
"hirarchy",
"...",
"A",
"bit",
"2",
"much",
"effort",
"to",
"calc",
"maybe",
"just",
"fixed",
"with",
"10",
"style",
"seps",
"would",
"have",
"been",
"enough",
"visually",
":",
"◈────────────◈"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L666-L695 |
roaet/eh | eh/mdv/markdownviewer.py | main | def main(md=None, filename=None, cols=None, theme=None, c_theme=None, bg=None,
c_no_guess=None, display_links=None, from_txt=None, do_html=None,
no_colors=None, **kw):
""" md is markdown string. alternatively we use filename and read """
args = locals()
if not md:
if not filename:... | python | def main(md=None, filename=None, cols=None, theme=None, c_theme=None, bg=None,
c_no_guess=None, display_links=None, from_txt=None, do_html=None,
no_colors=None, **kw):
""" md is markdown string. alternatively we use filename and read """
args = locals()
if not md:
if not filename:... | [
"def",
"main",
"(",
"md",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"cols",
"=",
"None",
",",
"theme",
"=",
"None",
",",
"c_theme",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"c_no_guess",
"=",
"None",
",",
"display_links",
"=",
"None",
",",
... | md is markdown string. alternatively we use filename and read | [
"md",
"is",
"markdown",
"string",
".",
"alternatively",
"we",
"use",
"filename",
"and",
"read"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L709-L836 |
roaet/eh | eh/mdv/markdownviewer.py | monitor | def monitor(args):
""" file monitor mode """
filename = args.get('MDFILE')
if not filename:
print col('Need file argument', 2)
raise SystemExit
last_err = ''
last_stat = 0
while True:
if not os.path.exists(filename):
last_err = 'File %s not found. Will continu... | python | def monitor(args):
""" file monitor mode """
filename = args.get('MDFILE')
if not filename:
print col('Need file argument', 2)
raise SystemExit
last_err = ''
last_stat = 0
while True:
if not os.path.exists(filename):
last_err = 'File %s not found. Will continu... | [
"def",
"monitor",
"(",
"args",
")",
":",
"filename",
"=",
"args",
".",
"get",
"(",
"'MDFILE'",
")",
"if",
"not",
"filename",
":",
"print",
"col",
"(",
"'Need file argument'",
",",
"2",
")",
"raise",
"SystemExit",
"last_err",
"=",
"''",
"last_stat",
"=",
... | file monitor mode | [
"file",
"monitor",
"mode"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L849-L872 |
roaet/eh | eh/mdv/markdownviewer.py | run_changed_file_cmd | def run_changed_file_cmd(cmd, fp, pretty):
""" running commands on changes.
pretty the parsed file
"""
with open(fp) as f:
raw = f.read()
# go sure regarding quotes:
for ph in (dir_mon_filepath_ph, dir_mon_content_raw,
dir_mon_content_pretty):
if ph in cmd and... | python | def run_changed_file_cmd(cmd, fp, pretty):
""" running commands on changes.
pretty the parsed file
"""
with open(fp) as f:
raw = f.read()
# go sure regarding quotes:
for ph in (dir_mon_filepath_ph, dir_mon_content_raw,
dir_mon_content_pretty):
if ph in cmd and... | [
"def",
"run_changed_file_cmd",
"(",
"cmd",
",",
"fp",
",",
"pretty",
")",
":",
"with",
"open",
"(",
"fp",
")",
"as",
"f",
":",
"raw",
"=",
"f",
".",
"read",
"(",
")",
"# go sure regarding quotes:",
"for",
"ph",
"in",
"(",
"dir_mon_filepath_ph",
",",
"d... | running commands on changes.
pretty the parsed file | [
"running",
"commands",
"on",
"changes",
".",
"pretty",
"the",
"parsed",
"file"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L883-L904 |
roaet/eh | eh/mdv/markdownviewer.py | monitor_dir | def monitor_dir(args):
""" displaying the changed files """
def show_fp(fp):
args['MDFILE'] = fp
pretty = run_args(args)
print pretty
print "(%s)" % col(fp, L)
cmd = args.get('change_cmd')
if cmd:
run_changed_file_cmd(cmd, fp=fp, pretty=pretty)
f... | python | def monitor_dir(args):
""" displaying the changed files """
def show_fp(fp):
args['MDFILE'] = fp
pretty = run_args(args)
print pretty
print "(%s)" % col(fp, L)
cmd = args.get('change_cmd')
if cmd:
run_changed_file_cmd(cmd, fp=fp, pretty=pretty)
f... | [
"def",
"monitor_dir",
"(",
"args",
")",
":",
"def",
"show_fp",
"(",
"fp",
")",
":",
"args",
"[",
"'MDFILE'",
"]",
"=",
"fp",
"pretty",
"=",
"run_args",
"(",
"args",
")",
"print",
"pretty",
"print",
"\"(%s)\"",
"%",
"col",
"(",
"fp",
",",
"L",
")",
... | displaying the changed files | [
"displaying",
"the",
"changed",
"files"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L907-L991 |
roaet/eh | eh/mdv/markdownviewer.py | run_args | def run_args(args):
""" call the lib entry function with CLI args """
return main(filename = args.get('MDFILE')
,theme = args.get('-t', 'random')
,cols = args.get('-c')
,from_txt = args.get('-f')
,c_theme = args.get('-T... | python | def run_args(args):
""" call the lib entry function with CLI args """
return main(filename = args.get('MDFILE')
,theme = args.get('-t', 'random')
,cols = args.get('-c')
,from_txt = args.get('-f')
,c_theme = args.get('-T... | [
"def",
"run_args",
"(",
"args",
")",
":",
"return",
"main",
"(",
"filename",
"=",
"args",
".",
"get",
"(",
"'MDFILE'",
")",
",",
"theme",
"=",
"args",
".",
"get",
"(",
"'-t'",
",",
"'random'",
")",
",",
"cols",
"=",
"args",
".",
"get",
"(",
"'-c'... | call the lib entry function with CLI args | [
"call",
"the",
"lib",
"entry",
"function",
"with",
"CLI",
"args"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L1011-L1021 |
roaet/eh | eh/mdv/markdownviewer.py | Tags.code | def code(_, s, from_fenced_block = None, **kw):
""" md code AND ``` style fenced raw code ends here"""
lang = kw.get('lang')
raw_code = s
if have_pygments:
s = style_ansi(raw_code, lang=lang)
# outest hir is 2, use it for fenced:
ind = ' ' * kw.get('hir', 2... | python | def code(_, s, from_fenced_block = None, **kw):
""" md code AND ``` style fenced raw code ends here"""
lang = kw.get('lang')
raw_code = s
if have_pygments:
s = style_ansi(raw_code, lang=lang)
# outest hir is 2, use it for fenced:
ind = ' ' * kw.get('hir', 2... | [
"def",
"code",
"(",
"_",
",",
"s",
",",
"from_fenced_block",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"lang",
"=",
"kw",
".",
"get",
"(",
"'lang'",
")",
"raw_code",
"=",
"s",
"if",
"have_pygments",
":",
"s",
"=",
"style_ansi",
"(",
"raw_code",
... | md code AND ``` style fenced raw code ends here | [
"md",
"code",
"AND",
"style",
"fenced",
"raw",
"code",
"ends",
"here"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/markdownviewer.py#L361-L383 |
calvinku96/labreporthelper | labreporthelper/bestfit/curvefit.py | CurveFit.do_bestfit | def do_bestfit(self):
"""
Do bestfit
"""
self.check_important_variables()
x = np.array(self.args["x"])
y = np.array(self.args["y"])
p = self.args.get("params", np.ones(self.args["num_vars"]))
self.fit_args, self.cov = opt.curve_fit(self.args["func"], x, y,... | python | def do_bestfit(self):
"""
Do bestfit
"""
self.check_important_variables()
x = np.array(self.args["x"])
y = np.array(self.args["y"])
p = self.args.get("params", np.ones(self.args["num_vars"]))
self.fit_args, self.cov = opt.curve_fit(self.args["func"], x, y,... | [
"def",
"do_bestfit",
"(",
"self",
")",
":",
"self",
".",
"check_important_variables",
"(",
")",
"x",
"=",
"np",
".",
"array",
"(",
"self",
".",
"args",
"[",
"\"x\"",
"]",
")",
"y",
"=",
"np",
".",
"array",
"(",
"self",
".",
"args",
"[",
"\"y\"",
... | Do bestfit | [
"Do",
"bestfit"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/bestfit/curvefit.py#L33-L42 |
calvinku96/labreporthelper | labreporthelper/bestfit/curvefit.py | ODRFit.bestfit_func | def bestfit_func(self, bestfit_x):
"""
Returns y value
"""
if not self.bestfit_func:
raise KeyError("Do do_bestfit first")
return self.args["func"](self.fit_args, bestfit_x) | python | def bestfit_func(self, bestfit_x):
"""
Returns y value
"""
if not self.bestfit_func:
raise KeyError("Do do_bestfit first")
return self.args["func"](self.fit_args, bestfit_x) | [
"def",
"bestfit_func",
"(",
"self",
",",
"bestfit_x",
")",
":",
"if",
"not",
"self",
".",
"bestfit_func",
":",
"raise",
"KeyError",
"(",
"\"Do do_bestfit first\"",
")",
"return",
"self",
".",
"args",
"[",
"\"func\"",
"]",
"(",
"self",
".",
"fit_args",
",",... | Returns y value | [
"Returns",
"y",
"value"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/bestfit/curvefit.py#L57-L63 |
calvinku96/labreporthelper | labreporthelper/bestfit/curvefit.py | ODRFit.do_bestfit | def do_bestfit(self):
"""
do bestfit using scipy.odr
"""
self.check_important_variables()
x = np.array(self.args["x"])
y = np.array(self.args["y"])
if self.args.get("use_RealData", True):
realdata_kwargs = self.args.get("RealData_kwargs", {})
... | python | def do_bestfit(self):
"""
do bestfit using scipy.odr
"""
self.check_important_variables()
x = np.array(self.args["x"])
y = np.array(self.args["y"])
if self.args.get("use_RealData", True):
realdata_kwargs = self.args.get("RealData_kwargs", {})
... | [
"def",
"do_bestfit",
"(",
"self",
")",
":",
"self",
".",
"check_important_variables",
"(",
")",
"x",
"=",
"np",
".",
"array",
"(",
"self",
".",
"args",
"[",
"\"x\"",
"]",
")",
"y",
"=",
"np",
".",
"array",
"(",
"self",
".",
"args",
"[",
"\"y\"",
... | do bestfit using scipy.odr | [
"do",
"bestfit",
"using",
"scipy",
".",
"odr"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/bestfit/curvefit.py#L65-L90 |
scdoshi/django-bits | bits/gis.py | gprmc_to_degdec | def gprmc_to_degdec(lat, latDirn, lng, lngDirn):
"""Converts GPRMC formats (Decimal Minutes) to Degrees Decimal."""
x = float(lat[0:2]) + float(lat[2:]) / 60
y = float(lng[0:3]) + float(lng[3:]) / 60
if latDirn == 'S':
x = -x
if lngDirn == 'W':
y = -y
return x, y | python | def gprmc_to_degdec(lat, latDirn, lng, lngDirn):
"""Converts GPRMC formats (Decimal Minutes) to Degrees Decimal."""
x = float(lat[0:2]) + float(lat[2:]) / 60
y = float(lng[0:3]) + float(lng[3:]) / 60
if latDirn == 'S':
x = -x
if lngDirn == 'W':
y = -y
return x, y | [
"def",
"gprmc_to_degdec",
"(",
"lat",
",",
"latDirn",
",",
"lng",
",",
"lngDirn",
")",
":",
"x",
"=",
"float",
"(",
"lat",
"[",
"0",
":",
"2",
"]",
")",
"+",
"float",
"(",
"lat",
"[",
"2",
":",
"]",
")",
"/",
"60",
"y",
"=",
"float",
"(",
"... | Converts GPRMC formats (Decimal Minutes) to Degrees Decimal. | [
"Converts",
"GPRMC",
"formats",
"(",
"Decimal",
"Minutes",
")",
"to",
"Degrees",
"Decimal",
"."
] | train | https://github.com/scdoshi/django-bits/blob/0a2f4fd9374d2a8acb8df9a7b83eebcf2782256f/bits/gis.py#L15-L25 |
scdoshi/django-bits | bits/gis.py | tinygps_to_degdec | def tinygps_to_degdec(lat, lng):
"""Converts TinyGPS formats (Decimal Degrees to e-5) to Degrees Decimal."""
x = float(lat[:-5] + '.' + lat[-5:])
y = float(lng[:-5] + '.' + lng[-5:])
return x, y | python | def tinygps_to_degdec(lat, lng):
"""Converts TinyGPS formats (Decimal Degrees to e-5) to Degrees Decimal."""
x = float(lat[:-5] + '.' + lat[-5:])
y = float(lng[:-5] + '.' + lng[-5:])
return x, y | [
"def",
"tinygps_to_degdec",
"(",
"lat",
",",
"lng",
")",
":",
"x",
"=",
"float",
"(",
"lat",
"[",
":",
"-",
"5",
"]",
"+",
"'.'",
"+",
"lat",
"[",
"-",
"5",
":",
"]",
")",
"y",
"=",
"float",
"(",
"lng",
"[",
":",
"-",
"5",
"]",
"+",
"'.'"... | Converts TinyGPS formats (Decimal Degrees to e-5) to Degrees Decimal. | [
"Converts",
"TinyGPS",
"formats",
"(",
"Decimal",
"Degrees",
"to",
"e",
"-",
"5",
")",
"to",
"Degrees",
"Decimal",
"."
] | train | https://github.com/scdoshi/django-bits/blob/0a2f4fd9374d2a8acb8df9a7b83eebcf2782256f/bits/gis.py#L28-L33 |
scdoshi/django-bits | bits/gis.py | change_in_longitude | def change_in_longitude(lat, miles):
"""Given a latitude and a distance west, return the change in longitude."""
# Find the radius of a circle around the earth at given latitude.
r = earth_radius * math.cos(lat * degrees_to_radians)
return (miles / r) * radians_to_degrees | python | def change_in_longitude(lat, miles):
"""Given a latitude and a distance west, return the change in longitude."""
# Find the radius of a circle around the earth at given latitude.
r = earth_radius * math.cos(lat * degrees_to_radians)
return (miles / r) * radians_to_degrees | [
"def",
"change_in_longitude",
"(",
"lat",
",",
"miles",
")",
":",
"# Find the radius of a circle around the earth at given latitude.",
"r",
"=",
"earth_radius",
"*",
"math",
".",
"cos",
"(",
"lat",
"*",
"degrees_to_radians",
")",
"return",
"(",
"miles",
"/",
"r",
... | Given a latitude and a distance west, return the change in longitude. | [
"Given",
"a",
"latitude",
"and",
"a",
"distance",
"west",
"return",
"the",
"change",
"in",
"longitude",
"."
] | train | https://github.com/scdoshi/django-bits/blob/0a2f4fd9374d2a8acb8df9a7b83eebcf2782256f/bits/gis.py#L55-L60 |
scdoshi/django-bits | bits/gis.py | calculate_boundingbox | def calculate_boundingbox(lng, lat, miles):
"""
Given a latitude, longitude and a distance in miles, calculate
the co-ordinates of the bounding box 2*miles on long each side with the
given co-ordinates at the center.
"""
latChange = change_in_latitude(miles)
latSouth = lat - latChange
l... | python | def calculate_boundingbox(lng, lat, miles):
"""
Given a latitude, longitude and a distance in miles, calculate
the co-ordinates of the bounding box 2*miles on long each side with the
given co-ordinates at the center.
"""
latChange = change_in_latitude(miles)
latSouth = lat - latChange
l... | [
"def",
"calculate_boundingbox",
"(",
"lng",
",",
"lat",
",",
"miles",
")",
":",
"latChange",
"=",
"change_in_latitude",
"(",
"miles",
")",
"latSouth",
"=",
"lat",
"-",
"latChange",
"latNorth",
"=",
"lat",
"+",
"latChange",
"lngChange",
"=",
"change_in_longitud... | Given a latitude, longitude and a distance in miles, calculate
the co-ordinates of the bounding box 2*miles on long each side with the
given co-ordinates at the center. | [
"Given",
"a",
"latitude",
"longitude",
"and",
"a",
"distance",
"in",
"miles",
"calculate",
"the",
"co",
"-",
"ordinates",
"of",
"the",
"bounding",
"box",
"2",
"*",
"miles",
"on",
"long",
"each",
"side",
"with",
"the",
"given",
"co",
"-",
"ordinates",
"at... | train | https://github.com/scdoshi/django-bits/blob/0a2f4fd9374d2a8acb8df9a7b83eebcf2782256f/bits/gis.py#L63-L76 |
20c/xbahn | xbahn/connection/link.py | Wire.disconnect | def disconnect(self):
"""
Close all connections that are set on this wire
"""
if self.connection_receive:
self.connection_receive.close()
if self.connection_respond:
self.connection_respond.close()
if self.connection_send:
self.connect... | python | def disconnect(self):
"""
Close all connections that are set on this wire
"""
if self.connection_receive:
self.connection_receive.close()
if self.connection_respond:
self.connection_respond.close()
if self.connection_send:
self.connect... | [
"def",
"disconnect",
"(",
"self",
")",
":",
"if",
"self",
".",
"connection_receive",
":",
"self",
".",
"connection_receive",
".",
"close",
"(",
")",
"if",
"self",
".",
"connection_respond",
":",
"self",
".",
"connection_respond",
".",
"close",
"(",
")",
"i... | Close all connections that are set on this wire | [
"Close",
"all",
"connections",
"that",
"are",
"set",
"on",
"this",
"wire"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/link.py#L32-L42 |
20c/xbahn | xbahn/connection/link.py | Wire.send_and_wait | def send_and_wait(self, path, message, timeout=0, responder=None):
"""
Send a message and block until a response is received. Return response message
"""
message.on("response", lambda x,event_origin,source:None, once=True)
if timeout > 0:
ts = time.time()
el... | python | def send_and_wait(self, path, message, timeout=0, responder=None):
"""
Send a message and block until a response is received. Return response message
"""
message.on("response", lambda x,event_origin,source:None, once=True)
if timeout > 0:
ts = time.time()
el... | [
"def",
"send_and_wait",
"(",
"self",
",",
"path",
",",
"message",
",",
"timeout",
"=",
"0",
",",
"responder",
"=",
"None",
")",
":",
"message",
".",
"on",
"(",
"\"response\"",
",",
"lambda",
"x",
",",
"event_origin",
",",
"source",
":",
"None",
",",
... | Send a message and block until a response is received. Return response message | [
"Send",
"a",
"message",
"and",
"block",
"until",
"a",
"response",
"is",
"received",
".",
"Return",
"response",
"message"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/link.py#L61-L82 |
20c/xbahn | xbahn/connection/link.py | Link.wire | def wire(self, name, receive=None, send=None, respond=None, **kwargs):
"""
Wires the link to a connection. Can be called multiple
times to set up wires to different connections
After creation wire will be accessible on the link via its name
as an attribute.
You can und... | python | def wire(self, name, receive=None, send=None, respond=None, **kwargs):
"""
Wires the link to a connection. Can be called multiple
times to set up wires to different connections
After creation wire will be accessible on the link via its name
as an attribute.
You can und... | [
"def",
"wire",
"(",
"self",
",",
"name",
",",
"receive",
"=",
"None",
",",
"send",
"=",
"None",
",",
"respond",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"name",
")",
"and",
"name",
"!=",
"\"main\"",
":",
... | Wires the link to a connection. Can be called multiple
times to set up wires to different connections
After creation wire will be accessible on the link via its name
as an attribute.
You can undo this action with the cut() method
Arguments:
- name (str): unique na... | [
"Wires",
"the",
"link",
"to",
"a",
"connection",
".",
"Can",
"be",
"called",
"multiple",
"times",
"to",
"set",
"up",
"wires",
"to",
"different",
"connections"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/link.py#L152-L199 |
20c/xbahn | xbahn/connection/link.py | Link.cut | def cut(self, name, disconnect=False):
"""
Cut a wire (undo a wire() call)
Arguments:
- name (str): name of the wire
Keyword Arguments:
- disconnect (bool): if True also disconnect all connections on the
specified wire
"""
wir... | python | def cut(self, name, disconnect=False):
"""
Cut a wire (undo a wire() call)
Arguments:
- name (str): name of the wire
Keyword Arguments:
- disconnect (bool): if True also disconnect all connections on the
specified wire
"""
wir... | [
"def",
"cut",
"(",
"self",
",",
"name",
",",
"disconnect",
"=",
"False",
")",
":",
"wire",
"=",
"getattr",
"(",
"self",
",",
"name",
",",
"None",
")",
"if",
"wire",
"and",
"isinstance",
"(",
"wire",
",",
"Wire",
")",
":",
"if",
"name",
"!=",
"\"m... | Cut a wire (undo a wire() call)
Arguments:
- name (str): name of the wire
Keyword Arguments:
- disconnect (bool): if True also disconnect all connections on the
specified wire | [
"Cut",
"a",
"wire",
"(",
"undo",
"a",
"wire",
"()",
"call",
")"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/link.py#L201-L225 |
20c/xbahn | xbahn/connection/link.py | Link.set_main_wire | def set_main_wire(self, wire=None):
"""
Sets the specified wire as the link's main wire
This is done automatically during the first wire() call
Keyword Arguments:
- wire (Wire): if None, use the first wire instance found
Returns:
- Wire: the new main ... | python | def set_main_wire(self, wire=None):
"""
Sets the specified wire as the link's main wire
This is done automatically during the first wire() call
Keyword Arguments:
- wire (Wire): if None, use the first wire instance found
Returns:
- Wire: the new main ... | [
"def",
"set_main_wire",
"(",
"self",
",",
"wire",
"=",
"None",
")",
":",
"if",
"not",
"wire",
":",
"for",
"k",
"in",
"dir",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"getattr",
"(",
"self",
",",
"k",
")",
",",
"Wire",
")",
":",
"wire",
"=... | Sets the specified wire as the link's main wire
This is done automatically during the first wire() call
Keyword Arguments:
- wire (Wire): if None, use the first wire instance found
Returns:
- Wire: the new main wire instance | [
"Sets",
"the",
"specified",
"wire",
"as",
"the",
"link",
"s",
"main",
"wire",
"This",
"is",
"done",
"automatically",
"during",
"the",
"first",
"wire",
"()",
"call"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/link.py#L227-L254 |
20c/xbahn | xbahn/connection/link.py | Link.wires | def wires(self):
"""
Yields name (str), wire (Wire) for all wires on
this link
"""
for k in dir(self):
if isinstance(getattr(self, k), Wire):
yield k, getattr(self, k) | python | def wires(self):
"""
Yields name (str), wire (Wire) for all wires on
this link
"""
for k in dir(self):
if isinstance(getattr(self, k), Wire):
yield k, getattr(self, k) | [
"def",
"wires",
"(",
"self",
")",
":",
"for",
"k",
"in",
"dir",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"getattr",
"(",
"self",
",",
"k",
")",
",",
"Wire",
")",
":",
"yield",
"k",
",",
"getattr",
"(",
"self",
",",
"k",
")"
] | Yields name (str), wire (Wire) for all wires on
this link | [
"Yields",
"name",
"(",
"str",
")",
"wire",
"(",
"Wire",
")",
"for",
"all",
"wires",
"on",
"this",
"link"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/link.py#L256-L264 |
20c/xbahn | xbahn/connection/link.py | Link.disconnect | def disconnect(self):
"""
Cut all wires and disconnect all connections established on this link
"""
for name, wire in self.wires():
self.cut(name, disconnect=True) | python | def disconnect(self):
"""
Cut all wires and disconnect all connections established on this link
"""
for name, wire in self.wires():
self.cut(name, disconnect=True) | [
"def",
"disconnect",
"(",
"self",
")",
":",
"for",
"name",
",",
"wire",
"in",
"self",
".",
"wires",
"(",
")",
":",
"self",
".",
"cut",
"(",
"name",
",",
"disconnect",
"=",
"True",
")"
] | Cut all wires and disconnect all connections established on this link | [
"Cut",
"all",
"wires",
"and",
"disconnect",
"all",
"connections",
"established",
"on",
"this",
"link"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/link.py#L266-L272 |
AtteqCom/zsl_client | python/zsl_client.py | Service.call | def call(self, task, decorators=None):
"""
Call given task on service layer.
:param task: task to be called. task will be decorated with
TaskDecorator's contained in 'decorators' list
:type task: instance of Task class
:param decorators: list of TaskDecorator's / Tas... | python | def call(self, task, decorators=None):
"""
Call given task on service layer.
:param task: task to be called. task will be decorated with
TaskDecorator's contained in 'decorators' list
:type task: instance of Task class
:param decorators: list of TaskDecorator's / Tas... | [
"def",
"call",
"(",
"self",
",",
"task",
",",
"decorators",
"=",
"None",
")",
":",
"if",
"decorators",
"is",
"None",
":",
"decorators",
"=",
"[",
"]",
"task",
"=",
"self",
".",
"apply_task_decorators",
"(",
"task",
",",
"decorators",
")",
"data",
"=",
... | Call given task on service layer.
:param task: task to be called. task will be decorated with
TaskDecorator's contained in 'decorators' list
:type task: instance of Task class
:param decorators: list of TaskDecorator's / TaskResultDecorator's
inherited classes
:t... | [
"Call",
"given",
"task",
"on",
"service",
"layer",
"."
] | train | https://github.com/AtteqCom/zsl_client/blob/d362c618f7d7b7fd7e85220a17f9854fd229d583/python/zsl_client.py#L173-L198 |
edeposit/edeposit.amqp.pdfgen | src/edeposit/amqp/pdfgen/specialization.py | _resource_context | def _resource_context(fn):
"""
Compose path to the ``resources`` directory for given `fn`.
Args:
fn (str): Filename of file in ``resources`` directory.
Returns:
str: Absolute path to the file in resources directory.
"""
return os.path.join(
os.path.dirname(__file__),
... | python | def _resource_context(fn):
"""
Compose path to the ``resources`` directory for given `fn`.
Args:
fn (str): Filename of file in ``resources`` directory.
Returns:
str: Absolute path to the file in resources directory.
"""
return os.path.join(
os.path.dirname(__file__),
... | [
"def",
"_resource_context",
"(",
"fn",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"DES_DIR",
",",
"fn",
")"
] | Compose path to the ``resources`` directory for given `fn`.
Args:
fn (str): Filename of file in ``resources`` directory.
Returns:
str: Absolute path to the file in resources directory. | [
"Compose",
"path",
"to",
"the",
"resources",
"directory",
"for",
"given",
"fn",
"."
] | train | https://github.com/edeposit/edeposit.amqp.pdfgen/blob/1022d6d01196f4928d664a71e49273c2d8c67e63/src/edeposit/amqp/pdfgen/specialization.py#L26-L40 |
edeposit/edeposit.amqp.pdfgen | src/edeposit/amqp/pdfgen/specialization.py | get_contract | def get_contract(firma, pravni_forma, sidlo, ic, dic, zastoupen):
"""
Compose contract and create PDF.
Args:
firma (str): firma
pravni_forma (str): pravni_forma
sidlo (str): sidlo
ic (str): ic
dic (str): dic
zastoupen (str): zastoupen
Returns:
ob... | python | def get_contract(firma, pravni_forma, sidlo, ic, dic, zastoupen):
"""
Compose contract and create PDF.
Args:
firma (str): firma
pravni_forma (str): pravni_forma
sidlo (str): sidlo
ic (str): ic
dic (str): dic
zastoupen (str): zastoupen
Returns:
ob... | [
"def",
"get_contract",
"(",
"firma",
",",
"pravni_forma",
",",
"sidlo",
",",
"ic",
",",
"dic",
",",
"zastoupen",
")",
":",
"contract_fn",
"=",
"_resource_context",
"(",
"\"Licencni_smlouva_o_dodavani_elektronickych_publikaci\"",
"\"_a_jejich_uziti.rst\"",
")",
"# load c... | Compose contract and create PDF.
Args:
firma (str): firma
pravni_forma (str): pravni_forma
sidlo (str): sidlo
ic (str): ic
dic (str): dic
zastoupen (str): zastoupen
Returns:
obj: StringIO file instance containing PDF file. | [
"Compose",
"contract",
"and",
"create",
"PDF",
"."
] | train | https://github.com/edeposit/edeposit.amqp.pdfgen/blob/1022d6d01196f4928d664a71e49273c2d8c67e63/src/edeposit/amqp/pdfgen/specialization.py#L43-L85 |
edeposit/edeposit.amqp.pdfgen | src/edeposit/amqp/pdfgen/specialization.py | get_review | def get_review(review_struct):
"""
Generate review from `review_struct`.
Args:
review_struct (obj): :class:`.GenerateReview` instance.
Returns:
obj: StringIO file instance containing PDF file.
"""
review_fn = _resource_context("review.rst")
# read review template
with ... | python | def get_review(review_struct):
"""
Generate review from `review_struct`.
Args:
review_struct (obj): :class:`.GenerateReview` instance.
Returns:
obj: StringIO file instance containing PDF file.
"""
review_fn = _resource_context("review.rst")
# read review template
with ... | [
"def",
"get_review",
"(",
"review_struct",
")",
":",
"review_fn",
"=",
"_resource_context",
"(",
"\"review.rst\"",
")",
"# read review template",
"with",
"open",
"(",
"review_fn",
")",
"as",
"f",
":",
"review",
"=",
"f",
".",
"read",
"(",
")",
"# generate qr c... | Generate review from `review_struct`.
Args:
review_struct (obj): :class:`.GenerateReview` instance.
Returns:
obj: StringIO file instance containing PDF file. | [
"Generate",
"review",
"from",
"review_struct",
"."
] | train | https://github.com/edeposit/edeposit.amqp.pdfgen/blob/1022d6d01196f4928d664a71e49273c2d8c67e63/src/edeposit/amqp/pdfgen/specialization.py#L88-L125 |
anrosent/perg | enum.py | enum_subpattern | def enum_subpattern(p):
subpattern_id, d = p
patterns = list(enum_gen(d))
'''
if subpattern_id:
subpat_iter = EnumSubpatternIterator(subpattern_id, patterns)
SUBPATTERNS[subpattern_id] = subpat_iter
return subpat_iter
else:
return patterns
'''
return patt... | python | def enum_subpattern(p):
subpattern_id, d = p
patterns = list(enum_gen(d))
'''
if subpattern_id:
subpat_iter = EnumSubpatternIterator(subpattern_id, patterns)
SUBPATTERNS[subpattern_id] = subpat_iter
return subpat_iter
else:
return patterns
'''
return patt... | [
"def",
"enum_subpattern",
"(",
"p",
")",
":",
"subpattern_id",
",",
"d",
"=",
"p",
"patterns",
"=",
"list",
"(",
"enum_gen",
"(",
"d",
")",
")",
"return",
"patterns"
] | if subpattern_id:
subpat_iter = EnumSubpatternIterator(subpattern_id, patterns)
SUBPATTERNS[subpattern_id] = subpat_iter
return subpat_iter
else:
return patterns | [
"if",
"subpattern_id",
":",
"subpat_iter",
"=",
"EnumSubpatternIterator",
"(",
"subpattern_id",
"patterns",
")",
"SUBPATTERNS",
"[",
"subpattern_id",
"]",
"=",
"subpat_iter",
"return",
"subpat_iter",
"else",
":",
"return",
"patterns"
] | train | https://github.com/anrosent/perg/blob/53293f7ed5e0f2e45fb185b60e344ea8436f02aa/enum.py#L88-L100 |
minhhoit/yacms | yacms/template/__init__.py | Library.as_tag | def as_tag(self, tag_func):
"""
Creates a tag expecting the format:
``{% tag_name as var_name %}``
The decorated func returns the value that is given to
``var_name`` in the template.
"""
@wraps(tag_func)
def tag_wrapper(parser, token):
class As... | python | def as_tag(self, tag_func):
"""
Creates a tag expecting the format:
``{% tag_name as var_name %}``
The decorated func returns the value that is given to
``var_name`` in the template.
"""
@wraps(tag_func)
def tag_wrapper(parser, token):
class As... | [
"def",
"as_tag",
"(",
"self",
",",
"tag_func",
")",
":",
"@",
"wraps",
"(",
"tag_func",
")",
"def",
"tag_wrapper",
"(",
"parser",
",",
"token",
")",
":",
"class",
"AsTagNode",
"(",
"template",
".",
"Node",
")",
":",
"def",
"render",
"(",
"self",
",",... | Creates a tag expecting the format:
``{% tag_name as var_name %}``
The decorated func returns the value that is given to
``var_name`` in the template. | [
"Creates",
"a",
"tag",
"expecting",
"the",
"format",
":",
"{",
"%",
"tag_name",
"as",
"var_name",
"%",
"}",
"The",
"decorated",
"func",
"returns",
"the",
"value",
"that",
"is",
"given",
"to",
"var_name",
"in",
"the",
"template",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/template/__init__.py#L19-L49 |
minhhoit/yacms | yacms/template/__init__.py | Library.render_tag | def render_tag(self, tag_func):
"""
Creates a tag using the decorated func as the render function
for the template tag node. The render function takes two
arguments - the template context and the tag token.
"""
@wraps(tag_func)
def tag_wrapper(parser, token):
... | python | def render_tag(self, tag_func):
"""
Creates a tag using the decorated func as the render function
for the template tag node. The render function takes two
arguments - the template context and the tag token.
"""
@wraps(tag_func)
def tag_wrapper(parser, token):
... | [
"def",
"render_tag",
"(",
"self",
",",
"tag_func",
")",
":",
"@",
"wraps",
"(",
"tag_func",
")",
"def",
"tag_wrapper",
"(",
"parser",
",",
"token",
")",
":",
"class",
"RenderTagNode",
"(",
"template",
".",
"Node",
")",
":",
"def",
"render",
"(",
"self"... | Creates a tag using the decorated func as the render function
for the template tag node. The render function takes two
arguments - the template context and the tag token. | [
"Creates",
"a",
"tag",
"using",
"the",
"decorated",
"func",
"as",
"the",
"render",
"function",
"for",
"the",
"template",
"tag",
"node",
".",
"The",
"render",
"function",
"takes",
"two",
"arguments",
"-",
"the",
"template",
"context",
"and",
"the",
"tag",
"... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/template/__init__.py#L51-L63 |
minhhoit/yacms | yacms/template/__init__.py | Library.to_end_tag | def to_end_tag(self, tag_func):
"""
Creates a tag that parses until it finds the corresponding end
tag, eg: for a tag named ``mytag`` it will parse until
``endmytag``. The decorated func's return value is used to
render the parsed content and takes three arguments - the
p... | python | def to_end_tag(self, tag_func):
"""
Creates a tag that parses until it finds the corresponding end
tag, eg: for a tag named ``mytag`` it will parse until
``endmytag``. The decorated func's return value is used to
render the parsed content and takes three arguments - the
p... | [
"def",
"to_end_tag",
"(",
"self",
",",
"tag_func",
")",
":",
"@",
"wraps",
"(",
"tag_func",
")",
"def",
"tag_wrapper",
"(",
"parser",
",",
"token",
")",
":",
"class",
"ToEndTagNode",
"(",
"template",
".",
"Node",
")",
":",
"def",
"__init__",
"(",
"self... | Creates a tag that parses until it finds the corresponding end
tag, eg: for a tag named ``mytag`` it will parse until
``endmytag``. The decorated func's return value is used to
render the parsed content and takes three arguments - the
parsed content between the start and end tags, the te... | [
"Creates",
"a",
"tag",
"that",
"parses",
"until",
"it",
"finds",
"the",
"corresponding",
"end",
"tag",
"eg",
":",
"for",
"a",
"tag",
"named",
"mytag",
"it",
"will",
"parse",
"until",
"endmytag",
".",
"The",
"decorated",
"func",
"s",
"return",
"value",
"i... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/template/__init__.py#L65-L90 |
minhhoit/yacms | yacms/template/__init__.py | Library.inclusion_tag | def inclusion_tag(self, name, context_class=Context, takes_context=False):
"""
Replacement for Django's ``inclusion_tag`` which looks up device
specific templates at render time.
"""
def tag_decorator(tag_func):
@wraps(tag_func)
def tag_wrapper(parser, to... | python | def inclusion_tag(self, name, context_class=Context, takes_context=False):
"""
Replacement for Django's ``inclusion_tag`` which looks up device
specific templates at render time.
"""
def tag_decorator(tag_func):
@wraps(tag_func)
def tag_wrapper(parser, to... | [
"def",
"inclusion_tag",
"(",
"self",
",",
"name",
",",
"context_class",
"=",
"Context",
",",
"takes_context",
"=",
"False",
")",
":",
"def",
"tag_decorator",
"(",
"tag_func",
")",
":",
"@",
"wraps",
"(",
"tag_func",
")",
"def",
"tag_wrapper",
"(",
"parser"... | Replacement for Django's ``inclusion_tag`` which looks up device
specific templates at render time. | [
"Replacement",
"for",
"Django",
"s",
"inclusion_tag",
"which",
"looks",
"up",
"device",
"specific",
"templates",
"at",
"render",
"time",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/template/__init__.py#L92-L126 |
catalyst/stacktask-tempest | stacktask_tempest_plugin/stacktask_client.py | StacktaskClient.user_list | def user_list(self, params=None):
"""Lists all users within the tenant."""
uri = 'openstack/users'
if params:
uri += '?%s' % urllib.urlencode(params)
resp, body = self.get(uri)
self.expected_success(200, resp.status)
body = json.loads(body)
return re... | python | def user_list(self, params=None):
"""Lists all users within the tenant."""
uri = 'openstack/users'
if params:
uri += '?%s' % urllib.urlencode(params)
resp, body = self.get(uri)
self.expected_success(200, resp.status)
body = json.loads(body)
return re... | [
"def",
"user_list",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"uri",
"=",
"'openstack/users'",
"if",
"params",
":",
"uri",
"+=",
"'?%s'",
"%",
"urllib",
".",
"urlencode",
"(",
"params",
")",
"resp",
",",
"body",
"=",
"self",
".",
"get",
"(",... | Lists all users within the tenant. | [
"Lists",
"all",
"users",
"within",
"the",
"tenant",
"."
] | train | https://github.com/catalyst/stacktask-tempest/blob/0171161338a0a02de1fe62b6baaebf3c58f44db6/stacktask_tempest_plugin/stacktask_client.py#L11-L21 |
catalyst/stacktask-tempest | stacktask_tempest_plugin/stacktask_client.py | StacktaskClient.user_invite | def user_invite(self, username, email, roles):
""" Invite a user to the tenant. """
uri = 'openstack/users'
data = {
"username": username,
"email": email,
"roles": list(set(roles))
}
post_body = json.dumps(data)
resp, body = self.post(... | python | def user_invite(self, username, email, roles):
""" Invite a user to the tenant. """
uri = 'openstack/users'
data = {
"username": username,
"email": email,
"roles": list(set(roles))
}
post_body = json.dumps(data)
resp, body = self.post(... | [
"def",
"user_invite",
"(",
"self",
",",
"username",
",",
"email",
",",
"roles",
")",
":",
"uri",
"=",
"'openstack/users'",
"data",
"=",
"{",
"\"username\"",
":",
"username",
",",
"\"email\"",
":",
"email",
",",
"\"roles\"",
":",
"list",
"(",
"set",
"(",
... | Invite a user to the tenant. | [
"Invite",
"a",
"user",
"to",
"the",
"tenant",
"."
] | train | https://github.com/catalyst/stacktask-tempest/blob/0171161338a0a02de1fe62b6baaebf3c58f44db6/stacktask_tempest_plugin/stacktask_client.py#L23-L36 |
catalyst/stacktask-tempest | stacktask_tempest_plugin/stacktask_client.py | StacktaskClient.revoke_user | def revoke_user(self, user_id):
""" Revoke a user from the tenant
This will remove pending or approved roles but
will not not delete the user from Keystone.
"""
uri = 'openstack/users/%s' % user_id
try:
resp = self.delete(uri)
except Attribute... | python | def revoke_user(self, user_id):
""" Revoke a user from the tenant
This will remove pending or approved roles but
will not not delete the user from Keystone.
"""
uri = 'openstack/users/%s' % user_id
try:
resp = self.delete(uri)
except Attribute... | [
"def",
"revoke_user",
"(",
"self",
",",
"user_id",
")",
":",
"uri",
"=",
"'openstack/users/%s'",
"%",
"user_id",
"try",
":",
"resp",
"=",
"self",
".",
"delete",
"(",
"uri",
")",
"except",
"AttributeError",
":",
"# note: this breaks. stacktask returns a string, not... | Revoke a user from the tenant
This will remove pending or approved roles but
will not not delete the user from Keystone. | [
"Revoke",
"a",
"user",
"from",
"the",
"tenant",
"This",
"will",
"remove",
"pending",
"or",
"approved",
"roles",
"but",
"will",
"not",
"not",
"delete",
"the",
"user",
"from",
"Keystone",
"."
] | train | https://github.com/catalyst/stacktask-tempest/blob/0171161338a0a02de1fe62b6baaebf3c58f44db6/stacktask_tempest_plugin/stacktask_client.py#L38-L51 |
catalyst/stacktask-tempest | stacktask_tempest_plugin/stacktask_client.py | StacktaskClient.get_tokens | def get_tokens(self, filters={}):
""" Returns dict of tokens matching the provided filters """
uri = 'tokens'
if filters:
filters = {'filters': json.dumps(filters)}
uri += "?%s" % urllib.urlencode(filters, True)
resp, body = self.get(uri)
self.expected_s... | python | def get_tokens(self, filters={}):
""" Returns dict of tokens matching the provided filters """
uri = 'tokens'
if filters:
filters = {'filters': json.dumps(filters)}
uri += "?%s" % urllib.urlencode(filters, True)
resp, body = self.get(uri)
self.expected_s... | [
"def",
"get_tokens",
"(",
"self",
",",
"filters",
"=",
"{",
"}",
")",
":",
"uri",
"=",
"'tokens'",
"if",
"filters",
":",
"filters",
"=",
"{",
"'filters'",
":",
"json",
".",
"dumps",
"(",
"filters",
")",
"}",
"uri",
"+=",
"\"?%s\"",
"%",
"urllib",
"... | Returns dict of tokens matching the provided filters | [
"Returns",
"dict",
"of",
"tokens",
"matching",
"the",
"provided",
"filters"
] | train | https://github.com/catalyst/stacktask-tempest/blob/0171161338a0a02de1fe62b6baaebf3c58f44db6/stacktask_tempest_plugin/stacktask_client.py#L53-L64 |
catalyst/stacktask-tempest | stacktask_tempest_plugin/stacktask_client.py | StacktaskClient.token_submit | def token_submit(self, token_id, json_data={}):
""" Submits a given token, along with optional data """
uri = 'tokens/%s' % token_id
post_body = json.dumps(json_data)
resp, body = self.post(uri, post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
... | python | def token_submit(self, token_id, json_data={}):
""" Submits a given token, along with optional data """
uri = 'tokens/%s' % token_id
post_body = json.dumps(json_data)
resp, body = self.post(uri, post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
... | [
"def",
"token_submit",
"(",
"self",
",",
"token_id",
",",
"json_data",
"=",
"{",
"}",
")",
":",
"uri",
"=",
"'tokens/%s'",
"%",
"token_id",
"post_body",
"=",
"json",
".",
"dumps",
"(",
"json_data",
")",
"resp",
",",
"body",
"=",
"self",
".",
"post",
... | Submits a given token, along with optional data | [
"Submits",
"a",
"given",
"token",
"along",
"with",
"optional",
"data"
] | train | https://github.com/catalyst/stacktask-tempest/blob/0171161338a0a02de1fe62b6baaebf3c58f44db6/stacktask_tempest_plugin/stacktask_client.py#L66-L74 |
catalyst/stacktask-tempest | stacktask_tempest_plugin/stacktask_client.py | StacktaskClient.approve_task | def approve_task(self, task_id):
""" Returns dict of tasks matching the provided filters """
uri = 'tasks/%s' % task_id
data = {"approved": True}
resp, body = self.post(uri, json.dumps(data))
self.expected_success(200, resp.status)
body = json.loads(body)
return... | python | def approve_task(self, task_id):
""" Returns dict of tasks matching the provided filters """
uri = 'tasks/%s' % task_id
data = {"approved": True}
resp, body = self.post(uri, json.dumps(data))
self.expected_success(200, resp.status)
body = json.loads(body)
return... | [
"def",
"approve_task",
"(",
"self",
",",
"task_id",
")",
":",
"uri",
"=",
"'tasks/%s'",
"%",
"task_id",
"data",
"=",
"{",
"\"approved\"",
":",
"True",
"}",
"resp",
",",
"body",
"=",
"self",
".",
"post",
"(",
"uri",
",",
"json",
".",
"dumps",
"(",
"... | Returns dict of tasks matching the provided filters | [
"Returns",
"dict",
"of",
"tasks",
"matching",
"the",
"provided",
"filters"
] | train | https://github.com/catalyst/stacktask-tempest/blob/0171161338a0a02de1fe62b6baaebf3c58f44db6/stacktask_tempest_plugin/stacktask_client.py#L89-L98 |
catalyst/stacktask-tempest | stacktask_tempest_plugin/stacktask_client.py | StacktaskClient.signup | def signup(self, project_name, email):
""" Signup for a new project. """
uri = 'openstack/sign-up'
data = {
"project_name": project_name,
"email": email,
}
post_body = json.dumps(data)
resp, body = self.post(uri, body=post_body)
self.expec... | python | def signup(self, project_name, email):
""" Signup for a new project. """
uri = 'openstack/sign-up'
data = {
"project_name": project_name,
"email": email,
}
post_body = json.dumps(data)
resp, body = self.post(uri, body=post_body)
self.expec... | [
"def",
"signup",
"(",
"self",
",",
"project_name",
",",
"email",
")",
":",
"uri",
"=",
"'openstack/sign-up'",
"data",
"=",
"{",
"\"project_name\"",
":",
"project_name",
",",
"\"email\"",
":",
"email",
",",
"}",
"post_body",
"=",
"json",
".",
"dumps",
"(",
... | Signup for a new project. | [
"Signup",
"for",
"a",
"new",
"project",
"."
] | train | https://github.com/catalyst/stacktask-tempest/blob/0171161338a0a02de1fe62b6baaebf3c58f44db6/stacktask_tempest_plugin/stacktask_client.py#L100-L112 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch.get_event | def get_event(self, name, default=_sentinel):
"""
Lookup an event by name.
:param str item: Event name
:return Event: Event instance under key
"""
if name not in self.events:
if self.create_events_on_access:
self.add_event(name)
el... | python | def get_event(self, name, default=_sentinel):
"""
Lookup an event by name.
:param str item: Event name
:return Event: Event instance under key
"""
if name not in self.events:
if self.create_events_on_access:
self.add_event(name)
el... | [
"def",
"get_event",
"(",
"self",
",",
"name",
",",
"default",
"=",
"_sentinel",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"events",
":",
"if",
"self",
".",
"create_events_on_access",
":",
"self",
".",
"add_event",
"(",
"name",
")",
"elif",
"def... | Lookup an event by name.
:param str item: Event name
:return Event: Event instance under key | [
"Lookup",
"an",
"event",
"by",
"name",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L116-L128 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch._add_internal_event | def _add_internal_event(self, name, send_event=False, internal_event_factory=None):
"""
This is only here to ensure my constant hatred for Python 2's horrid variable argument support.
"""
if not internal_event_factory:
internal_event_factory = self.internal_event_factory
... | python | def _add_internal_event(self, name, send_event=False, internal_event_factory=None):
"""
This is only here to ensure my constant hatred for Python 2's horrid variable argument support.
"""
if not internal_event_factory:
internal_event_factory = self.internal_event_factory
... | [
"def",
"_add_internal_event",
"(",
"self",
",",
"name",
",",
"send_event",
"=",
"False",
",",
"internal_event_factory",
"=",
"None",
")",
":",
"if",
"not",
"internal_event_factory",
":",
"internal_event_factory",
"=",
"self",
".",
"internal_event_factory",
"return",... | This is only here to ensure my constant hatred for Python 2's horrid variable argument support. | [
"This",
"is",
"only",
"here",
"to",
"ensure",
"my",
"constant",
"hatred",
"for",
"Python",
"2",
"s",
"horrid",
"variable",
"argument",
"support",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L154-L160 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch.add_events | def add_events(self, names, send_event=True, event_factory=None):
"""
Add event by name.
This is called for you as needed if you allow auto creation of events (see __init__).
Upon an event being added, all handlers are searched for if they have this event,
and if they do, they ... | python | def add_events(self, names, send_event=True, event_factory=None):
"""
Add event by name.
This is called for you as needed if you allow auto creation of events (see __init__).
Upon an event being added, all handlers are searched for if they have this event,
and if they do, they ... | [
"def",
"add_events",
"(",
"self",
",",
"names",
",",
"send_event",
"=",
"True",
",",
"event_factory",
"=",
"None",
")",
":",
"if",
"not",
"event_factory",
":",
"event_factory",
"=",
"self",
".",
"event_factory",
"# Create events",
"self",
".",
"events",
".",... | Add event by name.
This is called for you as needed if you allow auto creation of events (see __init__).
Upon an event being added, all handlers are searched for if they have this event,
and if they do, they are added to the Event's list of callables.
:param tuple names: Names | [
"Add",
"event",
"by",
"name",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L167-L187 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch.add_event | def add_event(self, name, send_event=True, event_factory=None):
"""
Add event by name.
This is called for you as needed if you allow auto creation of events (see __init__).
Upon an event being added, all handlers are searched for if they have this event,
and if they do, they ar... | python | def add_event(self, name, send_event=True, event_factory=None):
"""
Add event by name.
This is called for you as needed if you allow auto creation of events (see __init__).
Upon an event being added, all handlers are searched for if they have this event,
and if they do, they ar... | [
"def",
"add_event",
"(",
"self",
",",
"name",
",",
"send_event",
"=",
"True",
",",
"event_factory",
"=",
"None",
")",
":",
"return",
"self",
".",
"add_events",
"(",
"(",
"name",
",",
")",
",",
"send_event",
"=",
"send_event",
",",
"event_factory",
"=",
... | Add event by name.
This is called for you as needed if you allow auto creation of events (see __init__).
Upon an event being added, all handlers are searched for if they have this event,
and if they do, they are added to the Event's list of callables.
This is only here to ensure my co... | [
"Add",
"event",
"by",
"name",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L189-L202 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch._attach_handler_events | def _attach_handler_events(self, handler, events=None):
"""
Search handler for methods named after events, attaching to event handlers as applicable.
:param object handler: Handler instance
:param list events: List of event names to look for. If not specified, will do all known event na... | python | def _attach_handler_events(self, handler, events=None):
"""
Search handler for methods named after events, attaching to event handlers as applicable.
:param object handler: Handler instance
:param list events: List of event names to look for. If not specified, will do all known event na... | [
"def",
"_attach_handler_events",
"(",
"self",
",",
"handler",
",",
"events",
"=",
"None",
")",
":",
"if",
"not",
"events",
":",
"events",
"=",
"self",
"for",
"name",
"in",
"events",
":",
"meth",
"=",
"getattr",
"(",
"handler",
",",
"name",
",",
"None",... | Search handler for methods named after events, attaching to event handlers as applicable.
:param object handler: Handler instance
:param list events: List of event names to look for. If not specified, will do all known event names. | [
"Search",
"handler",
"for",
"methods",
"named",
"after",
"events",
"attaching",
"to",
"event",
"handlers",
"as",
"applicable",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L204-L216 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch._add | def _add(self, handler, allow_dupe=False, send_event=True):
"""
Add handler instance and attach any events to it.
:param object handler: handler instance
:param bool allow_dupe: If True, allow registering a handler more than once.
:return object: The handler you added is given b... | python | def _add(self, handler, allow_dupe=False, send_event=True):
"""
Add handler instance and attach any events to it.
:param object handler: handler instance
:param bool allow_dupe: If True, allow registering a handler more than once.
:return object: The handler you added is given b... | [
"def",
"_add",
"(",
"self",
",",
"handler",
",",
"allow_dupe",
"=",
"False",
",",
"send_event",
"=",
"True",
")",
":",
"if",
"not",
"allow_dupe",
"and",
"handler",
"in",
"self",
".",
"handlers",
":",
"raise",
"ValueError",
"(",
"\"Handler already present: %s... | Add handler instance and attach any events to it.
:param object handler: handler instance
:param bool allow_dupe: If True, allow registering a handler more than once.
:return object: The handler you added is given back so this can be used as a decorator. | [
"Add",
"handler",
"instance",
"and",
"attach",
"any",
"events",
"to",
"it",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L218-L231 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch.add | def add(self, handler, allow_dupe=False, send_event=True):
"""
Add handler instance and attach any events to it.
:param object handler: handler instance
:param bool allow_dupe: If True, allow registering a handler more than once.
:return object: The handler you added is given ba... | python | def add(self, handler, allow_dupe=False, send_event=True):
"""
Add handler instance and attach any events to it.
:param object handler: handler instance
:param bool allow_dupe: If True, allow registering a handler more than once.
:return object: The handler you added is given ba... | [
"def",
"add",
"(",
"self",
",",
"handler",
",",
"allow_dupe",
"=",
"False",
",",
"send_event",
"=",
"True",
")",
":",
"self",
".",
"_add",
"(",
"handler",
",",
"allow_dupe",
"=",
"allow_dupe",
",",
"send_event",
"=",
"send_event",
")",
"return",
"handler... | Add handler instance and attach any events to it.
:param object handler: handler instance
:param bool allow_dupe: If True, allow registering a handler more than once.
:return object: The handler you added is given back so this can be used as a decorator. | [
"Add",
"handler",
"instance",
"and",
"attach",
"any",
"events",
"to",
"it",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L233-L242 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch._remove | def _remove(self, handler, send_event=True):
"""
Remove handler instance and detach any methods bound to it from uninhibited.
:param object handler: handler instance
:return object: The handler you added is given back so this can be used as a decorator.
"""
for event in ... | python | def _remove(self, handler, send_event=True):
"""
Remove handler instance and detach any methods bound to it from uninhibited.
:param object handler: handler instance
:return object: The handler you added is given back so this can be used as a decorator.
"""
for event in ... | [
"def",
"_remove",
"(",
"self",
",",
"handler",
",",
"send_event",
"=",
"True",
")",
":",
"for",
"event",
"in",
"self",
":",
"event",
".",
"remove_handlers_bound_to_instance",
"(",
"handler",
")",
"self",
".",
"handlers",
".",
"remove",
"(",
"handler",
")",... | Remove handler instance and detach any methods bound to it from uninhibited.
:param object handler: handler instance
:return object: The handler you added is given back so this can be used as a decorator. | [
"Remove",
"handler",
"instance",
"and",
"detach",
"any",
"methods",
"bound",
"to",
"it",
"from",
"uninhibited",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L254-L265 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch.fire | def fire(self, event, *args, **kwargs):
"""
Fire event. call event's handlers using given arguments, return a list of results.
:param str name: Event name
:param tuple args: positional arguments to call each handler with
:param dict kwargs: keyword arguments to call each handler... | python | def fire(self, event, *args, **kwargs):
"""
Fire event. call event's handlers using given arguments, return a list of results.
:param str name: Event name
:param tuple args: positional arguments to call each handler with
:param dict kwargs: keyword arguments to call each handler... | [
"def",
"fire",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_maybe_create_on_fire",
"(",
"event",
")",
":",
"return",
"return",
"self",
"[",
"event",
"]",
".",
"fire",
"(",
"*",
"args",
... | Fire event. call event's handlers using given arguments, return a list of results.
:param str name: Event name
:param tuple args: positional arguments to call each handler with
:param dict kwargs: keyword arguments to call each handler with
:return list: a list of tuples of handler, ret... | [
"Fire",
"event",
".",
"call",
"event",
"s",
"handlers",
"using",
"given",
"arguments",
"return",
"a",
"list",
"of",
"results",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L296-L307 |
akatrevorjay/uninhibited | uninhibited/dispatch.py | Dispatch.ifire | def ifire(self, event, *args, **kwargs):
"""
Iteratively fire event, returning generator. Calls each handler using given arguments, upon iteration,
yielding each result.
:param str name: Event name
:param tuple args: positional arguments to call each handler with
:param ... | python | def ifire(self, event, *args, **kwargs):
"""
Iteratively fire event, returning generator. Calls each handler using given arguments, upon iteration,
yielding each result.
:param str name: Event name
:param tuple args: positional arguments to call each handler with
:param ... | [
"def",
"ifire",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_maybe_create_on_fire",
"(",
"event",
")",
":",
"return",
"# Wrap the generator per item to force that this method be a generator",
"# Python... | Iteratively fire event, returning generator. Calls each handler using given arguments, upon iteration,
yielding each result.
:param str name: Event name
:param tuple args: positional arguments to call each handler with
:param dict kwargs: keyword arguments to call each handler with
... | [
"Iteratively",
"fire",
"event",
"returning",
"generator",
".",
"Calls",
"each",
"handler",
"using",
"given",
"arguments",
"upon",
"iteration",
"yielding",
"each",
"result",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/dispatch.py#L311-L328 |
dansackett/django-toolset | django_toolset/templatetags/custom_tags.py | active | def active(context, pattern_or_urlname, class_name='active', *args, **kwargs):
"""Based on a URL Pattern or name, determine if it is the current page.
This is useful if you're creating a navigation component and want to give
the active URL a specific class for UI purposes. It will accept a named
URL or... | python | def active(context, pattern_or_urlname, class_name='active', *args, **kwargs):
"""Based on a URL Pattern or name, determine if it is the current page.
This is useful if you're creating a navigation component and want to give
the active URL a specific class for UI purposes. It will accept a named
URL or... | [
"def",
"active",
"(",
"context",
",",
"pattern_or_urlname",
",",
"class_name",
"=",
"'active'",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
"=",
"context",
".",
"dicts",
"[",
"1",
"]",
".",
"get",
"(",
"'request'",
")",
"try",
":"... | Based on a URL Pattern or name, determine if it is the current page.
This is useful if you're creating a navigation component and want to give
the active URL a specific class for UI purposes. It will accept a named
URL or a regex pattern. If you have a URL which accepts args or kwargs then
you may pass... | [
"Based",
"on",
"a",
"URL",
"Pattern",
"or",
"name",
"determine",
"if",
"it",
"is",
"the",
"current",
"page",
"."
] | train | https://github.com/dansackett/django-toolset/blob/a28cc19e32cf41130e848c268d26c1858a7cf26a/django_toolset/templatetags/custom_tags.py#L10-L57 |
hapylestat/apputils | apputils/console/progress_bar.py | _ProgressBarTiming.init_timer | def init_timer(self, max_value):
"""
:type max_value int
"""
self.__max_value = max_value
self.__prev_tick = time.time()
self.__unit_per_sec = 0
self.__unit_per_sec_prev = 0 | python | def init_timer(self, max_value):
"""
:type max_value int
"""
self.__max_value = max_value
self.__prev_tick = time.time()
self.__unit_per_sec = 0
self.__unit_per_sec_prev = 0 | [
"def",
"init_timer",
"(",
"self",
",",
"max_value",
")",
":",
"self",
".",
"__max_value",
"=",
"max_value",
"self",
".",
"__prev_tick",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"__unit_per_sec",
"=",
"0",
"self",
".",
"__unit_per_sec_prev",
"=",
... | :type max_value int | [
":",
"type",
"max_value",
"int"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/console/progress_bar.py#L87-L94 |
hapylestat/apputils | apputils/console/progress_bar.py | _ProgressBarTiming.tick | def tick(self, unit_value):
"""
:type unit_value int
"""
total_secs = round(time.time() - self.__prev_tick)
if total_secs >= 1:
self.__unit_per_sec = unit_value / total_secs - self.__unit_per_sec_prev
self.__unit_per_sec_prev = unit_value
self.__prev_tick = time.time() | python | def tick(self, unit_value):
"""
:type unit_value int
"""
total_secs = round(time.time() - self.__prev_tick)
if total_secs >= 1:
self.__unit_per_sec = unit_value / total_secs - self.__unit_per_sec_prev
self.__unit_per_sec_prev = unit_value
self.__prev_tick = time.time() | [
"def",
"tick",
"(",
"self",
",",
"unit_value",
")",
":",
"total_secs",
"=",
"round",
"(",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"__prev_tick",
")",
"if",
"total_secs",
">=",
"1",
":",
"self",
".",
"__unit_per_sec",
"=",
"unit_value",
"/",
... | :type unit_value int | [
":",
"type",
"unit_value",
"int"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/console/progress_bar.py#L96-L104 |
hapylestat/apputils | apputils/console/progress_bar.py | ProgressBar.start | def start(self, max_val):
"""
:arg max_val Maximum value
:type max_val int
"""
self._timer.init_timer(max_value=max_val)
self._infinite_mode = max_val <= 0
self._infinite_position = 0
self._max = max_val
self._fill_empty()
self._value = 0
self.progress(0)
self._status =... | python | def start(self, max_val):
"""
:arg max_val Maximum value
:type max_val int
"""
self._timer.init_timer(max_value=max_val)
self._infinite_mode = max_val <= 0
self._infinite_position = 0
self._max = max_val
self._fill_empty()
self._value = 0
self.progress(0)
self._status =... | [
"def",
"start",
"(",
"self",
",",
"max_val",
")",
":",
"self",
".",
"_timer",
".",
"init_timer",
"(",
"max_value",
"=",
"max_val",
")",
"self",
".",
"_infinite_mode",
"=",
"max_val",
"<=",
"0",
"self",
".",
"_infinite_position",
"=",
"0",
"self",
".",
... | :arg max_val Maximum value
:type max_val int | [
":",
"arg",
"max_val",
"Maximum",
"value",
":",
"type",
"max_val",
"int"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/console/progress_bar.py#L182-L196 |
hapylestat/apputils | apputils/console/progress_bar.py | ProgressBar.progress | def progress(self, value, new_status=None):
"""
:type value int
:type new_status str
"""
space_fillers = 0
if new_status is not None:
# if new text is shorter, then we need fill previously used place
space_fillers = len(self._status_msg) - len(new_status) if self._status_msg and len... | python | def progress(self, value, new_status=None):
"""
:type value int
:type new_status str
"""
space_fillers = 0
if new_status is not None:
# if new text is shorter, then we need fill previously used place
space_fillers = len(self._status_msg) - len(new_status) if self._status_msg and len... | [
"def",
"progress",
"(",
"self",
",",
"value",
",",
"new_status",
"=",
"None",
")",
":",
"space_fillers",
"=",
"0",
"if",
"new_status",
"is",
"not",
"None",
":",
"# if new text is shorter, then we need fill previously used place",
"space_fillers",
"=",
"len",
"(",
... | :type value int
:type new_status str | [
":",
"type",
"value",
"int",
":",
"type",
"new_status",
"str"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/console/progress_bar.py#L221-L264 |
hapylestat/apputils | apputils/console/progress_bar.py | ProgressBar.progress_inc | def progress_inc(self, step=1, new_status=None):
"""
:type step int
:type new_status str
"""
self._value += step
self.progress(self._value, new_status=new_status) | python | def progress_inc(self, step=1, new_status=None):
"""
:type step int
:type new_status str
"""
self._value += step
self.progress(self._value, new_status=new_status) | [
"def",
"progress_inc",
"(",
"self",
",",
"step",
"=",
"1",
",",
"new_status",
"=",
"None",
")",
":",
"self",
".",
"_value",
"+=",
"step",
"self",
".",
"progress",
"(",
"self",
".",
"_value",
",",
"new_status",
"=",
"new_status",
")"
] | :type step int
:type new_status str | [
":",
"type",
"step",
"int",
":",
"type",
"new_status",
"str"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/console/progress_bar.py#L266-L272 |
hapylestat/apputils | apputils/console/progress_bar.py | ProgressBar.stop | def stop(self, hide_progress=False, new_status=None):
"""
:arg hide_progress Hide progress bar
:type hide_progress bool
:type new_status str
"""
self._status = ProgressBarStatus.stopped
if hide_progress:
sep = " - "
if new_status is None:
new_status = sep = ""
kwa... | python | def stop(self, hide_progress=False, new_status=None):
"""
:arg hide_progress Hide progress bar
:type hide_progress bool
:type new_status str
"""
self._status = ProgressBarStatus.stopped
if hide_progress:
sep = " - "
if new_status is None:
new_status = sep = ""
kwa... | [
"def",
"stop",
"(",
"self",
",",
"hide_progress",
"=",
"False",
",",
"new_status",
"=",
"None",
")",
":",
"self",
".",
"_status",
"=",
"ProgressBarStatus",
".",
"stopped",
"if",
"hide_progress",
":",
"sep",
"=",
"\" - \"",
"if",
"new_status",
"is",
"None",... | :arg hide_progress Hide progress bar
:type hide_progress bool
:type new_status str | [
":",
"arg",
"hide_progress",
"Hide",
"progress",
"bar",
":",
"type",
"hide_progress",
"bool",
":",
"type",
"new_status",
"str"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/console/progress_bar.py#L280-L304 |
ravenac95/subwrap | subwrap.py | run | def run(sub_command, exit_handle=None, **options):
"""Run a command"""
command = Command(sub_command, exit_handle)
return command.run(**options) | python | def run(sub_command, exit_handle=None, **options):
"""Run a command"""
command = Command(sub_command, exit_handle)
return command.run(**options) | [
"def",
"run",
"(",
"sub_command",
",",
"exit_handle",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"command",
"=",
"Command",
"(",
"sub_command",
",",
"exit_handle",
")",
"return",
"command",
".",
"run",
"(",
"*",
"*",
"options",
")"
] | Run a command | [
"Run",
"a",
"command"
] | train | https://github.com/ravenac95/subwrap/blob/ba0d4898e537881a217ade6ce2a1cee45407aa62/subwrap.py#L49-L52 |
pjuren/pyokit | src/pyokit/io/genomeAlignment.py | __trim_extensions_dot | def __trim_extensions_dot(exts):
"""trim leading dots from extensions and drop any empty strings."""
if exts is None:
return None
res = []
for i in range(0, len(exts)):
if exts[i] == "":
continue
res.append(__trim_extension_dot(exts[i]))
return res | python | def __trim_extensions_dot(exts):
"""trim leading dots from extensions and drop any empty strings."""
if exts is None:
return None
res = []
for i in range(0, len(exts)):
if exts[i] == "":
continue
res.append(__trim_extension_dot(exts[i]))
return res | [
"def",
"__trim_extensions_dot",
"(",
"exts",
")",
":",
"if",
"exts",
"is",
"None",
":",
"return",
"None",
"res",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"exts",
")",
")",
":",
"if",
"exts",
"[",
"i",
"]",
"==",
"\"\... | trim leading dots from extensions and drop any empty strings. | [
"trim",
"leading",
"dots",
"from",
"extensions",
"and",
"drop",
"any",
"empty",
"strings",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/genomeAlignment.py#L63-L72 |
pjuren/pyokit | src/pyokit/io/genomeAlignment.py | __split_genomic_interval_filename | def __split_genomic_interval_filename(fn):
"""
Split a filename of the format chrom:start-end.ext or chrom.ext (full chrom).
:return: tuple of (chrom, start, end) -- 'start' and 'end' are None if not
present in the filename.
"""
if fn is None or fn == "":
raise ValueError("invalid filename: " ... | python | def __split_genomic_interval_filename(fn):
"""
Split a filename of the format chrom:start-end.ext or chrom.ext (full chrom).
:return: tuple of (chrom, start, end) -- 'start' and 'end' are None if not
present in the filename.
"""
if fn is None or fn == "":
raise ValueError("invalid filename: " ... | [
"def",
"__split_genomic_interval_filename",
"(",
"fn",
")",
":",
"if",
"fn",
"is",
"None",
"or",
"fn",
"==",
"\"\"",
":",
"raise",
"ValueError",
"(",
"\"invalid filename: \"",
"+",
"str",
"(",
"fn",
")",
")",
"fn",
"=",
"\".\"",
".",
"join",
"(",
"fn",
... | Split a filename of the format chrom:start-end.ext or chrom.ext (full chrom).
:return: tuple of (chrom, start, end) -- 'start' and 'end' are None if not
present in the filename. | [
"Split",
"a",
"filename",
"of",
"the",
"format",
"chrom",
":",
"start",
"-",
"end",
".",
"ext",
"or",
"chrom",
".",
"ext",
"(",
"full",
"chrom",
")",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/genomeAlignment.py#L75-L92 |
pjuren/pyokit | src/pyokit/io/genomeAlignment.py | load_just_in_time_genome_alignment | def load_just_in_time_genome_alignment(path, ref_spec, extensions=None,
index_exts=None, fail_no_index=True,
verbose=False):
"""Load a just-in-time genome alignment from a directory."""
if index_exts is None and fail_no_index:
r... | python | def load_just_in_time_genome_alignment(path, ref_spec, extensions=None,
index_exts=None, fail_no_index=True,
verbose=False):
"""Load a just-in-time genome alignment from a directory."""
if index_exts is None and fail_no_index:
r... | [
"def",
"load_just_in_time_genome_alignment",
"(",
"path",
",",
"ref_spec",
",",
"extensions",
"=",
"None",
",",
"index_exts",
"=",
"None",
",",
"fail_no_index",
"=",
"True",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"index_exts",
"is",
"None",
"and",
"fa... | Load a just-in-time genome alignment from a directory. | [
"Load",
"a",
"just",
"-",
"in",
"-",
"time",
"genome",
"alignment",
"from",
"a",
"directory",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/genomeAlignment.py#L99-L141 |
pjuren/pyokit | src/pyokit/io/genomeAlignment.py | __find_index | def __find_index(alig_file_pth, idx_extensions):
"""
Find an index file for a genome alignment file in the same directory.
:param alig_file_path: path to the alignment file.
:param idx_extensions: check for index files with these extensions
:return: path to first index file that matches the name of the align... | python | def __find_index(alig_file_pth, idx_extensions):
"""
Find an index file for a genome alignment file in the same directory.
:param alig_file_path: path to the alignment file.
:param idx_extensions: check for index files with these extensions
:return: path to first index file that matches the name of the align... | [
"def",
"__find_index",
"(",
"alig_file_pth",
",",
"idx_extensions",
")",
":",
"if",
"idx_extensions",
"is",
"None",
":",
"return",
"None",
"base",
",",
"_",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"alig_file_pth",
")",
"for",
"idx_ext",
"in",
"idx_ex... | Find an index file for a genome alignment file in the same directory.
:param alig_file_path: path to the alignment file.
:param idx_extensions: check for index files with these extensions
:return: path to first index file that matches the name of the alignment file
and has one of the specified extensi... | [
"Find",
"an",
"index",
"file",
"for",
"a",
"genome",
"alignment",
"file",
"in",
"the",
"same",
"directory",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/genomeAlignment.py#L148-L164 |
pjuren/pyokit | src/pyokit/io/genomeAlignment.py | build_genome_alignment_from_directory | def build_genome_alignment_from_directory(d_name, ref_spec, extensions=None,
index_exts=None,
fail_no_index=False):
"""
build a genome aligment by loading all files in a directory.
Fiel without indexes are loaded immediately; tho... | python | def build_genome_alignment_from_directory(d_name, ref_spec, extensions=None,
index_exts=None,
fail_no_index=False):
"""
build a genome aligment by loading all files in a directory.
Fiel without indexes are loaded immediately; tho... | [
"def",
"build_genome_alignment_from_directory",
"(",
"d_name",
",",
"ref_spec",
",",
"extensions",
"=",
"None",
",",
"index_exts",
"=",
"None",
",",
"fail_no_index",
"=",
"False",
")",
":",
"if",
"index_exts",
"is",
"None",
"and",
"fail_no_index",
":",
"raise",
... | build a genome aligment by loading all files in a directory.
Fiel without indexes are loaded immediately; those with indexes are
loaded on-demand. Not recursive (i.e. subdirectories are not parsed).
:param d_name: directory to load from.
:param ref_spec: which species in the alignemnt files is the... | [
"build",
"a",
"genome",
"aligment",
"by",
"loading",
"all",
"files",
"in",
"a",
"directory",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/genomeAlignment.py#L167-L201 |
pjuren/pyokit | src/pyokit/io/genomeAlignment.py | build_genome_alignment_from_file | def build_genome_alignment_from_file(ga_path, ref_spec, idx_path=None,
verbose=False):
"""
build a genome alignment by loading from a single MAF file.
:param ga_path: the path to the file to load.
:param ref_spec: which species in the MAF file is the reference?
:param id... | python | def build_genome_alignment_from_file(ga_path, ref_spec, idx_path=None,
verbose=False):
"""
build a genome alignment by loading from a single MAF file.
:param ga_path: the path to the file to load.
:param ref_spec: which species in the MAF file is the reference?
:param id... | [
"def",
"build_genome_alignment_from_file",
"(",
"ga_path",
",",
"ref_spec",
",",
"idx_path",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"blocks",
"=",
"[",
"]",
"if",
"(",
"idx_path",
"is",
"not",
"None",
")",
":",
"bound_iter",
"=",
"functools",... | build a genome alignment by loading from a single MAF file.
:param ga_path: the path to the file to load.
:param ref_spec: which species in the MAF file is the reference?
:param idx_path: if provided, use this index to generate a just-in-time
genome alignment, instead of loading the file imme... | [
"build",
"a",
"genome",
"alignment",
"by",
"loading",
"from",
"a",
"single",
"MAF",
"file",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/genomeAlignment.py#L204-L235 |
pjuren/pyokit | src/pyokit/io/genomeAlignment.py | genome_alignment_iterator | def genome_alignment_iterator(fn, reference_species, index_friendly=False,
verbose=False):
"""
build an iterator for an MAF file of genome alignment blocks.
:param fn: filename or stream-like object to iterate over.
:param reference_species: which species in the a... | python | def genome_alignment_iterator(fn, reference_species, index_friendly=False,
verbose=False):
"""
build an iterator for an MAF file of genome alignment blocks.
:param fn: filename or stream-like object to iterate over.
:param reference_species: which species in the a... | [
"def",
"genome_alignment_iterator",
"(",
"fn",
",",
"reference_species",
",",
"index_friendly",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"kw_args",
"=",
"{",
"\"reference_species\"",
":",
"reference_species",
"}",
"for",
"e",
"in",
"maf",
".",
"ma... | build an iterator for an MAF file of genome alignment blocks.
:param fn: filename or stream-like object to iterate over.
:param reference_species: which species in the alignment should be treated
as the reference?
:param index_friendly: if True, buffering is disa... | [
"build",
"an",
"iterator",
"for",
"an",
"MAF",
"file",
"of",
"genome",
"alignment",
"blocks",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/genomeAlignment.py#L242-L260 |
pjuren/pyokit | src/pyokit/io/genomeAlignment.py | _build_index | def _build_index(maf_strm, ref_spec):
"""Build an index for a MAF genome alig file and return StringIO of it."""
idx_strm = StringIO.StringIO()
bound_iter = functools.partial(genome_alignment_iterator,
reference_species=ref_spec)
hash_func = JustInTimeGenomeAlignmentBlock.build_... | python | def _build_index(maf_strm, ref_spec):
"""Build an index for a MAF genome alig file and return StringIO of it."""
idx_strm = StringIO.StringIO()
bound_iter = functools.partial(genome_alignment_iterator,
reference_species=ref_spec)
hash_func = JustInTimeGenomeAlignmentBlock.build_... | [
"def",
"_build_index",
"(",
"maf_strm",
",",
"ref_spec",
")",
":",
"idx_strm",
"=",
"StringIO",
".",
"StringIO",
"(",
")",
"bound_iter",
"=",
"functools",
".",
"partial",
"(",
"genome_alignment_iterator",
",",
"reference_species",
"=",
"ref_spec",
")",
"hash_fun... | Build an index for a MAF genome alig file and return StringIO of it. | [
"Build",
"an",
"index",
"for",
"a",
"MAF",
"genome",
"alig",
"file",
"and",
"return",
"StringIO",
"of",
"it",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/genomeAlignment.py#L297-L306 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | ScanResult.update | def update(self, name, rssi):
"""Update the device name and/or RSSI.
During an ongoing scan, multiple records from the same device can be
received during the scan. Each time that happens this method is
called to update the :attr:`name` and/or :attr:`rssi` attributes.
"""
... | python | def update(self, name, rssi):
"""Update the device name and/or RSSI.
During an ongoing scan, multiple records from the same device can be
received during the scan. Each time that happens this method is
called to update the :attr:`name` and/or :attr:`rssi` attributes.
"""
... | [
"def",
"update",
"(",
"self",
",",
"name",
",",
"rssi",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"rssi",
"=",
"rssi",
"self",
".",
"_age",
"=",
"time",
".",
"time",
"(",
")"
] | Update the device name and/or RSSI.
During an ongoing scan, multiple records from the same device can be
received during the scan. Each time that happens this method is
called to update the :attr:`name` and/or :attr:`rssi` attributes. | [
"Update",
"the",
"device",
"name",
"and",
"/",
"or",
"RSSI",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L64-L73 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | ScanResults.update | def update(self, addr, raw_addr, name=None, rssi=None):
"""Updates the collection of results with a newly received scan response.
Args:
addr (str): Device hardware address in xx:xx:xx:xx:xx:xx format.
raw_addr (bytearray): Device hardware address as raw bytes.
name (... | python | def update(self, addr, raw_addr, name=None, rssi=None):
"""Updates the collection of results with a newly received scan response.
Args:
addr (str): Device hardware address in xx:xx:xx:xx:xx:xx format.
raw_addr (bytearray): Device hardware address as raw bytes.
name (... | [
"def",
"update",
"(",
"self",
",",
"addr",
",",
"raw_addr",
",",
"name",
"=",
"None",
",",
"rssi",
"=",
"None",
")",
":",
"if",
"addr",
"in",
"self",
".",
"_devices",
":",
"# logger.debug('UPDATE scan result: {} / {}'.format(addr, name))",
"self",
".",
"_devic... | Updates the collection of results with a newly received scan response.
Args:
addr (str): Device hardware address in xx:xx:xx:xx:xx:xx format.
raw_addr (bytearray): Device hardware address as raw bytes.
name (str): Device name (if available) as ASCII text. May be None.
... | [
"Updates",
"the",
"collection",
"of",
"results",
"with",
"a",
"newly",
"received",
"scan",
"response",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L107-L126 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | ScanResults.get_device | def get_device(self, addr_or_name):
"""Retrieve a device with a given address or name from the results.
Args:
addr_or_name (str): a string containing either a BLE address in xx:xx:xx:xx:xx:xx
format, or a plain device name. The supplied value is checked as an address... | python | def get_device(self, addr_or_name):
"""Retrieve a device with a given address or name from the results.
Args:
addr_or_name (str): a string containing either a BLE address in xx:xx:xx:xx:xx:xx
format, or a plain device name. The supplied value is checked as an address... | [
"def",
"get_device",
"(",
"self",
",",
"addr_or_name",
")",
":",
"if",
"addr_or_name",
"in",
"self",
".",
"_devices",
":",
"return",
"self",
".",
"_devices",
"[",
"addr_or_name",
"]",
"for",
"v",
"in",
"self",
".",
"_devices",
".",
"values",
"(",
")",
... | Retrieve a device with a given address or name from the results.
Args:
addr_or_name (str): a string containing either a BLE address in xx:xx:xx:xx:xx:xx
format, or a plain device name. The supplied value is checked as an address
first and if that fails to pro... | [
"Retrieve",
"a",
"device",
"with",
"a",
"given",
"address",
"or",
"name",
"from",
"the",
"results",
".",
"Args",
":",
"addr_or_name",
"(",
"str",
")",
":",
"a",
"string",
"containing",
"either",
"a",
"BLE",
"address",
"in",
"xx",
":",
"xx",
":",
"xx",
... | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L137-L156 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.set_calibration | def set_calibration(self, enabled, imus):
"""Set calibration state for attached IMUs.
Args:
enabled (bool): True to apply calibration to IMU data (if available).
False to output uncalibrated data.
imus (list): indicates which IMUs the calibration state should be set... | python | def set_calibration(self, enabled, imus):
"""Set calibration state for attached IMUs.
Args:
enabled (bool): True to apply calibration to IMU data (if available).
False to output uncalibrated data.
imus (list): indicates which IMUs the calibration state should be set... | [
"def",
"set_calibration",
"(",
"self",
",",
"enabled",
",",
"imus",
")",
":",
"if",
"len",
"(",
"imus",
")",
"==",
"0",
":",
"imus",
"=",
"list",
"(",
"range",
"(",
"MAX_IMUS",
")",
")",
"for",
"i",
"in",
"imus",
":",
"if",
"i",
"<",
"0",
"or",... | Set calibration state for attached IMUs.
Args:
enabled (bool): True to apply calibration to IMU data (if available).
False to output uncalibrated data.
imus (list): indicates which IMUs the calibration state should be set on.
Empty list or [0, 1, 2, 3, 4] will ... | [
"Set",
"calibration",
"state",
"for",
"attached",
"IMUs",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L240-L257 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.load_calibration | def load_calibration(self, calibration_file=None):
"""Load calibration data for IMU(s) connected to this SK8.
This method attempts to load a set of calibration data from a .ini file
produced by the sk8_calibration_gui application (TODO link!).
By default, it will look for a file name ... | python | def load_calibration(self, calibration_file=None):
"""Load calibration data for IMU(s) connected to this SK8.
This method attempts to load a set of calibration data from a .ini file
produced by the sk8_calibration_gui application (TODO link!).
By default, it will look for a file name ... | [
"def",
"load_calibration",
"(",
"self",
",",
"calibration_file",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'Loading calibration for {}'",
".",
"format",
"(",
"self",
".",
"addr",
")",
")",
"calibration_data",
"=",
"ConfigParser",
"(",
")",
"path",
... | Load calibration data for IMU(s) connected to this SK8.
This method attempts to load a set of calibration data from a .ini file
produced by the sk8_calibration_gui application (TODO link!).
By default, it will look for a file name "sk8calib.ini" in the current working
directory. This ... | [
"Load",
"calibration",
"data",
"for",
"IMU",
"(",
"s",
")",
"connected",
"to",
"this",
"SK8",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L270-L298 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.disconnect | def disconnect(self):
"""Disconnect the dongle from this SK8.
Simply closes the active BLE connection to the device represented by the current instance.
Returns:
bool. True if connection was closed, False if not (e.g. if already closed).
"""
result = False
l... | python | def disconnect(self):
"""Disconnect the dongle from this SK8.
Simply closes the active BLE connection to the device represented by the current instance.
Returns:
bool. True if connection was closed, False if not (e.g. if already closed).
"""
result = False
l... | [
"def",
"disconnect",
"(",
"self",
")",
":",
"result",
"=",
"False",
"logger",
".",
"debug",
"(",
"'SK8.disconnect({})'",
".",
"format",
"(",
"self",
".",
"conn_handle",
")",
")",
"if",
"self",
".",
"conn_handle",
">=",
"0",
":",
"logger",
".",
"debug",
... | Disconnect the dongle from this SK8.
Simply closes the active BLE connection to the device represented by the current instance.
Returns:
bool. True if connection was closed, False if not (e.g. if already closed). | [
"Disconnect",
"the",
"dongle",
"from",
"this",
"SK8",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L300-L316 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.set_extana_callback | def set_extana_callback(self, callback, data=None):
"""Register a callback for incoming data packets from the SK8-ExtAna board.
This method allows you to pass in a callable which will be called on
receipt of each packet sent from the SK8-ExtAna board. Set to `None` to
disable it again.... | python | def set_extana_callback(self, callback, data=None):
"""Register a callback for incoming data packets from the SK8-ExtAna board.
This method allows you to pass in a callable which will be called on
receipt of each packet sent from the SK8-ExtAna board. Set to `None` to
disable it again.... | [
"def",
"set_extana_callback",
"(",
"self",
",",
"callback",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"extana_callback",
"=",
"callback",
"self",
".",
"extana_callback_data",
"=",
"data"
] | Register a callback for incoming data packets from the SK8-ExtAna board.
This method allows you to pass in a callable which will be called on
receipt of each packet sent from the SK8-ExtAna board. Set to `None` to
disable it again.
Args:
callback: a callable with the follo... | [
"Register",
"a",
"callback",
"for",
"incoming",
"data",
"packets",
"from",
"the",
"SK8",
"-",
"ExtAna",
"board",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L318-L338 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.enable_extana_streaming | def enable_extana_streaming(self, include_imu=False, enabled_sensors=SENSOR_ALL):
"""Configures and enables sensor data streaming from the SK8-ExtAna device.
By default this will cause the SK8 to only stream data from the analog
sensors on the SK8-ExtAna, but if `include_imu` is set to True, i... | python | def enable_extana_streaming(self, include_imu=False, enabled_sensors=SENSOR_ALL):
"""Configures and enables sensor data streaming from the SK8-ExtAna device.
By default this will cause the SK8 to only stream data from the analog
sensors on the SK8-ExtAna, but if `include_imu` is set to True, i... | [
"def",
"enable_extana_streaming",
"(",
"self",
",",
"include_imu",
"=",
"False",
",",
"enabled_sensors",
"=",
"SENSOR_ALL",
")",
":",
"if",
"not",
"self",
".",
"dongle",
".",
"_enable_extana_streaming",
"(",
"self",
",",
"include_imu",
",",
"enabled_sensors",
")... | Configures and enables sensor data streaming from the SK8-ExtAna device.
By default this will cause the SK8 to only stream data from the analog
sensors on the SK8-ExtAna, but if `include_imu` is set to True, it will
also send data from the internal IMU in the SK8.
NOTE: only one str... | [
"Configures",
"and",
"enables",
"sensor",
"data",
"streaming",
"from",
"the",
"SK8",
"-",
"ExtAna",
"device",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L340-L367 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.get_extana_led | def get_extana_led(self, cached=True):
"""Returns the current (R, G, B) colour of the SK8-ExtAna LED.
Args:
cached (bool): if True, returns the locally cached state of the LED (based
on the last call to :meth:`set_extana_led`). Otherwise query the device
for ... | python | def get_extana_led(self, cached=True):
"""Returns the current (R, G, B) colour of the SK8-ExtAna LED.
Args:
cached (bool): if True, returns the locally cached state of the LED (based
on the last call to :meth:`set_extana_led`). Otherwise query the device
for ... | [
"def",
"get_extana_led",
"(",
"self",
",",
"cached",
"=",
"True",
")",
":",
"if",
"cached",
"and",
"self",
".",
"led_state",
"is",
"not",
"None",
":",
"return",
"self",
".",
"led_state",
"extana_led",
"=",
"self",
".",
"get_characteristic_handle_from_uuid",
... | Returns the current (R, G, B) colour of the SK8-ExtAna LED.
Args:
cached (bool): if True, returns the locally cached state of the LED (based
on the last call to :meth:`set_extana_led`). Otherwise query the device
for the current state.
Returns:
a... | [
"Returns",
"the",
"current",
"(",
"R",
"G",
"B",
")",
"colour",
"of",
"the",
"SK8",
"-",
"ExtAna",
"LED",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L378-L401 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.set_extana_led | def set_extana_led(self, r, g, b, check_state=True):
"""Update the colour of the RGB LED on the SK8-ExtAna board.
Args:
r (int): red channel, 0-255
g (int): green channel, 0-255
b (int): blue channel, 0-255
check_state (bool): if True (default) and the lo... | python | def set_extana_led(self, r, g, b, check_state=True):
"""Update the colour of the RGB LED on the SK8-ExtAna board.
Args:
r (int): red channel, 0-255
g (int): green channel, 0-255
b (int): blue channel, 0-255
check_state (bool): if True (default) and the lo... | [
"def",
"set_extana_led",
"(",
"self",
",",
"r",
",",
"g",
",",
"b",
",",
"check_state",
"=",
"True",
")",
":",
"r",
",",
"g",
",",
"b",
"=",
"map",
"(",
"int",
",",
"[",
"r",
",",
"g",
",",
"b",
"]",
")",
"if",
"min",
"(",
"[",
"r",
",",
... | Update the colour of the RGB LED on the SK8-ExtAna board.
Args:
r (int): red channel, 0-255
g (int): green channel, 0-255
b (int): blue channel, 0-255
check_state (bool): if True (default) and the locally cached LED state matches
the given (r, g, ... | [
"Update",
"the",
"colour",
"of",
"the",
"RGB",
"LED",
"on",
"the",
"SK8",
"-",
"ExtAna",
"board",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L403-L442 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.set_imu_callback | def set_imu_callback(self, callback, data=None):
"""Register a callback for incoming IMU data packets.
This method allows you to pass in a callbable which will be called on
receipt of each IMU data packet sent by this SK8 device. Set to `None`
to disable it again.
Args:... | python | def set_imu_callback(self, callback, data=None):
"""Register a callback for incoming IMU data packets.
This method allows you to pass in a callbable which will be called on
receipt of each IMU data packet sent by this SK8 device. Set to `None`
to disable it again.
Args:... | [
"def",
"set_imu_callback",
"(",
"self",
",",
"callback",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"imu_callback",
"=",
"callback",
"self",
".",
"imu_callback_data",
"=",
"data"
] | Register a callback for incoming IMU data packets.
This method allows you to pass in a callbable which will be called on
receipt of each IMU data packet sent by this SK8 device. Set to `None`
to disable it again.
Args:
callback: a callable with the following signatu... | [
"Register",
"a",
"callback",
"for",
"incoming",
"IMU",
"data",
"packets",
".",
"This",
"method",
"allows",
"you",
"to",
"pass",
"in",
"a",
"callbable",
"which",
"will",
"be",
"called",
"on",
"receipt",
"of",
"each",
"IMU",
"data",
"packet",
"sent",
"by",
... | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L444-L464 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.enable_imu_streaming | def enable_imu_streaming(self, enabled_imus, enabled_sensors=SENSOR_ALL):
"""Configures and enables IMU sensor data streaming.
NOTE: only one streaming mode can be active at any time, so e.g. if you
want to stream IMU data, you must disable SK8-ExtAna streaming first.
Args:
... | python | def enable_imu_streaming(self, enabled_imus, enabled_sensors=SENSOR_ALL):
"""Configures and enables IMU sensor data streaming.
NOTE: only one streaming mode can be active at any time, so e.g. if you
want to stream IMU data, you must disable SK8-ExtAna streaming first.
Args:
... | [
"def",
"enable_imu_streaming",
"(",
"self",
",",
"enabled_imus",
",",
"enabled_sensors",
"=",
"SENSOR_ALL",
")",
":",
"imus_enabled",
"=",
"0",
"for",
"imu",
"in",
"enabled_imus",
":",
"imus_enabled",
"|=",
"(",
"1",
"<<",
"imu",
")",
"if",
"enabled_sensors",
... | Configures and enables IMU sensor data streaming.
NOTE: only one streaming mode can be active at any time, so e.g. if you
want to stream IMU data, you must disable SK8-ExtAna streaming first.
Args:
enabled_imus (list): a list of distinct ints in the range `0`-`4`
i... | [
"Configures",
"and",
"enables",
"IMU",
"sensor",
"data",
"streaming",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L466-L501 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.disable_imu_streaming | def disable_imu_streaming(self):
"""Disable IMU streaming for this device.
Returns:
True on success, False if an error occurred.
"""
self.enabled_imus = []
# reset IMU data state
for imu in self.imus:
imu.reset()
return self.dongle._disabl... | python | def disable_imu_streaming(self):
"""Disable IMU streaming for this device.
Returns:
True on success, False if an error occurred.
"""
self.enabled_imus = []
# reset IMU data state
for imu in self.imus:
imu.reset()
return self.dongle._disabl... | [
"def",
"disable_imu_streaming",
"(",
"self",
")",
":",
"self",
".",
"enabled_imus",
"=",
"[",
"]",
"# reset IMU data state",
"for",
"imu",
"in",
"self",
".",
"imus",
":",
"imu",
".",
"reset",
"(",
")",
"return",
"self",
".",
"dongle",
".",
"_disable_imu_st... | Disable IMU streaming for this device.
Returns:
True on success, False if an error occurred. | [
"Disable",
"IMU",
"streaming",
"for",
"this",
"device",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L525-L535 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | SK8.get_battery_level | def get_battery_level(self):
"""Reads the battery level descriptor on the device.
Returns:
int. If successful this will be a positive value representing the current
battery level as a percentage. On error, -1 is returned.
"""
battery_level = self.get_character... | python | def get_battery_level(self):
"""Reads the battery level descriptor on the device.
Returns:
int. If successful this will be a positive value representing the current
battery level as a percentage. On error, -1 is returned.
"""
battery_level = self.get_character... | [
"def",
"get_battery_level",
"(",
"self",
")",
":",
"battery_level",
"=",
"self",
".",
"get_characteristic_handle_from_uuid",
"(",
"UUID_BATTERY_LEVEL",
")",
"if",
"battery_level",
"is",
"None",
":",
"logger",
".",
"warn",
"(",
"'Failed to find handle for battery level'"... | Reads the battery level descriptor on the device.
Returns:
int. If successful this will be a positive value representing the current
battery level as a percentage. On error, -1 is returned. | [
"Reads",
"the",
"battery",
"level",
"descriptor",
"on",
"the",
"device",
"."
] | train | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L537-L553 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.