repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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",
"=",
"''",
"if",
"not",
"isinstance",
"(",
"parameter",
",",
"list",
")",
":",
"parameter",
"=",
"[",
"parameter",
"]",
"for",
"name",
"in",
"parameter",
":",
"re... | 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 |
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",
"=",
"{",
"}",
"apps_status",
"=",
"subprocess",
".",
"Popen",
"(",
"'cozy-monitor status'",
",",
"shell",
"=",
"True",
",",... | 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 |
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",
")",
":",
"links",
"=",
"list",
"(",
"m",
".",
"match",
"(",
"orig",
",",
"rel",
")",
")",
"for",
"link",
"in",
"links",
":",
"yield",
"link",
"[",
"0",
"]",
"[",
"TARGET",
"]",
"y... | 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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",
"if",
"\"concepts\"",
"in",
"request",
".",
"GET",
":",
"concepts",
"=",
"Concept... | 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 |
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 |
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 |
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 |
assamite/creamas | creamas/grid.py | GridEnvironment.add_to_grid | def add_to_grid(self, agent):
'''Add agent to the next available spot in the grid.
:returns:
(x,y) of the agent in the grid. This is the agent's overall
coordinate in the grand grid (i.e. the actual coordinate of the
agent w.t.r **origin**).
:raises: `ValueE... | python | def add_to_grid(self, agent):
'''Add agent to the next available spot in the grid.
:returns:
(x,y) of the agent in the grid. This is the agent's overall
coordinate in the grand grid (i.e. the actual coordinate of the
agent w.t.r **origin**).
:raises: `ValueE... | [
"def",
"add_to_grid",
"(",
"self",
",",
"agent",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"grid",
")",
")",
":",
"for",
"j",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"grid",
"[",
"0",
"]",
")",
")",
":",
"if",
... | Add agent to the next available spot in the grid.
:returns:
(x,y) of the agent in the grid. This is the agent's overall
coordinate in the grand grid (i.e. the actual coordinate of the
agent w.t.r **origin**).
:raises: `ValueError` if the grid is full. | [
"Add",
"agent",
"to",
"the",
"next",
"available",
"spot",
"in",
"the",
"grid",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L203-L222 | train |
assamite/creamas | creamas/grid.py | GridEnvironment.set_agent_neighbors | async def set_agent_neighbors(self):
'''Set neighbors for each agent in each cardinal direction.
This method assumes that the neighboring :class:`GridEnvironment` of
this grid environment have already been set.
'''
for i in range(len(self.grid)):
for j in range(len(s... | python | async def set_agent_neighbors(self):
'''Set neighbors for each agent in each cardinal direction.
This method assumes that the neighboring :class:`GridEnvironment` of
this grid environment have already been set.
'''
for i in range(len(self.grid)):
for j in range(len(s... | [
"async",
"def",
"set_agent_neighbors",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"grid",
")",
")",
":",
"for",
"j",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"grid",
"[",
"0",
"]",
")",
")",
":",
"agent"... | Set neighbors for each agent in each cardinal direction.
This method assumes that the neighboring :class:`GridEnvironment` of
this grid environment have already been set. | [
"Set",
"neighbors",
"for",
"each",
"agent",
"in",
"each",
"cardinal",
"direction",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L254-L287 | train |
assamite/creamas | creamas/grid.py | GridMultiEnvironment.set_slave_params | async def set_slave_params(self):
'''Set origin and grid size for each slave environment.
This method needs to be called before slave environments are populated
and agents' and slave environments' neighbors are set.
'''
self._slave_origins = []
cur_x = self.origin[0]
... | python | async def set_slave_params(self):
'''Set origin and grid size for each slave environment.
This method needs to be called before slave environments are populated
and agents' and slave environments' neighbors are set.
'''
self._slave_origins = []
cur_x = self.origin[0]
... | [
"async",
"def",
"set_slave_params",
"(",
"self",
")",
":",
"self",
".",
"_slave_origins",
"=",
"[",
"]",
"cur_x",
"=",
"self",
".",
"origin",
"[",
"0",
"]",
"for",
"addr",
"in",
"self",
".",
"addrs",
":",
"new_origin",
"=",
"(",
"cur_x",
",",
"self",... | Set origin and grid size for each slave environment.
This method needs to be called before slave environments are populated
and agents' and slave environments' neighbors are set. | [
"Set",
"origin",
"and",
"grid",
"size",
"for",
"each",
"slave",
"environment",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L387-L401 | train |
assamite/creamas | creamas/grid.py | GridMultiEnvironment.set_agent_neighbors | async def set_agent_neighbors(self):
'''Set neighbors for all the agents in all the slave environments.
Assumes that all the slave environments have their neighbors set.
'''
for addr in self.addrs:
r_manager = await self.env.connect(addr)
await r_manager.set_agent... | python | async def set_agent_neighbors(self):
'''Set neighbors for all the agents in all the slave environments.
Assumes that all the slave environments have their neighbors set.
'''
for addr in self.addrs:
r_manager = await self.env.connect(addr)
await r_manager.set_agent... | [
"async",
"def",
"set_agent_neighbors",
"(",
"self",
")",
":",
"for",
"addr",
"in",
"self",
".",
"addrs",
":",
"r_manager",
"=",
"await",
"self",
".",
"env",
".",
"connect",
"(",
"addr",
")",
"await",
"r_manager",
".",
"set_agent_neighbors",
"(",
")"
] | Set neighbors for all the agents in all the slave environments.
Assumes that all the slave environments have their neighbors set. | [
"Set",
"neighbors",
"for",
"all",
"the",
"agents",
"in",
"all",
"the",
"slave",
"environments",
".",
"Assumes",
"that",
"all",
"the",
"slave",
"environments",
"have",
"their",
"neighbors",
"set",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L504-L510 | train |
assamite/creamas | creamas/grid.py | GridMultiEnvironment.populate | async def populate(self, agent_cls, *args, **kwargs):
'''Populate all the slave grid environments with agents. Assumes that
no agents have been spawned yet to the slave environment grids. This
excludes the slave environment managers as they are not in the grids.)
'''
n = self.gs[... | python | async def populate(self, agent_cls, *args, **kwargs):
'''Populate all the slave grid environments with agents. Assumes that
no agents have been spawned yet to the slave environment grids. This
excludes the slave environment managers as they are not in the grids.)
'''
n = self.gs[... | [
"async",
"def",
"populate",
"(",
"self",
",",
"agent_cls",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"n",
"=",
"self",
".",
"gs",
"[",
"0",
"]",
"*",
"self",
".",
"gs",
"[",
"1",
"]",
"tasks",
"=",
"[",
"]",
"for",
"addr",
"in",
"self"... | Populate all the slave grid environments with agents. Assumes that
no agents have been spawned yet to the slave environment grids. This
excludes the slave environment managers as they are not in the grids.) | [
"Populate",
"all",
"the",
"slave",
"grid",
"environments",
"with",
"agents",
".",
"Assumes",
"that",
"no",
"agents",
"have",
"been",
"spawned",
"yet",
"to",
"the",
"slave",
"environment",
"grids",
".",
"This",
"excludes",
"the",
"slave",
"environment",
"manage... | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L527-L540 | train |
safarijv/sbo-sphinx | sbo_sphinx/jsdoc.py | generate_docs | def generate_docs(app):
""" Generate the reST documentation files for the JavaScript code """
# Figure out the correct directories to use
config = app.config
config_dir = app.env.srcdir
javascript_root = os.path.join(config_dir, config.jsdoc_source_root)
if javascript_root[-1] != os.path.sep:
... | python | def generate_docs(app):
""" Generate the reST documentation files for the JavaScript code """
# Figure out the correct directories to use
config = app.config
config_dir = app.env.srcdir
javascript_root = os.path.join(config_dir, config.jsdoc_source_root)
if javascript_root[-1] != os.path.sep:
... | [
"def",
"generate_docs",
"(",
"app",
")",
":",
"config",
"=",
"app",
".",
"config",
"config_dir",
"=",
"app",
".",
"env",
".",
"srcdir",
"javascript_root",
"=",
"os",
".",
"path",
".",
"join",
"(",
"config_dir",
",",
"config",
".",
"jsdoc_source_root",
")... | Generate the reST documentation files for the JavaScript code | [
"Generate",
"the",
"reST",
"documentation",
"files",
"for",
"the",
"JavaScript",
"code"
] | 7a8efb7c49488131c90c19ef1a1563f595630a36 | https://github.com/safarijv/sbo-sphinx/blob/7a8efb7c49488131c90c19ef1a1563f595630a36/sbo_sphinx/jsdoc.py#L42-L82 | train |
safarijv/sbo-sphinx | sbo_sphinx/jsdoc.py | setup | def setup(app):
"""Sphinx extension entry point"""
app.add_config_value('jsdoc_source_root', '..', 'env')
app.add_config_value('jsdoc_output_root', 'javascript', 'env')
app.add_config_value('jsdoc_exclude', [], 'env')
app.connect('builder-inited', generate_docs) | python | def setup(app):
"""Sphinx extension entry point"""
app.add_config_value('jsdoc_source_root', '..', 'env')
app.add_config_value('jsdoc_output_root', 'javascript', 'env')
app.add_config_value('jsdoc_exclude', [], 'env')
app.connect('builder-inited', generate_docs) | [
"def",
"setup",
"(",
"app",
")",
":",
"app",
".",
"add_config_value",
"(",
"'jsdoc_source_root'",
",",
"'..'",
",",
"'env'",
")",
"app",
".",
"add_config_value",
"(",
"'jsdoc_output_root'",
",",
"'javascript'",
",",
"'env'",
")",
"app",
".",
"add_config_value"... | Sphinx extension entry point | [
"Sphinx",
"extension",
"entry",
"point"
] | 7a8efb7c49488131c90c19ef1a1563f595630a36 | https://github.com/safarijv/sbo-sphinx/blob/7a8efb7c49488131c90c19ef1a1563f595630a36/sbo_sphinx/jsdoc.py#L94-L99 | train |
projectshift/shift-boiler | boiler/cli/user.py | find_user | def find_user(search_params):
"""
Find user
Attempts to find a user by a set of search params. You must be in
application context.
"""
user = None
params = {prop: value for prop, value in search_params.items() if value}
if 'id' in params or 'email' in params:
user = user_service.... | python | def find_user(search_params):
"""
Find user
Attempts to find a user by a set of search params. You must be in
application context.
"""
user = None
params = {prop: value for prop, value in search_params.items() if value}
if 'id' in params or 'email' in params:
user = user_service.... | [
"def",
"find_user",
"(",
"search_params",
")",
":",
"user",
"=",
"None",
"params",
"=",
"{",
"prop",
":",
"value",
"for",
"prop",
",",
"value",
"in",
"search_params",
".",
"items",
"(",
")",
"if",
"value",
"}",
"if",
"'id'",
"in",
"params",
"or",
"'e... | Find user
Attempts to find a user by a set of search params. You must be in
application context. | [
"Find",
"user",
"Attempts",
"to",
"find",
"a",
"user",
"by",
"a",
"set",
"of",
"search",
"params",
".",
"You",
"must",
"be",
"in",
"application",
"context",
"."
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L19-L29 | train |
projectshift/shift-boiler | boiler/cli/user.py | create | def create(email, password):
""" Creates a new user record """
with get_app().app_context():
user = User(email=email, password=password)
result = user_service.save(user)
if not isinstance(result, User):
print_validation_errors(result)
return
click.echo(gr... | python | def create(email, password):
""" Creates a new user record """
with get_app().app_context():
user = User(email=email, password=password)
result = user_service.save(user)
if not isinstance(result, User):
print_validation_errors(result)
return
click.echo(gr... | [
"def",
"create",
"(",
"email",
",",
"password",
")",
":",
"with",
"get_app",
"(",
")",
".",
"app_context",
"(",
")",
":",
"user",
"=",
"User",
"(",
"email",
"=",
"email",
",",
"password",
"=",
"password",
")",
"result",
"=",
"user_service",
".",
"sav... | Creates a new user record | [
"Creates",
"a",
"new",
"user",
"record"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L48-L59 | train |
projectshift/shift-boiler | boiler/cli/user.py | change_password | def change_password(*_, user_id=None, password=None):
""" Change user password """
click.echo(green('\nChange password:'))
click.echo(green('-' * 40))
with get_app().app_context():
user = find_user(dict(id=user_id))
if not user:
click.echo(red('User not found\n'))
... | python | def change_password(*_, user_id=None, password=None):
""" Change user password """
click.echo(green('\nChange password:'))
click.echo(green('-' * 40))
with get_app().app_context():
user = find_user(dict(id=user_id))
if not user:
click.echo(red('User not found\n'))
... | [
"def",
"change_password",
"(",
"*",
"_",
",",
"user_id",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"click",
".",
"echo",
"(",
"green",
"(",
"'\\nChange password:'",
")",
")",
"click",
".",
"echo",
"(",
"green",
"(",
"'-'",
"*",
"40",
")",
... | Change user password | [
"Change",
"user",
"password"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L84-L102 | train |
projectshift/shift-boiler | boiler/cli/user.py | change_email | def change_email(*_, user_id=None, new_email=None):
""" Change email for a user """
click.echo(green('\nChange email:'))
click.echo(green('-' * 40))
with get_app().app_context():
user = find_user(dict(id=user_id))
if not user:
click.echo(red('User not found\n'))
... | python | def change_email(*_, user_id=None, new_email=None):
""" Change email for a user """
click.echo(green('\nChange email:'))
click.echo(green('-' * 40))
with get_app().app_context():
user = find_user(dict(id=user_id))
if not user:
click.echo(red('User not found\n'))
... | [
"def",
"change_email",
"(",
"*",
"_",
",",
"user_id",
"=",
"None",
",",
"new_email",
"=",
"None",
")",
":",
"click",
".",
"echo",
"(",
"green",
"(",
"'\\nChange email:'",
")",
")",
"click",
".",
"echo",
"(",
"green",
"(",
"'-'",
"*",
"40",
")",
")"... | Change email for a user | [
"Change",
"email",
"for",
"a",
"user"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L108-L128 | train |
projectshift/shift-boiler | boiler/cli/user.py | create_role | def create_role(*_, **kwargs):
""" Create user role """
click.echo(green('\nCreating new role:'))
click.echo(green('-' * 40))
with get_app().app_context():
role = Role(**kwargs)
result = role_service.save(role)
if not isinstance(result, Role):
print_validation_errors... | python | def create_role(*_, **kwargs):
""" Create user role """
click.echo(green('\nCreating new role:'))
click.echo(green('-' * 40))
with get_app().app_context():
role = Role(**kwargs)
result = role_service.save(role)
if not isinstance(result, Role):
print_validation_errors... | [
"def",
"create_role",
"(",
"*",
"_",
",",
"**",
"kwargs",
")",
":",
"click",
".",
"echo",
"(",
"green",
"(",
"'\\nCreating new role:'",
")",
")",
"click",
".",
"echo",
"(",
"green",
"(",
"'-'",
"*",
"40",
")",
")",
"with",
"get_app",
"(",
")",
".",... | Create user role | [
"Create",
"user",
"role"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L135-L146 | train |
projectshift/shift-boiler | boiler/cli/user.py | list_roles | def list_roles():
""" List existing roles """
click.echo(green('\nListing roles:'))
click.echo(green('-' * 40))
with get_app().app_context():
roles = Role.query.all()
if not roles:
click.echo(red('No roles found'))
return
for index,role in enumerate(roles... | python | def list_roles():
""" List existing roles """
click.echo(green('\nListing roles:'))
click.echo(green('-' * 40))
with get_app().app_context():
roles = Role.query.all()
if not roles:
click.echo(red('No roles found'))
return
for index,role in enumerate(roles... | [
"def",
"list_roles",
"(",
")",
":",
"click",
".",
"echo",
"(",
"green",
"(",
"'\\nListing roles:'",
")",
")",
"click",
".",
"echo",
"(",
"green",
"(",
"'-'",
"*",
"40",
")",
")",
"with",
"get_app",
"(",
")",
".",
"app_context",
"(",
")",
":",
"role... | List existing roles | [
"List",
"existing",
"roles"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L150-L167 | train |
projectshift/shift-boiler | boiler/cli/user.py | list_user_roles | def list_user_roles(*_, user_id):
""" List user roles """
click.echo(green('\nListing user roles:'))
click.echo(green('-' * 40))
with get_app().app_context():
user = find_user(dict(id=user_id))
if not user:
click.echo(red('User not found\n'))
return
for i... | python | def list_user_roles(*_, user_id):
""" List user roles """
click.echo(green('\nListing user roles:'))
click.echo(green('-' * 40))
with get_app().app_context():
user = find_user(dict(id=user_id))
if not user:
click.echo(red('User not found\n'))
return
for i... | [
"def",
"list_user_roles",
"(",
"*",
"_",
",",
"user_id",
")",
":",
"click",
".",
"echo",
"(",
"green",
"(",
"'\\nListing user roles:'",
")",
")",
"click",
".",
"echo",
"(",
"green",
"(",
"'-'",
"*",
"40",
")",
")",
"with",
"get_app",
"(",
")",
".",
... | List user roles | [
"List",
"user",
"roles"
] | 8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L172-L189 | train |
cgrok/cr-async | crasync/models.py | Base.update | async def update(self):
'''Update an object with current info.'''
if self.client.session.closed:
async with core.Client() as client:
data = await client.request(self.url)
else:
data = await self.client.request(self.url)
self.raw_data = data
... | python | async def update(self):
'''Update an object with current info.'''
if self.client.session.closed:
async with core.Client() as client:
data = await client.request(self.url)
else:
data = await self.client.request(self.url)
self.raw_data = data
... | [
"async",
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"client",
".",
"session",
".",
"closed",
":",
"async",
"with",
"core",
".",
"Client",
"(",
")",
"as",
"client",
":",
"data",
"=",
"await",
"client",
".",
"request",
"(",
"self",
".... | Update an object with current info. | [
"Update",
"an",
"object",
"with",
"current",
"info",
"."
] | f65a968e54704168706d137d1ba662f55f8ab852 | https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/crasync/models.py#L57-L68 | train |
cgrok/cr-async | crasync/models.py | Profile.clan_badge_url | def clan_badge_url(self):
'''Returns clan badge url'''
if self.clan_tag is None:
return None
url = self.raw_data.get('clan').get('badge').get('url')
if not url:
return None
return "http://api.cr-api.com" + url | python | def clan_badge_url(self):
'''Returns clan badge url'''
if self.clan_tag is None:
return None
url = self.raw_data.get('clan').get('badge').get('url')
if not url:
return None
return "http://api.cr-api.com" + url | [
"def",
"clan_badge_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"clan_tag",
"is",
"None",
":",
"return",
"None",
"url",
"=",
"self",
".",
"raw_data",
".",
"get",
"(",
"'clan'",
")",
".",
"get",
"(",
"'badge'",
")",
".",
"get",
"(",
"'url'",
")",... | Returns clan badge url | [
"Returns",
"clan",
"badge",
"url"
] | f65a968e54704168706d137d1ba662f55f8ab852 | https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/crasync/models.py#L344-L351 | train |
cgrok/cr-async | crasync/models.py | Profile.get_chest | def get_chest(self, index=0):
'''Get your current chest +- the index'''
index += self.chest_cycle.position
if index == self.chest_cycle.super_magical:
return 'Super Magical'
if index == self.chest_cycle.epic:
return 'Epic'
if index == self.chest_... | python | def get_chest(self, index=0):
'''Get your current chest +- the index'''
index += self.chest_cycle.position
if index == self.chest_cycle.super_magical:
return 'Super Magical'
if index == self.chest_cycle.epic:
return 'Epic'
if index == self.chest_... | [
"def",
"get_chest",
"(",
"self",
",",
"index",
"=",
"0",
")",
":",
"index",
"+=",
"self",
".",
"chest_cycle",
".",
"position",
"if",
"index",
"==",
"self",
".",
"chest_cycle",
".",
"super_magical",
":",
"return",
"'Super Magical'",
"if",
"index",
"==",
"... | Get your current chest +- the index | [
"Get",
"your",
"current",
"chest",
"+",
"-",
"the",
"index"
] | f65a968e54704168706d137d1ba662f55f8ab852 | https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/crasync/models.py#L353-L365 | train |
ronhanson/python-tbx | fabfile/virtualenv.py | update | def update():
"""Update virtual env with requirements packages."""
with settings(warn_only=True):
print(cyan('\nInstalling/Updating required packages...'))
pip = local('venv/bin/pip install -U --allow-all-external --src libs -r requirements.txt', capture=True)
if pip.failed:
... | python | def update():
"""Update virtual env with requirements packages."""
with settings(warn_only=True):
print(cyan('\nInstalling/Updating required packages...'))
pip = local('venv/bin/pip install -U --allow-all-external --src libs -r requirements.txt', capture=True)
if pip.failed:
... | [
"def",
"update",
"(",
")",
":",
"with",
"settings",
"(",
"warn_only",
"=",
"True",
")",
":",
"print",
"(",
"cyan",
"(",
"'\\nInstalling/Updating required packages...'",
")",
")",
"pip",
"=",
"local",
"(",
"'venv/bin/pip install -U --allow-all-external --src libs -r re... | Update virtual env with requirements packages. | [
"Update",
"virtual",
"env",
"with",
"requirements",
"packages",
"."
] | 87f72ae0cadecafbcd144f1e930181fba77f6b83 | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/fabfile/virtualenv.py#L22-L32 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver._detect_devices | def _detect_devices(self) -> None:
'''Detect whether devices connected.'''
devices_num = len(self.devices_list)
if devices_num == 0:
raise DeviceConnectionException(
'No devices are connected. Please connect the device with USB or via WLAN and turn on the USB debuggin... | python | def _detect_devices(self) -> None:
'''Detect whether devices connected.'''
devices_num = len(self.devices_list)
if devices_num == 0:
raise DeviceConnectionException(
'No devices are connected. Please connect the device with USB or via WLAN and turn on the USB debuggin... | [
"def",
"_detect_devices",
"(",
"self",
")",
"->",
"None",
":",
"devices_num",
"=",
"len",
"(",
"self",
".",
"devices_list",
")",
"if",
"devices_num",
"==",
"0",
":",
"raise",
"DeviceConnectionException",
"(",
"'No devices are connected. Please connect the device with ... | Detect whether devices connected. | [
"Detect",
"whether",
"devices",
"connected",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L77-L90 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_device_model | def get_device_model(self) -> str:
'''Show device model.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'getprop', 'ro.product.model')
return output.strip() | python | def get_device_model(self) -> str:
'''Show device model.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'getprop', 'ro.product.model')
return output.strip() | [
"def",
"get_device_model",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'getprop'",
",",
"'ro.product.model'",
")",
"return",
"output",
".",
"strip... | Show device model. | [
"Show",
"device",
"model",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L131-L135 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_battery_info | def get_battery_info(self) -> dict:
'''Show device battery information.
Returns:
A dict. For example:
{'AC powered': 'false',
'Charge counter': '0',
'Max charging current': '0',
'Max charging voltage': '0',
'US... | python | def get_battery_info(self) -> dict:
'''Show device battery information.
Returns:
A dict. For example:
{'AC powered': 'false',
'Charge counter': '0',
'Max charging current': '0',
'Max charging voltage': '0',
'US... | [
"def",
"get_battery_info",
"(",
"self",
")",
"->",
"dict",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'dumpsys'",
",",
"'battery'",
")",
"battery_status",
"=",
"re",
".",
"sp... | Show device battery information.
Returns:
A dict. For example:
{'AC powered': 'false',
'Charge counter': '0',
'Max charging current': '0',
'Max charging voltage': '0',
'USB powered': 'false',
'Wireless ... | [
"Show",
"device",
"battery",
"information",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L137-L161 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_resolution | def get_resolution(self) -> list:
'''Show device resolution.'''
output, _ = self._execute('-s', self.device_sn, 'shell', 'wm', 'size')
return output.split()[2].split('x') | python | def get_resolution(self) -> list:
'''Show device resolution.'''
output, _ = self._execute('-s', self.device_sn, 'shell', 'wm', 'size')
return output.split()[2].split('x') | [
"def",
"get_resolution",
"(",
"self",
")",
"->",
"list",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'wm'",
",",
"'size'",
")",
"return",
"output",
".",
"split",
"(",
")",
... | Show device resolution. | [
"Show",
"device",
"resolution",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L163-L166 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_displays_params | def get_displays_params(self) -> str:
'''Show displays parameters.'''
output, error = self._execute(
'-s', self.device_sn, 'shell', 'dumpsys', 'window', 'displays')
return output | python | def get_displays_params(self) -> str:
'''Show displays parameters.'''
output, error = self._execute(
'-s', self.device_sn, 'shell', 'dumpsys', 'window', 'displays')
return output | [
"def",
"get_displays_params",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"error",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'dumpsys'",
",",
"'window'",
",",
"'displays'",
")",
"return",
"outp... | Show displays parameters. | [
"Show",
"displays",
"parameters",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L174-L178 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_android_id | def get_android_id(self) -> str:
'''Show Android ID.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'settings', 'get', 'secure', 'android_id')
return output.strip() | python | def get_android_id(self) -> str:
'''Show Android ID.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'settings', 'get', 'secure', 'android_id')
return output.strip() | [
"def",
"get_android_id",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'settings'",
",",
"'get'",
",",
"'secure'",
",",
"'android_id'",
")",
"retu... | Show Android ID. | [
"Show",
"Android",
"ID",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L180-L184 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_android_version | def get_android_version(self) -> str:
'''Show Android version.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'getprop', 'ro.build.version.release')
return output.strip() | python | def get_android_version(self) -> str:
'''Show Android version.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'getprop', 'ro.build.version.release')
return output.strip() | [
"def",
"get_android_version",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'getprop'",
",",
"'ro.build.version.release'",
")",
"return",
"output",
".... | Show Android version. | [
"Show",
"Android",
"version",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L186-L190 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_device_mac | def get_device_mac(self) -> str:
'''Show device MAC.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'cat', '/sys/class/net/wlan0/address')
return output.strip() | python | def get_device_mac(self) -> str:
'''Show device MAC.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'cat', '/sys/class/net/wlan0/address')
return output.strip() | [
"def",
"get_device_mac",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'cat'",
",",
"'/sys/class/net/wlan0/address'",
")",
"return",
"output",
".",
... | Show device MAC. | [
"Show",
"device",
"MAC",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L192-L196 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_cpu_info | def get_cpu_info(self) -> str:
'''Show device CPU information.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'cat', '/proc/cpuinfo')
return output | python | def get_cpu_info(self) -> str:
'''Show device CPU information.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'cat', '/proc/cpuinfo')
return output | [
"def",
"get_cpu_info",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'cat'",
",",
"'/proc/cpuinfo'",
")",
"return",
"output"
] | Show device CPU information. | [
"Show",
"device",
"CPU",
"information",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L198-L202 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_memory_info | def get_memory_info(self) -> str:
'''Show device memory information.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'cat', '/proc/meminfo')
return output | python | def get_memory_info(self) -> str:
'''Show device memory information.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'cat', '/proc/meminfo')
return output | [
"def",
"get_memory_info",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'cat'",
",",
"'/proc/meminfo'",
")",
"return",
"output"
] | Show device memory information. | [
"Show",
"device",
"memory",
"information",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L204-L208 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_sdk_version | def get_sdk_version(self) -> str:
'''Show Android SDK version.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'getprop', 'ro.build.version.sdk')
return output.strip() | python | def get_sdk_version(self) -> str:
'''Show Android SDK version.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'getprop', 'ro.build.version.sdk')
return output.strip() | [
"def",
"get_sdk_version",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'getprop'",
",",
"'ro.build.version.sdk'",
")",
"return",
"output",
".",
"st... | Show Android SDK version. | [
"Show",
"Android",
"SDK",
"version",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L210-L214 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.root | def root(self) -> None:
'''Restart adbd with root permissions.'''
output, _ = self._execute('-s', self.device_sn, 'root')
if not output:
raise PermissionError(
f'{self.device_sn!r} does not have root permission.') | python | def root(self) -> None:
'''Restart adbd with root permissions.'''
output, _ = self._execute('-s', self.device_sn, 'root')
if not output:
raise PermissionError(
f'{self.device_sn!r} does not have root permission.') | [
"def",
"root",
"(",
"self",
")",
"->",
"None",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'root'",
")",
"if",
"not",
"output",
":",
"raise",
"PermissionError",
"(",
"f'{self.device_sn!r} does ... | Restart adbd with root permissions. | [
"Restart",
"adbd",
"with",
"root",
"permissions",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L216-L221 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.tcpip | def tcpip(self, port: int or str = 5555) -> None:
'''Restart adb server listening on TCP on PORT.'''
self._execute('-s', self.device_sn, 'tcpip', str(port)) | python | def tcpip(self, port: int or str = 5555) -> None:
'''Restart adb server listening on TCP on PORT.'''
self._execute('-s', self.device_sn, 'tcpip', str(port)) | [
"def",
"tcpip",
"(",
"self",
",",
"port",
":",
"int",
"or",
"str",
"=",
"5555",
")",
"->",
"None",
":",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'tcpip'",
",",
"str",
"(",
"port",
")",
")"
] | Restart adb server listening on TCP on PORT. | [
"Restart",
"adb",
"server",
"listening",
"on",
"TCP",
"on",
"PORT",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L227-L229 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.get_ip_addr | def get_ip_addr(self) -> str:
'''Show IP Address.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'ip', '-f', 'inet', 'addr', 'show', 'wlan0')
ip_addr = re.findall(
r"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\... | python | def get_ip_addr(self) -> str:
'''Show IP Address.'''
output, _ = self._execute(
'-s', self.device_sn, 'shell', 'ip', '-f', 'inet', 'addr', 'show', 'wlan0')
ip_addr = re.findall(
r"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\... | [
"def",
"get_ip_addr",
"(",
"self",
")",
"->",
"str",
":",
"output",
",",
"_",
"=",
"self",
".",
"_execute",
"(",
"'-s'",
",",
"self",
".",
"device_sn",
",",
"'shell'",
",",
"'ip'",
",",
"'-f'",
",",
"'inet'",
",",
"'addr'",
",",
"'show'",
",",
"'wl... | Show IP Address. | [
"Show",
"IP",
"Address",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L231-L240 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.sync_l | def sync_l(self, option: str = 'all') -> None:
'''List but don't copy.
Args:
option: 'system', 'vendor', 'oem', 'data', 'all'
'''
if option in ['system', 'vendor', 'oem', 'data', 'all']:
self._execute('-s', self.device_sn, 'sync', '-l', option)
else:
... | python | def sync_l(self, option: str = 'all') -> None:
'''List but don't copy.
Args:
option: 'system', 'vendor', 'oem', 'data', 'all'
'''
if option in ['system', 'vendor', 'oem', 'data', 'all']:
self._execute('-s', self.device_sn, 'sync', '-l', option)
else:
... | [
"def",
"sync_l",
"(",
"self",
",",
"option",
":",
"str",
"=",
"'all'",
")",
"->",
"None",
":",
"if",
"option",
"in",
"[",
"'system'",
",",
"'vendor'",
",",
"'oem'",
",",
"'data'",
",",
"'all'",
"]",
":",
"self",
".",
"_execute",
"(",
"'-s'",
",",
... | List but don't copy.
Args:
option: 'system', 'vendor', 'oem', 'data', 'all' | [
"List",
"but",
"don",
"t",
"copy",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L285-L294 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.install | def install(self, package: str, option: str = '-r') -> None:
'''Push package to the device and install it.
Args:
option:
-l: forward lock application
-r: replace existing application
-t: allow test packages
-s: install applicat... | python | def install(self, package: str, option: str = '-r') -> None:
'''Push package to the device and install it.
Args:
option:
-l: forward lock application
-r: replace existing application
-t: allow test packages
-s: install applicat... | [
"def",
"install",
"(",
"self",
",",
"package",
":",
"str",
",",
"option",
":",
"str",
"=",
"'-r'",
")",
"->",
"None",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"package",
")",
":",
"raise",
"FileNotFoundError",
"(",
"f'{package!r} does n... | Push package to the device and install it.
Args:
option:
-l: forward lock application
-r: replace existing application
-t: allow test packages
-s: install application on sdcard
-d: allow version code downgrade (debuggab... | [
"Push",
"package",
"to",
"the",
"device",
"and",
"install",
"it",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L297-L314 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.uninstall | def uninstall(self, package: str) -> None:
'''Remove this app package from the device.'''
if package not in self.view_packgets_list():
raise NoSuchPackageException(
f'There is no such package {package!r}.')
self._execute('-s', self.device_sn, 'uninstall', package) | python | def uninstall(self, package: str) -> None:
'''Remove this app package from the device.'''
if package not in self.view_packgets_list():
raise NoSuchPackageException(
f'There is no such package {package!r}.')
self._execute('-s', self.device_sn, 'uninstall', package) | [
"def",
"uninstall",
"(",
"self",
",",
"package",
":",
"str",
")",
"->",
"None",
":",
"if",
"package",
"not",
"in",
"self",
".",
"view_packgets_list",
"(",
")",
":",
"raise",
"NoSuchPackageException",
"(",
"f'There is no such package {package!r}.'",
")",
"self",
... | Remove this app package from the device. | [
"Remove",
"this",
"app",
"package",
"from",
"the",
"device",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L338-L343 | train |
fjwCode/cerium | cerium/androiddriver.py | BaseAndroidDriver.view_packgets_list | def view_packgets_list(self, option: str = '-e', keyword: str = '') -> list:
'''Show all packages.
Args:
option:
-f see their associated file
-d filter to only show disabled packages
-e filter to only show enabled packages
-s f... | python | def view_packgets_list(self, option: str = '-e', keyword: str = '') -> list:
'''Show all packages.
Args:
option:
-f see their associated file
-d filter to only show disabled packages
-e filter to only show enabled packages
-s f... | [
"def",
"view_packgets_list",
"(",
"self",
",",
"option",
":",
"str",
"=",
"'-e'",
",",
"keyword",
":",
"str",
"=",
"''",
")",
"->",
"list",
":",
"if",
"option",
"not",
"in",
"[",
"'-f'",
",",
"'-d'",
",",
"'-e'",
",",
"'-s'",
",",
"'-3'",
",",
"'... | Show all packages.
Args:
option:
-f see their associated file
-d filter to only show disabled packages
-e filter to only show enabled packages
-s filter to only show system packages
-3 filter to only show third party pa... | [
"Show",
"all",
"packages",
"."
] | f6e06e0dcf83a0bc924828e9d6cb81383ed2364f | https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L352-L370 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.