repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.filter_all_reachable_leaves | def filter_all_reachable_leaves(self, identifier_filter, language, forbidden_identifiers=None):
"""
Get all leaves corresponding to the given filter:
* the filter is a list of lists;
* each of the inner list carries identifiers;
* for each identifier, we find an item and all its... | python | def filter_all_reachable_leaves(self, identifier_filter, language, forbidden_identifiers=None):
"""
Get all leaves corresponding to the given filter:
* the filter is a list of lists;
* each of the inner list carries identifiers;
* for each identifier, we find an item and all its... | [
"def",
"filter_all_reachable_leaves",
"(",
"self",
",",
"identifier_filter",
",",
"language",
",",
"forbidden_identifiers",
"=",
"None",
")",
":",
"return",
"self",
".",
"filter_all_reachable_leaves_many",
"(",
"[",
"identifier_filter",
"]",
",",
"language",
",",
"f... | Get all leaves corresponding to the given filter:
* the filter is a list of lists;
* each of the inner list carries identifiers;
* for each identifier, we find an item and all its reachable leaf items;
* within the inner list we union the reachable items;
* with the outer list w... | [
"Get",
"all",
"leaves",
"corresponding",
"to",
"the",
"given",
"filter",
":"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L397-L432 | train | Filter all leaves corresponding to the given filter |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.get_children_graph | def get_children_graph(self, item_ids=None, language=None, forbidden_item_ids=None):
"""
Get a subgraph of items reachable from the given set of items through
the 'child' relation.
Args:
item_ids (list): items which are taken as roots for the reachability
languag... | python | def get_children_graph(self, item_ids=None, language=None, forbidden_item_ids=None):
"""
Get a subgraph of items reachable from the given set of items through
the 'child' relation.
Args:
item_ids (list): items which are taken as roots for the reachability
languag... | [
"def",
"get_children_graph",
"(",
"self",
",",
"item_ids",
"=",
"None",
",",
"language",
"=",
"None",
",",
"forbidden_item_ids",
"=",
"None",
")",
":",
"if",
"forbidden_item_ids",
"is",
"None",
":",
"forbidden_item_ids",
"=",
"set",
"(",
")",
"def",
"_childr... | Get a subgraph of items reachable from the given set of items through
the 'child' relation.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter out items which are not
available in the given language
... | [
"Get",
"a",
"subgraph",
"of",
"items",
"reachable",
"from",
"the",
"given",
"set",
"of",
"items",
"through",
"the",
"child",
"relation",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L436-L471 | train | Returns a subgraph of items reachable from the given set of items through the child relation. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.get_parents_graph | def get_parents_graph(self, item_ids, language=None):
"""
Get a subgraph of items reachable from the given set of items through
the 'parent' relation.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter ... | python | def get_parents_graph(self, item_ids, language=None):
"""
Get a subgraph of items reachable from the given set of items through
the 'parent' relation.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter ... | [
"def",
"get_parents_graph",
"(",
"self",
",",
"item_ids",
",",
"language",
"=",
"None",
")",
":",
"def",
"_parents",
"(",
"item_ids",
")",
":",
"if",
"item_ids",
"is",
"None",
":",
"items",
"=",
"Item",
".",
"objects",
".",
"filter",
"(",
"active",
"="... | Get a subgraph of items reachable from the given set of items through
the 'parent' relation.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter out items which are not
available in the given language
... | [
"Get",
"a",
"subgraph",
"of",
"items",
"reachable",
"from",
"the",
"given",
"set",
"of",
"items",
"through",
"the",
"parent",
"relation",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L478-L505 | train | Returns a subgraph of items reachable from the given set of items through
the parent relation. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.get_graph | def get_graph(self, item_ids, language=None):
"""
Get a subgraph of items reachable from the given set of items through
any relation.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter out items which a... | python | def get_graph(self, item_ids, language=None):
"""
Get a subgraph of items reachable from the given set of items through
any relation.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter out items which a... | [
"def",
"get_graph",
"(",
"self",
",",
"item_ids",
",",
"language",
"=",
"None",
")",
":",
"def",
"_related",
"(",
"item_ids",
")",
":",
"if",
"item_ids",
"is",
"None",
":",
"items",
"=",
"Item",
".",
"objects",
".",
"filter",
"(",
"active",
"=",
"Tru... | Get a subgraph of items reachable from the given set of items through
any relation.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter out items which are not
available in the given language
Re... | [
"Get",
"a",
"subgraph",
"of",
"items",
"reachable",
"from",
"the",
"given",
"set",
"of",
"items",
"through",
"any",
"relation",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L507-L532 | train | Returns a subgraph of items reachable from the given set of items through the given language. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.translate_identifiers | def translate_identifiers(self, identifiers, language):
"""
Translate a list of identifiers to item ids. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
which uniquel... | python | def translate_identifiers(self, identifiers, language):
"""
Translate a list of identifiers to item ids. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
which uniquel... | [
"def",
"translate_identifiers",
"(",
"self",
",",
"identifiers",
",",
"language",
")",
":",
"result",
"=",
"{",
"}",
"identifiers",
"=",
"set",
"(",
"identifiers",
")",
"item_types",
"=",
"ItemType",
".",
"objects",
".",
"get_all_types",
"(",
")",
"for",
"... | Translate a list of identifiers to item ids. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
which uniquely specifies the table, and <model_identifier> is
identifier of the o... | [
"Translate",
"a",
"list",
"of",
"identifiers",
"to",
"item",
"ids",
".",
"Identifier",
"is",
"a",
"string",
"of",
"the",
"following",
"form",
":"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L539-L575 | train | Translate a list of identifiers to item ids. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.get_item_type_id_from_identifier | def get_item_type_id_from_identifier(self, identifier, item_types=None):
"""
Get an ID of item type for the given identifier. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
... | python | def get_item_type_id_from_identifier(self, identifier, item_types=None):
"""
Get an ID of item type for the given identifier. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
... | [
"def",
"get_item_type_id_from_identifier",
"(",
"self",
",",
"identifier",
",",
"item_types",
"=",
"None",
")",
":",
"if",
"item_types",
"is",
"None",
":",
"item_types",
"=",
"ItemType",
".",
"objects",
".",
"get_all_types",
"(",
")",
"identifier_type",
",",
"... | Get an ID of item type for the given identifier. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
which uniquely specifies the table, and <model_identifier> is
identifier of t... | [
"Get",
"an",
"ID",
"of",
"item",
"type",
"for",
"the",
"given",
"identifier",
".",
"Identifier",
"is",
"a",
"string",
"of",
"the",
"following",
"form",
":"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L577-L603 | train | Get an ID of item type for the given identifier. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.translate_item_ids | def translate_item_ids(self, item_ids, language, is_nested=None):
"""
Translate a list of item ids to JSON objects which reference them.
Args:
item_ids (list[int]): item ids
language (str): language used for further filtering (some objects
for different l... | python | def translate_item_ids(self, item_ids, language, is_nested=None):
"""
Translate a list of item ids to JSON objects which reference them.
Args:
item_ids (list[int]): item ids
language (str): language used for further filtering (some objects
for different l... | [
"def",
"translate_item_ids",
"(",
"self",
",",
"item_ids",
",",
"language",
",",
"is_nested",
"=",
"None",
")",
":",
"if",
"is_nested",
"is",
"None",
":",
"def",
"is_nested_fun",
"(",
"x",
")",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"is_nested",... | Translate a list of item ids to JSON objects which reference them.
Args:
item_ids (list[int]): item ids
language (str): language used for further filtering (some objects
for different languages share the same item)
is_nested (function): mapping from item ids ... | [
"Translate",
"a",
"list",
"of",
"item",
"ids",
"to",
"JSON",
"objects",
"which",
"reference",
"them",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L606-L647 | train | Translate a list of item ids to JSON objects which reference them. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.get_leaves | def get_leaves(self, item_ids=None, language=None, forbidden_item_ids=None):
"""
Get mapping of items to their reachable leaves. Leaves having
inactive relations to other items are omitted.
Args:
item_ids (list): items which are taken as roots for the reachability
... | python | def get_leaves(self, item_ids=None, language=None, forbidden_item_ids=None):
"""
Get mapping of items to their reachable leaves. Leaves having
inactive relations to other items are omitted.
Args:
item_ids (list): items which are taken as roots for the reachability
... | [
"def",
"get_leaves",
"(",
"self",
",",
"item_ids",
"=",
"None",
",",
"language",
"=",
"None",
",",
"forbidden_item_ids",
"=",
"None",
")",
":",
"forbidden_item_ids",
"=",
"set",
"(",
")",
"if",
"forbidden_item_ids",
"is",
"None",
"else",
"set",
"(",
"forbi... | Get mapping of items to their reachable leaves. Leaves having
inactive relations to other items are omitted.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter out items which are not
available in the g... | [
"Get",
"mapping",
"of",
"items",
"to",
"their",
"reachable",
"leaves",
".",
"Leaves",
"having",
"inactive",
"relations",
"to",
"other",
"items",
"are",
"omitted",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L651-L694 | train | Get mapping of items to their reachable leaves. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.get_all_leaves | def get_all_leaves(self, item_ids=None, language=None, forbidden_item_ids=None):
"""
Get all leaves reachable from the given set of items. Leaves having
inactive relations to other items are omitted.
Args:
item_ids (list): items which are taken as roots for the reachability
... | python | def get_all_leaves(self, item_ids=None, language=None, forbidden_item_ids=None):
"""
Get all leaves reachable from the given set of items. Leaves having
inactive relations to other items are omitted.
Args:
item_ids (list): items which are taken as roots for the reachability
... | [
"def",
"get_all_leaves",
"(",
"self",
",",
"item_ids",
"=",
"None",
",",
"language",
"=",
"None",
",",
"forbidden_item_ids",
"=",
"None",
")",
":",
"return",
"sorted",
"(",
"set",
"(",
"flatten",
"(",
"self",
".",
"get_leaves",
"(",
"item_ids",
",",
"lan... | Get all leaves reachable from the given set of items. Leaves having
inactive relations to other items are omitted.
Args:
item_ids (list): items which are taken as roots for the reachability
language (str): if specified, filter out items which are not
available in... | [
"Get",
"all",
"leaves",
"reachable",
"from",
"the",
"given",
"set",
"of",
"items",
".",
"Leaves",
"having",
"inactive",
"relations",
"to",
"other",
"items",
"are",
"omitted",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L697-L710 | train | Get all leaves reachable from the given set of items. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.get_reference_fields | def get_reference_fields(self, exclude_models=None):
"""
Get all Django model fields which reference the Item model.
"""
if exclude_models is None:
exclude_models = []
result = []
for django_model in django.apps.apps.get_models():
if any([issubclas... | python | def get_reference_fields(self, exclude_models=None):
"""
Get all Django model fields which reference the Item model.
"""
if exclude_models is None:
exclude_models = []
result = []
for django_model in django.apps.apps.get_models():
if any([issubclas... | [
"def",
"get_reference_fields",
"(",
"self",
",",
"exclude_models",
"=",
"None",
")",
":",
"if",
"exclude_models",
"is",
"None",
":",
"exclude_models",
"=",
"[",
"]",
"result",
"=",
"[",
"]",
"for",
"django_model",
"in",
"django",
".",
"apps",
".",
"apps",
... | Get all Django model fields which reference the Item model. | [
"Get",
"all",
"Django",
"model",
"fields",
"which",
"reference",
"the",
"Item",
"model",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L712-L726 | train | Get all Django model fields which reference the Item model. |
adaptive-learning/proso-apps | proso_models/models.py | ItemManager.override_parent_subgraph | def override_parent_subgraph(self, parent_subgraph, invisible_edges=None):
"""
Get all items with outcoming edges from the given subgraph, drop all
their parent relations, and then add parents according to the given
subgraph.
Args:
parent_subgraph (dict): item id -> ... | python | def override_parent_subgraph(self, parent_subgraph, invisible_edges=None):
"""
Get all items with outcoming edges from the given subgraph, drop all
their parent relations, and then add parents according to the given
subgraph.
Args:
parent_subgraph (dict): item id -> ... | [
"def",
"override_parent_subgraph",
"(",
"self",
",",
"parent_subgraph",
",",
"invisible_edges",
"=",
"None",
")",
":",
"with",
"transaction",
".",
"atomic",
"(",
")",
":",
"if",
"invisible_edges",
"is",
"None",
":",
"invisible_edges",
"=",
"set",
"(",
")",
"... | Get all items with outcoming edges from the given subgraph, drop all
their parent relations, and then add parents according to the given
subgraph.
Args:
parent_subgraph (dict): item id -> list of parents(item ids)
invisible_edges (list|set): set of (from, to) tuples spec... | [
"Get",
"all",
"items",
"with",
"outcoming",
"edges",
"from",
"the",
"given",
"subgraph",
"drop",
"all",
"their",
"parent",
"relations",
"and",
"then",
"add",
"parents",
"according",
"to",
"the",
"given",
"subgraph",
"."
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L728-L764 | train | Override the parent subgraph with the given subgraph. |
46elks/elkme | elkme/elks.py | Elks.query_api | def query_api(self, data=None, endpoint='SMS'):
""" Send a request to the 46elks API.
Fetches SMS history as JSON by default, sends a HTTP POST request
with the incoming data dictionary as a urlencoded query if data is
provided, otherwise HTTP GET
Throws HTTPError on non 2xx
... | python | def query_api(self, data=None, endpoint='SMS'):
""" Send a request to the 46elks API.
Fetches SMS history as JSON by default, sends a HTTP POST request
with the incoming data dictionary as a urlencoded query if data is
provided, otherwise HTTP GET
Throws HTTPError on non 2xx
... | [
"def",
"query_api",
"(",
"self",
",",
"data",
"=",
"None",
",",
"endpoint",
"=",
"'SMS'",
")",
":",
"url",
"=",
"self",
".",
"api_url",
"%",
"endpoint",
"if",
"data",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"url",
",",
"data",
"=",
"dat... | Send a request to the 46elks API.
Fetches SMS history as JSON by default, sends a HTTP POST request
with the incoming data dictionary as a urlencoded query if data is
provided, otherwise HTTP GET
Throws HTTPError on non 2xx | [
"Send",
"a",
"request",
"to",
"the",
"46elks",
"API",
".",
"Fetches",
"SMS",
"history",
"as",
"JSON",
"by",
"default",
"sends",
"a",
"HTTP",
"POST",
"request",
"with",
"the",
"incoming",
"data",
"dictionary",
"as",
"a",
"urlencoded",
"query",
"if",
"data",... | 6ebdce6f8ac852fc6f714d1f1b836f2777fece4e | https://github.com/46elks/elkme/blob/6ebdce6f8ac852fc6f714d1f1b836f2777fece4e/elkme/elks.py#L33-L58 | train | Send a request to the 46elks API. |
46elks/elkme | elkme/elks.py | Elks.validate_number | def validate_number(self, number):
""" Checks if a number looks somewhat like a E.164 number. Not an
exhaustive check, as the API takes care of that
"""
if not isinstance(number, str):
raise ElksException('Recipient phone number may not be empty')
if number[0] == '+' ... | python | def validate_number(self, number):
""" Checks if a number looks somewhat like a E.164 number. Not an
exhaustive check, as the API takes care of that
"""
if not isinstance(number, str):
raise ElksException('Recipient phone number may not be empty')
if number[0] == '+' ... | [
"def",
"validate_number",
"(",
"self",
",",
"number",
")",
":",
"if",
"not",
"isinstance",
"(",
"number",
",",
"str",
")",
":",
"raise",
"ElksException",
"(",
"'Recipient phone number may not be empty'",
")",
"if",
"number",
"[",
"0",
"]",
"==",
"'+'",
"and"... | Checks if a number looks somewhat like a E.164 number. Not an
exhaustive check, as the API takes care of that | [
"Checks",
"if",
"a",
"number",
"looks",
"somewhat",
"like",
"a",
"E",
".",
"164",
"number",
".",
"Not",
"an",
"exhaustive",
"check",
"as",
"the",
"API",
"takes",
"care",
"of",
"that"
] | 6ebdce6f8ac852fc6f714d1f1b836f2777fece4e | https://github.com/46elks/elkme/blob/6ebdce6f8ac852fc6f714d1f1b836f2777fece4e/elkme/elks.py#L61-L70 | train | Checks if a number looks like a E. 164 number. |
46elks/elkme | elkme/elks.py | Elks.format_sms_payload | def format_sms_payload(self, message, to, sender='elkme', options=[]):
""" Helper function to create a SMS payload with little effort
"""
self.validate_number(to)
if not isinstance(message, str):
message = " ".join(message)
message = message.rstrip()
sms = ... | python | def format_sms_payload(self, message, to, sender='elkme', options=[]):
""" Helper function to create a SMS payload with little effort
"""
self.validate_number(to)
if not isinstance(message, str):
message = " ".join(message)
message = message.rstrip()
sms = ... | [
"def",
"format_sms_payload",
"(",
"self",
",",
"message",
",",
"to",
",",
"sender",
"=",
"'elkme'",
",",
"options",
"=",
"[",
"]",
")",
":",
"self",
".",
"validate_number",
"(",
"to",
")",
"if",
"not",
"isinstance",
"(",
"message",
",",
"str",
")",
"... | Helper function to create a SMS payload with little effort | [
"Helper",
"function",
"to",
"create",
"a",
"SMS",
"payload",
"with",
"little",
"effort"
] | 6ebdce6f8ac852fc6f714d1f1b836f2777fece4e | https://github.com/46elks/elkme/blob/6ebdce6f8ac852fc6f714d1f1b836f2777fece4e/elkme/elks.py#L73-L94 | train | Helper function to create a SMS payload with little effort |
46elks/elkme | elkme/elks.py | Elks.send_sms | def send_sms(self, message, to, sender='elkme', options=[]):
"""Sends a text message to a configuration conf containing the message
in the message paramter"""
sms = self.format_sms_payload(message=message,
to=to,
sender=sender,
options=options)
return ... | python | def send_sms(self, message, to, sender='elkme', options=[]):
"""Sends a text message to a configuration conf containing the message
in the message paramter"""
sms = self.format_sms_payload(message=message,
to=to,
sender=sender,
options=options)
return ... | [
"def",
"send_sms",
"(",
"self",
",",
"message",
",",
"to",
",",
"sender",
"=",
"'elkme'",
",",
"options",
"=",
"[",
"]",
")",
":",
"sms",
"=",
"self",
".",
"format_sms_payload",
"(",
"message",
"=",
"message",
",",
"to",
"=",
"to",
",",
"sender",
"... | Sends a text message to a configuration conf containing the message
in the message paramter | [
"Sends",
"a",
"text",
"message",
"to",
"a",
"configuration",
"conf",
"containing",
"the",
"message",
"in",
"the",
"message",
"paramter"
] | 6ebdce6f8ac852fc6f714d1f1b836f2777fece4e | https://github.com/46elks/elkme/blob/6ebdce6f8ac852fc6f714d1f1b836f2777fece4e/elkme/elks.py#L96-L103 | train | Sends a text message to a configuration conf containing the message
in the message paramter |
Desiiii/weeb.py | weeb/client.py | Client.get_types | async def get_types(self):
"""Gets all available types.
This function is a coroutine.
Return Type: `list`"""
async with aiohttp.ClientSession() as session:
async with session.get('https://api.weeb.sh/images/types', headers=self.__headers) as resp:
if resp.st... | python | async def get_types(self):
"""Gets all available types.
This function is a coroutine.
Return Type: `list`"""
async with aiohttp.ClientSession() as session:
async with session.get('https://api.weeb.sh/images/types', headers=self.__headers) as resp:
if resp.st... | [
"async",
"def",
"get_types",
"(",
"self",
")",
":",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
")",
"as",
"session",
":",
"async",
"with",
"session",
".",
"get",
"(",
"'https://api.weeb.sh/images/types'",
",",
"headers",
"=",
"self",
".",
"__head... | Gets all available types.
This function is a coroutine.
Return Type: `list` | [
"Gets",
"all",
"available",
"types",
"."
] | 5174c22e0cd34cb77f69ad18fbe87ee1fad51859 | https://github.com/Desiiii/weeb.py/blob/5174c22e0cd34cb77f69ad18fbe87ee1fad51859/weeb/client.py#L18-L29 | train | Gets all available types. This function is a coroutine. |
Desiiii/weeb.py | weeb/client.py | Client.get_image | async def get_image(self, imgtype=None, tags=None, nsfw=None, hidden=None, filetype=None):
"""Request an image from weeb.sh.
This function is a coroutine.
Parameters:
imgtype: str - the type of image to get. (If not specified, needs at least one tag)
tags: list - the ta... | python | async def get_image(self, imgtype=None, tags=None, nsfw=None, hidden=None, filetype=None):
"""Request an image from weeb.sh.
This function is a coroutine.
Parameters:
imgtype: str - the type of image to get. (If not specified, needs at least one tag)
tags: list - the ta... | [
"async",
"def",
"get_image",
"(",
"self",
",",
"imgtype",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"nsfw",
"=",
"None",
",",
"hidden",
"=",
"None",
",",
"filetype",
"=",
"None",
")",
":",
"if",
"not",
"imgtype",
"and",
"not",
"tags",
":",
"raise... | Request an image from weeb.sh.
This function is a coroutine.
Parameters:
imgtype: str - the type of image to get. (If not specified, needs at least one tag)
tags: list - the tags to search by. (If not specified, needs type)
nsfw: str - whether or not the images reci... | [
"Request",
"an",
"image",
"from",
"weeb",
".",
"sh",
"."
] | 5174c22e0cd34cb77f69ad18fbe87ee1fad51859 | https://github.com/Desiiii/weeb.py/blob/5174c22e0cd34cb77f69ad18fbe87ee1fad51859/weeb/client.py#L44-L79 | train | Request an image from weeb. sh. |
Desiiii/weeb.py | weeb/client.py | Client.generate_image | async def generate_image(self, imgtype, face=None, hair=None):
"""Generate a basic image using the auto-image endpoint of weeb.sh.
This function is a coroutine.
Parameters:
imgtype: str - type of the generation to create, possible types are awooo, eyes, or won.
face: st... | python | async def generate_image(self, imgtype, face=None, hair=None):
"""Generate a basic image using the auto-image endpoint of weeb.sh.
This function is a coroutine.
Parameters:
imgtype: str - type of the generation to create, possible types are awooo, eyes, or won.
face: st... | [
"async",
"def",
"generate_image",
"(",
"self",
",",
"imgtype",
",",
"face",
"=",
"None",
",",
"hair",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"imgtype",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"type of 'imgtype' must be str.\"",
"... | Generate a basic image using the auto-image endpoint of weeb.sh.
This function is a coroutine.
Parameters:
imgtype: str - type of the generation to create, possible types are awooo, eyes, or won.
face: str - only used with awooo type, defines color of face
hair: str... | [
"Generate",
"a",
"basic",
"image",
"using",
"the",
"auto",
"-",
"image",
"endpoint",
"of",
"weeb",
".",
"sh",
"."
] | 5174c22e0cd34cb77f69ad18fbe87ee1fad51859 | https://github.com/Desiiii/weeb.py/blob/5174c22e0cd34cb77f69ad18fbe87ee1fad51859/weeb/client.py#L81-L106 | train | This function generates a basic image using the auto - image endpoint of weeb. sh. |
Desiiii/weeb.py | weeb/client.py | Client.generate_status | async def generate_status(self, status, avatar=None):
"""Generate a discord status icon below the image provided.
This function is a coroutine.
Parameters:
status: str - a discord status, must be online, idle, dnd, or streaming
avatar: str - http/s url pointing to an av... | python | async def generate_status(self, status, avatar=None):
"""Generate a discord status icon below the image provided.
This function is a coroutine.
Parameters:
status: str - a discord status, must be online, idle, dnd, or streaming
avatar: str - http/s url pointing to an av... | [
"async",
"def",
"generate_status",
"(",
"self",
",",
"status",
",",
"avatar",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"status",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"type of 'status' must be str.\"",
")",
"if",
"avatar",
"and",
... | Generate a discord status icon below the image provided.
This function is a coroutine.
Parameters:
status: str - a discord status, must be online, idle, dnd, or streaming
avatar: str - http/s url pointing to an avatar, has to have proper headers and be a direct link to an image... | [
"Generate",
"a",
"discord",
"status",
"icon",
"below",
"the",
"image",
"provided",
"."
] | 5174c22e0cd34cb77f69ad18fbe87ee1fad51859 | https://github.com/Desiiii/weeb.py/blob/5174c22e0cd34cb77f69ad18fbe87ee1fad51859/weeb/client.py#L108-L129 | train | Generate a discord status icon below the image provided. |
Desiiii/weeb.py | weeb/client.py | Client.generate_waifu_insult | async def generate_waifu_insult(self, avatar):
"""Generate a waifu insult image.
This function is a coroutine.
Parameters:
avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image
Return Type: image data"""
if not i... | python | async def generate_waifu_insult(self, avatar):
"""Generate a waifu insult image.
This function is a coroutine.
Parameters:
avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image
Return Type: image data"""
if not i... | [
"async",
"def",
"generate_waifu_insult",
"(",
"self",
",",
"avatar",
")",
":",
"if",
"not",
"isinstance",
"(",
"avatar",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"type of 'avatar' must be str.\"",
")",
"async",
"with",
"aiohttp",
".",
"ClientSession",
... | Generate a waifu insult image.
This function is a coroutine.
Parameters:
avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image
Return Type: image data | [
"Generate",
"a",
"waifu",
"insult",
"image",
"."
] | 5174c22e0cd34cb77f69ad18fbe87ee1fad51859 | https://github.com/Desiiii/weeb.py/blob/5174c22e0cd34cb77f69ad18fbe87ee1fad51859/weeb/client.py#L131-L147 | train | This function is a coroutine function that generates a waifu insult image. This function is a coroutine function that returns a response from the waifu - insult API. |
Desiiii/weeb.py | weeb/client.py | Client.generate_license | async def generate_license(self, title, avatar, badges=None, widgets=None):
"""Generate a license.
This function is a coroutine.
Parameters:
title: str - title of the license
avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link ... | python | async def generate_license(self, title, avatar, badges=None, widgets=None):
"""Generate a license.
This function is a coroutine.
Parameters:
title: str - title of the license
avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link ... | [
"async",
"def",
"generate_license",
"(",
"self",
",",
"title",
",",
"avatar",
",",
"badges",
"=",
"None",
",",
"widgets",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"title",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"type of 'title' ... | Generate a license.
This function is a coroutine.
Parameters:
title: str - title of the license
avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image
badges: list - list of 1-3 direct image urls. Same requirements... | [
"Generate",
"a",
"license",
"."
] | 5174c22e0cd34cb77f69ad18fbe87ee1fad51859 | https://github.com/Desiiii/weeb.py/blob/5174c22e0cd34cb77f69ad18fbe87ee1fad51859/weeb/client.py#L149-L179 | train | This function generates a license. |
Desiiii/weeb.py | weeb/client.py | Client.generate_love_ship | async def generate_love_ship(self, target_one, target_two):
"""Generate a love ship.
This function is a coroutine.
Parameters:
target_one: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image, image will be on the left side.
... | python | async def generate_love_ship(self, target_one, target_two):
"""Generate a love ship.
This function is a coroutine.
Parameters:
target_one: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image, image will be on the left side.
... | [
"async",
"def",
"generate_love_ship",
"(",
"self",
",",
"target_one",
",",
"target_two",
")",
":",
"if",
"not",
"isinstance",
"(",
"target_one",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"type of 'target_one' must be str.\"",
")",
"if",
"not",
"isinstan... | Generate a love ship.
This function is a coroutine.
Parameters:
target_one: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image, image will be on the left side.
target_two: str - http/s url pointing to an image, has to have proper ... | [
"Generate",
"a",
"love",
"ship",
"."
] | 5174c22e0cd34cb77f69ad18fbe87ee1fad51859 | https://github.com/Desiiii/weeb.py/blob/5174c22e0cd34cb77f69ad18fbe87ee1fad51859/weeb/client.py#L181-L201 | train | This function generates a love ship. |
cozy/python_cozy_management | cozy_management/monitor.py | launch_command | def launch_command(command, parameter=''):
'''Can launch a cozy-monitor command
:param command: The cozy-monitor command to launch
:param parameter: The parameter to push on cozy-monitor if needed
:returns: the command string
'''
result = ''
# Transform into an array if it not one
if n... | python | def launch_command(command, parameter=''):
'''Can launch a cozy-monitor command
:param command: The cozy-monitor command to launch
:param parameter: The parameter to push on cozy-monitor if needed
:returns: the command string
'''
result = ''
# Transform into an array if it not one
if n... | [
"def",
"launch_command",
"(",
"command",
",",
"parameter",
"=",
"''",
")",
":",
"result",
"=",
"''",
"# Transform into an array if it not one",
"if",
"not",
"isinstance",
"(",
"parameter",
",",
"list",
")",
":",
"parameter",
"=",
"[",
"parameter",
"]",
"# Iter... | Can launch a cozy-monitor command
:param command: The cozy-monitor command to launch
:param parameter: The parameter to push on cozy-monitor if needed
:returns: the command string | [
"Can",
"launch",
"a",
"cozy",
"-",
"monitor",
"command"
] | 820cea58458ae3e067fa8cc2da38edbda4681dac | https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/monitor.py#L15-L33 | train | Launch a cozy - monitor command |
cozy/python_cozy_management | cozy_management/monitor.py | status | def status(app_name=None, only_cozy=False, as_boolean=False):
'''Get apps status
:param app_name: If pass app name return this app status
:return: dict with all apps status or str with one app status
'''
apps = {}
# Get all apps status & slip them
apps_status = subprocess.Popen('cozy-monito... | python | def status(app_name=None, only_cozy=False, as_boolean=False):
'''Get apps status
:param app_name: If pass app name return this app status
:return: dict with all apps status or str with one app status
'''
apps = {}
# Get all apps status & slip them
apps_status = subprocess.Popen('cozy-monito... | [
"def",
"status",
"(",
"app_name",
"=",
"None",
",",
"only_cozy",
"=",
"False",
",",
"as_boolean",
"=",
"False",
")",
":",
"apps",
"=",
"{",
"}",
"# Get all apps status & slip them",
"apps_status",
"=",
"subprocess",
".",
"Popen",
"(",
"'cozy-monitor status'",
... | Get apps status
:param app_name: If pass app name return this app status
:return: dict with all apps status or str with one app status | [
"Get",
"apps",
"status"
] | 820cea58458ae3e067fa8cc2da38edbda4681dac | https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/monitor.py#L36-L69 | train | Get status of all apps and slip them |
uogbuji/versa | tools/py/util.py | transitive_closure | def transitive_closure(m, orig, rel):
'''
Generate the closure over a transitive relationship in depth-first fashion
'''
#FIXME: Broken for now
links = list(m.match(orig, rel))
for link in links:
yield link[0][TARGET]
yield from transitive_closure(m, target, rel) | python | def transitive_closure(m, orig, rel):
'''
Generate the closure over a transitive relationship in depth-first fashion
'''
#FIXME: Broken for now
links = list(m.match(orig, rel))
for link in links:
yield link[0][TARGET]
yield from transitive_closure(m, target, rel) | [
"def",
"transitive_closure",
"(",
"m",
",",
"orig",
",",
"rel",
")",
":",
"#FIXME: Broken for now",
"links",
"=",
"list",
"(",
"m",
".",
"match",
"(",
"orig",
",",
"rel",
")",
")",
"for",
"link",
"in",
"links",
":",
"yield",
"link",
"[",
"0",
"]",
... | Generate the closure over a transitive relationship in depth-first fashion | [
"Generate",
"the",
"closure",
"over",
"a",
"transitive",
"relationship",
"in",
"depth",
"-",
"first",
"fashion"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L36-L44 | train | Generate the transitive closure over a transitive relationship in depth - first fashion. |
uogbuji/versa | tools/py/util.py | all_origins | def all_origins(m):
'''
Generate all unique statement origins in the given model
'''
seen = set()
for link in m.match():
origin = link[ORIGIN]
if origin not in seen:
seen.add(origin)
yield origin | python | def all_origins(m):
'''
Generate all unique statement origins in the given model
'''
seen = set()
for link in m.match():
origin = link[ORIGIN]
if origin not in seen:
seen.add(origin)
yield origin | [
"def",
"all_origins",
"(",
"m",
")",
":",
"seen",
"=",
"set",
"(",
")",
"for",
"link",
"in",
"m",
".",
"match",
"(",
")",
":",
"origin",
"=",
"link",
"[",
"ORIGIN",
"]",
"if",
"origin",
"not",
"in",
"seen",
":",
"seen",
".",
"add",
"(",
"origin... | Generate all unique statement origins in the given model | [
"Generate",
"all",
"unique",
"statement",
"origins",
"in",
"the",
"given",
"model"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L47-L56 | train | Generate all unique statement origins in the given model |
uogbuji/versa | tools/py/util.py | column | def column(m, linkpart):
'''
Generate all parts of links according to the parameter
'''
assert linkpart in (0, 1, 2, 3)
seen = set()
for link in m.match():
val = link[linkpart]
if val not in seen:
seen.add(val)
yield val | python | def column(m, linkpart):
'''
Generate all parts of links according to the parameter
'''
assert linkpart in (0, 1, 2, 3)
seen = set()
for link in m.match():
val = link[linkpart]
if val not in seen:
seen.add(val)
yield val | [
"def",
"column",
"(",
"m",
",",
"linkpart",
")",
":",
"assert",
"linkpart",
"in",
"(",
"0",
",",
"1",
",",
"2",
",",
"3",
")",
"seen",
"=",
"set",
"(",
")",
"for",
"link",
"in",
"m",
".",
"match",
"(",
")",
":",
"val",
"=",
"link",
"[",
"li... | Generate all parts of links according to the parameter | [
"Generate",
"all",
"parts",
"of",
"links",
"according",
"to",
"the",
"parameter"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L59-L69 | train | Generate all the parts of links according to the parameter
|
uogbuji/versa | tools/py/util.py | resourcetypes | def resourcetypes(rid, model):
'''
Return a list of Versa types for a resource
'''
types = []
for o, r, t, a in model.match(rid, VTYPE_REL):
types.append(t)
return types | python | def resourcetypes(rid, model):
'''
Return a list of Versa types for a resource
'''
types = []
for o, r, t, a in model.match(rid, VTYPE_REL):
types.append(t)
return types | [
"def",
"resourcetypes",
"(",
"rid",
",",
"model",
")",
":",
"types",
"=",
"[",
"]",
"for",
"o",
",",
"r",
",",
"t",
",",
"a",
"in",
"model",
".",
"match",
"(",
"rid",
",",
"VTYPE_REL",
")",
":",
"types",
".",
"append",
"(",
"t",
")",
"return",
... | Return a list of Versa types for a resource | [
"Return",
"a",
"list",
"of",
"Versa",
"types",
"for",
"a",
"resource"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L72-L79 | train | Return a list of Versa types for a resource |
uogbuji/versa | tools/py/util.py | replace_values | def replace_values(in_m, out_m, map_from=(), map_to=()):
'''
Make a copy of a model with one value replaced with another
'''
for link in in_m.match():
new_link = list(link)
if map_from:
if link[ORIGIN] in map_from: new_link[ORIGIN] = map_to[map_from.index(link[ORIGIN])]
... | python | def replace_values(in_m, out_m, map_from=(), map_to=()):
'''
Make a copy of a model with one value replaced with another
'''
for link in in_m.match():
new_link = list(link)
if map_from:
if link[ORIGIN] in map_from: new_link[ORIGIN] = map_to[map_from.index(link[ORIGIN])]
... | [
"def",
"replace_values",
"(",
"in_m",
",",
"out_m",
",",
"map_from",
"=",
"(",
")",
",",
"map_to",
"=",
"(",
")",
")",
":",
"for",
"link",
"in",
"in_m",
".",
"match",
"(",
")",
":",
"new_link",
"=",
"list",
"(",
"link",
")",
"if",
"map_from",
":"... | Make a copy of a model with one value replaced with another | [
"Make",
"a",
"copy",
"of",
"a",
"model",
"with",
"one",
"value",
"replaced",
"with",
"another"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L83-L93 | train | Replace values in in_m with values in out_m. |
uogbuji/versa | tools/py/util.py | replace_entity_resource | def replace_entity_resource(model, oldres, newres):
'''
Replace one entity in the model with another with the same links
:param model: Versa model to be updated
:param oldres: old/former resource IRI to be replaced
:param newres: new/replacement resource IRI
:return: None
'''
oldrids = ... | python | def replace_entity_resource(model, oldres, newres):
'''
Replace one entity in the model with another with the same links
:param model: Versa model to be updated
:param oldres: old/former resource IRI to be replaced
:param newres: new/replacement resource IRI
:return: None
'''
oldrids = ... | [
"def",
"replace_entity_resource",
"(",
"model",
",",
"oldres",
",",
"newres",
")",
":",
"oldrids",
"=",
"set",
"(",
")",
"for",
"rid",
",",
"link",
"in",
"model",
":",
"if",
"link",
"[",
"ORIGIN",
"]",
"==",
"oldres",
"or",
"link",
"[",
"TARGET",
"]"... | Replace one entity in the model with another with the same links
:param model: Versa model to be updated
:param oldres: old/former resource IRI to be replaced
:param newres: new/replacement resource IRI
:return: None | [
"Replace",
"one",
"entity",
"in",
"the",
"model",
"with",
"another",
"with",
"the",
"same",
"links"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L96-L112 | train | Replace one entity in the model with another with the same links. |
uogbuji/versa | tools/py/util.py | duplicate_statements | def duplicate_statements(model, oldorigin, neworigin, rfilter=None):
'''
Take links with a given origin, and create duplicate links with the same information but a new origin
:param model: Versa model to be updated
:param oldres: resource IRI to be duplicated
:param newres: origin resource IRI for ... | python | def duplicate_statements(model, oldorigin, neworigin, rfilter=None):
'''
Take links with a given origin, and create duplicate links with the same information but a new origin
:param model: Versa model to be updated
:param oldres: resource IRI to be duplicated
:param newres: origin resource IRI for ... | [
"def",
"duplicate_statements",
"(",
"model",
",",
"oldorigin",
",",
"neworigin",
",",
"rfilter",
"=",
"None",
")",
":",
"for",
"o",
",",
"r",
",",
"t",
",",
"a",
"in",
"model",
".",
"match",
"(",
"oldorigin",
")",
":",
"if",
"rfilter",
"is",
"None",
... | Take links with a given origin, and create duplicate links with the same information but a new origin
:param model: Versa model to be updated
:param oldres: resource IRI to be duplicated
:param newres: origin resource IRI for duplication
:return: None | [
"Take",
"links",
"with",
"a",
"given",
"origin",
"and",
"create",
"duplicate",
"links",
"with",
"the",
"same",
"information",
"but",
"a",
"new",
"origin"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L115-L127 | train | Take links with a given origin and create duplicate links with the same information but a new origin. |
uogbuji/versa | tools/py/util.py | uniquify | def uniquify(model):
'''
Remove all duplicate relationships
'''
seen = set()
to_remove = set()
for ix, (o, r, t, a) in model:
hashable_link = (o, r, t) + tuple(sorted(a.items()))
#print(hashable_link)
if hashable_link in seen:
to_remove.add(ix)
seen.ad... | python | def uniquify(model):
'''
Remove all duplicate relationships
'''
seen = set()
to_remove = set()
for ix, (o, r, t, a) in model:
hashable_link = (o, r, t) + tuple(sorted(a.items()))
#print(hashable_link)
if hashable_link in seen:
to_remove.add(ix)
seen.ad... | [
"def",
"uniquify",
"(",
"model",
")",
":",
"seen",
"=",
"set",
"(",
")",
"to_remove",
"=",
"set",
"(",
")",
"for",
"ix",
",",
"(",
"o",
",",
"r",
",",
"t",
",",
"a",
")",
"in",
"model",
":",
"hashable_link",
"=",
"(",
"o",
",",
"r",
",",
"t... | Remove all duplicate relationships | [
"Remove",
"all",
"duplicate",
"relationships"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L130-L144 | train | Remove all duplicate relationships
|
uogbuji/versa | tools/py/util.py | jsonload | def jsonload(model, fp):
'''
Load Versa model dumped into JSON form, either raw or canonical
'''
dumped_list = json.load(fp)
for link in dumped_list:
if len(link) == 2:
sid, (s, p, o, a) = link
elif len(link) == 4: #canonical
(s, p, o, a) = link
tt... | python | def jsonload(model, fp):
'''
Load Versa model dumped into JSON form, either raw or canonical
'''
dumped_list = json.load(fp)
for link in dumped_list:
if len(link) == 2:
sid, (s, p, o, a) = link
elif len(link) == 4: #canonical
(s, p, o, a) = link
tt... | [
"def",
"jsonload",
"(",
"model",
",",
"fp",
")",
":",
"dumped_list",
"=",
"json",
".",
"load",
"(",
"fp",
")",
"for",
"link",
"in",
"dumped_list",
":",
"if",
"len",
"(",
"link",
")",
"==",
"2",
":",
"sid",
",",
"(",
"s",
",",
"p",
",",
"o",
"... | Load Versa model dumped into JSON form, either raw or canonical | [
"Load",
"Versa",
"model",
"dumped",
"into",
"JSON",
"form",
"either",
"raw",
"or",
"canonical"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L147-L164 | train | Load Versa model dumped into JSON form either raw or canonical
|
uogbuji/versa | tools/py/util.py | jsondump | def jsondump(model, fp):
'''
Dump Versa model into JSON form
'''
fp.write('[')
links_ser = []
for link in model:
links_ser.append(json.dumps(link))
fp.write(',\n'.join(links_ser))
fp.write(']') | python | def jsondump(model, fp):
'''
Dump Versa model into JSON form
'''
fp.write('[')
links_ser = []
for link in model:
links_ser.append(json.dumps(link))
fp.write(',\n'.join(links_ser))
fp.write(']') | [
"def",
"jsondump",
"(",
"model",
",",
"fp",
")",
":",
"fp",
".",
"write",
"(",
"'['",
")",
"links_ser",
"=",
"[",
"]",
"for",
"link",
"in",
"model",
":",
"links_ser",
".",
"append",
"(",
"json",
".",
"dumps",
"(",
"link",
")",
")",
"fp",
".",
"... | Dump Versa model into JSON form | [
"Dump",
"Versa",
"model",
"into",
"JSON",
"form"
] | f092ffc7ed363a5b170890955168500f32de0dd5 | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/util.py#L167-L176 | train | Dump Versa model into JSON form |
DsixTools/python-smeftrunner | smeftrunner/smpar.py | vMh2_to_m2Lambda | def vMh2_to_m2Lambda(v, Mh2, C, scale_high):
"""Function to numerically determine the parameters of the Higgs potential
given the physical Higgs VEV and mass."""
if C['phi'] == 0 and C['phiBox'] == 0 and C['phiD'] == 0:
return _vMh2_to_m2Lambda_SM(v, Mh2)
else:
def f0(x): # we want the ... | python | def vMh2_to_m2Lambda(v, Mh2, C, scale_high):
"""Function to numerically determine the parameters of the Higgs potential
given the physical Higgs VEV and mass."""
if C['phi'] == 0 and C['phiBox'] == 0 and C['phiD'] == 0:
return _vMh2_to_m2Lambda_SM(v, Mh2)
else:
def f0(x): # we want the ... | [
"def",
"vMh2_to_m2Lambda",
"(",
"v",
",",
"Mh2",
",",
"C",
",",
"scale_high",
")",
":",
"if",
"C",
"[",
"'phi'",
"]",
"==",
"0",
"and",
"C",
"[",
"'phiBox'",
"]",
"==",
"0",
"and",
"C",
"[",
"'phiD'",
"]",
"==",
"0",
":",
"return",
"_vMh2_to_m2La... | Function to numerically determine the parameters of the Higgs potential
given the physical Higgs VEV and mass. | [
"Function",
"to",
"numerically",
"determine",
"the",
"parameters",
"of",
"the",
"Higgs",
"potential",
"given",
"the",
"physical",
"Higgs",
"VEV",
"and",
"mass",
"."
] | 4c9130e53ad4f7bbb526657a82150ca9d57c4b37 | https://github.com/DsixTools/python-smeftrunner/blob/4c9130e53ad4f7bbb526657a82150ca9d57c4b37/smeftrunner/smpar.py#L52-L69 | train | Function to numerically determine the parameters of the Higgs potential
given the physical Higgs VEV and mass. |
DsixTools/python-smeftrunner | smeftrunner/smpar.py | get_gpbar | def get_gpbar(ebar, gbar, v, C, scale_high):
r"""Function to numerically determine the hypercharge gauge coupling
in terms of $\bar e$, $\bar g$, v, and the Wilson coefficients."""
if C['phiWB'] == 0: # this is the trivial case
gpbar = ebar * gbar / sqrt(gbar**2 - ebar**2)
else: # if epsilon !... | python | def get_gpbar(ebar, gbar, v, C, scale_high):
r"""Function to numerically determine the hypercharge gauge coupling
in terms of $\bar e$, $\bar g$, v, and the Wilson coefficients."""
if C['phiWB'] == 0: # this is the trivial case
gpbar = ebar * gbar / sqrt(gbar**2 - ebar**2)
else: # if epsilon !... | [
"def",
"get_gpbar",
"(",
"ebar",
",",
"gbar",
",",
"v",
",",
"C",
",",
"scale_high",
")",
":",
"if",
"C",
"[",
"'phiWB'",
"]",
"==",
"0",
":",
"# this is the trivial case",
"gpbar",
"=",
"ebar",
"*",
"gbar",
"/",
"sqrt",
"(",
"gbar",
"**",
"2",
"-"... | r"""Function to numerically determine the hypercharge gauge coupling
in terms of $\bar e$, $\bar g$, v, and the Wilson coefficients. | [
"r",
"Function",
"to",
"numerically",
"determine",
"the",
"hypercharge",
"gauge",
"coupling",
"in",
"terms",
"of",
"$",
"\\",
"bar",
"e$",
"$",
"\\",
"bar",
"g$",
"v",
"and",
"the",
"Wilson",
"coefficients",
"."
] | 4c9130e53ad4f7bbb526657a82150ca9d57c4b37 | https://github.com/DsixTools/python-smeftrunner/blob/4c9130e53ad4f7bbb526657a82150ca9d57c4b37/smeftrunner/smpar.py#L72-L86 | train | r Function to numerically determine the hypercharge gauge coupling
entric elements in terms of ebar gbar v and the Wilson coefficients. |
Kortemme-Lab/klab | klab/general/structures.py | nested_dict.update | def update(self, u):
''' Works like dict.update(dict) but handles nested dicts.
From http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth.
'''
for k, v in u.iteritems():
if isinstance(v, collections.Mapping):
r = ... | python | def update(self, u):
''' Works like dict.update(dict) but handles nested dicts.
From http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth.
'''
for k, v in u.iteritems():
if isinstance(v, collections.Mapping):
r = ... | [
"def",
"update",
"(",
"self",
",",
"u",
")",
":",
"for",
"k",
",",
"v",
"in",
"u",
".",
"iteritems",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"collections",
".",
"Mapping",
")",
":",
"r",
"=",
"nested_dict",
".",
"from_dict",
"(",
"self"... | Works like dict.update(dict) but handles nested dicts.
From http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth. | [
"Works",
"like",
"dict",
".",
"update",
"(",
"dict",
")",
"but",
"handles",
"nested",
"dicts",
".",
"From",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"3232943",
"/",
"update",
"-",
"value",
"-",
"of",
"-",
"a",
"-",
"nest... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/general/structures.py#L81-L93 | train | Updates the internal dictionary with the contents of u. |
TheGhouls/oct | oct/results/writer.py | ReportWriter.set_statics | def set_statics(self):
"""Create statics directory and copy files in it
"""
if not os.path.exists(self.results_dir):
return None
try:
shutil.copytree(os.path.join(self.templates_dir, 'css'), os.path.join(self.results_dir, 'css'))
shutil.copytree(os.pat... | python | def set_statics(self):
"""Create statics directory and copy files in it
"""
if not os.path.exists(self.results_dir):
return None
try:
shutil.copytree(os.path.join(self.templates_dir, 'css'), os.path.join(self.results_dir, 'css'))
shutil.copytree(os.pat... | [
"def",
"set_statics",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"results_dir",
")",
":",
"return",
"None",
"try",
":",
"shutil",
".",
"copytree",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
... | Create statics directory and copy files in it | [
"Create",
"statics",
"directory",
"and",
"copy",
"files",
"in",
"it"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/results/writer.py#L18-L35 | train | Create statics directory and copy files in it
|
TheGhouls/oct | oct/results/writer.py | ReportWriter.write_report | def write_report(self, template):
"""Write the compiled jinja template to the results file
:param template str: the compiled jinja template
"""
with open(self.fn, 'w') as f:
f.write(template) | python | def write_report(self, template):
"""Write the compiled jinja template to the results file
:param template str: the compiled jinja template
"""
with open(self.fn, 'w') as f:
f.write(template) | [
"def",
"write_report",
"(",
"self",
",",
"template",
")",
":",
"with",
"open",
"(",
"self",
".",
"fn",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"template",
")"
] | Write the compiled jinja template to the results file
:param template str: the compiled jinja template | [
"Write",
"the",
"compiled",
"jinja",
"template",
"to",
"the",
"results",
"file"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/results/writer.py#L37-L43 | train | Write the compiled jinja template to the results file
|
Sabesto/pyflexit | pyflexit/pyflexit.py | pyflexit.get_raw_input_register | def get_raw_input_register(self, name):
"""Get raw register value by name."""
if self._update_on_read:
self.update()
return self._input_regs[name] | python | def get_raw_input_register(self, name):
"""Get raw register value by name."""
if self._update_on_read:
self.update()
return self._input_regs[name] | [
"def",
"get_raw_input_register",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_update_on_read",
":",
"self",
".",
"update",
"(",
")",
"return",
"self",
".",
"_input_regs",
"[",
"name",
"]"
] | Get raw register value by name. | [
"Get",
"raw",
"register",
"value",
"by",
"name",
"."
] | b88c235fe1659c82c09fd5d3a16c59d407fcf94c | https://github.com/Sabesto/pyflexit/blob/b88c235fe1659c82c09fd5d3a16c59d407fcf94c/pyflexit/pyflexit.py#L159-L163 | train | Get raw input register value by name. |
Sabesto/pyflexit | pyflexit/pyflexit.py | pyflexit.get_raw_holding_register | def get_raw_holding_register(self, name):
"""Get raw register value by name."""
if self._update_on_read:
self.update()
return self._holding_regs[name] | python | def get_raw_holding_register(self, name):
"""Get raw register value by name."""
if self._update_on_read:
self.update()
return self._holding_regs[name] | [
"def",
"get_raw_holding_register",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_update_on_read",
":",
"self",
".",
"update",
"(",
")",
"return",
"self",
".",
"_holding_regs",
"[",
"name",
"]"
] | Get raw register value by name. | [
"Get",
"raw",
"register",
"value",
"by",
"name",
"."
] | b88c235fe1659c82c09fd5d3a16c59d407fcf94c | https://github.com/Sabesto/pyflexit/blob/b88c235fe1659c82c09fd5d3a16c59d407fcf94c/pyflexit/pyflexit.py#L165-L169 | train | Get the raw value of a holding register by name. |
Sabesto/pyflexit | pyflexit/pyflexit.py | pyflexit.set_raw_holding_register | def set_raw_holding_register(self, name, value):
"""Write to register by name."""
self._conn.write_register(
unit=self._slave,
address=(self._holding_regs[name]['addr']),
value=value) | python | def set_raw_holding_register(self, name, value):
"""Write to register by name."""
self._conn.write_register(
unit=self._slave,
address=(self._holding_regs[name]['addr']),
value=value) | [
"def",
"set_raw_holding_register",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"_conn",
".",
"write_register",
"(",
"unit",
"=",
"self",
".",
"_slave",
",",
"address",
"=",
"(",
"self",
".",
"_holding_regs",
"[",
"name",
"]",
"[",
"'... | Write to register by name. | [
"Write",
"to",
"register",
"by",
"name",
"."
] | b88c235fe1659c82c09fd5d3a16c59d407fcf94c | https://github.com/Sabesto/pyflexit/blob/b88c235fe1659c82c09fd5d3a16c59d407fcf94c/pyflexit/pyflexit.py#L171-L176 | train | Write to register by name. |
ronhanson/python-tbx | tbx/file.py | full_file_list | def full_file_list(scan_path):
"""
Returns a list of all files in a folder and its subfolders (only files).
"""
file_list = []
path = os.path.abspath(scan_path)
for root, dirs, files in os.walk(path):
if len(files) != 0 and not '.svn' in root and not '.git' in root:
for f in ... | python | def full_file_list(scan_path):
"""
Returns a list of all files in a folder and its subfolders (only files).
"""
file_list = []
path = os.path.abspath(scan_path)
for root, dirs, files in os.walk(path):
if len(files) != 0 and not '.svn' in root and not '.git' in root:
for f in ... | [
"def",
"full_file_list",
"(",
"scan_path",
")",
":",
"file_list",
"=",
"[",
"]",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"scan_path",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"if",
... | Returns a list of all files in a folder and its subfolders (only files). | [
"Returns",
"a",
"list",
"of",
"all",
"files",
"in",
"a",
"folder",
"and",
"its",
"subfolders",
"(",
"only",
"files",
")",
"."
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/file.py#L17-L27 | train | Returns a list of all files in a folder and its subfolders. |
ronhanson/python-tbx | tbx/file.py | list_files | def list_files(scan_path, contains=None):
"""
Returns a list of all files in a folder, without subfolders (only files).
"""
file_list = []
path = os.path.abspath(scan_path)
for f in sorted(os.listdir(path)):
if contains and f.find(contains) < 0:
continue
filepath = os... | python | def list_files(scan_path, contains=None):
"""
Returns a list of all files in a folder, without subfolders (only files).
"""
file_list = []
path = os.path.abspath(scan_path)
for f in sorted(os.listdir(path)):
if contains and f.find(contains) < 0:
continue
filepath = os... | [
"def",
"list_files",
"(",
"scan_path",
",",
"contains",
"=",
"None",
")",
":",
"file_list",
"=",
"[",
"]",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"scan_path",
")",
"for",
"f",
"in",
"sorted",
"(",
"os",
".",
"listdir",
"(",
"path",
")... | Returns a list of all files in a folder, without subfolders (only files). | [
"Returns",
"a",
"list",
"of",
"all",
"files",
"in",
"a",
"folder",
"without",
"subfolders",
"(",
"only",
"files",
")",
"."
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/file.py#L30-L42 | train | Returns a list of all files in a folder without subfolders. |
ronhanson/python-tbx | tbx/file.py | full_file_list_with_sequence | def full_file_list_with_sequence(scan_path):
"""
Returns a list of all files in a folder and its subfolders (only files).
"""
file_list = []
path = os.path.abspath(scan_path)
for root, dirs, files in os.walk(path):
if len(files) != 0 and not '.svn' in root and not '.git' in roo... | python | def full_file_list_with_sequence(scan_path):
"""
Returns a list of all files in a folder and its subfolders (only files).
"""
file_list = []
path = os.path.abspath(scan_path)
for root, dirs, files in os.walk(path):
if len(files) != 0 and not '.svn' in root and not '.git' in roo... | [
"def",
"full_file_list_with_sequence",
"(",
"scan_path",
")",
":",
"file_list",
"=",
"[",
"]",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"scan_path",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
... | Returns a list of all files in a folder and its subfolders (only files). | [
"Returns",
"a",
"list",
"of",
"all",
"files",
"in",
"a",
"folder",
"and",
"its",
"subfolders",
"(",
"only",
"files",
")",
"."
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/file.py#L45-L65 | train | Returns a list of all files in a folder and its subfolders with sequence number. |
ronhanson/python-tbx | tbx/file.py | readlinkabs | def readlinkabs(l):
"""
Return an absolute path for the destination
of a symlink
"""
assert (os.path.islink(l))
p = os.readlink(l)
if os.path.isabs(p):
return os.path.abspath(p)
return os.path.abspath(os.path.join(os.path.dirname(l), p)) | python | def readlinkabs(l):
"""
Return an absolute path for the destination
of a symlink
"""
assert (os.path.islink(l))
p = os.readlink(l)
if os.path.isabs(p):
return os.path.abspath(p)
return os.path.abspath(os.path.join(os.path.dirname(l), p)) | [
"def",
"readlinkabs",
"(",
"l",
")",
":",
"assert",
"(",
"os",
".",
"path",
".",
"islink",
"(",
"l",
")",
")",
"p",
"=",
"os",
".",
"readlink",
"(",
"l",
")",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"p",
")",
":",
"return",
"os",
".",
"... | Return an absolute path for the destination
of a symlink | [
"Return",
"an",
"absolute",
"path",
"for",
"the",
"destination",
"of",
"a",
"symlink"
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/file.py#L68-L77 | train | Return an absolute path for the destination
of a symlink |
ronhanson/python-tbx | tbx/file.py | unzip | def unzip(filepath, output_path):
"""
Unzip an archive file
"""
filename = os.path.split(filepath)[1]
(name, extension) = os.path.splitext(filename)
extension = extension[1:].lower()
extension2 = os.path.splitext(name)[1][1:].lower()
if extension not in ZIP_EXTENSIONS:
raise Exc... | python | def unzip(filepath, output_path):
"""
Unzip an archive file
"""
filename = os.path.split(filepath)[1]
(name, extension) = os.path.splitext(filename)
extension = extension[1:].lower()
extension2 = os.path.splitext(name)[1][1:].lower()
if extension not in ZIP_EXTENSIONS:
raise Exc... | [
"def",
"unzip",
"(",
"filepath",
",",
"output_path",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filepath",
")",
"[",
"1",
"]",
"(",
"name",
",",
"extension",
")",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",... | Unzip an archive file | [
"Unzip",
"an",
"archive",
"file"
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/file.py#L80-L152 | train | Unzip an archive file |
TheGhouls/oct | oct/core/hq.py | HightQuarter._configure_sockets | def _configure_sockets(self, config, with_streamer=False, with_forwarder=False):
"""Configure sockets for HQ
:param dict config: test configuration
:param bool with_streamer: tell if we need to connect to streamer or simply bind
:param bool with_forwarder: tell if we need to connect to ... | python | def _configure_sockets(self, config, with_streamer=False, with_forwarder=False):
"""Configure sockets for HQ
:param dict config: test configuration
:param bool with_streamer: tell if we need to connect to streamer or simply bind
:param bool with_forwarder: tell if we need to connect to ... | [
"def",
"_configure_sockets",
"(",
"self",
",",
"config",
",",
"with_streamer",
"=",
"False",
",",
"with_forwarder",
"=",
"False",
")",
":",
"rc_port",
"=",
"config",
".",
"get",
"(",
"'rc_port'",
",",
"5001",
")",
"self",
".",
"result_collector",
".",
"set... | Configure sockets for HQ
:param dict config: test configuration
:param bool with_streamer: tell if we need to connect to streamer or simply bind
:param bool with_forwarder: tell if we need to connect to forwarder or simply bind | [
"Configure",
"sockets",
"for",
"HQ"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/hq.py#L75-L87 | train | Configure sockets for HQ
|
TheGhouls/oct | oct/core/hq.py | HightQuarter.wait_turrets | def wait_turrets(self, wait_for):
"""Wait until wait_for turrets are connected and ready
"""
print("Waiting for %d turrets" % (wait_for - len(self.turrets_manager.turrets)))
while len(self.turrets_manager.turrets) < wait_for:
self.turrets_manager.status_request()
... | python | def wait_turrets(self, wait_for):
"""Wait until wait_for turrets are connected and ready
"""
print("Waiting for %d turrets" % (wait_for - len(self.turrets_manager.turrets)))
while len(self.turrets_manager.turrets) < wait_for:
self.turrets_manager.status_request()
... | [
"def",
"wait_turrets",
"(",
"self",
",",
"wait_for",
")",
":",
"print",
"(",
"\"Waiting for %d turrets\"",
"%",
"(",
"wait_for",
"-",
"len",
"(",
"self",
".",
"turrets_manager",
".",
"turrets",
")",
")",
")",
"while",
"len",
"(",
"self",
".",
"turrets_mana... | Wait until wait_for turrets are connected and ready | [
"Wait",
"until",
"wait_for",
"turrets",
"are",
"connected",
"and",
"ready"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/hq.py#L119-L133 | train | Wait until wait_for turrets are connected and ready |
TheGhouls/oct | oct/core/hq.py | HightQuarter.run | def run(self):
"""Run the hight quarter, lunch the turrets and wait for results
"""
elapsed = 0
run_time = self.config['run_time']
start_time = time.time()
t = time.time
self.turrets_manager.start(self.transaction_context)
self.started = True
whil... | python | def run(self):
"""Run the hight quarter, lunch the turrets and wait for results
"""
elapsed = 0
run_time = self.config['run_time']
start_time = time.time()
t = time.time
self.turrets_manager.start(self.transaction_context)
self.started = True
whil... | [
"def",
"run",
"(",
"self",
")",
":",
"elapsed",
"=",
"0",
"run_time",
"=",
"self",
".",
"config",
"[",
"'run_time'",
"]",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"t",
"=",
"time",
".",
"time",
"self",
".",
"turrets_manager",
".",
"start",
... | Run the hight quarter, lunch the turrets and wait for results | [
"Run",
"the",
"hight",
"quarter",
"lunch",
"the",
"turrets",
"and",
"wait",
"for",
"results"
] | 7e9bddeb3b8495a26442b1c86744e9fb187fe88f | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/hq.py#L135-L162 | train | Run the hight quarter lunch the turrets and wait for results |
Kortemme-Lab/klab | klab/bio/fragments/hpc/SGE.py | submit | def submit(command_filename, workingdir, send_mail = False, username = None):
'''Submit the given command filename to the queue. Adapted from the qb3 example.'''
return sge_interface.submit(command_filename, workingdir, send_mail = send_mail, username = username) | python | def submit(command_filename, workingdir, send_mail = False, username = None):
'''Submit the given command filename to the queue. Adapted from the qb3 example.'''
return sge_interface.submit(command_filename, workingdir, send_mail = send_mail, username = username) | [
"def",
"submit",
"(",
"command_filename",
",",
"workingdir",
",",
"send_mail",
"=",
"False",
",",
"username",
"=",
"None",
")",
":",
"return",
"sge_interface",
".",
"submit",
"(",
"command_filename",
",",
"workingdir",
",",
"send_mail",
"=",
"send_mail",
",",
... | Submit the given command filename to the queue. Adapted from the qb3 example. | [
"Submit",
"the",
"given",
"command",
"filename",
"to",
"the",
"queue",
".",
"Adapted",
"from",
"the",
"qb3",
"example",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fragments/hpc/SGE.py#L145-L147 | train | Submit the given command filename to the queue. |
Kortemme-Lab/klab | klab/bio/fragments/hpc/SGE.py | query | def query(logfile, jobID = None):
"""If jobID is an integer then return False if the job has finished and True if it is still running.
Otherwise, returns a table of jobs run by the user."""
joblist = logfile.readFromLogfile()
if jobID and type(jobID) == type(1):
command = ['qstat', '-j',... | python | def query(logfile, jobID = None):
"""If jobID is an integer then return False if the job has finished and True if it is still running.
Otherwise, returns a table of jobs run by the user."""
joblist = logfile.readFromLogfile()
if jobID and type(jobID) == type(1):
command = ['qstat', '-j',... | [
"def",
"query",
"(",
"logfile",
",",
"jobID",
"=",
"None",
")",
":",
"joblist",
"=",
"logfile",
".",
"readFromLogfile",
"(",
")",
"if",
"jobID",
"and",
"type",
"(",
"jobID",
")",
"==",
"type",
"(",
"1",
")",
":",
"command",
"=",
"[",
"'qstat'",
","... | If jobID is an integer then return False if the job has finished and True if it is still running.
Otherwise, returns a table of jobs run by the user. | [
"If",
"jobID",
"is",
"an",
"integer",
"then",
"return",
"False",
"if",
"the",
"job",
"has",
"finished",
"and",
"True",
"if",
"it",
"is",
"still",
"running",
".",
"Otherwise",
"returns",
"a",
"table",
"of",
"jobs",
"run",
"by",
"the",
"user",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fragments/hpc/SGE.py#L150-L210 | train | Query the jobs in the specified log file. |
thespacedoctor/HMpTy | HMpTy/cl_utils.py | main | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="DEBUG",
option... | python | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="DEBUG",
option... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# setup the command-line util settings",
"su",
"=",
"tools",
"(",
"arguments",
"=",
"arguments",
",",
"docString",
"=",
"__doc__",
",",
"logLevel",
"=",
"\"DEBUG\"",
",",
"options_first",
"=",
"False",
"... | *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* | [
"*",
"The",
"main",
"function",
"used",
"when",
"cl_utils",
".",
"py",
"is",
"run",
"as",
"a",
"single",
"script",
"from",
"the",
"cl",
"or",
"when",
"installed",
"as",
"a",
"cl",
"command",
"*"
] | 3ce2bdb7ce3351468962ab907ede9a6074c15912 | https://github.com/thespacedoctor/HMpTy/blob/3ce2bdb7ce3351468962ab907ede9a6074c15912/HMpTy/cl_utils.py#L52-L158 | train | This function is the main function used by the cl_utils. py module. |
PBR/MQ2 | MQ2/__init__.py | set_tmp_folder | def set_tmp_folder():
""" Create a temporary folder using the current time in which
the zip can be extracted and which should be destroyed afterward.
"""
output = "%s" % datetime.datetime.now()
for char in [' ', ':', '.', '-']:
output = output.replace(char, '')
output.strip()
tmp_fol... | python | def set_tmp_folder():
""" Create a temporary folder using the current time in which
the zip can be extracted and which should be destroyed afterward.
"""
output = "%s" % datetime.datetime.now()
for char in [' ', ':', '.', '-']:
output = output.replace(char, '')
output.strip()
tmp_fol... | [
"def",
"set_tmp_folder",
"(",
")",
":",
"output",
"=",
"\"%s\"",
"%",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"for",
"char",
"in",
"[",
"' '",
",",
"':'",
",",
"'.'",
",",
"'-'",
"]",
":",
"output",
"=",
"output",
".",
"replace",
"(",
... | Create a temporary folder using the current time in which
the zip can be extracted and which should be destroyed afterward. | [
"Create",
"a",
"temporary",
"folder",
"using",
"the",
"current",
"time",
"in",
"which",
"the",
"zip",
"can",
"be",
"extracted",
"and",
"which",
"should",
"be",
"destroyed",
"afterward",
"."
] | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/__init__.py#L39-L48 | train | Create a temporary folder using the current time in which
the zip can be extracted and which should be destroyed afterward. |
PBR/MQ2 | MQ2/__init__.py | extract_zip | def extract_zip(filename, extract_dir):
""" Extract the sources in a temporary folder.
:arg filename, name of the zip file containing the data from MapQTL
which will be extracted
:arg extract_dir, folder in which to extract the archive.
"""
LOG.info("Extracting %s in %s " % (filename, extract_di... | python | def extract_zip(filename, extract_dir):
""" Extract the sources in a temporary folder.
:arg filename, name of the zip file containing the data from MapQTL
which will be extracted
:arg extract_dir, folder in which to extract the archive.
"""
LOG.info("Extracting %s in %s " % (filename, extract_di... | [
"def",
"extract_zip",
"(",
"filename",
",",
"extract_dir",
")",
":",
"LOG",
".",
"info",
"(",
"\"Extracting %s in %s \"",
"%",
"(",
"filename",
",",
"extract_dir",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"extract_dir",
")",
":",
"tr... | Extract the sources in a temporary folder.
:arg filename, name of the zip file containing the data from MapQTL
which will be extracted
:arg extract_dir, folder in which to extract the archive. | [
"Extract",
"the",
"sources",
"in",
"a",
"temporary",
"folder",
".",
":",
"arg",
"filename",
"name",
"of",
"the",
"zip",
"file",
"containing",
"the",
"data",
"from",
"MapQTL",
"which",
"will",
"be",
"extracted",
":",
"arg",
"extract_dir",
"folder",
"in",
"w... | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/__init__.py#L51-L92 | train | Extract the sources from a zip file. |
PBR/MQ2 | MQ2/__init__.py | get_matrix_dimensions | def get_matrix_dimensions(filename):
""" Reads in a matrix file (comma separated) and returns the number
of rows and columns.
:arg filename, the full path to the file to read.
"""
stream = None
try:
stream = open(filename, 'r')
length = len(stream.readlines())
stream.seek... | python | def get_matrix_dimensions(filename):
""" Reads in a matrix file (comma separated) and returns the number
of rows and columns.
:arg filename, the full path to the file to read.
"""
stream = None
try:
stream = open(filename, 'r')
length = len(stream.readlines())
stream.seek... | [
"def",
"get_matrix_dimensions",
"(",
"filename",
")",
":",
"stream",
"=",
"None",
"try",
":",
"stream",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"length",
"=",
"len",
"(",
"stream",
".",
"readlines",
"(",
")",
")",
"stream",
".",
"seek",
"(",
"... | Reads in a matrix file (comma separated) and returns the number
of rows and columns.
:arg filename, the full path to the file to read. | [
"Reads",
"in",
"a",
"matrix",
"file",
"(",
"comma",
"separated",
")",
"and",
"returns",
"the",
"number",
"of",
"rows",
"and",
"columns",
".",
":",
"arg",
"filename",
"the",
"full",
"path",
"to",
"the",
"file",
"to",
"read",
"."
] | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/__init__.py#L95-L113 | train | Reads in a matrix file and returns the number of rows and columns. |
PBR/MQ2 | MQ2/__init__.py | read_input_file | def read_input_file(filename, sep='\t', noquote=False):
"""Reads a given inputfile (tab delimited) and returns a matrix
(list of list).
arg: filename, the complete path to the inputfile to read
"""
output = []
stream = None
try:
stream = open(filename, 'r')
for row in stream:... | python | def read_input_file(filename, sep='\t', noquote=False):
"""Reads a given inputfile (tab delimited) and returns a matrix
(list of list).
arg: filename, the complete path to the inputfile to read
"""
output = []
stream = None
try:
stream = open(filename, 'r')
for row in stream:... | [
"def",
"read_input_file",
"(",
"filename",
",",
"sep",
"=",
"'\\t'",
",",
"noquote",
"=",
"False",
")",
":",
"output",
"=",
"[",
"]",
"stream",
"=",
"None",
"try",
":",
"stream",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"for",
"row",
"in",
"s... | Reads a given inputfile (tab delimited) and returns a matrix
(list of list).
arg: filename, the complete path to the inputfile to read | [
"Reads",
"a",
"given",
"inputfile",
"(",
"tab",
"delimited",
")",
"and",
"returns",
"a",
"matrix",
"(",
"list",
"of",
"list",
")",
".",
"arg",
":",
"filename",
"the",
"complete",
"path",
"to",
"the",
"inputfile",
"to",
"read"
] | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/__init__.py#L116-L137 | train | Reads a given inputfile and returns a list of lists. |
PBR/MQ2 | MQ2/__init__.py | write_matrix | def write_matrix(outputfile, matrix):
""" Write down the provided matrix in the specified outputfile.
:arg outputfile, name of the outputfile in which the QTLs found are
written.
:arg matrix, the list of lists of data to write.
"""
try:
stream = open(outputfile, 'w')
for row... | python | def write_matrix(outputfile, matrix):
""" Write down the provided matrix in the specified outputfile.
:arg outputfile, name of the outputfile in which the QTLs found are
written.
:arg matrix, the list of lists of data to write.
"""
try:
stream = open(outputfile, 'w')
for row... | [
"def",
"write_matrix",
"(",
"outputfile",
",",
"matrix",
")",
":",
"try",
":",
"stream",
"=",
"open",
"(",
"outputfile",
",",
"'w'",
")",
"for",
"row",
"in",
"matrix",
":",
"if",
"isinstance",
"(",
"row",
",",
"list",
")",
"or",
"isinstance",
"(",
"r... | Write down the provided matrix in the specified outputfile.
:arg outputfile, name of the outputfile in which the QTLs found are
written.
:arg matrix, the list of lists of data to write. | [
"Write",
"down",
"the",
"provided",
"matrix",
"in",
"the",
"specified",
"outputfile",
".",
":",
"arg",
"outputfile",
"name",
"of",
"the",
"outputfile",
"in",
"which",
"the",
"QTLs",
"found",
"are",
"written",
".",
":",
"arg",
"matrix",
"the",
"list",
"of",... | 6d84dea47e6751333004743f588f03158e35c28d | https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/__init__.py#L140-L161 | train | Write down the provided matrix of QTLs in the specified outputfile. |
projectshift/shift-boiler | boiler/log/file.py | file_logger | def file_logger(app, level=None):
"""
Get file logger
Returns configured fire logger ready to be attached to app
:param app: application instance
:param level: log this level
:return: RotatingFileHandler
"""
path = os.path.join(os.getcwd(), 'var', 'logs', 'app.... | python | def file_logger(app, level=None):
"""
Get file logger
Returns configured fire logger ready to be attached to app
:param app: application instance
:param level: log this level
:return: RotatingFileHandler
"""
path = os.path.join(os.getcwd(), 'var', 'logs', 'app.... | [
"def",
"file_logger",
"(",
"app",
",",
"level",
"=",
"None",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'var'",
",",
"'logs'",
",",
"'app.log'",
")",
"max_bytes",
"=",
"1024",
"*",
"1024",
"*"... | Get file logger
Returns configured fire logger ready to be attached to app
:param app: application instance
:param level: log this level
:return: RotatingFileHandler | [
"Get",
"file",
"logger",
"Returns",
"configured",
"fire",
"logger",
"ready",
"to",
"be",
"attached",
"to",
"app"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/log/file.py#L5-L31 | train | Returns a RotatingFileHandler that will log the file at the specified level. |
TUNE-Archive/freight_forwarder | freight_forwarder/image.py | Image.tag | def tag(self, repository_tag, tags=[]):
"""
Tags image with one or more tags.
Raises exception on failure.
"""
if not isinstance(repository_tag, six.string_types):
raise TypeError('repository_tag must be a string')
if not isinstance(tags, list):
... | python | def tag(self, repository_tag, tags=[]):
"""
Tags image with one or more tags.
Raises exception on failure.
"""
if not isinstance(repository_tag, six.string_types):
raise TypeError('repository_tag must be a string')
if not isinstance(tags, list):
... | [
"def",
"tag",
"(",
"self",
",",
"repository_tag",
",",
"tags",
"=",
"[",
"]",
")",
":",
"if",
"not",
"isinstance",
"(",
"repository_tag",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'repository_tag must be a string'",
")",
"if",
... | Tags image with one or more tags.
Raises exception on failure. | [
"Tags",
"image",
"with",
"one",
"or",
"more",
"tags",
"."
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/image.py#L52-L84 | train | Tags image with one or more tags. |
TUNE-Archive/freight_forwarder | freight_forwarder/image.py | Image._inspect_and_map | def _inspect_and_map(self, identifier):
"""
example response:
{
u'comment': u'',
u'virtual_size': 566087127,
u'container': u'a2ea130e8c7a945823c804253c20f7c877376c69a36311a0cc614d5c455f645f',
u'os': u'linux',
u'p... | python | def _inspect_and_map(self, identifier):
"""
example response:
{
u'comment': u'',
u'virtual_size': 566087127,
u'container': u'a2ea130e8c7a945823c804253c20f7c877376c69a36311a0cc614d5c455f645f',
u'os': u'linux',
u'p... | [
"def",
"_inspect_and_map",
"(",
"self",
",",
"identifier",
")",
":",
"# validate",
"try",
":",
"response",
"=",
"normalize_keys",
"(",
"self",
".",
"client",
".",
"inspect_image",
"(",
"identifier",
")",
")",
"self",
".",
"comment",
"=",
"response",
"[",
"... | example response:
{
u'comment': u'',
u'virtual_size': 566087127,
u'container': u'a2ea130e8c7a945823c804253c20f7c877376c69a36311a0cc614d5c455f645f',
u'os': u'linux',
u'parent': u'14e75a5684c2fabb7db24d92bdda09d11da1179a7d86ab4c96... | [
"example",
"response",
":",
"{",
"u",
"comment",
":",
"u",
"u",
"virtual_size",
":",
"566087127",
"u",
"container",
":",
"u",
"a2ea130e8c7a945823c804253c20f7c877376c69a36311a0cc614d5c455f645f",
"u",
"os",
":",
"u",
"linux",
"u",
"parent",
":",
"u",
"14e75a5684c2fa... | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/image.py#L98-L209 | train | This function returns a dict of the information for a specific class. |
TUNE-Archive/freight_forwarder | freight_forwarder/image.py | Image.build | def build(client, repository_tag, docker_file, tag=None, use_cache=False):
"""
Build a docker image
"""
if not isinstance(client, docker.Client):
raise TypeError("client needs to be of type docker.Client.")
if not isinstance(docker_file, six.string_types) or not os.p... | python | def build(client, repository_tag, docker_file, tag=None, use_cache=False):
"""
Build a docker image
"""
if not isinstance(client, docker.Client):
raise TypeError("client needs to be of type docker.Client.")
if not isinstance(docker_file, six.string_types) or not os.p... | [
"def",
"build",
"(",
"client",
",",
"repository_tag",
",",
"docker_file",
",",
"tag",
"=",
"None",
",",
"use_cache",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"client",
",",
"docker",
".",
"Client",
")",
":",
"raise",
"TypeError",
"(",
"\... | Build a docker image | [
"Build",
"a",
"docker",
"image"
] | 6ea4a49f474ec04abb8bb81b175c774a16b5312f | https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/image.py#L322-L378 | train | Build a docker image and return the ID of the image. |
uw-it-aca/uw-restclients-sws | uw_sws/enrollment.py | get_grades_by_regid_and_term | def get_grades_by_regid_and_term(regid, term):
"""
Returns a StudentGrades model for the regid and term.
"""
url = "{}/{},{},{}.json".format(enrollment_res_url_prefix,
term.year,
term.quarter,
reg... | python | def get_grades_by_regid_and_term(regid, term):
"""
Returns a StudentGrades model for the regid and term.
"""
url = "{}/{},{},{}.json".format(enrollment_res_url_prefix,
term.year,
term.quarter,
reg... | [
"def",
"get_grades_by_regid_and_term",
"(",
"regid",
",",
"term",
")",
":",
"url",
"=",
"\"{}/{},{},{}.json\"",
".",
"format",
"(",
"enrollment_res_url_prefix",
",",
"term",
".",
"year",
",",
"term",
".",
"quarter",
",",
"regid",
")",
"return",
"_json_to_grades"... | Returns a StudentGrades model for the regid and term. | [
"Returns",
"a",
"StudentGrades",
"model",
"for",
"the",
"regid",
"and",
"term",
"."
] | 4d36776dcca36855fc15c1b8fe7650ae045194cf | https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/enrollment.py#L21-L29 | train | Returns a StudentGrades model for the regid and term. |
uw-it-aca/uw-restclients-sws | uw_sws/enrollment.py | _enrollment_search | def _enrollment_search(regid, verbose, transcriptable, changed_since_date):
"""
See SWS Enrollment search resource spec at:
https://wiki.cac.washington.edu/x/_qjeAw
:return: search result json data
"""
url = "{}{}&{}".format(enrollment_search_url_prefix,
regid,
... | python | def _enrollment_search(regid, verbose, transcriptable, changed_since_date):
"""
See SWS Enrollment search resource spec at:
https://wiki.cac.washington.edu/x/_qjeAw
:return: search result json data
"""
url = "{}{}&{}".format(enrollment_search_url_prefix,
regid,
... | [
"def",
"_enrollment_search",
"(",
"regid",
",",
"verbose",
",",
"transcriptable",
",",
"changed_since_date",
")",
":",
"url",
"=",
"\"{}{}&{}\"",
".",
"format",
"(",
"enrollment_search_url_prefix",
",",
"regid",
",",
"urlencode",
"(",
"{",
"\"verbose\"",
":",
"v... | See SWS Enrollment search resource spec at:
https://wiki.cac.washington.edu/x/_qjeAw
:return: search result json data | [
"See",
"SWS",
"Enrollment",
"search",
"resource",
"spec",
"at",
":",
"https",
":",
"//",
"wiki",
".",
"cac",
".",
"washington",
".",
"edu",
"/",
"x",
"/",
"_qjeAw",
":",
"return",
":",
"search",
"result",
"json",
"data"
] | 4d36776dcca36855fc15c1b8fe7650ae045194cf | https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/enrollment.py#L52-L64 | train | Search for an enrollment list. |
uw-it-aca/uw-restclients-sws | uw_sws/enrollment.py | enrollment_search_by_regid | def enrollment_search_by_regid(regid,
verbose='true',
transcriptable_course='all',
changed_since_date='',
include_unfinished_pce_course_reg=True):
"""
:return: a dictionary of {Term: Enrol... | python | def enrollment_search_by_regid(regid,
verbose='true',
transcriptable_course='all',
changed_since_date='',
include_unfinished_pce_course_reg=True):
"""
:return: a dictionary of {Term: Enrol... | [
"def",
"enrollment_search_by_regid",
"(",
"regid",
",",
"verbose",
"=",
"'true'",
",",
"transcriptable_course",
"=",
"'all'",
",",
"changed_since_date",
"=",
"''",
",",
"include_unfinished_pce_course_reg",
"=",
"True",
")",
":",
"return",
"_json_to_term_enrollment_dict"... | :return: a dictionary of {Term: Enrollment} | [
":",
"return",
":",
"a",
"dictionary",
"of",
"{",
"Term",
":",
"Enrollment",
"}"
] | 4d36776dcca36855fc15c1b8fe7650ae045194cf | https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/enrollment.py#L67-L78 | train | Search for an enrollment by the given regid. |
uw-it-aca/uw-restclients-sws | uw_sws/enrollment.py | get_enrollment_history_by_regid | def get_enrollment_history_by_regid(regid,
verbose='true',
transcriptable_course='all',
changed_since_date='',
include_unfinished_pce_course_reg=False):
"""
:return: a ... | python | def get_enrollment_history_by_regid(regid,
verbose='true',
transcriptable_course='all',
changed_since_date='',
include_unfinished_pce_course_reg=False):
"""
:return: a ... | [
"def",
"get_enrollment_history_by_regid",
"(",
"regid",
",",
"verbose",
"=",
"'true'",
",",
"transcriptable_course",
"=",
"'all'",
",",
"changed_since_date",
"=",
"''",
",",
"include_unfinished_pce_course_reg",
"=",
"False",
")",
":",
"return",
"_json_to_enrollment_list... | :return: a complete chronological list of all the enrollemnts
[Enrollment], where the Enrollment object has a term element. | [
":",
"return",
":",
"a",
"complete",
"chronological",
"list",
"of",
"all",
"the",
"enrollemnts",
"[",
"Enrollment",
"]",
"where",
"the",
"Enrollment",
"object",
"has",
"a",
"term",
"element",
"."
] | 4d36776dcca36855fc15c1b8fe7650ae045194cf | https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/enrollment.py#L216-L228 | train | Get the list of Enrollment objects that are in the registry. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber._requires_refresh_token | def _requires_refresh_token(self):
"""
Check if a refresh of the token is needed
"""
expires_on = datetime.datetime.strptime(
self.login_data['token']['expiresOn'], '%Y-%m-%dT%H:%M:%SZ')
refresh = datetime.datetime.utcnow() + datetime.timedelta(seconds=30)
ret... | python | def _requires_refresh_token(self):
"""
Check if a refresh of the token is needed
"""
expires_on = datetime.datetime.strptime(
self.login_data['token']['expiresOn'], '%Y-%m-%dT%H:%M:%SZ')
refresh = datetime.datetime.utcnow() + datetime.timedelta(seconds=30)
ret... | [
"def",
"_requires_refresh_token",
"(",
"self",
")",
":",
"expires_on",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"self",
".",
"login_data",
"[",
"'token'",
"]",
"[",
"'expiresOn'",
"]",
",",
"'%Y-%m-%dT%H:%M:%SZ'",
")",
"refresh",
"=",
"datetime"... | Check if a refresh of the token is needed | [
"Check",
"if",
"a",
"refresh",
"of",
"the",
"token",
"is",
"needed"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L32-L39 | train | Check if a refresh of the token is needed |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber._request_token | def _request_token(self, force=False):
"""
Request a new auth token
"""
if self.login_data is None:
raise RuntimeError("Don't have a token to refresh")
if not force:
if not self._requires_refresh_token():
# no need to refresh as token is v... | python | def _request_token(self, force=False):
"""
Request a new auth token
"""
if self.login_data is None:
raise RuntimeError("Don't have a token to refresh")
if not force:
if not self._requires_refresh_token():
# no need to refresh as token is v... | [
"def",
"_request_token",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"login_data",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Don't have a token to refresh\"",
")",
"if",
"not",
"force",
":",
"if",
"not",
"self",
".",
"_r... | Request a new auth token | [
"Request",
"a",
"new",
"auth",
"token"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L41-L75 | train | Request a new auth token from the API. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber._login | def _login(self):
"""
Login using username / password and get the first auth token
"""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json"
}
url = self.api_base_url + "account/directlogin"
data = ... | python | def _login(self):
"""
Login using username / password and get the first auth token
"""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json"
}
url = self.api_base_url + "account/directlogin"
data = ... | [
"def",
"_login",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"\"Content-Type\"",
":",
"\"application/x-www-form-urlencoded\"",
",",
"\"Accept\"",
":",
"\"application/json\"",
"}",
"url",
"=",
"self",
".",
"api_base_url",
"+",
"\"account/directlogin\"",
"data",
"=",
... | Login using username / password and get the first auth token | [
"Login",
"using",
"username",
"/",
"password",
"and",
"get",
"the",
"first",
"auth",
"token"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L77-L109 | train | Login using username and password and get the first auth token |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.get_home | def get_home(self, home_id=None):
"""
Get the data about a home
"""
now = datetime.datetime.utcnow()
if self.home and now < self.home_refresh_at:
return self.home
if not self._do_auth():
raise RuntimeError("Unable to login")
if home_id is... | python | def get_home(self, home_id=None):
"""
Get the data about a home
"""
now = datetime.datetime.utcnow()
if self.home and now < self.home_refresh_at:
return self.home
if not self._do_auth():
raise RuntimeError("Unable to login")
if home_id is... | [
"def",
"get_home",
"(",
"self",
",",
"home_id",
"=",
"None",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"if",
"self",
".",
"home",
"and",
"now",
"<",
"self",
".",
"home_refresh_at",
":",
"return",
"self",
".",
"home",... | Get the data about a home | [
"Get",
"the",
"data",
"about",
"a",
"home"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L121-L162 | train | Get the data about a home. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.get_zones | def get_zones(self):
"""
Get all zones
"""
home_data = self.get_home()
if not home_data['isSuccess']:
return []
zones = []
for receiver in home_data['data']['receivers']:
for zone in receiver['zones']:
zones.append(zone)
... | python | def get_zones(self):
"""
Get all zones
"""
home_data = self.get_home()
if not home_data['isSuccess']:
return []
zones = []
for receiver in home_data['data']['receivers']:
for zone in receiver['zones']:
zones.append(zone)
... | [
"def",
"get_zones",
"(",
"self",
")",
":",
"home_data",
"=",
"self",
".",
"get_home",
"(",
")",
"if",
"not",
"home_data",
"[",
"'isSuccess'",
"]",
":",
"return",
"[",
"]",
"zones",
"=",
"[",
"]",
"for",
"receiver",
"in",
"home_data",
"[",
"'data'",
"... | Get all zones | [
"Get",
"all",
"zones"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L164-L178 | train | Get all zones in the home data. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.get_zone_names | def get_zone_names(self):
"""
Get the name of all zones
"""
zone_names = []
for zone in self.get_zones():
zone_names.append(zone['name'])
return zone_names | python | def get_zone_names(self):
"""
Get the name of all zones
"""
zone_names = []
for zone in self.get_zones():
zone_names.append(zone['name'])
return zone_names | [
"def",
"get_zone_names",
"(",
"self",
")",
":",
"zone_names",
"=",
"[",
"]",
"for",
"zone",
"in",
"self",
".",
"get_zones",
"(",
")",
":",
"zone_names",
".",
"append",
"(",
"zone",
"[",
"'name'",
"]",
")",
"return",
"zone_names"
] | Get the name of all zones | [
"Get",
"the",
"name",
"of",
"all",
"zones"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L180-L188 | train | Get the name of all zones in the current session. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.get_zone | def get_zone(self, zone_name):
"""
Get the information about a particular zone
"""
for zone in self.get_zones():
if zone_name == zone['name']:
return zone
raise RuntimeError("Unknown zone") | python | def get_zone(self, zone_name):
"""
Get the information about a particular zone
"""
for zone in self.get_zones():
if zone_name == zone['name']:
return zone
raise RuntimeError("Unknown zone") | [
"def",
"get_zone",
"(",
"self",
",",
"zone_name",
")",
":",
"for",
"zone",
"in",
"self",
".",
"get_zones",
"(",
")",
":",
"if",
"zone_name",
"==",
"zone",
"[",
"'name'",
"]",
":",
"return",
"zone",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")"
] | Get the information about a particular zone | [
"Get",
"the",
"information",
"about",
"a",
"particular",
"zone"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L190-L198 | train | Get the information about a particular zone |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.is_zone_active | def is_zone_active(self, zone_name):
"""
Check if a zone is active
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unable to get zone")
return zone['isCurrentlyActive'] | python | def is_zone_active(self, zone_name):
"""
Check if a zone is active
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unable to get zone")
return zone['isCurrentlyActive'] | [
"def",
"is_zone_active",
"(",
"self",
",",
"zone_name",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to get zone\"",
")",
"return",
"zone",
"[",
"'isCurrentlyA... | Check if a zone is active | [
"Check",
"if",
"a",
"zone",
"is",
"active"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L200-L208 | train | Check if a zone is active |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.get_zone_temperature | def get_zone_temperature(self, zone_name):
"""
Get the temperature for a zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return zone['currentTemperature'] | python | def get_zone_temperature(self, zone_name):
"""
Get the temperature for a zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return zone['currentTemperature'] | [
"def",
"get_zone_temperature",
"(",
"self",
",",
"zone_name",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")",
"return",
"zone",
"[",
"'currentTempe... | Get the temperature for a zone | [
"Get",
"the",
"temperature",
"for",
"a",
"zone"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L210-L219 | train | Get the temperature for a zone |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.is_boost_active | def is_boost_active(self, zone_name):
"""
Check if a zone is active
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return zone['isBoostActive'] | python | def is_boost_active(self, zone_name):
"""
Check if a zone is active
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return zone['isBoostActive'] | [
"def",
"is_boost_active",
"(",
"self",
",",
"zone_name",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")",
"return",
"zone",
"[",
"'isBoostActive'",
... | Check if a zone is active | [
"Check",
"if",
"a",
"zone",
"is",
"active"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L221-L230 | train | Check if a zone is boost active |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.is_target_temperature_reached | def is_target_temperature_reached(self, zone_name):
"""
Check if a zone is active
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return zone['isTargetTemperatureReached'] | python | def is_target_temperature_reached(self, zone_name):
"""
Check if a zone is active
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return zone['isTargetTemperatureReached'] | [
"def",
"is_target_temperature_reached",
"(",
"self",
",",
"zone_name",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")",
"return",
"zone",
"[",
"'isT... | Check if a zone is active | [
"Check",
"if",
"a",
"zone",
"is",
"active"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L232-L241 | train | Check if target temperature is reached in a zone. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.set_target_temperature_by_id | def set_target_temperature_by_id(self, zone_id, target_temperature):
"""
Set the target temperature for a zone by id
"""
if not self._do_auth():
raise RuntimeError("Unable to login")
data = {
"ZoneId": zone_id,
"TargetTemperature": target_temp... | python | def set_target_temperature_by_id(self, zone_id, target_temperature):
"""
Set the target temperature for a zone by id
"""
if not self._do_auth():
raise RuntimeError("Unable to login")
data = {
"ZoneId": zone_id,
"TargetTemperature": target_temp... | [
"def",
"set_target_temperature_by_id",
"(",
"self",
",",
"zone_id",
",",
"target_temperature",
")",
":",
"if",
"not",
"self",
".",
"_do_auth",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to login\"",
")",
"data",
"=",
"{",
"\"ZoneId\"",
":",
"zone_i... | Set the target temperature for a zone by id | [
"Set",
"the",
"target",
"temperature",
"for",
"a",
"zone",
"by",
"id"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L243-L272 | train | Set the target temperature for a zone by id |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.set_target_temperture_by_name | def set_target_temperture_by_name(self, zone_name, target_temperature):
"""
Set the target temperature for a zone by name
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return self.set_target_temperature_by_id(zone["z... | python | def set_target_temperture_by_name(self, zone_name, target_temperature):
"""
Set the target temperature for a zone by name
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return self.set_target_temperature_by_id(zone["z... | [
"def",
"set_target_temperture_by_name",
"(",
"self",
",",
"zone_name",
",",
"target_temperature",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")",
"re... | Set the target temperature for a zone by name | [
"Set",
"the",
"target",
"temperature",
"for",
"a",
"zone",
"by",
"name"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L274-L284 | train | Set the target temperature for a zone by name |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.activate_boost_by_id | def activate_boost_by_id(self, zone_id, target_temperature, num_hours=1):
"""
Activate boost for a zone based on the numeric id
"""
if not self._do_auth():
raise RuntimeError("Unable to login")
zones = [zone_id]
data = {
"ZoneIds": zones,
... | python | def activate_boost_by_id(self, zone_id, target_temperature, num_hours=1):
"""
Activate boost for a zone based on the numeric id
"""
if not self._do_auth():
raise RuntimeError("Unable to login")
zones = [zone_id]
data = {
"ZoneIds": zones,
... | [
"def",
"activate_boost_by_id",
"(",
"self",
",",
"zone_id",
",",
"target_temperature",
",",
"num_hours",
"=",
"1",
")",
":",
"if",
"not",
"self",
".",
"_do_auth",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to login\"",
")",
"zones",
"=",
"[",
"... | Activate boost for a zone based on the numeric id | [
"Activate",
"boost",
"for",
"a",
"zone",
"based",
"on",
"the",
"numeric",
"id"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L286-L317 | train | Activate boost for a zone based on the numeric id |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.activate_boost_by_name | def activate_boost_by_name(self,
zone_name,
target_temperature,
num_hours=1):
"""
Activate boost by the name of the zone
"""
zone = self.get_zone(zone_name)
if zone is None:
... | python | def activate_boost_by_name(self,
zone_name,
target_temperature,
num_hours=1):
"""
Activate boost by the name of the zone
"""
zone = self.get_zone(zone_name)
if zone is None:
... | [
"def",
"activate_boost_by_name",
"(",
"self",
",",
"zone_name",
",",
"target_temperature",
",",
"num_hours",
"=",
"1",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"... | Activate boost by the name of the zone | [
"Activate",
"boost",
"by",
"the",
"name",
"of",
"the",
"zone"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L319-L332 | train | Activate boost by the name of the zone. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.deactivate_boost_by_name | def deactivate_boost_by_name(self, zone_name):
"""
Deactivate boost by the name of the zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return self.deactivate_boost_by_id(zone["zoneId"]) | python | def deactivate_boost_by_name(self, zone_name):
"""
Deactivate boost by the name of the zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return self.deactivate_boost_by_id(zone["zoneId"]) | [
"def",
"deactivate_boost_by_name",
"(",
"self",
",",
"zone_name",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")",
"return",
"self",
".",
"deactivat... | Deactivate boost by the name of the zone | [
"Deactivate",
"boost",
"by",
"the",
"name",
"of",
"the",
"zone"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L362-L371 | train | Deactivate boost by the name of the zone. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.set_mode_by_id | def set_mode_by_id(self, zone_id, mode):
"""
Set the mode by using the zone id
Supported zones are available in the enum Mode
"""
if not self._do_auth():
raise RuntimeError("Unable to login")
data = {
"ZoneId": zone_id,
"mode": mode.va... | python | def set_mode_by_id(self, zone_id, mode):
"""
Set the mode by using the zone id
Supported zones are available in the enum Mode
"""
if not self._do_auth():
raise RuntimeError("Unable to login")
data = {
"ZoneId": zone_id,
"mode": mode.va... | [
"def",
"set_mode_by_id",
"(",
"self",
",",
"zone_id",
",",
"mode",
")",
":",
"if",
"not",
"self",
".",
"_do_auth",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to login\"",
")",
"data",
"=",
"{",
"\"ZoneId\"",
":",
"zone_id",
",",
"\"mode\"",
"... | Set the mode by using the zone id
Supported zones are available in the enum Mode | [
"Set",
"the",
"mode",
"by",
"using",
"the",
"zone",
"id",
"Supported",
"zones",
"are",
"available",
"in",
"the",
"enum",
"Mode"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L373-L402 | train | Set the mode by using the zone id |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.set_mode_by_name | def set_mode_by_name(self, zone_name, mode):
"""
Set the mode by using the name of the zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return self.set_mode_by_id(zone["zoneId"], mode) | python | def set_mode_by_name(self, zone_name, mode):
"""
Set the mode by using the name of the zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return self.set_mode_by_id(zone["zoneId"], mode) | [
"def",
"set_mode_by_name",
"(",
"self",
",",
"zone_name",
",",
"mode",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")",
"return",
"self",
".",
"... | Set the mode by using the name of the zone | [
"Set",
"the",
"mode",
"by",
"using",
"the",
"name",
"of",
"the",
"zone"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L404-L412 | train | Set the mode by using the name of the zone. |
ttroy50/pyephember | pyephember/pyephember.py | EphEmber.get_zone_mode | def get_zone_mode(self, zone_name):
"""
Get the mode for a zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return ZoneMode(zone['mode']) | python | def get_zone_mode(self, zone_name):
"""
Get the mode for a zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return ZoneMode(zone['mode']) | [
"def",
"get_zone_mode",
"(",
"self",
",",
"zone_name",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")",
"return",
"ZoneMode",
"(",
"zone",
"[",
... | Get the mode for a zone | [
"Get",
"the",
"mode",
"for",
"a",
"zone"
] | 3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4 | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L414-L423 | train | Get the mode for a zone |
ABI-Software/MeshParser | src/meshparser/vrmlparser/parser.py | _remove_comment | def _remove_comment(line):
"""
Removes any comments from a line. A comment starts from a # symbol
to the end of the line. But don't remove from # symbol that are embedded
in strings.
"""
# First find just quotes and their indexes.
quote_indexes = []
hash_indexes = []
for i, ch in e... | python | def _remove_comment(line):
"""
Removes any comments from a line. A comment starts from a # symbol
to the end of the line. But don't remove from # symbol that are embedded
in strings.
"""
# First find just quotes and their indexes.
quote_indexes = []
hash_indexes = []
for i, ch in e... | [
"def",
"_remove_comment",
"(",
"line",
")",
":",
"# First find just quotes and their indexes.",
"quote_indexes",
"=",
"[",
"]",
"hash_indexes",
"=",
"[",
"]",
"for",
"i",
",",
"ch",
"in",
"enumerate",
"(",
"line",
")",
":",
"if",
"ch",
"==",
"'\"'",
":",
"... | Removes any comments from a line. A comment starts from a # symbol
to the end of the line. But don't remove from # symbol that are embedded
in strings. | [
"Removes",
"any",
"comments",
"from",
"a",
"line",
".",
"A",
"comment",
"starts",
"from",
"a",
"#",
"symbol",
"to",
"the",
"end",
"of",
"the",
"line",
".",
"But",
"don",
"t",
"remove",
"from",
"#",
"symbol",
"that",
"are",
"embedded",
"in",
"strings",
... | 08dc0ce7c44d0149b443261ff6d3708e28a928e7 | https://github.com/ABI-Software/MeshParser/blob/08dc0ce7c44d0149b443261ff6d3708e28a928e7/src/meshparser/vrmlparser/parser.py#L81-L107 | train | Removes any comments from a line. |
ABI-Software/MeshParser | src/meshparser/vrmlparser/parser.py | _check_index_within_index_pairs | def _check_index_within_index_pairs(index, index_ranges):
"""
Check that the index 'index' lies within the set of indexes.
:param index: Index to determine whether it falls within the range or index pairs.
:param index_ranges: A list of index pairs, monotonically increasing pairs.
:return: True if t... | python | def _check_index_within_index_pairs(index, index_ranges):
"""
Check that the index 'index' lies within the set of indexes.
:param index: Index to determine whether it falls within the range or index pairs.
:param index_ranges: A list of index pairs, monotonically increasing pairs.
:return: True if t... | [
"def",
"_check_index_within_index_pairs",
"(",
"index",
",",
"index_ranges",
")",
":",
"in_range",
"=",
"False",
"for",
"index_range",
"in",
"index_ranges",
":",
"if",
"index_range",
"[",
"0",
"]",
"<",
"index",
"<",
"index_range",
"[",
"1",
"]",
":",
"in_ra... | Check that the index 'index' lies within the set of indexes.
:param index: Index to determine whether it falls within the range or index pairs.
:param index_ranges: A list of index pairs, monotonically increasing pairs.
:return: True if the given index lies within a range specified by an index pair, False o... | [
"Check",
"that",
"the",
"index",
"index",
"lies",
"within",
"the",
"set",
"of",
"indexes",
".",
":",
"param",
"index",
":",
"Index",
"to",
"determine",
"whether",
"it",
"falls",
"within",
"the",
"range",
"or",
"index",
"pairs",
".",
":",
"param",
"index_... | 08dc0ce7c44d0149b443261ff6d3708e28a928e7 | https://github.com/ABI-Software/MeshParser/blob/08dc0ce7c44d0149b443261ff6d3708e28a928e7/src/meshparser/vrmlparser/parser.py#L110-L121 | train | Checks whether the given index falls within the set of index pairs. |
ABI-Software/MeshParser | src/meshparser/vrmlparser/parser.py | _convertToElementList | def _convertToElementList(elements_list):
"""
Take a list of element node indexes deliminated by -1 and convert
it into a list element node indexes list.
"""
elements = []
current_element = []
for node_index in elements_list:
if node_index == -1:
elements.append(current_e... | python | def _convertToElementList(elements_list):
"""
Take a list of element node indexes deliminated by -1 and convert
it into a list element node indexes list.
"""
elements = []
current_element = []
for node_index in elements_list:
if node_index == -1:
elements.append(current_e... | [
"def",
"_convertToElementList",
"(",
"elements_list",
")",
":",
"elements",
"=",
"[",
"]",
"current_element",
"=",
"[",
"]",
"for",
"node_index",
"in",
"elements_list",
":",
"if",
"node_index",
"==",
"-",
"1",
":",
"elements",
".",
"append",
"(",
"current_el... | Take a list of element node indexes deliminated by -1 and convert
it into a list element node indexes list. | [
"Take",
"a",
"list",
"of",
"element",
"node",
"indexes",
"deliminated",
"by",
"-",
"1",
"and",
"convert",
"it",
"into",
"a",
"list",
"element",
"node",
"indexes",
"list",
"."
] | 08dc0ce7c44d0149b443261ff6d3708e28a928e7 | https://github.com/ABI-Software/MeshParser/blob/08dc0ce7c44d0149b443261ff6d3708e28a928e7/src/meshparser/vrmlparser/parser.py#L561-L575 | train | Convert a list of element node indexes deliminated by - 1 into a list of element node indexes list. |
ABI-Software/MeshParser | src/meshparser/vrmlparser/parser.py | _get_VRML_node | def _get_VRML_node(name):
"""
Return the node object that matches the given named node. The name must be a valid VRML node name.
:param name: The name of the object to return.
:return: The VRML Node object that matches the given name.
"""
known_nodes = _get_known_nodes()
index = known_nodes... | python | def _get_VRML_node(name):
"""
Return the node object that matches the given named node. The name must be a valid VRML node name.
:param name: The name of the object to return.
:return: The VRML Node object that matches the given name.
"""
known_nodes = _get_known_nodes()
index = known_nodes... | [
"def",
"_get_VRML_node",
"(",
"name",
")",
":",
"known_nodes",
"=",
"_get_known_nodes",
"(",
")",
"index",
"=",
"known_nodes",
".",
"index",
"(",
"name",
")",
"return",
"_BaseNode",
".",
"__subclasses__",
"(",
")",
"[",
"index",
"]",
"(",
")"
] | Return the node object that matches the given named node. The name must be a valid VRML node name.
:param name: The name of the object to return.
:return: The VRML Node object that matches the given name. | [
"Return",
"the",
"node",
"object",
"that",
"matches",
"the",
"given",
"named",
"node",
".",
"The",
"name",
"must",
"be",
"a",
"valid",
"VRML",
"node",
"name",
".",
":",
"param",
"name",
":",
"The",
"name",
"of",
"the",
"object",
"to",
"return",
".",
... | 08dc0ce7c44d0149b443261ff6d3708e28a928e7 | https://github.com/ABI-Software/MeshParser/blob/08dc0ce7c44d0149b443261ff6d3708e28a928e7/src/meshparser/vrmlparser/parser.py#L599-L607 | train | Returns the VRML Node object that matches the given name. |
projectshift/shift-boiler | boiler/jinja/filters.py | LocalizableFilterSet.get_locale | def get_locale(self):
"""
Get locale
Will extract locale from application, trying to get one from babel
first, then, if not available, will get one from app config
"""
if not self.locale:
try:
import flask_babel as babel
self.lo... | python | def get_locale(self):
"""
Get locale
Will extract locale from application, trying to get one from babel
first, then, if not available, will get one from app config
"""
if not self.locale:
try:
import flask_babel as babel
self.lo... | [
"def",
"get_locale",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"locale",
":",
"try",
":",
"import",
"flask_babel",
"as",
"babel",
"self",
".",
"locale",
"=",
"str",
"(",
"babel",
".",
"get_locale",
"(",
")",
")",
".",
"lower",
"(",
")",
"exc... | Get locale
Will extract locale from application, trying to get one from babel
first, then, if not available, will get one from app config | [
"Get",
"locale",
"Will",
"extract",
"locale",
"from",
"application",
"trying",
"to",
"get",
"one",
"from",
"babel",
"first",
"then",
"if",
"not",
"available",
"will",
"get",
"one",
"from",
"app",
"config"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/jinja/filters.py#L15-L29 | train | Get locale from babel and current app config |
projectshift/shift-boiler | boiler/jinja/filters.py | LocalizableFilterSet.get_language | def get_language(self):
"""
Get language
If locale contains region, will cut that off. Returns just
the language code
"""
locale = self.get_locale()
language = locale
if '_' in locale:
language = locale[0:locale.index('_')]
return langu... | python | def get_language(self):
"""
Get language
If locale contains region, will cut that off. Returns just
the language code
"""
locale = self.get_locale()
language = locale
if '_' in locale:
language = locale[0:locale.index('_')]
return langu... | [
"def",
"get_language",
"(",
"self",
")",
":",
"locale",
"=",
"self",
".",
"get_locale",
"(",
")",
"language",
"=",
"locale",
"if",
"'_'",
"in",
"locale",
":",
"language",
"=",
"locale",
"[",
"0",
":",
"locale",
".",
"index",
"(",
"'_'",
")",
"]",
"... | Get language
If locale contains region, will cut that off. Returns just
the language code | [
"Get",
"language",
"If",
"locale",
"contains",
"region",
"will",
"cut",
"that",
"off",
".",
"Returns",
"just",
"the",
"language",
"code"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/jinja/filters.py#L31-L41 | train | Get language from locale |
projectshift/shift-boiler | boiler/jinja/filters.py | HumanizeFilters.localize_humanize | def localize_humanize(self):
""" Setts current language to humanize """
import humanize
language = self.get_language()
if language != 'en':
humanize.i18n.activate(language) | python | def localize_humanize(self):
""" Setts current language to humanize """
import humanize
language = self.get_language()
if language != 'en':
humanize.i18n.activate(language) | [
"def",
"localize_humanize",
"(",
"self",
")",
":",
"import",
"humanize",
"language",
"=",
"self",
".",
"get_language",
"(",
")",
"if",
"language",
"!=",
"'en'",
":",
"humanize",
".",
"i18n",
".",
"activate",
"(",
"language",
")"
] | Setts current language to humanize | [
"Setts",
"current",
"language",
"to",
"humanize"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/jinja/filters.py#L62-L67 | train | Setts current language to humanize |
projectshift/shift-boiler | boiler/jinja/filters.py | HumanizeFilters.get_filters | def get_filters(self):
""" Returns a dictionary of filters """
filters = dict()
for filter in self.get_filter_names():
filters[filter] = getattr(self, filter)
return filters | python | def get_filters(self):
""" Returns a dictionary of filters """
filters = dict()
for filter in self.get_filter_names():
filters[filter] = getattr(self, filter)
return filters | [
"def",
"get_filters",
"(",
"self",
")",
":",
"filters",
"=",
"dict",
"(",
")",
"for",
"filter",
"in",
"self",
".",
"get_filter_names",
"(",
")",
":",
"filters",
"[",
"filter",
"]",
"=",
"getattr",
"(",
"self",
",",
"filter",
")",
"return",
"filters"
] | Returns a dictionary of filters | [
"Returns",
"a",
"dictionary",
"of",
"filters"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/jinja/filters.py#L80-L85 | train | Returns a dictionary of filters |
projectshift/shift-boiler | boiler/jinja/filters.py | DateFilters.date_fromnow | def date_fromnow(self, value):
""" Displays humanized date (time since) """
import humanize
language = self.get_language()
if language != 'en':
humanize.i18n.activate(language)
return Markup(humanize.naturaltime(value)) | python | def date_fromnow(self, value):
""" Displays humanized date (time since) """
import humanize
language = self.get_language()
if language != 'en':
humanize.i18n.activate(language)
return Markup(humanize.naturaltime(value)) | [
"def",
"date_fromnow",
"(",
"self",
",",
"value",
")",
":",
"import",
"humanize",
"language",
"=",
"self",
".",
"get_language",
"(",
")",
"if",
"language",
"!=",
"'en'",
":",
"humanize",
".",
"i18n",
".",
"activate",
"(",
"language",
")",
"return",
"Mark... | Displays humanized date (time since) | [
"Displays",
"humanized",
"date",
"(",
"time",
"since",
")"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/jinja/filters.py#L104-L110 | train | Displays a humanized date from the given time since |
projectshift/shift-boiler | boiler/jinja/filters.py | MomentJsFilters._render | def _render(self, value, format):
""" Writes javascript to call momentjs function """
template = '<script>\ndocument.write(moment(\"{t}\").{f});\n</script>'
return Markup(template.format(t=value, f=format)) | python | def _render(self, value, format):
""" Writes javascript to call momentjs function """
template = '<script>\ndocument.write(moment(\"{t}\").{f});\n</script>'
return Markup(template.format(t=value, f=format)) | [
"def",
"_render",
"(",
"self",
",",
"value",
",",
"format",
")",
":",
"template",
"=",
"'<script>\\ndocument.write(moment(\\\"{t}\\\").{f});\\n</script>'",
"return",
"Markup",
"(",
"template",
".",
"format",
"(",
"t",
"=",
"value",
",",
"f",
"=",
"format",
")",
... | Writes javascript to call momentjs function | [
"Writes",
"javascript",
"to",
"call",
"momentjs",
"function"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/jinja/filters.py#L132-L135 | train | Writes javascript to call momentjs function |
projectshift/shift-boiler | boiler/jinja/filters.py | MomentJsFilters.get_filters | def get_filters(self):
""" Returns a collection of momentjs filters """
return dict(
moment_format=self.format,
moment_calendar=self.calendar,
moment_fromnow=self.from_now,
) | python | def get_filters(self):
""" Returns a collection of momentjs filters """
return dict(
moment_format=self.format,
moment_calendar=self.calendar,
moment_fromnow=self.from_now,
) | [
"def",
"get_filters",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"moment_format",
"=",
"self",
".",
"format",
",",
"moment_calendar",
"=",
"self",
".",
"calendar",
",",
"moment_fromnow",
"=",
"self",
".",
"from_now",
",",
")"
] | Returns a collection of momentjs filters | [
"Returns",
"a",
"collection",
"of",
"momentjs",
"filters"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/jinja/filters.py#L146-L152 | train | Returns a collection of momentjs filters |
adaptive-learning/proso-apps | proso_concepts/views.py | user_stats | def user_stats(request):
"""
JSON of user stats of the user
GET parameters:
html (bool):
turn on the HTML version of the API, defaults to false
user (int):
identifier of the user, defaults to logged user
concepts (list):
list of identifiers of concepts, defaults to... | python | def user_stats(request):
"""
JSON of user stats of the user
GET parameters:
html (bool):
turn on the HTML version of the API, defaults to false
user (int):
identifier of the user, defaults to logged user
concepts (list):
list of identifiers of concepts, defaults to... | [
"def",
"user_stats",
"(",
"request",
")",
":",
"user",
"=",
"get_user_id",
"(",
"request",
")",
"language",
"=",
"get_language",
"(",
"request",
")",
"concepts",
"=",
"None",
"# meaning all concept",
"if",
"\"concepts\"",
"in",
"request",
".",
"GET",
":",
"c... | JSON of user stats of the user
GET parameters:
html (bool):
turn on the HTML version of the API, defaults to false
user (int):
identifier of the user, defaults to logged user
concepts (list):
list of identifiers of concepts, defaults to all concepts
lang (str):
... | [
"JSON",
"of",
"user",
"stats",
"of",
"the",
"user"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_concepts/views.py#L47-L69 | train | Returns a JSON response of the user stats of the user |
adaptive-learning/proso-apps | proso_concepts/views.py | user_stats_bulk | def user_stats_bulk(request):
"""
Get statistics for selected users and concepts
since:
time as timestamp - get stats changed since
users:
list of identifiers of users
concepts (Optional):
list of identifiers of concepts
language:
language of concepts
"""
langua... | python | def user_stats_bulk(request):
"""
Get statistics for selected users and concepts
since:
time as timestamp - get stats changed since
users:
list of identifiers of users
concepts (Optional):
list of identifiers of concepts
language:
language of concepts
"""
langua... | [
"def",
"user_stats_bulk",
"(",
"request",
")",
":",
"language",
"=",
"get_language",
"(",
"request",
")",
"users",
"=",
"load_query_json",
"(",
"request",
".",
"GET",
",",
"\"users\"",
")",
"if",
"request",
".",
"user",
".",
"is_staff",
":",
"if",
"not",
... | Get statistics for selected users and concepts
since:
time as timestamp - get stats changed since
users:
list of identifiers of users
concepts (Optional):
list of identifiers of concepts
language:
language of concepts | [
"Get",
"statistics",
"for",
"selected",
"users",
"and",
"concepts"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_concepts/views.py#L72-L109 | train | Get statistics for selected users and concepts |
adaptive-learning/proso-apps | proso_concepts/views.py | user_stats_api | def user_stats_api(request, provider):
"""
Get statistics for selected Edookit users
key:
api key
since:
time as timestamp - get stats changed since
"""
if 'key' not in request.GET or provider not in settings.USER_STATS_API_KEY \
or request.GET['key'] != settings.USER_S... | python | def user_stats_api(request, provider):
"""
Get statistics for selected Edookit users
key:
api key
since:
time as timestamp - get stats changed since
"""
if 'key' not in request.GET or provider not in settings.USER_STATS_API_KEY \
or request.GET['key'] != settings.USER_S... | [
"def",
"user_stats_api",
"(",
"request",
",",
"provider",
")",
":",
"if",
"'key'",
"not",
"in",
"request",
".",
"GET",
"or",
"provider",
"not",
"in",
"settings",
".",
"USER_STATS_API_KEY",
"or",
"request",
".",
"GET",
"[",
"'key'",
"]",
"!=",
"settings",
... | Get statistics for selected Edookit users
key:
api key
since:
time as timestamp - get stats changed since | [
"Get",
"statistics",
"for",
"selected",
"Edookit",
"users"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_concepts/views.py#L112-L138 | train | Get statistics for selected Edookit users
|
adaptive-learning/proso-apps | proso_concepts/views.py | tag_values | def tag_values(request):
"""
Get tags types and values with localized names
language:
language of tags
"""
data = defaultdict(lambda: {"values": {}})
for tag in Tag.objects.filter(lang=get_language(request)):
data[tag.type]["name"] = tag.type_name
data[tag.type]["values"]... | python | def tag_values(request):
"""
Get tags types and values with localized names
language:
language of tags
"""
data = defaultdict(lambda: {"values": {}})
for tag in Tag.objects.filter(lang=get_language(request)):
data[tag.type]["name"] = tag.type_name
data[tag.type]["values"]... | [
"def",
"tag_values",
"(",
"request",
")",
":",
"data",
"=",
"defaultdict",
"(",
"lambda",
":",
"{",
"\"values\"",
":",
"{",
"}",
"}",
")",
"for",
"tag",
"in",
"Tag",
".",
"objects",
".",
"filter",
"(",
"lang",
"=",
"get_language",
"(",
"request",
")"... | Get tags types and values with localized names
language:
language of tags | [
"Get",
"tags",
"types",
"and",
"values",
"with",
"localized",
"names"
] | 8278c72e498d6ef8d392cc47b48473f4ec037142 | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_concepts/views.py#L141-L154 | train | Get tags types and values with localized names
language |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.