repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
mfcloud/python-zvm-sdk | zvmsdk/vmops.py | VMOps.execute_cmd | def execute_cmd(self, userid, cmdStr):
"""Execute commands on the guest vm."""
LOG.debug("executing cmd: %s", cmdStr)
return self._smtclient.execute_cmd(userid, cmdStr) | python | def execute_cmd(self, userid, cmdStr):
"""Execute commands on the guest vm."""
LOG.debug("executing cmd: %s", cmdStr)
return self._smtclient.execute_cmd(userid, cmdStr) | [
"def",
"execute_cmd",
"(",
"self",
",",
"userid",
",",
"cmdStr",
")",
":",
"LOG",
".",
"debug",
"(",
"\"executing cmd: %s\"",
",",
"cmdStr",
")",
"return",
"self",
".",
"_smtclient",
".",
"execute_cmd",
"(",
"userid",
",",
"cmdStr",
")"
] | Execute commands on the guest vm. | [
"Execute",
"commands",
"on",
"the",
"guest",
"vm",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/vmops.py#L236-L239 |
mfcloud/python-zvm-sdk | zvmsdk/vmops.py | VMOps.set_hostname | def set_hostname(self, userid, hostname, os_version):
"""Punch a script that used to set the hostname of the guest.
:param str guest: the user id of the guest
:param str hostname: the hostname of the guest
:param str os_version: version of guest operation system
"""
tmp_... | python | def set_hostname(self, userid, hostname, os_version):
"""Punch a script that used to set the hostname of the guest.
:param str guest: the user id of the guest
:param str hostname: the hostname of the guest
:param str os_version: version of guest operation system
"""
tmp_... | [
"def",
"set_hostname",
"(",
"self",
",",
"userid",
",",
"hostname",
",",
"os_version",
")",
":",
"tmp_path",
"=",
"self",
".",
"_pathutils",
".",
"get_guest_temp_path",
"(",
"userid",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"tmp_path",
"... | Punch a script that used to set the hostname of the guest.
:param str guest: the user id of the guest
:param str hostname: the hostname of the guest
:param str os_version: version of guest operation system | [
"Punch",
"a",
"script",
"that",
"used",
"to",
"set",
"the",
"hostname",
"of",
"the",
"guest",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/vmops.py#L241-L270 |
mfcloud/python-zvm-sdk | smtLayer/generalUtils.py | cvtToBlocks | def cvtToBlocks(rh, diskSize):
"""
Convert a disk storage value to a number of blocks.
Input:
Request Handle
Size of disk in bytes
Output:
Results structure:
overallRC - Overall return code for the function:
0 - Everything went ok
... | python | def cvtToBlocks(rh, diskSize):
"""
Convert a disk storage value to a number of blocks.
Input:
Request Handle
Size of disk in bytes
Output:
Results structure:
overallRC - Overall return code for the function:
0 - Everything went ok
... | [
"def",
"cvtToBlocks",
"(",
"rh",
",",
"diskSize",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter generalUtils.cvtToBlocks\"",
")",
"blocks",
"=",
"0",
"results",
"=",
"{",
"'overallRC'",
":",
"0",
",",
"'rc'",
":",
"0",
",",
"'rs'",
":",
"0",
",",
"... | Convert a disk storage value to a number of blocks.
Input:
Request Handle
Size of disk in bytes
Output:
Results structure:
overallRC - Overall return code for the function:
0 - Everything went ok
4 - Input validation error
... | [
"Convert",
"a",
"disk",
"storage",
"value",
"to",
"a",
"number",
"of",
"blocks",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/generalUtils.py#L25-L78 |
mfcloud/python-zvm-sdk | smtLayer/generalUtils.py | cvtToMag | def cvtToMag(rh, size):
"""
Convert a size value to a number with a magnitude appended.
Input:
Request Handle
Size bytes
Output:
Converted value with a magnitude
"""
rh.printSysLog("Enter generalUtils.cvtToMag")
mSize = ''
size = size / (1024 * 1024)
if size... | python | def cvtToMag(rh, size):
"""
Convert a size value to a number with a magnitude appended.
Input:
Request Handle
Size bytes
Output:
Converted value with a magnitude
"""
rh.printSysLog("Enter generalUtils.cvtToMag")
mSize = ''
size = size / (1024 * 1024)
if size... | [
"def",
"cvtToMag",
"(",
"rh",
",",
"size",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter generalUtils.cvtToMag\"",
")",
"mSize",
"=",
"''",
"size",
"=",
"size",
"/",
"(",
"1024",
"*",
"1024",
")",
"if",
"size",
">",
"(",
"1024",
"*",
"5",
")",
... | Convert a size value to a number with a magnitude appended.
Input:
Request Handle
Size bytes
Output:
Converted value with a magnitude | [
"Convert",
"a",
"size",
"value",
"to",
"a",
"number",
"with",
"a",
"magnitude",
"appended",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/generalUtils.py#L137-L163 |
mfcloud/python-zvm-sdk | smtLayer/generalUtils.py | getSizeFromPage | def getSizeFromPage(rh, page):
"""
Convert a size value from page to a number with a magnitude appended.
Input:
Request Handle
Size in page
Output:
Converted value with a magnitude
"""
rh.printSysLog("Enter generalUtils.getSizeFromPage")
bSize = float(page) * 4096
... | python | def getSizeFromPage(rh, page):
"""
Convert a size value from page to a number with a magnitude appended.
Input:
Request Handle
Size in page
Output:
Converted value with a magnitude
"""
rh.printSysLog("Enter generalUtils.getSizeFromPage")
bSize = float(page) * 4096
... | [
"def",
"getSizeFromPage",
"(",
"rh",
",",
"page",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter generalUtils.getSizeFromPage\"",
")",
"bSize",
"=",
"float",
"(",
"page",
")",
"*",
"4096",
"mSize",
"=",
"cvtToMag",
"(",
"rh",
",",
"bSize",
")",
"rh",
... | Convert a size value from page to a number with a magnitude appended.
Input:
Request Handle
Size in page
Output:
Converted value with a magnitude | [
"Convert",
"a",
"size",
"value",
"from",
"page",
"to",
"a",
"number",
"with",
"a",
"magnitude",
"appended",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/generalUtils.py#L166-L183 |
mfcloud/python-zvm-sdk | smtLayer/generalUtils.py | parseCmdline | def parseCmdline(rh, posOpsList, keyOpsList):
"""
Parse the request command input.
Input:
Request Handle
Positional Operands List. This is a dictionary that contains
an array for each subfunction. The array contains a entry
(itself an array) for each positional operand.
... | python | def parseCmdline(rh, posOpsList, keyOpsList):
"""
Parse the request command input.
Input:
Request Handle
Positional Operands List. This is a dictionary that contains
an array for each subfunction. The array contains a entry
(itself an array) for each positional operand.
... | [
"def",
"parseCmdline",
"(",
"rh",
",",
"posOpsList",
",",
"keyOpsList",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter generalUtils.parseCmdline\"",
")",
"# Handle any positional operands on the line.",
"if",
"rh",
".",
"results",
"[",
"'overallRC'",
"]",
"==",
"... | Parse the request command input.
Input:
Request Handle
Positional Operands List. This is a dictionary that contains
an array for each subfunction. The array contains a entry
(itself an array) for each positional operand.
That array contains:
- Human readable name of t... | [
"Parse",
"the",
"request",
"command",
"input",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/generalUtils.py#L186-L336 |
rpkilby/SurveyGizmo | surveygizmo/surveygizmo.py | default_52xhandler | def default_52xhandler(response, resource, url, params):
"""
Default 52x handler that loops every second until a non 52x response is received.
:param response: The response of the last executed api request.
:param resource: The resource of the last executed api request.
:param url: The url of the la... | python | def default_52xhandler(response, resource, url, params):
"""
Default 52x handler that loops every second until a non 52x response is received.
:param response: The response of the last executed api request.
:param resource: The resource of the last executed api request.
:param url: The url of the la... | [
"def",
"default_52xhandler",
"(",
"response",
",",
"resource",
",",
"url",
",",
"params",
")",
":",
"time",
".",
"sleep",
"(",
"1",
")",
"return",
"resource",
".",
"execute",
"(",
"url",
",",
"params",
")"
] | Default 52x handler that loops every second until a non 52x response is received.
:param response: The response of the last executed api request.
:param resource: The resource of the last executed api request.
:param url: The url of the last executed api request sans encoded query parameters.
:param par... | [
"Default",
"52x",
"handler",
"that",
"loops",
"every",
"second",
"until",
"a",
"non",
"52x",
"response",
"is",
"received",
".",
":",
"param",
"response",
":",
"The",
"response",
"of",
"the",
"last",
"executed",
"api",
"request",
".",
":",
"param",
"resourc... | train | https://github.com/rpkilby/SurveyGizmo/blob/a097091dc7dcfb58f70242fb1becabc98df049a5/surveygizmo/surveygizmo.py#L17-L26 |
rpkilby/SurveyGizmo | surveygizmo/surveygizmo.py | Config.validate | def validate(self):
"""
Perform validation check on properties.
"""
if not self.api_token or not self.api_token_secret:
raise ImproperlyConfigured("'api_token' and 'api_token_secret' are required for authentication.")
if self.response_type not in ["json", "pson", "xm... | python | def validate(self):
"""
Perform validation check on properties.
"""
if not self.api_token or not self.api_token_secret:
raise ImproperlyConfigured("'api_token' and 'api_token_secret' are required for authentication.")
if self.response_type not in ["json", "pson", "xm... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"api_token",
"or",
"not",
"self",
".",
"api_token_secret",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"'api_token' and 'api_token_secret' are required for authentication.\"",
")",
"if",
"self",
".",... | Perform validation check on properties. | [
"Perform",
"validation",
"check",
"on",
"properties",
"."
] | train | https://github.com/rpkilby/SurveyGizmo/blob/a097091dc7dcfb58f70242fb1becabc98df049a5/surveygizmo/surveygizmo.py#L41-L49 |
rpkilby/SurveyGizmo | surveygizmo/surveygizmo.py | API.execute | def execute(self, url, params):
""" Executes a call to the API.
:param url: The full url for the api call.
:param params: Query parameters encoded in the request.
"""
response = requests.get(url, params=params, **self.config.requests_kwargs)
if 520 <= response.st... | python | def execute(self, url, params):
""" Executes a call to the API.
:param url: The full url for the api call.
:param params: Query parameters encoded in the request.
"""
response = requests.get(url, params=params, **self.config.requests_kwargs)
if 520 <= response.st... | [
"def",
"execute",
"(",
"self",
",",
"url",
",",
"params",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"params",
"=",
"params",
",",
"*",
"*",
"self",
".",
"config",
".",
"requests_kwargs",
")",
"if",
"520",
"<=",
"response",
... | Executes a call to the API.
:param url: The full url for the api call.
:param params: Query parameters encoded in the request. | [
"Executes",
"a",
"call",
"to",
"the",
"API",
".",
":",
"param",
"url",
":",
"The",
"full",
"url",
"for",
"the",
"api",
"call",
".",
":",
"param",
"params",
":",
"Query",
"parameters",
"encoded",
"in",
"the",
"request",
"."
] | train | https://github.com/rpkilby/SurveyGizmo/blob/a097091dc7dcfb58f70242fb1becabc98df049a5/surveygizmo/surveygizmo.py#L106-L122 |
mfcloud/python-zvm-sdk | zvmsdk/networkops.py | NetworkOPS._create_invokeScript | def _create_invokeScript(self, network_file_path, commands,
files_map):
"""invokeScript: Configure zLinux os network
invokeScript is included in the network.doscript, it is used to put
the network configuration file to the directory where it belongs and
call... | python | def _create_invokeScript(self, network_file_path, commands,
files_map):
"""invokeScript: Configure zLinux os network
invokeScript is included in the network.doscript, it is used to put
the network configuration file to the directory where it belongs and
call... | [
"def",
"_create_invokeScript",
"(",
"self",
",",
"network_file_path",
",",
"commands",
",",
"files_map",
")",
":",
"LOG",
".",
"debug",
"(",
"'Creating invokeScript shell in the folder %s'",
"%",
"network_file_path",
")",
"invokeScript",
"=",
"\"invokeScript.sh\"",
"con... | invokeScript: Configure zLinux os network
invokeScript is included in the network.doscript, it is used to put
the network configuration file to the directory where it belongs and
call znetconfig to configure the network | [
"invokeScript",
":",
"Configure",
"zLinux",
"os",
"network"
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/networkops.py#L213-L240 |
mfcloud/python-zvm-sdk | zvmsdk/networkops.py | NetworkOPS._create_network_doscript | def _create_network_doscript(self, network_file_path):
"""doscript: contains a invokeScript.sh which will do the special work
The network.doscript contains network configuration files and it will
be used by zvmguestconfigure to configure zLinux os network when it
starts up
"""
... | python | def _create_network_doscript(self, network_file_path):
"""doscript: contains a invokeScript.sh which will do the special work
The network.doscript contains network configuration files and it will
be used by zvmguestconfigure to configure zLinux os network when it
starts up
"""
... | [
"def",
"_create_network_doscript",
"(",
"self",
",",
"network_file_path",
")",
":",
"# Generate the tar package for punch",
"LOG",
".",
"debug",
"(",
"'Creating network doscript in the folder %s'",
"%",
"network_file_path",
")",
"network_doscript",
"=",
"os",
".",
"path",
... | doscript: contains a invokeScript.sh which will do the special work
The network.doscript contains network configuration files and it will
be used by zvmguestconfigure to configure zLinux os network when it
starts up | [
"doscript",
":",
"contains",
"a",
"invokeScript",
".",
"sh",
"which",
"will",
"do",
"the",
"special",
"work"
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/networkops.py#L242-L258 |
jvarho/pylibscrypt | pylibscrypt/pypyscrypt.py | R | def R(X, destination, a1, a2, b):
"""A single Salsa20 row operation"""
a = (X[a1] + X[a2]) & 0xffffffff
X[destination] ^= ((a << b) | (a >> (32 - b))) | python | def R(X, destination, a1, a2, b):
"""A single Salsa20 row operation"""
a = (X[a1] + X[a2]) & 0xffffffff
X[destination] ^= ((a << b) | (a >> (32 - b))) | [
"def",
"R",
"(",
"X",
",",
"destination",
",",
"a1",
",",
"a2",
",",
"b",
")",
":",
"a",
"=",
"(",
"X",
"[",
"a1",
"]",
"+",
"X",
"[",
"a2",
"]",
")",
"&",
"0xffffffff",
"X",
"[",
"destination",
"]",
"^=",
"(",
"(",
"a",
"<<",
"b",
")",
... | A single Salsa20 row operation | [
"A",
"single",
"Salsa20",
"row",
"operation"
] | train | https://github.com/jvarho/pylibscrypt/blob/f2ff02e49f44aa620e308a4a64dd8376b9510f99/pylibscrypt/pypyscrypt.py#L60-L64 |
jvarho/pylibscrypt | pylibscrypt/pypyscrypt.py | salsa20_8 | def salsa20_8(B, x, src, s_start, dest, d_start):
"""Salsa20/8 http://en.wikipedia.org/wiki/Salsa20"""
# Merged blockxor for speed
for i in xrange(16):
x[i] = B[i] = B[i] ^ src[s_start + i]
# This is the actual Salsa 20/8: four identical double rounds
for i in xrange(4):
R(x, 4, 0,... | python | def salsa20_8(B, x, src, s_start, dest, d_start):
"""Salsa20/8 http://en.wikipedia.org/wiki/Salsa20"""
# Merged blockxor for speed
for i in xrange(16):
x[i] = B[i] = B[i] ^ src[s_start + i]
# This is the actual Salsa 20/8: four identical double rounds
for i in xrange(4):
R(x, 4, 0,... | [
"def",
"salsa20_8",
"(",
"B",
",",
"x",
",",
"src",
",",
"s_start",
",",
"dest",
",",
"d_start",
")",
":",
"# Merged blockxor for speed",
"for",
"i",
"in",
"xrange",
"(",
"16",
")",
":",
"x",
"[",
"i",
"]",
"=",
"B",
"[",
"i",
"]",
"=",
"B",
"[... | Salsa20/8 http://en.wikipedia.org/wiki/Salsa20 | [
"Salsa20",
"/",
"8",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Salsa20"
] | train | https://github.com/jvarho/pylibscrypt/blob/f2ff02e49f44aa620e308a4a64dd8376b9510f99/pylibscrypt/pypyscrypt.py#L67-L88 |
mfcloud/python-zvm-sdk | zvmsdk/sdkwsgi/handlers/file.py | fileChunkIter | def fileChunkIter(file_object, file_chunk_size=65536):
"""
Return an iterator to a file-like object that yields fixed size chunks
:param file_object: a file-like object
:param file_chunk_size: maximum size of chunk
"""
while True:
chunk = file_object.read(file_chunk_size)
if chu... | python | def fileChunkIter(file_object, file_chunk_size=65536):
"""
Return an iterator to a file-like object that yields fixed size chunks
:param file_object: a file-like object
:param file_chunk_size: maximum size of chunk
"""
while True:
chunk = file_object.read(file_chunk_size)
if chu... | [
"def",
"fileChunkIter",
"(",
"file_object",
",",
"file_chunk_size",
"=",
"65536",
")",
":",
"while",
"True",
":",
"chunk",
"=",
"file_object",
".",
"read",
"(",
"file_chunk_size",
")",
"if",
"chunk",
":",
"yield",
"chunk",
"else",
":",
"break"
] | Return an iterator to a file-like object that yields fixed size chunks
:param file_object: a file-like object
:param file_chunk_size: maximum size of chunk | [
"Return",
"an",
"iterator",
"to",
"a",
"file",
"-",
"like",
"object",
"that",
"yields",
"fixed",
"size",
"chunks"
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/sdkwsgi/handlers/file.py#L223-L235 |
jvarho/pylibscrypt | pylibscrypt/pylibscrypt.py | scrypt | def scrypt(password, salt, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, olen=64):
"""Returns a key derived using the scrypt key-derivarion function
N must be a power of two larger than 1 but no larger than 2 ** 63 (insane)
r and p must be positive numbers such that r * p < 2 ** 30
The default values are:
N... | python | def scrypt(password, salt, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p, olen=64):
"""Returns a key derived using the scrypt key-derivarion function
N must be a power of two larger than 1 but no larger than 2 ** 63 (insane)
r and p must be positive numbers such that r * p < 2 ** 30
The default values are:
N... | [
"def",
"scrypt",
"(",
"password",
",",
"salt",
",",
"N",
"=",
"SCRYPT_N",
",",
"r",
"=",
"SCRYPT_r",
",",
"p",
"=",
"SCRYPT_p",
",",
"olen",
"=",
"64",
")",
":",
"check_args",
"(",
"password",
",",
"salt",
",",
"N",
",",
"r",
",",
"p",
",",
"ol... | Returns a key derived using the scrypt key-derivarion function
N must be a power of two larger than 1 but no larger than 2 ** 63 (insane)
r and p must be positive numbers such that r * p < 2 ** 30
The default values are:
N -- 2**14 (~16k)
r -- 8
p -- 1
Memory usage is proportional to N*r.... | [
"Returns",
"a",
"key",
"derived",
"using",
"the",
"scrypt",
"key",
"-",
"derivarion",
"function"
] | train | https://github.com/jvarho/pylibscrypt/blob/f2ff02e49f44aa620e308a4a64dd8376b9510f99/pylibscrypt/pylibscrypt.py#L71-L98 |
jvarho/pylibscrypt | pylibscrypt/pylibscrypt.py | scrypt_mcf | def scrypt_mcf(password, salt=None, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p,
prefix=SCRYPT_MCF_PREFIX_DEFAULT):
"""Derives a Modular Crypt Format hash using the scrypt KDF
Parameter space is smaller than for scrypt():
N must be a power of two larger than 1 but no larger than 2 ** 31
r and p m... | python | def scrypt_mcf(password, salt=None, N=SCRYPT_N, r=SCRYPT_r, p=SCRYPT_p,
prefix=SCRYPT_MCF_PREFIX_DEFAULT):
"""Derives a Modular Crypt Format hash using the scrypt KDF
Parameter space is smaller than for scrypt():
N must be a power of two larger than 1 but no larger than 2 ** 31
r and p m... | [
"def",
"scrypt_mcf",
"(",
"password",
",",
"salt",
"=",
"None",
",",
"N",
"=",
"SCRYPT_N",
",",
"r",
"=",
"SCRYPT_r",
",",
"p",
"=",
"SCRYPT_p",
",",
"prefix",
"=",
"SCRYPT_MCF_PREFIX_DEFAULT",
")",
":",
"if",
"(",
"prefix",
"!=",
"SCRYPT_MCF_PREFIX_s1",
... | Derives a Modular Crypt Format hash using the scrypt KDF
Parameter space is smaller than for scrypt():
N must be a power of two larger than 1 but no larger than 2 ** 31
r and p must be positive numbers between 1 and 255
Salt must be a byte string 1-16 bytes long.
If no salt is given, a random salt... | [
"Derives",
"a",
"Modular",
"Crypt",
"Format",
"hash",
"using",
"the",
"scrypt",
"KDF"
] | train | https://github.com/jvarho/pylibscrypt/blob/f2ff02e49f44aa620e308a4a64dd8376b9510f99/pylibscrypt/pylibscrypt.py#L101-L142 |
jvarho/pylibscrypt | pylibscrypt/pylibscrypt.py | scrypt_mcf_check | def scrypt_mcf_check(mcf, password):
"""Returns True if the password matches the given MCF hash"""
if not isinstance(mcf, bytes):
raise TypeError('MCF must be a byte string')
if isinstance(password, unicode):
password = password.encode('utf8')
elif not isinstance(password, bytes):
... | python | def scrypt_mcf_check(mcf, password):
"""Returns True if the password matches the given MCF hash"""
if not isinstance(mcf, bytes):
raise TypeError('MCF must be a byte string')
if isinstance(password, unicode):
password = password.encode('utf8')
elif not isinstance(password, bytes):
... | [
"def",
"scrypt_mcf_check",
"(",
"mcf",
",",
"password",
")",
":",
"if",
"not",
"isinstance",
"(",
"mcf",
",",
"bytes",
")",
":",
"raise",
"TypeError",
"(",
"'MCF must be a byte string'",
")",
"if",
"isinstance",
"(",
"password",
",",
"unicode",
")",
":",
"... | Returns True if the password matches the given MCF hash | [
"Returns",
"True",
"if",
"the",
"password",
"matches",
"the",
"given",
"MCF",
"hash"
] | train | https://github.com/jvarho/pylibscrypt/blob/f2ff02e49f44aa620e308a4a64dd8376b9510f99/pylibscrypt/pylibscrypt.py#L145-L161 |
ratcave/wavefront_reader | wavefront_reader/reading.py | parse_mixed_delim_str | def parse_mixed_delim_str(line):
"""Turns .obj face index string line into [verts, texcoords, normals] numeric tuples."""
arrs = [[], [], []]
for group in line.split(' '):
for col, coord in enumerate(group.split('/')):
if coord:
arrs[col].append(int(coord))
return [t... | python | def parse_mixed_delim_str(line):
"""Turns .obj face index string line into [verts, texcoords, normals] numeric tuples."""
arrs = [[], [], []]
for group in line.split(' '):
for col, coord in enumerate(group.split('/')):
if coord:
arrs[col].append(int(coord))
return [t... | [
"def",
"parse_mixed_delim_str",
"(",
"line",
")",
":",
"arrs",
"=",
"[",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
"]",
"for",
"group",
"in",
"line",
".",
"split",
"(",
"' '",
")",
":",
"for",
"col",
",",
"coord",
"in",
"enumerate",
"(",
"group",
... | Turns .obj face index string line into [verts, texcoords, normals] numeric tuples. | [
"Turns",
".",
"obj",
"face",
"index",
"string",
"line",
"into",
"[",
"verts",
"texcoords",
"normals",
"]",
"numeric",
"tuples",
"."
] | train | https://github.com/ratcave/wavefront_reader/blob/c515164a3952d6b85f8044f429406fddd862bfd0/wavefront_reader/reading.py#L7-L15 |
ratcave/wavefront_reader | wavefront_reader/reading.py | read_objfile | def read_objfile(fname):
"""Takes .obj filename and returns dict of object properties for each object in file."""
verts = defaultdict(list)
obj_props = []
with open(fname) as f:
lines = f.read().splitlines()
for line in lines:
if line:
split_line = line.strip().split(' '... | python | def read_objfile(fname):
"""Takes .obj filename and returns dict of object properties for each object in file."""
verts = defaultdict(list)
obj_props = []
with open(fname) as f:
lines = f.read().splitlines()
for line in lines:
if line:
split_line = line.strip().split(' '... | [
"def",
"read_objfile",
"(",
"fname",
")",
":",
"verts",
"=",
"defaultdict",
"(",
"list",
")",
"obj_props",
"=",
"[",
"]",
"with",
"open",
"(",
"fname",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",
"f... | Takes .obj filename and returns dict of object properties for each object in file. | [
"Takes",
".",
"obj",
"filename",
"and",
"returns",
"dict",
"of",
"object",
"properties",
"for",
"each",
"object",
"in",
"file",
"."
] | train | https://github.com/ratcave/wavefront_reader/blob/c515164a3952d6b85f8044f429406fddd862bfd0/wavefront_reader/reading.py#L18-L65 |
ratcave/wavefront_reader | wavefront_reader/reading.py | read_wavefront | def read_wavefront(fname_obj):
"""Returns mesh dictionary along with their material dictionary from a wavefront (.obj and/or .mtl) file."""
fname_mtl = ''
geoms = read_objfile(fname_obj)
for line in open(fname_obj):
if line:
split_line = line.strip().split(' ', 1)
if len(... | python | def read_wavefront(fname_obj):
"""Returns mesh dictionary along with their material dictionary from a wavefront (.obj and/or .mtl) file."""
fname_mtl = ''
geoms = read_objfile(fname_obj)
for line in open(fname_obj):
if line:
split_line = line.strip().split(' ', 1)
if len(... | [
"def",
"read_wavefront",
"(",
"fname_obj",
")",
":",
"fname_mtl",
"=",
"''",
"geoms",
"=",
"read_objfile",
"(",
"fname_obj",
")",
"for",
"line",
"in",
"open",
"(",
"fname_obj",
")",
":",
"if",
"line",
":",
"split_line",
"=",
"line",
".",
"strip",
"(",
... | Returns mesh dictionary along with their material dictionary from a wavefront (.obj and/or .mtl) file. | [
"Returns",
"mesh",
"dictionary",
"along",
"with",
"their",
"material",
"dictionary",
"from",
"a",
"wavefront",
"(",
".",
"obj",
"and",
"/",
"or",
".",
"mtl",
")",
"file",
"."
] | train | https://github.com/ratcave/wavefront_reader/blob/c515164a3952d6b85f8044f429406fddd862bfd0/wavefront_reader/reading.py#L98-L119 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | disableEnableDisk | def disableEnableDisk(rh, userid, vaddr, option):
"""
Disable or enable a disk.
Input:
Request Handle:
owning userid
virtual address
option ('-e': enable, '-d': disable)
Output:
Dictionary containing the following:
overallRC - overall return code, ... | python | def disableEnableDisk(rh, userid, vaddr, option):
"""
Disable or enable a disk.
Input:
Request Handle:
owning userid
virtual address
option ('-e': enable, '-d': disable)
Output:
Dictionary containing the following:
overallRC - overall return code, ... | [
"def",
"disableEnableDisk",
"(",
"rh",
",",
"userid",
",",
"vaddr",
",",
"option",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.disableEnableDisk, userid: \"",
"+",
"userid",
"+",
"\" addr: \"",
"+",
"vaddr",
"+",
"\" option: \"",
"+",
"option",
")"... | Disable or enable a disk.
Input:
Request Handle:
owning userid
virtual address
option ('-e': enable, '-d': disable)
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
rc - rc from th... | [
"Disable",
"or",
"enable",
"a",
"disk",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L28-L77 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | execCmdThruIUCV | def execCmdThruIUCV(rh, userid, strCmd, hideInLog=[]):
"""
Send a command to a virtual machine using IUCV.
Input:
Request Handle
Userid of the target virtual machine
Command string to send
(Optional) List of strCmd words (by index) to hide in
sysLog by replacing the wo... | python | def execCmdThruIUCV(rh, userid, strCmd, hideInLog=[]):
"""
Send a command to a virtual machine using IUCV.
Input:
Request Handle
Userid of the target virtual machine
Command string to send
(Optional) List of strCmd words (by index) to hide in
sysLog by replacing the wo... | [
"def",
"execCmdThruIUCV",
"(",
"rh",
",",
"userid",
",",
"strCmd",
",",
"hideInLog",
"=",
"[",
"]",
")",
":",
"if",
"len",
"(",
"hideInLog",
")",
"==",
"0",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.execCmdThruIUCV, userid: \"",
"+",
"userid",
"... | Send a command to a virtual machine using IUCV.
Input:
Request Handle
Userid of the target virtual machine
Command string to send
(Optional) List of strCmd words (by index) to hide in
sysLog by replacing the word with "<hidden>".
Output:
Dictionary containing the f... | [
"Send",
"a",
"command",
"to",
"a",
"virtual",
"machine",
"using",
"IUCV",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L80-L203 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | getPerfInfo | def getPerfInfo(rh, useridlist):
"""
Get the performance information for a userid
Input:
Request Handle
Userid to query <- may change this to a list later.
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
... | python | def getPerfInfo(rh, useridlist):
"""
Get the performance information for a userid
Input:
Request Handle
Userid to query <- may change this to a list later.
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
... | [
"def",
"getPerfInfo",
"(",
"rh",
",",
"useridlist",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.getPerfInfo, userid: \"",
"+",
"useridlist",
")",
"parms",
"=",
"[",
"\"-T\"",
",",
"rh",
".",
"userid",
",",
"\"-c\"",
",",
"\"1\"",
"]",
"results"... | Get the performance information for a userid
Input:
Request Handle
Userid to query <- may change this to a list later.
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
rc - RC returned from SMCLI if over... | [
"Get",
"the",
"performance",
"information",
"for",
"a",
"userid"
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L206-L269 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | installFS | def installFS(rh, vaddr, mode, fileSystem, diskType):
"""
Install a filesystem on a virtual machine's dasd.
Input:
Request Handle:
userid - Userid that owns the disk
Virtual address as known to the owning system.
Access mode to use to get the disk.
Disk Type - 3390 or ... | python | def installFS(rh, vaddr, mode, fileSystem, diskType):
"""
Install a filesystem on a virtual machine's dasd.
Input:
Request Handle:
userid - Userid that owns the disk
Virtual address as known to the owning system.
Access mode to use to get the disk.
Disk Type - 3390 or ... | [
"def",
"installFS",
"(",
"rh",
",",
"vaddr",
",",
"mode",
",",
"fileSystem",
",",
"diskType",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.installFS, userid: \"",
"+",
"rh",
".",
"userid",
"+",
"\", vaddr: \"",
"+",
"str",
"(",
"vaddr",
")",
"... | Install a filesystem on a virtual machine's dasd.
Input:
Request Handle:
userid - Userid that owns the disk
Virtual address as known to the owning system.
Access mode to use to get the disk.
Disk Type - 3390 or 9336
Output:
Dictionary containing the following:
... | [
"Install",
"a",
"filesystem",
"on",
"a",
"virtual",
"machine",
"s",
"dasd",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L272-L570 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | invokeSMCLI | def invokeSMCLI(rh, api, parms, hideInLog=[]):
"""
Invoke SMCLI and parse the results.
Input:
Request Handle
API name,
SMCLI parms as an array
(Optional) List of parms (by index) to hide in
sysLog by replacing the parm with "<hidden>".
Output:
Dictionary co... | python | def invokeSMCLI(rh, api, parms, hideInLog=[]):
"""
Invoke SMCLI and parse the results.
Input:
Request Handle
API name,
SMCLI parms as an array
(Optional) List of parms (by index) to hide in
sysLog by replacing the parm with "<hidden>".
Output:
Dictionary co... | [
"def",
"invokeSMCLI",
"(",
"rh",
",",
"api",
",",
"parms",
",",
"hideInLog",
"=",
"[",
"]",
")",
":",
"if",
"len",
"(",
"hideInLog",
")",
"==",
"0",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.invokeSMCLI, userid: \"",
"+",
"rh",
".",
"userid",
... | Invoke SMCLI and parse the results.
Input:
Request Handle
API name,
SMCLI parms as an array
(Optional) List of parms (by index) to hide in
sysLog by replacing the parm with "<hidden>".
Output:
Dictionary containing the following:
overallRC - overall retur... | [
"Invoke",
"SMCLI",
"and",
"parse",
"the",
"results",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L573-L721 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | isLoggedOn | def isLoggedOn(rh, userid):
"""
Determine whether a virtual machine is logged on.
Input:
Request Handle:
userid being queried
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
rc - 0: if we got... | python | def isLoggedOn(rh, userid):
"""
Determine whether a virtual machine is logged on.
Input:
Request Handle:
userid being queried
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
rc - 0: if we got... | [
"def",
"isLoggedOn",
"(",
"rh",
",",
"userid",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.isLoggedOn, userid: \"",
"+",
"userid",
")",
"results",
"=",
"{",
"'overallRC'",
":",
"0",
",",
"'rc'",
":",
"0",
",",
"'rs'",
":",
"0",
",",
"}",
... | Determine whether a virtual machine is logged on.
Input:
Request Handle:
userid being queried
Output:
Dictionary containing the following:
overallRC - overall return code, 0: success, non-zero: failure
rc - 0: if we got status. Otherwise, it is the
... | [
"Determine",
"whether",
"a",
"virtual",
"machine",
"is",
"logged",
"on",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L724-L779 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | punch2reader | def punch2reader(rh, userid, fileLoc, spoolClass):
"""
Punch a file to a virtual reader of the specified virtual machine.
Input:
Request Handle - for general use and to hold the results
userid - userid of the virtual machine
fileLoc - File to send
spoolClass -... | python | def punch2reader(rh, userid, fileLoc, spoolClass):
"""
Punch a file to a virtual reader of the specified virtual machine.
Input:
Request Handle - for general use and to hold the results
userid - userid of the virtual machine
fileLoc - File to send
spoolClass -... | [
"def",
"punch2reader",
"(",
"rh",
",",
"userid",
",",
"fileLoc",
",",
"spoolClass",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter punch2reader.punchFile\"",
")",
"results",
"=",
"{",
"}",
"# Setting rc to time out rc code as default and its changed during runtime",
... | Punch a file to a virtual reader of the specified virtual machine.
Input:
Request Handle - for general use and to hold the results
userid - userid of the virtual machine
fileLoc - File to send
spoolClass - Spool class
Output:
Request Handle updated with th... | [
"Punch",
"a",
"file",
"to",
"a",
"virtual",
"reader",
"of",
"the",
"specified",
"virtual",
"machine",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L782-L952 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | waitForOSState | def waitForOSState(rh, userid, desiredState, maxQueries=90, sleepSecs=5):
"""
Wait for the virtual OS to go into the indicated state.
Input:
Request Handle
userid whose state is to be monitored
Desired state, 'up' or 'down', case sensitive
Maximum attempts to wait for desired st... | python | def waitForOSState(rh, userid, desiredState, maxQueries=90, sleepSecs=5):
"""
Wait for the virtual OS to go into the indicated state.
Input:
Request Handle
userid whose state is to be monitored
Desired state, 'up' or 'down', case sensitive
Maximum attempts to wait for desired st... | [
"def",
"waitForOSState",
"(",
"rh",
",",
"userid",
",",
"desiredState",
",",
"maxQueries",
"=",
"90",
",",
"sleepSecs",
"=",
"5",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.waitForOSState, userid: \"",
"+",
"userid",
"+",
"\" state: \"",
"+",
"d... | Wait for the virtual OS to go into the indicated state.
Input:
Request Handle
userid whose state is to be monitored
Desired state, 'up' or 'down', case sensitive
Maximum attempts to wait for desired state before giving up
Sleep duration between waits
Output:
Dictionar... | [
"Wait",
"for",
"the",
"virtual",
"OS",
"to",
"go",
"into",
"the",
"indicated",
"state",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L955-L1016 |
mfcloud/python-zvm-sdk | smtLayer/vmUtils.py | waitForVMState | def waitForVMState(rh, userid, desiredState, maxQueries=90, sleepSecs=5):
"""
Wait for the virtual machine to go into the indicated state.
Input:
Request Handle
userid whose state is to be monitored
Desired state, 'on' or 'off', case sensitive
Maximum attempts to wait for desire... | python | def waitForVMState(rh, userid, desiredState, maxQueries=90, sleepSecs=5):
"""
Wait for the virtual machine to go into the indicated state.
Input:
Request Handle
userid whose state is to be monitored
Desired state, 'on' or 'off', case sensitive
Maximum attempts to wait for desire... | [
"def",
"waitForVMState",
"(",
"rh",
",",
"userid",
",",
"desiredState",
",",
"maxQueries",
"=",
"90",
",",
"sleepSecs",
"=",
"5",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter vmUtils.waitForVMState, userid: \"",
"+",
"userid",
"+",
"\" state: \"",
"+",
"d... | Wait for the virtual machine to go into the indicated state.
Input:
Request Handle
userid whose state is to be monitored
Desired state, 'on' or 'off', case sensitive
Maximum attempts to wait for desired state before giving up
Sleep duration between waits
Output:
Dicti... | [
"Wait",
"for",
"the",
"virtual",
"machine",
"to",
"go",
"into",
"the",
"indicated",
"state",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/vmUtils.py#L1019-L1102 |
marrow/cinje | cinje/inline/comment.py | Comment.match | def match(self, context, line):
"""Match lines prefixed with a hash ("#") mark that don't look like text."""
stripped = line.stripped
return stripped.startswith('#') and not stripped.startswith('#{') | python | def match(self, context, line):
"""Match lines prefixed with a hash ("#") mark that don't look like text."""
stripped = line.stripped
return stripped.startswith('#') and not stripped.startswith('#{') | [
"def",
"match",
"(",
"self",
",",
"context",
",",
"line",
")",
":",
"stripped",
"=",
"line",
".",
"stripped",
"return",
"stripped",
".",
"startswith",
"(",
"'#'",
")",
"and",
"not",
"stripped",
".",
"startswith",
"(",
"'#{'",
")"
] | Match lines prefixed with a hash ("#") mark that don't look like text. | [
"Match",
"lines",
"prefixed",
"with",
"a",
"hash",
"(",
"#",
")",
"mark",
"that",
"don",
"t",
"look",
"like",
"text",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/inline/comment.py#L18-L21 |
marrow/cinje | cinje/util.py | stream | def stream(input, encoding=None, errors='strict'):
"""Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding.
Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body.
"""
input = (i for i in input if i) # Omits `None` (empty wr... | python | def stream(input, encoding=None, errors='strict'):
"""Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding.
Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body.
"""
input = (i for i in input if i) # Omits `None` (empty wr... | [
"def",
"stream",
"(",
"input",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"input",
"=",
"(",
"i",
"for",
"i",
"in",
"input",
"if",
"i",
")",
"# Omits `None` (empty wrappers) and empty chunks.",
"if",
"encoding",
":",
"# Automatic... | Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding.
Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body. | [
"Safely",
"iterate",
"a",
"template",
"generator",
"ignoring",
"None",
"values",
"and",
"optionally",
"stream",
"encoding",
".",
"Used",
"internally",
"by",
"cinje",
".",
"flatten",
"this",
"allows",
"for",
"easy",
"use",
"of",
"a",
"template",
"generator",
"a... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L71-L82 |
marrow/cinje | cinje/util.py | flatten | def flatten(input, file=None, encoding=None, errors='strict'):
"""Return a flattened representation of a cinje chunk stream.
This has several modes of operation. If no `file` argument is given, output will be returned as a string.
The type of string will be determined by the presence of an `encoding`; if one is g... | python | def flatten(input, file=None, encoding=None, errors='strict'):
"""Return a flattened representation of a cinje chunk stream.
This has several modes of operation. If no `file` argument is given, output will be returned as a string.
The type of string will be determined by the presence of an `encoding`; if one is g... | [
"def",
"flatten",
"(",
"input",
",",
"file",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"input",
"=",
"stream",
"(",
"input",
",",
"encoding",
",",
"errors",
")",
"if",
"file",
"is",
"None",
":",
"# Exit earl... | Return a flattened representation of a cinje chunk stream.
This has several modes of operation. If no `file` argument is given, output will be returned as a string.
The type of string will be determined by the presence of an `encoding`; if one is given the returned value is a
binary string, otherwise the native u... | [
"Return",
"a",
"flattened",
"representation",
"of",
"a",
"cinje",
"chunk",
"stream",
".",
"This",
"has",
"several",
"modes",
"of",
"operation",
".",
"If",
"no",
"file",
"argument",
"is",
"given",
"output",
"will",
"be",
"returned",
"as",
"a",
"string",
"."... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L85-L111 |
marrow/cinje | cinje/util.py | fragment | def fragment(string, name="anonymous", **context):
"""Translate a template fragment into a callable function.
**Note:** Use of this function is discouraged everywhere except tests, as no caching is implemented at this time.
Only one function may be declared, either manually, or automatically. If automatic defint... | python | def fragment(string, name="anonymous", **context):
"""Translate a template fragment into a callable function.
**Note:** Use of this function is discouraged everywhere except tests, as no caching is implemented at this time.
Only one function may be declared, either manually, or automatically. If automatic defint... | [
"def",
"fragment",
"(",
"string",
",",
"name",
"=",
"\"anonymous\"",
",",
"*",
"*",
"context",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"bytes",
")",
":",
"string",
"=",
"string",
".",
"decode",
"(",
"'utf-8'",
")",
"if",
"\": def\"",
"in",
... | Translate a template fragment into a callable function.
**Note:** Use of this function is discouraged everywhere except tests, as no caching is implemented at this time.
Only one function may be declared, either manually, or automatically. If automatic defintition is chosen the
resulting function takes no argume... | [
"Translate",
"a",
"template",
"fragment",
"into",
"a",
"callable",
"function",
".",
"**",
"Note",
":",
"**",
"Use",
"of",
"this",
"function",
"is",
"discouraged",
"everywhere",
"except",
"tests",
"as",
"no",
"caching",
"is",
"implemented",
"at",
"this",
"tim... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L114-L146 |
marrow/cinje | cinje/util.py | iterate | def iterate(obj):
"""Loop over an iterable and track progress, including first and last state.
On each iteration yield an Iteration named tuple with the first and last flags, current element index, total
iterable length (if possible to acquire), and value, in that order.
for iteration in iterate(something):
... | python | def iterate(obj):
"""Loop over an iterable and track progress, including first and last state.
On each iteration yield an Iteration named tuple with the first and last flags, current element index, total
iterable length (if possible to acquire), and value, in that order.
for iteration in iterate(something):
... | [
"def",
"iterate",
"(",
"obj",
")",
":",
"global",
"next",
",",
"Iteration",
"next",
"=",
"next",
"Iteration",
"=",
"Iteration",
"total",
"=",
"len",
"(",
"obj",
")",
"if",
"isinstance",
"(",
"obj",
",",
"Sized",
")",
"else",
"None",
"iterator",
"=",
... | Loop over an iterable and track progress, including first and last state.
On each iteration yield an Iteration named tuple with the first and last flags, current element index, total
iterable length (if possible to acquire), and value, in that order.
for iteration in iterate(something):
iteration.value # Do... | [
"Loop",
"over",
"an",
"iterable",
"and",
"track",
"progress",
"including",
"first",
"and",
"last",
"state",
".",
"On",
"each",
"iteration",
"yield",
"an",
"Iteration",
"named",
"tuple",
"with",
"the",
"first",
"and",
"last",
"flags",
"current",
"element",
"i... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L159-L211 |
marrow/cinje | cinje/util.py | chunk | def chunk(line, mapping={None: 'text', '${': 'escape', '#{': 'bless', '&{': 'args', '%{': 'format', '@{': 'json'}):
"""Chunkify and "tag" a block of text into plain text and code sections.
The first delimeter is blank to represent text sections, and keep the indexes aligned with the tags.
Values are yielded in t... | python | def chunk(line, mapping={None: 'text', '${': 'escape', '#{': 'bless', '&{': 'args', '%{': 'format', '@{': 'json'}):
"""Chunkify and "tag" a block of text into plain text and code sections.
The first delimeter is blank to represent text sections, and keep the indexes aligned with the tags.
Values are yielded in t... | [
"def",
"chunk",
"(",
"line",
",",
"mapping",
"=",
"{",
"None",
":",
"'text'",
",",
"'${'",
":",
"'escape'",
",",
"'#{'",
":",
"'bless'",
",",
"'&{'",
":",
"'args'",
",",
"'%{'",
":",
"'format'",
",",
"'@{'",
":",
"'json'",
"}",
")",
":",
"skipping"... | Chunkify and "tag" a block of text into plain text and code sections.
The first delimeter is blank to represent text sections, and keep the indexes aligned with the tags.
Values are yielded in the form (tag, text). | [
"Chunkify",
"and",
"tag",
"a",
"block",
"of",
"text",
"into",
"plain",
"text",
"and",
"code",
"sections",
".",
"The",
"first",
"delimeter",
"is",
"blank",
"to",
"represent",
"text",
"sections",
"and",
"keep",
"the",
"indexes",
"aligned",
"with",
"the",
"ta... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L253-L294 |
marrow/cinje | cinje/util.py | Context.prepare | def prepare(self):
"""Prepare the ordered list of transformers and reset context state to initial."""
self.scope = 0
self.mapping = deque([0])
self._handler = [i() for i in sorted(self.handlers, key=lambda handler: handler.priority)] | python | def prepare(self):
"""Prepare the ordered list of transformers and reset context state to initial."""
self.scope = 0
self.mapping = deque([0])
self._handler = [i() for i in sorted(self.handlers, key=lambda handler: handler.priority)] | [
"def",
"prepare",
"(",
"self",
")",
":",
"self",
".",
"scope",
"=",
"0",
"self",
".",
"mapping",
"=",
"deque",
"(",
"[",
"0",
"]",
")",
"self",
".",
"_handler",
"=",
"[",
"i",
"(",
")",
"for",
"i",
"in",
"sorted",
"(",
"self",
".",
"handlers",
... | Prepare the ordered list of transformers and reset context state to initial. | [
"Prepare",
"the",
"ordered",
"list",
"of",
"transformers",
"and",
"reset",
"context",
"state",
"to",
"initial",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L468-L472 |
marrow/cinje | cinje/util.py | Context.stream | def stream(self):
"""The workhorse of cinje: transform input lines and emit output lines.
After constructing an instance with a set of input lines iterate this property to generate the template.
"""
if 'init' not in self.flag:
root = True
self.prepare()
else:
root = False
# Track which lin... | python | def stream(self):
"""The workhorse of cinje: transform input lines and emit output lines.
After constructing an instance with a set of input lines iterate this property to generate the template.
"""
if 'init' not in self.flag:
root = True
self.prepare()
else:
root = False
# Track which lin... | [
"def",
"stream",
"(",
"self",
")",
":",
"if",
"'init'",
"not",
"in",
"self",
".",
"flag",
":",
"root",
"=",
"True",
"self",
".",
"prepare",
"(",
")",
"else",
":",
"root",
"=",
"False",
"# Track which lines were generated in response to which lines of source code... | The workhorse of cinje: transform input lines and emit output lines.
After constructing an instance with a set of input lines iterate this property to generate the template. | [
"The",
"workhorse",
"of",
"cinje",
":",
"transform",
"input",
"lines",
"and",
"emit",
"output",
"lines",
".",
"After",
"constructing",
"an",
"instance",
"with",
"a",
"set",
"of",
"input",
"lines",
"iterate",
"this",
"property",
"to",
"generate",
"the",
"temp... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L475-L511 |
marrow/cinje | cinje/util.py | Context.classify | def classify(self, line):
"""Identify the correct handler for a given line of input."""
for handler in self._handler:
if handler.match(self, line):
return handler | python | def classify(self, line):
"""Identify the correct handler for a given line of input."""
for handler in self._handler:
if handler.match(self, line):
return handler | [
"def",
"classify",
"(",
"self",
",",
"line",
")",
":",
"for",
"handler",
"in",
"self",
".",
"_handler",
":",
"if",
"handler",
".",
"match",
"(",
"self",
",",
"line",
")",
":",
"return",
"handler"
] | Identify the correct handler for a given line of input. | [
"Identify",
"the",
"correct",
"handler",
"for",
"a",
"given",
"line",
"of",
"input",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L513-L518 |
marrow/cinje | cinje/block/module.py | red | def red(numbers):
"""Encode the deltas to reduce entropy."""
line = 0
deltas = []
for value in numbers:
deltas.append(value - line)
line = value
return b64encode(compress(b''.join(chr(i).encode('latin1') for i in deltas))).decode('latin1') | python | def red(numbers):
"""Encode the deltas to reduce entropy."""
line = 0
deltas = []
for value in numbers:
deltas.append(value - line)
line = value
return b64encode(compress(b''.join(chr(i).encode('latin1') for i in deltas))).decode('latin1') | [
"def",
"red",
"(",
"numbers",
")",
":",
"line",
"=",
"0",
"deltas",
"=",
"[",
"]",
"for",
"value",
"in",
"numbers",
":",
"deltas",
".",
"append",
"(",
"value",
"-",
"line",
")",
"line",
"=",
"value",
"return",
"b64encode",
"(",
"compress",
"(",
"b'... | Encode the deltas to reduce entropy. | [
"Encode",
"the",
"deltas",
"to",
"reduce",
"entropy",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/block/module.py#L12-L22 |
marrow/cinje | cinje/block/generic.py | Generic.match | def match(self, context, line):
"""Match code lines prefixed with a variety of keywords."""
return line.kind == 'code' and line.partitioned[0] in self._both | python | def match(self, context, line):
"""Match code lines prefixed with a variety of keywords."""
return line.kind == 'code' and line.partitioned[0] in self._both | [
"def",
"match",
"(",
"self",
",",
"context",
",",
"line",
")",
":",
"return",
"line",
".",
"kind",
"==",
"'code'",
"and",
"line",
".",
"partitioned",
"[",
"0",
"]",
"in",
"self",
".",
"_both"
] | Match code lines prefixed with a variety of keywords. | [
"Match",
"code",
"lines",
"prefixed",
"with",
"a",
"variety",
"of",
"keywords",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/block/generic.py#L56-L59 |
fgmacedo/django-export-action | export_action/introspection.py | _get_field_by_name | def _get_field_by_name(model_class, field_name):
"""
Compatible with old API of model_class._meta.get_field_by_name(field_name)
"""
field = model_class._meta.get_field(field_name)
return (
field, # field
field.model, ... | python | def _get_field_by_name(model_class, field_name):
"""
Compatible with old API of model_class._meta.get_field_by_name(field_name)
"""
field = model_class._meta.get_field(field_name)
return (
field, # field
field.model, ... | [
"def",
"_get_field_by_name",
"(",
"model_class",
",",
"field_name",
")",
":",
"field",
"=",
"model_class",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"return",
"(",
"field",
",",
"# field",
"field",
".",
"model",
",",
"# model",
"not",
"field",
... | Compatible with old API of model_class._meta.get_field_by_name(field_name) | [
"Compatible",
"with",
"old",
"API",
"of",
"model_class",
".",
"_meta",
".",
"get_field_by_name",
"(",
"field_name",
")"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/introspection.py#L11-L21 |
fgmacedo/django-export-action | export_action/introspection.py | _get_remote_field | def _get_remote_field(field):
"""
Compatible with Django 1.8~1.10 ('related' was renamed to 'remote_field')
"""
if hasattr(field, 'remote_field'):
return field.remote_field
elif hasattr(field, 'related'):
return field.related
else:
return None | python | def _get_remote_field(field):
"""
Compatible with Django 1.8~1.10 ('related' was renamed to 'remote_field')
"""
if hasattr(field, 'remote_field'):
return field.remote_field
elif hasattr(field, 'related'):
return field.related
else:
return None | [
"def",
"_get_remote_field",
"(",
"field",
")",
":",
"if",
"hasattr",
"(",
"field",
",",
"'remote_field'",
")",
":",
"return",
"field",
".",
"remote_field",
"elif",
"hasattr",
"(",
"field",
",",
"'related'",
")",
":",
"return",
"field",
".",
"related",
"els... | Compatible with Django 1.8~1.10 ('related' was renamed to 'remote_field') | [
"Compatible",
"with",
"Django",
"1",
".",
"8~1",
".",
"10",
"(",
"related",
"was",
"renamed",
"to",
"remote_field",
")"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/introspection.py#L24-L33 |
fgmacedo/django-export-action | export_action/introspection.py | _get_all_field_names | def _get_all_field_names(model):
"""
100% compatible version of the old API of model._meta.get_all_field_names()
From: https://docs.djangoproject.com/en/1.9/ref/models/meta/#migrating-from-the-old-api
"""
return list(set(chain.from_iterable(
(field.name, field.attname) if hasattr(field, 'att... | python | def _get_all_field_names(model):
"""
100% compatible version of the old API of model._meta.get_all_field_names()
From: https://docs.djangoproject.com/en/1.9/ref/models/meta/#migrating-from-the-old-api
"""
return list(set(chain.from_iterable(
(field.name, field.attname) if hasattr(field, 'att... | [
"def",
"_get_all_field_names",
"(",
"model",
")",
":",
"return",
"list",
"(",
"set",
"(",
"chain",
".",
"from_iterable",
"(",
"(",
"field",
".",
"name",
",",
"field",
".",
"attname",
")",
"if",
"hasattr",
"(",
"field",
",",
"'attname'",
")",
"else",
"(... | 100% compatible version of the old API of model._meta.get_all_field_names()
From: https://docs.djangoproject.com/en/1.9/ref/models/meta/#migrating-from-the-old-api | [
"100%",
"compatible",
"version",
"of",
"the",
"old",
"API",
"of",
"model",
".",
"_meta",
".",
"get_all_field_names",
"()",
"From",
":",
"https",
":",
"//",
"docs",
".",
"djangoproject",
".",
"com",
"/",
"en",
"/",
"1",
".",
"9",
"/",
"ref",
"/",
"mod... | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/introspection.py#L36-L47 |
fgmacedo/django-export-action | export_action/introspection.py | get_relation_fields_from_model | def get_relation_fields_from_model(model_class):
""" Get related fields (m2m, FK, and reverse FK) """
relation_fields = []
all_fields_names = _get_all_field_names(model_class)
for field_name in all_fields_names:
field, model, direct, m2m = _get_field_by_name(model_class, field_name)
# ge... | python | def get_relation_fields_from_model(model_class):
""" Get related fields (m2m, FK, and reverse FK) """
relation_fields = []
all_fields_names = _get_all_field_names(model_class)
for field_name in all_fields_names:
field, model, direct, m2m = _get_field_by_name(model_class, field_name)
# ge... | [
"def",
"get_relation_fields_from_model",
"(",
"model_class",
")",
":",
"relation_fields",
"=",
"[",
"]",
"all_fields_names",
"=",
"_get_all_field_names",
"(",
"model_class",
")",
"for",
"field_name",
"in",
"all_fields_names",
":",
"field",
",",
"model",
",",
"direct... | Get related fields (m2m, FK, and reverse FK) | [
"Get",
"related",
"fields",
"(",
"m2m",
"FK",
"and",
"reverse",
"FK",
")"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/introspection.py#L50-L63 |
fgmacedo/django-export-action | export_action/introspection.py | get_direct_fields_from_model | def get_direct_fields_from_model(model_class):
""" Direct, not m2m, not FK """
direct_fields = []
all_fields_names = _get_all_field_names(model_class)
for field_name in all_fields_names:
field, model, direct, m2m = _get_field_by_name(model_class, field_name)
if direct and not m2m and not... | python | def get_direct_fields_from_model(model_class):
""" Direct, not m2m, not FK """
direct_fields = []
all_fields_names = _get_all_field_names(model_class)
for field_name in all_fields_names:
field, model, direct, m2m = _get_field_by_name(model_class, field_name)
if direct and not m2m and not... | [
"def",
"get_direct_fields_from_model",
"(",
"model_class",
")",
":",
"direct_fields",
"=",
"[",
"]",
"all_fields_names",
"=",
"_get_all_field_names",
"(",
"model_class",
")",
"for",
"field_name",
"in",
"all_fields_names",
":",
"field",
",",
"model",
",",
"direct",
... | Direct, not m2m, not FK | [
"Direct",
"not",
"m2m",
"not",
"FK"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/introspection.py#L66-L74 |
fgmacedo/django-export-action | export_action/introspection.py | get_model_from_path_string | def get_model_from_path_string(root_model, path):
""" Return a model class for a related model
root_model is the class of the initial model
path is like foo__bar where bar is related to foo
"""
for path_section in path.split('__'):
if path_section:
try:
field, mod... | python | def get_model_from_path_string(root_model, path):
""" Return a model class for a related model
root_model is the class of the initial model
path is like foo__bar where bar is related to foo
"""
for path_section in path.split('__'):
if path_section:
try:
field, mod... | [
"def",
"get_model_from_path_string",
"(",
"root_model",
",",
"path",
")",
":",
"for",
"path_section",
"in",
"path",
".",
"split",
"(",
"'__'",
")",
":",
"if",
"path_section",
":",
"try",
":",
"field",
",",
"model",
",",
"direct",
",",
"m2m",
"=",
"_get_f... | Return a model class for a related model
root_model is the class of the initial model
path is like foo__bar where bar is related to foo | [
"Return",
"a",
"model",
"class",
"for",
"a",
"related",
"model",
"root_model",
"is",
"the",
"class",
"of",
"the",
"initial",
"model",
"path",
"is",
"like",
"foo__bar",
"where",
"bar",
"is",
"related",
"to",
"foo"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/introspection.py#L77-L99 |
fgmacedo/django-export-action | export_action/introspection.py | get_fields | def get_fields(model_class, field_name='', path=''):
""" Get fields and meta data from a model
:param model_class: A django model class
:param field_name: The field name to get sub fields from
:param path: path of our field in format
field_name__second_field_name__ect__
:returns: Returns fi... | python | def get_fields(model_class, field_name='', path=''):
""" Get fields and meta data from a model
:param model_class: A django model class
:param field_name: The field name to get sub fields from
:param path: path of our field in format
field_name__second_field_name__ect__
:returns: Returns fi... | [
"def",
"get_fields",
"(",
"model_class",
",",
"field_name",
"=",
"''",
",",
"path",
"=",
"''",
")",
":",
"fields",
"=",
"get_direct_fields_from_model",
"(",
"model_class",
")",
"app_label",
"=",
"model_class",
".",
"_meta",
".",
"app_label",
"if",
"field_name"... | Get fields and meta data from a model
:param model_class: A django model class
:param field_name: The field name to get sub fields from
:param path: path of our field in format
field_name__second_field_name__ect__
:returns: Returns fields and meta data about such fields
fields: Django m... | [
"Get",
"fields",
"and",
"meta",
"data",
"from",
"a",
"model"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/introspection.py#L102-L139 |
fgmacedo/django-export-action | export_action/introspection.py | get_related_fields | def get_related_fields(model_class, field_name, path=""):
""" Get fields for a given model """
if field_name:
field, model, direct, m2m = _get_field_by_name(model_class, field_name)
if direct:
# Direct field
try:
new_model = _get_remote_field(field).parent... | python | def get_related_fields(model_class, field_name, path=""):
""" Get fields for a given model """
if field_name:
field, model, direct, m2m = _get_field_by_name(model_class, field_name)
if direct:
# Direct field
try:
new_model = _get_remote_field(field).parent... | [
"def",
"get_related_fields",
"(",
"model_class",
",",
"field_name",
",",
"path",
"=",
"\"\"",
")",
":",
"if",
"field_name",
":",
"field",
",",
"model",
",",
"direct",
",",
"m2m",
"=",
"_get_field_by_name",
"(",
"model_class",
",",
"field_name",
")",
"if",
... | Get fields for a given model | [
"Get",
"fields",
"for",
"a",
"given",
"model"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/introspection.py#L142-L167 |
marrow/cinje | cinje/inline/flush.py | flush_template | def flush_template(context, declaration=None, reconstruct=True):
"""Emit the code needed to flush the buffer.
Will only emit the yield and clear if the buffer is known to be dirty.
"""
if declaration is None:
declaration = Line(0, '')
if {'text', 'dirty'}.issubset(context.flag):
yield declaration.clone(... | python | def flush_template(context, declaration=None, reconstruct=True):
"""Emit the code needed to flush the buffer.
Will only emit the yield and clear if the buffer is known to be dirty.
"""
if declaration is None:
declaration = Line(0, '')
if {'text', 'dirty'}.issubset(context.flag):
yield declaration.clone(... | [
"def",
"flush_template",
"(",
"context",
",",
"declaration",
"=",
"None",
",",
"reconstruct",
"=",
"True",
")",
":",
"if",
"declaration",
"is",
"None",
":",
"declaration",
"=",
"Line",
"(",
"0",
",",
"''",
")",
"if",
"{",
"'text'",
",",
"'dirty'",
"}",... | Emit the code needed to flush the buffer.
Will only emit the yield and clear if the buffer is known to be dirty. | [
"Emit",
"the",
"code",
"needed",
"to",
"flush",
"the",
"buffer",
".",
"Will",
"only",
"emit",
"the",
"yield",
"and",
"clear",
"if",
"the",
"buffer",
"is",
"known",
"to",
"be",
"dirty",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/inline/flush.py#L6-L26 |
marrow/cinje | cinje/block/function.py | Function._optimize | def _optimize(self, context, argspec):
"""Inject speedup shortcut bindings into the argument specification for a function.
This assigns these labels to the local scope, avoiding a cascade through to globals(), saving time.
This also has some unfortunate side-effects for using these sentinels in argument def... | python | def _optimize(self, context, argspec):
"""Inject speedup shortcut bindings into the argument specification for a function.
This assigns these labels to the local scope, avoiding a cascade through to globals(), saving time.
This also has some unfortunate side-effects for using these sentinels in argument def... | [
"def",
"_optimize",
"(",
"self",
",",
"context",
",",
"argspec",
")",
":",
"argspec",
"=",
"argspec",
".",
"strip",
"(",
")",
"optimization",
"=",
"\", \"",
".",
"join",
"(",
"i",
"+",
"\"=\"",
"+",
"i",
"for",
"i",
"in",
"self",
".",
"OPTIMIZE",
"... | Inject speedup shortcut bindings into the argument specification for a function.
This assigns these labels to the local scope, avoiding a cascade through to globals(), saving time.
This also has some unfortunate side-effects for using these sentinels in argument default values! | [
"Inject",
"speedup",
"shortcut",
"bindings",
"into",
"the",
"argument",
"specification",
"for",
"a",
"function",
".",
"This",
"assigns",
"these",
"labels",
"to",
"the",
"local",
"scope",
"avoiding",
"a",
"cascade",
"through",
"to",
"globals",
"()",
"saving",
"... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/block/function.py#L33-L76 |
fgmacedo/django-export-action | export_action/report.py | _can_change_or_view | def _can_change_or_view(model, user):
""" Return True iff `user` has either change or view permission
for `model`.
"""
model_name = model._meta.model_name
app_label = model._meta.app_label
can_change = user.has_perm(app_label + '.change_' + model_name)
can_view = user.has_perm(app_label + '.... | python | def _can_change_or_view(model, user):
""" Return True iff `user` has either change or view permission
for `model`.
"""
model_name = model._meta.model_name
app_label = model._meta.app_label
can_change = user.has_perm(app_label + '.change_' + model_name)
can_view = user.has_perm(app_label + '.... | [
"def",
"_can_change_or_view",
"(",
"model",
",",
"user",
")",
":",
"model_name",
"=",
"model",
".",
"_meta",
".",
"model_name",
"app_label",
"=",
"model",
".",
"_meta",
".",
"app_label",
"can_change",
"=",
"user",
".",
"has_perm",
"(",
"app_label",
"+",
"'... | Return True iff `user` has either change or view permission
for `model`. | [
"Return",
"True",
"iff",
"user",
"has",
"either",
"change",
"or",
"view",
"permission",
"for",
"model",
"."
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/report.py#L37-L46 |
fgmacedo/django-export-action | export_action/report.py | report_to_list | def report_to_list(queryset, display_fields, user):
""" Create list from a report with all data filtering.
queryset: initial queryset to generate results
display_fields: list of field references or DisplayField models
user: requesting user
Returns list, message in case of issues.
"""
model... | python | def report_to_list(queryset, display_fields, user):
""" Create list from a report with all data filtering.
queryset: initial queryset to generate results
display_fields: list of field references or DisplayField models
user: requesting user
Returns list, message in case of issues.
"""
model... | [
"def",
"report_to_list",
"(",
"queryset",
",",
"display_fields",
",",
"user",
")",
":",
"model_class",
"=",
"queryset",
".",
"model",
"objects",
"=",
"queryset",
"message",
"=",
"\"\"",
"if",
"not",
"_can_change_or_view",
"(",
"model_class",
",",
"user",
")",
... | Create list from a report with all data filtering.
queryset: initial queryset to generate results
display_fields: list of field references or DisplayField models
user: requesting user
Returns list, message in case of issues. | [
"Create",
"list",
"from",
"a",
"report",
"with",
"all",
"data",
"filtering",
"."
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/report.py#L49-L100 |
fgmacedo/django-export-action | export_action/report.py | list_to_workbook | def list_to_workbook(data, title='report', header=None, widths=None):
""" Create just a openpxl workbook from a list of data """
wb = Workbook()
title = re.sub(r'\W+', '', title)[:30]
if isinstance(data, dict):
i = 0
for sheet_name, sheet_data in data.items():
if i > 0:
... | python | def list_to_workbook(data, title='report', header=None, widths=None):
""" Create just a openpxl workbook from a list of data """
wb = Workbook()
title = re.sub(r'\W+', '', title)[:30]
if isinstance(data, dict):
i = 0
for sheet_name, sheet_data in data.items():
if i > 0:
... | [
"def",
"list_to_workbook",
"(",
"data",
",",
"title",
"=",
"'report'",
",",
"header",
"=",
"None",
",",
"widths",
"=",
"None",
")",
":",
"wb",
"=",
"Workbook",
"(",
")",
"title",
"=",
"re",
".",
"sub",
"(",
"r'\\W+'",
",",
"''",
",",
"title",
")",
... | Create just a openpxl workbook from a list of data | [
"Create",
"just",
"a",
"openpxl",
"workbook",
"from",
"a",
"list",
"of",
"data"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/report.py#L136-L153 |
fgmacedo/django-export-action | export_action/report.py | build_xlsx_response | def build_xlsx_response(wb, title="report"):
""" Take a workbook and return a xlsx file response """
title = generate_filename(title, '.xlsx')
myfile = BytesIO()
myfile.write(save_virtual_workbook(wb))
response = HttpResponse(
myfile.getvalue(),
content_type='application/vnd.openxmlf... | python | def build_xlsx_response(wb, title="report"):
""" Take a workbook and return a xlsx file response """
title = generate_filename(title, '.xlsx')
myfile = BytesIO()
myfile.write(save_virtual_workbook(wb))
response = HttpResponse(
myfile.getvalue(),
content_type='application/vnd.openxmlf... | [
"def",
"build_xlsx_response",
"(",
"wb",
",",
"title",
"=",
"\"report\"",
")",
":",
"title",
"=",
"generate_filename",
"(",
"title",
",",
"'.xlsx'",
")",
"myfile",
"=",
"BytesIO",
"(",
")",
"myfile",
".",
"write",
"(",
"save_virtual_workbook",
"(",
"wb",
"... | Take a workbook and return a xlsx file response | [
"Take",
"a",
"workbook",
"and",
"return",
"a",
"xlsx",
"file",
"response"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/report.py#L156-L166 |
fgmacedo/django-export-action | export_action/report.py | list_to_xlsx_response | def list_to_xlsx_response(data, title='report', header=None,
widths=None):
""" Make 2D list into a xlsx response for download
data can be a 2d array or a dict of 2d arrays
like {'sheet_1': [['A1', 'B1']]}
"""
wb = list_to_workbook(data, title, header, widths)
return bui... | python | def list_to_xlsx_response(data, title='report', header=None,
widths=None):
""" Make 2D list into a xlsx response for download
data can be a 2d array or a dict of 2d arrays
like {'sheet_1': [['A1', 'B1']]}
"""
wb = list_to_workbook(data, title, header, widths)
return bui... | [
"def",
"list_to_xlsx_response",
"(",
"data",
",",
"title",
"=",
"'report'",
",",
"header",
"=",
"None",
",",
"widths",
"=",
"None",
")",
":",
"wb",
"=",
"list_to_workbook",
"(",
"data",
",",
"title",
",",
"header",
",",
"widths",
")",
"return",
"build_xl... | Make 2D list into a xlsx response for download
data can be a 2d array or a dict of 2d arrays
like {'sheet_1': [['A1', 'B1']]} | [
"Make",
"2D",
"list",
"into",
"a",
"xlsx",
"response",
"for",
"download",
"data",
"can",
"be",
"a",
"2d",
"array",
"or",
"a",
"dict",
"of",
"2d",
"arrays",
"like",
"{",
"sheet_1",
":",
"[[",
"A1",
"B1",
"]]",
"}"
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/report.py#L169-L176 |
fgmacedo/django-export-action | export_action/report.py | list_to_csv_response | def list_to_csv_response(data, title='report', header=None, widths=None):
""" Make 2D list into a csv response for download data.
"""
response = HttpResponse(content_type="text/csv; charset=UTF-8")
cw = csv.writer(response)
for row in chain([header] if header else [], data):
cw.writerow([for... | python | def list_to_csv_response(data, title='report', header=None, widths=None):
""" Make 2D list into a csv response for download data.
"""
response = HttpResponse(content_type="text/csv; charset=UTF-8")
cw = csv.writer(response)
for row in chain([header] if header else [], data):
cw.writerow([for... | [
"def",
"list_to_csv_response",
"(",
"data",
",",
"title",
"=",
"'report'",
",",
"header",
"=",
"None",
",",
"widths",
"=",
"None",
")",
":",
"response",
"=",
"HttpResponse",
"(",
"content_type",
"=",
"\"text/csv; charset=UTF-8\"",
")",
"cw",
"=",
"csv",
".",... | Make 2D list into a csv response for download data. | [
"Make",
"2D",
"list",
"into",
"a",
"csv",
"response",
"for",
"download",
"data",
"."
] | train | https://github.com/fgmacedo/django-export-action/blob/215fecb9044d22e3ae19d86c3b220041a11fad07/export_action/report.py#L179-L186 |
marrow/cinje | cinje/inline/text.py | Text.wrap | def wrap(scope, lines, format=BARE_FORMAT):
"""Wrap a stream of lines in armour.
Takes a stream of lines, for example, the following single line:
Line(1, "Lorem ipsum dolor.")
Or the following multiple lines:
Line(1, "Lorem ipsum")
Line(2, "dolor")
Line(3, "sit amet.")
Provides a gene... | python | def wrap(scope, lines, format=BARE_FORMAT):
"""Wrap a stream of lines in armour.
Takes a stream of lines, for example, the following single line:
Line(1, "Lorem ipsum dolor.")
Or the following multiple lines:
Line(1, "Lorem ipsum")
Line(2, "dolor")
Line(3, "sit amet.")
Provides a gene... | [
"def",
"wrap",
"(",
"scope",
",",
"lines",
",",
"format",
"=",
"BARE_FORMAT",
")",
":",
"for",
"line",
"in",
"iterate",
"(",
"lines",
")",
":",
"prefix",
"=",
"suffix",
"=",
"''",
"if",
"line",
".",
"first",
"and",
"line",
".",
"last",
":",
"prefix... | Wrap a stream of lines in armour.
Takes a stream of lines, for example, the following single line:
Line(1, "Lorem ipsum dolor.")
Or the following multiple lines:
Line(1, "Lorem ipsum")
Line(2, "dolor")
Line(3, "sit amet.")
Provides a generator of wrapped lines. For a single line, the f... | [
"Wrap",
"a",
"stream",
"of",
"lines",
"in",
"armour",
".",
"Takes",
"a",
"stream",
"of",
"lines",
"for",
"example",
"the",
"following",
"single",
"line",
":",
"Line",
"(",
"1",
"Lorem",
"ipsum",
"dolor",
".",
")",
"Or",
"the",
"following",
"multiple",
... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/inline/text.py#L36-L70 |
marrow/cinje | cinje/inline/text.py | Text.gather | def gather(input):
"""Collect contiguous lines of text, preserving line numbers."""
try:
line = input.next()
except StopIteration:
return
lead = True
buffer = []
# Gather contiguous (uninterrupted) lines of template text.
while line.kind == 'text':
value = line.line.rstrip().rstrip('\\')... | python | def gather(input):
"""Collect contiguous lines of text, preserving line numbers."""
try:
line = input.next()
except StopIteration:
return
lead = True
buffer = []
# Gather contiguous (uninterrupted) lines of template text.
while line.kind == 'text':
value = line.line.rstrip().rstrip('\\')... | [
"def",
"gather",
"(",
"input",
")",
":",
"try",
":",
"line",
"=",
"input",
".",
"next",
"(",
")",
"except",
"StopIteration",
":",
"return",
"lead",
"=",
"True",
"buffer",
"=",
"[",
"]",
"# Gather contiguous (uninterrupted) lines of template text.",
"while",
"l... | Collect contiguous lines of text, preserving line numbers. | [
"Collect",
"contiguous",
"lines",
"of",
"text",
"preserving",
"line",
"numbers",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/inline/text.py#L73-L110 |
marrow/cinje | cinje/inline/text.py | Text.process | def process(self, context, lines):
"""Chop up individual lines into static and dynamic parts.
Applies light optimizations, such as empty chunk removal, and calls out to other methods to process different
chunk types.
The processor protocol here requires the method to accept values by yielding resulting li... | python | def process(self, context, lines):
"""Chop up individual lines into static and dynamic parts.
Applies light optimizations, such as empty chunk removal, and calls out to other methods to process different
chunk types.
The processor protocol here requires the method to accept values by yielding resulting li... | [
"def",
"process",
"(",
"self",
",",
"context",
",",
"lines",
")",
":",
"handler",
"=",
"None",
"for",
"line",
"in",
"lines",
":",
"for",
"chunk",
"in",
"chunk_",
"(",
"line",
")",
":",
"if",
"'strip'",
"in",
"context",
".",
"flag",
":",
"chunk",
".... | Chop up individual lines into static and dynamic parts.
Applies light optimizations, such as empty chunk removal, and calls out to other methods to process different
chunk types.
The processor protocol here requires the method to accept values by yielding resulting lines while accepting
sent chunks. Defer... | [
"Chop",
"up",
"individual",
"lines",
"into",
"static",
"and",
"dynamic",
"parts",
".",
"Applies",
"light",
"optimizations",
"such",
"as",
"empty",
"chunk",
"removal",
"and",
"calls",
"out",
"to",
"other",
"methods",
"to",
"process",
"different",
"chunk",
"type... | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/inline/text.py#L112-L162 |
marrow/cinje | cinje/inline/text.py | Text.process_text | def process_text(self, kind, context):
"""Combine multiple lines of bare text and emit as a Python string literal."""
result = None
while True:
chunk = yield None
if chunk is None:
if result:
yield result.clone(line=repr(result.line))
return
if not result:
result = chu... | python | def process_text(self, kind, context):
"""Combine multiple lines of bare text and emit as a Python string literal."""
result = None
while True:
chunk = yield None
if chunk is None:
if result:
yield result.clone(line=repr(result.line))
return
if not result:
result = chu... | [
"def",
"process_text",
"(",
"self",
",",
"kind",
",",
"context",
")",
":",
"result",
"=",
"None",
"while",
"True",
":",
"chunk",
"=",
"yield",
"None",
"if",
"chunk",
"is",
"None",
":",
"if",
"result",
":",
"yield",
"result",
".",
"clone",
"(",
"line"... | Combine multiple lines of bare text and emit as a Python string literal. | [
"Combine",
"multiple",
"lines",
"of",
"bare",
"text",
"and",
"emit",
"as",
"a",
"Python",
"string",
"literal",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/inline/text.py#L164-L182 |
marrow/cinje | cinje/inline/text.py | Text.process_generic | def process_generic(self, kind, context):
"""Transform otherwise unhandled kinds of chunks by calling an underscore prefixed function by that name."""
result = None
while True:
chunk = yield result
if chunk is None:
return
result = chunk.clone(line='_' + kind + '(' + chunk.line + ')') | python | def process_generic(self, kind, context):
"""Transform otherwise unhandled kinds of chunks by calling an underscore prefixed function by that name."""
result = None
while True:
chunk = yield result
if chunk is None:
return
result = chunk.clone(line='_' + kind + '(' + chunk.line + ')') | [
"def",
"process_generic",
"(",
"self",
",",
"kind",
",",
"context",
")",
":",
"result",
"=",
"None",
"while",
"True",
":",
"chunk",
"=",
"yield",
"result",
"if",
"chunk",
"is",
"None",
":",
"return",
"result",
"=",
"chunk",
".",
"clone",
"(",
"line",
... | Transform otherwise unhandled kinds of chunks by calling an underscore prefixed function by that name. | [
"Transform",
"otherwise",
"unhandled",
"kinds",
"of",
"chunks",
"by",
"calling",
"an",
"underscore",
"prefixed",
"function",
"by",
"that",
"name",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/inline/text.py#L185-L196 |
marrow/cinje | cinje/inline/text.py | Text.process_format | def process_format(self, kind, context):
"""Handle transforming format string + arguments into Python code."""
result = None
while True:
chunk = yield result
if chunk is None:
return
# We need to split the expression defining the format string from the values to pass when formatting.
... | python | def process_format(self, kind, context):
"""Handle transforming format string + arguments into Python code."""
result = None
while True:
chunk = yield result
if chunk is None:
return
# We need to split the expression defining the format string from the values to pass when formatting.
... | [
"def",
"process_format",
"(",
"self",
",",
"kind",
",",
"context",
")",
":",
"result",
"=",
"None",
"while",
"True",
":",
"chunk",
"=",
"yield",
"result",
"if",
"chunk",
"is",
"None",
":",
"return",
"# We need to split the expression defining the format string fro... | Handle transforming format string + arguments into Python code. | [
"Handle",
"transforming",
"format",
"string",
"+",
"arguments",
"into",
"Python",
"code",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/inline/text.py#L198-L220 |
Ajedi32/echovr-api | echovr_api/game_state.py | GameState.find_player | def find_player(self, username: str = None):
"""Find the :class:`~.Player` with the given properties
Returns the player whose attributes match the given properties, or
``None`` if no match is found.
:param username: The username of the Player
"""
if username != None:
... | python | def find_player(self, username: str = None):
"""Find the :class:`~.Player` with the given properties
Returns the player whose attributes match the given properties, or
``None`` if no match is found.
:param username: The username of the Player
"""
if username != None:
... | [
"def",
"find_player",
"(",
"self",
",",
"username",
":",
"str",
"=",
"None",
")",
":",
"if",
"username",
"!=",
"None",
":",
"return",
"next",
"(",
"(",
"player",
"for",
"player",
"in",
"self",
".",
"players",
"if",
"player",
".",
"name",
"==",
"usern... | Find the :class:`~.Player` with the given properties
Returns the player whose attributes match the given properties, or
``None`` if no match is found.
:param username: The username of the Player | [
"Find",
"the",
":",
"class",
":",
"~",
".",
"Player",
"with",
"the",
"given",
"properties"
] | train | https://github.com/Ajedi32/echovr-api/blob/e135f25fb5b188e2931133d04c47c5e66e83a6c5/echovr_api/game_state.py#L138-L149 |
Ajedi32/echovr-api | echovr_api/game_state.py | GameState.find_team | def find_team(self, color: str = None):
"""Find the :class:`~.Team` with the given properties
Returns the team whose attributes match the given properties, or
``None`` if no match is found.
:param color: The :class:`~.Team.Color` of the Team
"""
if color != None:
... | python | def find_team(self, color: str = None):
"""Find the :class:`~.Team` with the given properties
Returns the team whose attributes match the given properties, or
``None`` if no match is found.
:param color: The :class:`~.Team.Color` of the Team
"""
if color != None:
... | [
"def",
"find_team",
"(",
"self",
",",
"color",
":",
"str",
"=",
"None",
")",
":",
"if",
"color",
"!=",
"None",
":",
"if",
"color",
"is",
"Team",
".",
"Color",
".",
"BLUE",
":",
"return",
"self",
".",
"blue_team",
"else",
":",
"return",
"self",
".",... | Find the :class:`~.Team` with the given properties
Returns the team whose attributes match the given properties, or
``None`` if no match is found.
:param color: The :class:`~.Team.Color` of the Team | [
"Find",
"the",
":",
"class",
":",
"~",
".",
"Team",
"with",
"the",
"given",
"properties"
] | train | https://github.com/Ajedi32/echovr-api/blob/e135f25fb5b188e2931133d04c47c5e66e83a6c5/echovr_api/game_state.py#L151-L165 |
azavea/python-omgeo | omgeo/services/esri.py | EsriWGS._geocode | def _geocode(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery object to use for geocoding
:returns: list of location Candidates
"""
#: List of desired output fields
#: See `ESRI docs <https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm>_`... | python | def _geocode(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery object to use for geocoding
:returns: list of location Candidates
"""
#: List of desired output fields
#: See `ESRI docs <https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm>_`... | [
"def",
"_geocode",
"(",
"self",
",",
"pq",
")",
":",
"#: List of desired output fields",
"#: See `ESRI docs <https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm>_` for details",
"outFields",
"=",
"(",
"'Loc_name'",
",",
"# 'Shape',",
"'Score'",
... | :arg PlaceQuery pq: PlaceQuery object to use for geocoding
:returns: list of location Candidates | [
":",
"arg",
"PlaceQuery",
"pq",
":",
"PlaceQuery",
"object",
"to",
"use",
"for",
"geocoding",
":",
"returns",
":",
"list",
"of",
"location",
"Candidates"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/esri.py#L95-L215 |
azavea/python-omgeo | omgeo/services/esri.py | EsriWGS._street_addr_from_response | def _street_addr_from_response(self, attributes):
"""Construct a street address (no city, region, etc.) from a geocoder response.
:param attributes: A dict of address attributes as returned by the Esri geocoder.
"""
# The exact ordering of the address component fields that should be
... | python | def _street_addr_from_response(self, attributes):
"""Construct a street address (no city, region, etc.) from a geocoder response.
:param attributes: A dict of address attributes as returned by the Esri geocoder.
"""
# The exact ordering of the address component fields that should be
... | [
"def",
"_street_addr_from_response",
"(",
"self",
",",
"attributes",
")",
":",
"# The exact ordering of the address component fields that should be",
"# used to reconstruct the full street address is not specified in the",
"# Esri documentation, but the examples imply that it is this.",
"order... | Construct a street address (no city, region, etc.) from a geocoder response.
:param attributes: A dict of address attributes as returned by the Esri geocoder. | [
"Construct",
"a",
"street",
"address",
"(",
"no",
"city",
"region",
"etc",
".",
")",
"from",
"a",
"geocoder",
"response",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/esri.py#L217-L232 |
azavea/python-omgeo | omgeo/services/esri.py | EsriWGS.get_token | def get_token(self, expires=None):
"""
:param expires: The time until the returned token expires.
Must be an instance of :class:`datetime.timedelta`.
If not specified, the token will expire in 2 hours.
:returns: A token suitable for use with the Esri geocoding API
... | python | def get_token(self, expires=None):
"""
:param expires: The time until the returned token expires.
Must be an instance of :class:`datetime.timedelta`.
If not specified, the token will expire in 2 hours.
:returns: A token suitable for use with the Esri geocoding API
... | [
"def",
"get_token",
"(",
"self",
",",
"expires",
"=",
"None",
")",
":",
"endpoint",
"=",
"'https://www.arcgis.com/sharing/rest/oauth2/token/'",
"query",
"=",
"{",
"'client_id'",
":",
"self",
".",
"_client_id",
",",
"'client_secret'",
":",
"self",
".",
"_client_sec... | :param expires: The time until the returned token expires.
Must be an instance of :class:`datetime.timedelta`.
If not specified, the token will expire in 2 hours.
:returns: A token suitable for use with the Esri geocoding API | [
":",
"param",
"expires",
":",
"The",
"time",
"until",
"the",
"returned",
"token",
"expires",
".",
"Must",
"be",
"an",
"instance",
"of",
":",
"class",
":",
"datetime",
".",
"timedelta",
".",
"If",
"not",
"specified",
"the",
"token",
"will",
"expire",
"in"... | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/esri.py#L234-L253 |
azavea/python-omgeo | omgeo/preprocessors.py | ReplaceRangeWithNumber.process | def process(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:returns: PlaceQuery instance with truncated address range / number
"""
pq.query = self.replace_range(pq.query)
pq.address = self.replace_range(pq.address)
return pq | python | def process(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:returns: PlaceQuery instance with truncated address range / number
"""
pq.query = self.replace_range(pq.query)
pq.address = self.replace_range(pq.address)
return pq | [
"def",
"process",
"(",
"self",
",",
"pq",
")",
":",
"pq",
".",
"query",
"=",
"self",
".",
"replace_range",
"(",
"pq",
".",
"query",
")",
"pq",
".",
"address",
"=",
"self",
".",
"replace_range",
"(",
"pq",
".",
"address",
")",
"return",
"pq"
] | :arg PlaceQuery pq: PlaceQuery instance
:returns: PlaceQuery instance with truncated address range / number | [
":",
"arg",
"PlaceQuery",
"pq",
":",
"PlaceQuery",
"instance",
":",
"returns",
":",
"PlaceQuery",
"instance",
"with",
"truncated",
"address",
"range",
"/",
"number"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/preprocessors.py#L55-L62 |
azavea/python-omgeo | omgeo/preprocessors.py | ParseSingleLine.process | def process(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:returns: PlaceQuery instance with :py:attr:`query`
converted to individual elements
"""
if pq.query != '':
postcode = address = city = '' # define the vars we'll use
# ... | python | def process(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:returns: PlaceQuery instance with :py:attr:`query`
converted to individual elements
"""
if pq.query != '':
postcode = address = city = '' # define the vars we'll use
# ... | [
"def",
"process",
"(",
"self",
",",
"pq",
")",
":",
"if",
"pq",
".",
"query",
"!=",
"''",
":",
"postcode",
"=",
"address",
"=",
"city",
"=",
"''",
"# define the vars we'll use",
"# global regex postcode search, pop off last result",
"postcode_matches",
"=",
"self"... | :arg PlaceQuery pq: PlaceQuery instance
:returns: PlaceQuery instance with :py:attr:`query`
converted to individual elements | [
":",
"arg",
"PlaceQuery",
"pq",
":",
"PlaceQuery",
"instance",
":",
"returns",
":",
"PlaceQuery",
"instance",
"with",
":",
"py",
":",
"attr",
":",
"query",
"converted",
"to",
"individual",
"elements"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/preprocessors.py#L81-L127 |
azavea/python-omgeo | omgeo/preprocessors.py | CountryPreProcessor.process | def process(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:returns: modified PlaceQuery, or ``False`` if country is not acceptable.
"""
# Map country, but don't let map overwrite
if pq.country not in self.acceptable_countries and pq.country in self.country_map:
... | python | def process(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:returns: modified PlaceQuery, or ``False`` if country is not acceptable.
"""
# Map country, but don't let map overwrite
if pq.country not in self.acceptable_countries and pq.country in self.country_map:
... | [
"def",
"process",
"(",
"self",
",",
"pq",
")",
":",
"# Map country, but don't let map overwrite",
"if",
"pq",
".",
"country",
"not",
"in",
"self",
".",
"acceptable_countries",
"and",
"pq",
".",
"country",
"in",
"self",
".",
"country_map",
":",
"pq",
".",
"co... | :arg PlaceQuery pq: PlaceQuery instance
:returns: modified PlaceQuery, or ``False`` if country is not acceptable. | [
":",
"arg",
"PlaceQuery",
"pq",
":",
"PlaceQuery",
"instance",
":",
"returns",
":",
"modified",
"PlaceQuery",
"or",
"False",
"if",
"country",
"is",
"not",
"acceptable",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/preprocessors.py#L170-L182 |
azavea/python-omgeo | omgeo/preprocessors.py | RequireCountry.process | def process(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:returns: One of the three following values:
* unmodified PlaceQuery instance if pq.country is not empty
* PlaceQuery instance with pq.country changed to default country.
*... | python | def process(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:returns: One of the three following values:
* unmodified PlaceQuery instance if pq.country is not empty
* PlaceQuery instance with pq.country changed to default country.
*... | [
"def",
"process",
"(",
"self",
",",
"pq",
")",
":",
"if",
"pq",
".",
"country",
".",
"strip",
"(",
")",
"==",
"''",
":",
"if",
"self",
".",
"default_country",
"==",
"''",
":",
"return",
"False",
"else",
":",
"pq",
".",
"country",
"=",
"self",
"."... | :arg PlaceQuery pq: PlaceQuery instance
:returns: One of the three following values:
* unmodified PlaceQuery instance if pq.country is not empty
* PlaceQuery instance with pq.country changed to default country.
* ``False`` if pq.country is empty and self.... | [
":",
"arg",
"PlaceQuery",
"pq",
":",
"PlaceQuery",
"instance",
":",
"returns",
":",
"One",
"of",
"the",
"three",
"following",
"values",
":",
"*",
"unmodified",
"PlaceQuery",
"instance",
"if",
"pq",
".",
"country",
"is",
"not",
"empty",
"*",
"PlaceQuery",
"... | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/preprocessors.py#L258-L271 |
azavea/python-omgeo | omgeo/services/us_census.py | USCensus._street_addr_from_response | def _street_addr_from_response(self, match):
"""Construct a street address (no city, region, etc.) from a geocoder response.
:param match: The match object returned by the geocoder.
"""
# Same caveat as above regarding the ordering of these fields; the
# documentation is not exp... | python | def _street_addr_from_response(self, match):
"""Construct a street address (no city, region, etc.) from a geocoder response.
:param match: The match object returned by the geocoder.
"""
# Same caveat as above regarding the ordering of these fields; the
# documentation is not exp... | [
"def",
"_street_addr_from_response",
"(",
"self",
",",
"match",
")",
":",
"# Same caveat as above regarding the ordering of these fields; the",
"# documentation is not explicit about the correct ordering for",
"# reconstructing a full address, but implies that this is the ordering.",
"ordered_... | Construct a street address (no city, region, etc.) from a geocoder response.
:param match: The match object returned by the geocoder. | [
"Construct",
"a",
"street",
"address",
"(",
"no",
"city",
"region",
"etc",
".",
")",
"from",
"a",
"geocoder",
"response",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/us_census.py#L53-L78 |
morpframework/morpfw | morpfw/app.py | Request.copy | def copy(self, *args, **kwargs):
"""
Copy the request and environment object.
This only does a shallow copy, except of wsgi.input
"""
self.make_body_seekable()
env = self.environ.copy()
new_req = self.__class__(env, *args, **kwargs)
new_req.copy_body()
... | python | def copy(self, *args, **kwargs):
"""
Copy the request and environment object.
This only does a shallow copy, except of wsgi.input
"""
self.make_body_seekable()
env = self.environ.copy()
new_req = self.__class__(env, *args, **kwargs)
new_req.copy_body()
... | [
"def",
"copy",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"make_body_seekable",
"(",
")",
"env",
"=",
"self",
".",
"environ",
".",
"copy",
"(",
")",
"new_req",
"=",
"self",
".",
"__class__",
"(",
"env",
",",
"*... | Copy the request and environment object.
This only does a shallow copy, except of wsgi.input | [
"Copy",
"the",
"request",
"and",
"environment",
"object",
"."
] | train | https://github.com/morpframework/morpfw/blob/803fbf29714e6f29456482f1cfbdbd4922b020b0/morpfw/app.py#L48-L59 |
azavea/python-omgeo | omgeo/geocoder.py | Geocoder.add_source | def add_source(self, source):
"""
Add a geocoding service to this instance.
"""
geocode_service = self._get_service_by_name(source[0])
self._sources.append(geocode_service(**source[1])) | python | def add_source(self, source):
"""
Add a geocoding service to this instance.
"""
geocode_service = self._get_service_by_name(source[0])
self._sources.append(geocode_service(**source[1])) | [
"def",
"add_source",
"(",
"self",
",",
"source",
")",
":",
"geocode_service",
"=",
"self",
".",
"_get_service_by_name",
"(",
"source",
"[",
"0",
"]",
")",
"self",
".",
"_sources",
".",
"append",
"(",
"geocode_service",
"(",
"*",
"*",
"source",
"[",
"1",
... | Add a geocoding service to this instance. | [
"Add",
"a",
"geocoding",
"service",
"to",
"this",
"instance",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/geocoder.py#L37-L42 |
azavea/python-omgeo | omgeo/geocoder.py | Geocoder.remove_source | def remove_source(self, source):
"""
Remove a geocoding service from this instance.
"""
geocode_service = self._get_service_by_name(source[0])
self._sources.remove(geocode_service(**source[1])) | python | def remove_source(self, source):
"""
Remove a geocoding service from this instance.
"""
geocode_service = self._get_service_by_name(source[0])
self._sources.remove(geocode_service(**source[1])) | [
"def",
"remove_source",
"(",
"self",
",",
"source",
")",
":",
"geocode_service",
"=",
"self",
".",
"_get_service_by_name",
"(",
"source",
"[",
"0",
"]",
")",
"self",
".",
"_sources",
".",
"remove",
"(",
"geocode_service",
"(",
"*",
"*",
"source",
"[",
"1... | Remove a geocoding service from this instance. | [
"Remove",
"a",
"geocoding",
"service",
"from",
"this",
"instance",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/geocoder.py#L44-L49 |
azavea/python-omgeo | omgeo/geocoder.py | Geocoder.set_sources | def set_sources(self, sources):
"""
Creates GeocodeServiceConfigs from each str source
"""
if len(sources) == 0:
raise Exception('Must declare at least one source for a geocoder')
self._sources = []
for source in sources: # iterate through a list of sources
... | python | def set_sources(self, sources):
"""
Creates GeocodeServiceConfigs from each str source
"""
if len(sources) == 0:
raise Exception('Must declare at least one source for a geocoder')
self._sources = []
for source in sources: # iterate through a list of sources
... | [
"def",
"set_sources",
"(",
"self",
",",
"sources",
")",
":",
"if",
"len",
"(",
"sources",
")",
"==",
"0",
":",
"raise",
"Exception",
"(",
"'Must declare at least one source for a geocoder'",
")",
"self",
".",
"_sources",
"=",
"[",
"]",
"for",
"source",
"in",... | Creates GeocodeServiceConfigs from each str source | [
"Creates",
"GeocodeServiceConfigs",
"from",
"each",
"str",
"source"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/geocoder.py#L51-L59 |
azavea/python-omgeo | omgeo/geocoder.py | Geocoder.geocode | def geocode(self, pq, waterfall=None, force_stats_logging=False):
"""
:arg PlaceQuery pq: PlaceQuery object (required).
:arg bool waterfall: Boolean set to True if all geocoders listed should
be used to find results, instead of stopping after
... | python | def geocode(self, pq, waterfall=None, force_stats_logging=False):
"""
:arg PlaceQuery pq: PlaceQuery object (required).
:arg bool waterfall: Boolean set to True if all geocoders listed should
be used to find results, instead of stopping after
... | [
"def",
"geocode",
"(",
"self",
",",
"pq",
",",
"waterfall",
"=",
"None",
",",
"force_stats_logging",
"=",
"False",
")",
":",
"waterfall",
"=",
"self",
".",
"waterfall",
"if",
"waterfall",
"is",
"None",
"else",
"waterfall",
"if",
"type",
"(",
"pq",
")",
... | :arg PlaceQuery pq: PlaceQuery object (required).
:arg bool waterfall: Boolean set to True if all geocoders listed should
be used to find results, instead of stopping after
the first geocoding service with valid candidates
(... | [
":",
"arg",
"PlaceQuery",
"pq",
":",
"PlaceQuery",
"object",
"(",
"required",
")",
".",
":",
"arg",
"bool",
"waterfall",
":",
"Boolean",
"set",
"to",
"True",
"if",
"all",
"geocoders",
"listed",
"should",
"be",
"used",
"to",
"find",
"results",
"instead",
... | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/geocoder.py#L86-L132 |
venmo/btnamespace | btnamespace/patch.py | PatchedMethod._apply_param_actions | def _apply_param_actions(self, params, schema_params):
"""Traverse a schema and perform the updates it describes to params."""
for key, val in schema_params.items():
if key not in params:
continue
if isinstance(val, dict):
self._apply_param_actio... | python | def _apply_param_actions(self, params, schema_params):
"""Traverse a schema and perform the updates it describes to params."""
for key, val in schema_params.items():
if key not in params:
continue
if isinstance(val, dict):
self._apply_param_actio... | [
"def",
"_apply_param_actions",
"(",
"self",
",",
"params",
",",
"schema_params",
")",
":",
"for",
"key",
",",
"val",
"in",
"schema_params",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"params",
":",
"continue",
"if",
"isinstance",
"(",
"val",
... | Traverse a schema and perform the updates it describes to params. | [
"Traverse",
"a",
"schema",
"and",
"perform",
"the",
"updates",
"it",
"describes",
"to",
"params",
"."
] | train | https://github.com/venmo/btnamespace/blob/55a42959bbfbb2409e8b5cb6bfc4cb75f37cbcde/btnamespace/patch.py#L52-L72 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.validator | def validator(self):
"""
VCF Validator
"""
tstart = datetime.now()
v = validator.Validator(self.vcf_file)
std = v.run()
if std == 0:
self.is_validated = True
tend = datetime.now()
execution_time = tend - tstart | python | def validator(self):
"""
VCF Validator
"""
tstart = datetime.now()
v = validator.Validator(self.vcf_file)
std = v.run()
if std == 0:
self.is_validated = True
tend = datetime.now()
execution_time = tend - tstart | [
"def",
"validator",
"(",
"self",
")",
":",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"v",
"=",
"validator",
".",
"Validator",
"(",
"self",
".",
"vcf_file",
")",
"std",
"=",
"v",
".",
"run",
"(",
")",
"if",
"std",
"==",
"0",
":",
"self",
... | VCF Validator | [
"VCF",
"Validator"
] | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L173-L185 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.sanitycheck | def sanitycheck(self):
"""
Search and Remove variants with [0/0, ./.]
Search and Replace chr from the beggining of the chromossomes to get positionning.
Sort VCF by 1...22, X, Y, MT and nothing else
#Discard other variants
"""
# logging.info('Starting Sanity C... | python | def sanitycheck(self):
"""
Search and Remove variants with [0/0, ./.]
Search and Replace chr from the beggining of the chromossomes to get positionning.
Sort VCF by 1...22, X, Y, MT and nothing else
#Discard other variants
"""
# logging.info('Starting Sanity C... | [
"def",
"sanitycheck",
"(",
"self",
")",
":",
"# logging.info('Starting Sanity Check...')",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"# command = 'python %s/sanity_check.py -i %s' % (scripts_dir, self.vcf_file)",
"# self.shell(command)",
"sc",
"=",
"sanity_check",
".",
... | Search and Remove variants with [0/0, ./.]
Search and Replace chr from the beggining of the chromossomes to get positionning.
Sort VCF by 1...22, X, Y, MT and nothing else
#Discard other variants | [
"Search",
"and",
"Remove",
"variants",
"with",
"[",
"0",
"/",
"0",
".",
"/",
".",
"]",
"Search",
"and",
"Replace",
"chr",
"from",
"the",
"beggining",
"of",
"the",
"chromossomes",
"to",
"get",
"positionning",
".",
"Sort",
"VCF",
"by",
"1",
"...",
"22",
... | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L187-L204 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.snpeff | def snpeff(self):
"""
Annotation with snpEff
"""
# calculate time thread took to finish
# logging.info('Starting snpEff')
tstart = datetime.now()
se = snpeff.Snpeff(self.vcf_file)
std = se.run()
tend = datetime.now()
execution_time = ten... | python | def snpeff(self):
"""
Annotation with snpEff
"""
# calculate time thread took to finish
# logging.info('Starting snpEff')
tstart = datetime.now()
se = snpeff.Snpeff(self.vcf_file)
std = se.run()
tend = datetime.now()
execution_time = ten... | [
"def",
"snpeff",
"(",
"self",
")",
":",
"# calculate time thread took to finish",
"# logging.info('Starting snpEff')",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"se",
"=",
"snpeff",
".",
"Snpeff",
"(",
"self",
".",
"vcf_file",
")",
"std",
"=",
"se",
"."... | Annotation with snpEff | [
"Annotation",
"with",
"snpEff"
] | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L207-L219 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.vep | def vep(self):
"""VEP"""
# calculate time thread took to finish
# logging.info('Starting VEP ')
tstart = datetime.now()
vep_obj = vep.Vep(self.vcf_file)
std = vep_obj.run()
# command = 'python %s/vep.py -i sanity_check/checked.vcf' % (scripts_dir)
# sel... | python | def vep(self):
"""VEP"""
# calculate time thread took to finish
# logging.info('Starting VEP ')
tstart = datetime.now()
vep_obj = vep.Vep(self.vcf_file)
std = vep_obj.run()
# command = 'python %s/vep.py -i sanity_check/checked.vcf' % (scripts_dir)
# sel... | [
"def",
"vep",
"(",
"self",
")",
":",
"# calculate time thread took to finish",
"# logging.info('Starting VEP ')",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"vep_obj",
"=",
"vep",
".",
"Vep",
"(",
"self",
".",
"vcf_file",
")",
"std",
"=",
"vep_obj",
".",... | VEP | [
"VEP"
] | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L225-L245 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.decipher | def decipher(self):
"""Decipher """
# calculate time thread took to finish
# logging.info('Starting HI score')
tstart = datetime.now()
decipher_obj = decipher.Decipher(self.vcf_file)
decipher_obj.run()
tend = datetime.now()
execution_time = tend - tstar... | python | def decipher(self):
"""Decipher """
# calculate time thread took to finish
# logging.info('Starting HI score')
tstart = datetime.now()
decipher_obj = decipher.Decipher(self.vcf_file)
decipher_obj.run()
tend = datetime.now()
execution_time = tend - tstar... | [
"def",
"decipher",
"(",
"self",
")",
":",
"# calculate time thread took to finish",
"# logging.info('Starting HI score')",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"decipher_obj",
"=",
"decipher",
".",
"Decipher",
"(",
"self",
".",
"vcf_file",
")",
"decipher... | Decipher | [
"Decipher"
] | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L249-L260 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.hgmd | def hgmd(self):
"""Hi Index """
# calculate time thread took to finish
# logging.info('Starting HI score')
tstart = datetime.now()
if os.path.isfile(settings.hgmd_file):
hgmd_obj = hgmd.HGMD(self.vcf_file)
hgmd_obj.run()
tend = datetime.now()... | python | def hgmd(self):
"""Hi Index """
# calculate time thread took to finish
# logging.info('Starting HI score')
tstart = datetime.now()
if os.path.isfile(settings.hgmd_file):
hgmd_obj = hgmd.HGMD(self.vcf_file)
hgmd_obj.run()
tend = datetime.now()... | [
"def",
"hgmd",
"(",
"self",
")",
":",
"# calculate time thread took to finish",
"# logging.info('Starting HI score')",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"settings",
".",
"hgmd_file",
")",
":",
"hgmd_obj... | Hi Index | [
"Hi",
"Index"
] | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L264-L278 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.snpsift | def snpsift(self):
"""SnpSift"""
tstart = datetime.now()
# command = 'python %s/snpsift.py -i sanity_check/checked.vcf 2>log/snpsift.log' % (scripts_dir)
# self.shell(command)
ss = snpsift.SnpSift(self.vcf_file)
ss.run()
tend = datetime.now()
execution... | python | def snpsift(self):
"""SnpSift"""
tstart = datetime.now()
# command = 'python %s/snpsift.py -i sanity_check/checked.vcf 2>log/snpsift.log' % (scripts_dir)
# self.shell(command)
ss = snpsift.SnpSift(self.vcf_file)
ss.run()
tend = datetime.now()
execution... | [
"def",
"snpsift",
"(",
"self",
")",
":",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"# command = 'python %s/snpsift.py -i sanity_check/checked.vcf 2>log/snpsift.log' % (scripts_dir)",
"# self.shell(command)",
"ss",
"=",
"snpsift",
".",
"SnpSift",
"(",
"self",
".",
... | SnpSift | [
"SnpSift"
] | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L309-L321 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.vcf_annotator | def vcf_annotator(self):
"""Vcf annotator"""
tstart = datetime.now()
# python ../scripts/annotate_vcfs.py -i mm13173_14.ug.target1.vcf -r 1000genomes dbsnp138 clinvar esp6500 -a ../data/1000genomes/ALL.wgs.integrated_phase1_v3.20101123.snps_indels_sv.sites.vcf.gz ../data/dbsnp138/00-All.vcf.gz... | python | def vcf_annotator(self):
"""Vcf annotator"""
tstart = datetime.now()
# python ../scripts/annotate_vcfs.py -i mm13173_14.ug.target1.vcf -r 1000genomes dbsnp138 clinvar esp6500 -a ../data/1000genomes/ALL.wgs.integrated_phase1_v3.20101123.snps_indels_sv.sites.vcf.gz ../data/dbsnp138/00-All.vcf.gz... | [
"def",
"vcf_annotator",
"(",
"self",
")",
":",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"# python ../scripts/annotate_vcfs.py -i mm13173_14.ug.target1.vcf -r 1000genomes dbsnp138 clinvar esp6500 -a ../data/1000genomes/ALL.wgs.integrated_phase1_v3.20101123.snps_indels_sv.sites.vcf.g... | Vcf annotator | [
"Vcf",
"annotator"
] | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L325-L360 |
raonyguimaraes/pynnotator | pynnotator/annotator.py | Annotator.dbnsfp | def dbnsfp(self):
"""dbnsfp"""
tstart = datetime.now()
# python ../scripts/annotate_vcfs.py -i mm13173_14.ug.target1.vcf -r 1000genomes dbsnp138 clinvar esp6500 -a ../data/1000genomes/ALL.wgs.integrated_phase1_v3.20101123.snps_indels_sv.sites.vcf.gz ../data/dbsnp138/00-All.vcf.gz ../data/dbsnp... | python | def dbnsfp(self):
"""dbnsfp"""
tstart = datetime.now()
# python ../scripts/annotate_vcfs.py -i mm13173_14.ug.target1.vcf -r 1000genomes dbsnp138 clinvar esp6500 -a ../data/1000genomes/ALL.wgs.integrated_phase1_v3.20101123.snps_indels_sv.sites.vcf.gz ../data/dbsnp138/00-All.vcf.gz ../data/dbsnp... | [
"def",
"dbnsfp",
"(",
"self",
")",
":",
"tstart",
"=",
"datetime",
".",
"now",
"(",
")",
"# python ../scripts/annotate_vcfs.py -i mm13173_14.ug.target1.vcf -r 1000genomes dbsnp138 clinvar esp6500 -a ../data/1000genomes/ALL.wgs.integrated_phase1_v3.20101123.snps_indels_sv.sites.vcf.gz ../da... | dbnsfp | [
"dbnsfp"
] | train | https://github.com/raonyguimaraes/pynnotator/blob/84ba8c3cdefde4c1894b853ba8370d3b4ff1d62a/pynnotator/annotator.py#L364-L377 |
morpframework/morpfw | morpfw/cli.py | cli | def cli(ctx, settings, app):
"""Manage Morp application services"""
if app is None and settings is None:
print('Either --app or --settings must be supplied')
ctx.ensure_object(dict)
ctx.obj['app'] = app
ctx.obj['settings'] = settings | python | def cli(ctx, settings, app):
"""Manage Morp application services"""
if app is None and settings is None:
print('Either --app or --settings must be supplied')
ctx.ensure_object(dict)
ctx.obj['app'] = app
ctx.obj['settings'] = settings | [
"def",
"cli",
"(",
"ctx",
",",
"settings",
",",
"app",
")",
":",
"if",
"app",
"is",
"None",
"and",
"settings",
"is",
"None",
":",
"print",
"(",
"'Either --app or --settings must be supplied'",
")",
"ctx",
".",
"ensure_object",
"(",
"dict",
")",
"ctx",
".",... | Manage Morp application services | [
"Manage",
"Morp",
"application",
"services"
] | train | https://github.com/morpframework/morpfw/blob/803fbf29714e6f29456482f1cfbdbd4922b020b0/morpfw/cli.py#L71-L77 |
azavea/python-omgeo | omgeo/services/base.py | GeocodeService._settings_checker | def _settings_checker(self, required_settings=None, accept_none=True):
"""
Take a list of required _settings dictionary keys
and make sure they are set. This can be added to a custom
constructor in a subclass and tested to see if it returns ``True``.
:arg list required_settings:... | python | def _settings_checker(self, required_settings=None, accept_none=True):
"""
Take a list of required _settings dictionary keys
and make sure they are set. This can be added to a custom
constructor in a subclass and tested to see if it returns ``True``.
:arg list required_settings:... | [
"def",
"_settings_checker",
"(",
"self",
",",
"required_settings",
"=",
"None",
",",
"accept_none",
"=",
"True",
")",
":",
"if",
"required_settings",
"is",
"not",
"None",
":",
"for",
"keyname",
"in",
"required_settings",
":",
"if",
"keyname",
"not",
"in",
"s... | Take a list of required _settings dictionary keys
and make sure they are set. This can be added to a custom
constructor in a subclass and tested to see if it returns ``True``.
:arg list required_settings: A list of required keys to look for.
:arg bool accept_none: Boolean set to True if... | [
"Take",
"a",
"list",
"of",
"required",
"_settings",
"dictionary",
"keys",
"and",
"make",
"sure",
"they",
"are",
"set",
".",
"This",
"can",
"be",
"added",
"to",
"a",
"custom",
"constructor",
"in",
"a",
"subclass",
"and",
"tested",
"to",
"see",
"if",
"it",... | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/base.py#L109-L129 |
azavea/python-omgeo | omgeo/services/base.py | GeocodeService._get_response | def _get_response(self, endpoint, query, is_post=False):
"""Returns response or False in event of failure"""
timeout_secs = self._settings.get('timeout', 10)
headers = self._settings.get('request_headers', {})
try:
if is_post:
response = requests.post(
... | python | def _get_response(self, endpoint, query, is_post=False):
"""Returns response or False in event of failure"""
timeout_secs = self._settings.get('timeout', 10)
headers = self._settings.get('request_headers', {})
try:
if is_post:
response = requests.post(
... | [
"def",
"_get_response",
"(",
"self",
",",
"endpoint",
",",
"query",
",",
"is_post",
"=",
"False",
")",
":",
"timeout_secs",
"=",
"self",
".",
"_settings",
".",
"get",
"(",
"'timeout'",
",",
"10",
")",
"headers",
"=",
"self",
".",
"_settings",
".",
"get... | Returns response or False in event of failure | [
"Returns",
"response",
"or",
"False",
"in",
"event",
"of",
"failure"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/base.py#L131-L153 |
azavea/python-omgeo | omgeo/services/base.py | GeocodeService._get_json_obj | def _get_json_obj(self, endpoint, query, is_post=False):
"""
Return False if connection could not be made.
Otherwise, return a response object from JSON.
"""
response = self._get_response(endpoint, query, is_post=is_post)
content = response.text
try:
r... | python | def _get_json_obj(self, endpoint, query, is_post=False):
"""
Return False if connection could not be made.
Otherwise, return a response object from JSON.
"""
response = self._get_response(endpoint, query, is_post=is_post)
content = response.text
try:
r... | [
"def",
"_get_json_obj",
"(",
"self",
",",
"endpoint",
",",
"query",
",",
"is_post",
"=",
"False",
")",
":",
"response",
"=",
"self",
".",
"_get_response",
"(",
"endpoint",
",",
"query",
",",
"is_post",
"=",
"is_post",
")",
"content",
"=",
"response",
"."... | Return False if connection could not be made.
Otherwise, return a response object from JSON. | [
"Return",
"False",
"if",
"connection",
"could",
"not",
"be",
"made",
".",
"Otherwise",
"return",
"a",
"response",
"object",
"from",
"JSON",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/base.py#L155-L166 |
azavea/python-omgeo | omgeo/services/base.py | GeocodeService._get_xml_doc | def _get_xml_doc(self, endpoint, query, is_post=False):
"""
Return False if connection could not be made.
Otherwise, return a minidom Document.
"""
response = self._get_response(endpoint, query, is_post=is_post)
return minidom.parse(response.text) | python | def _get_xml_doc(self, endpoint, query, is_post=False):
"""
Return False if connection could not be made.
Otherwise, return a minidom Document.
"""
response = self._get_response(endpoint, query, is_post=is_post)
return minidom.parse(response.text) | [
"def",
"_get_xml_doc",
"(",
"self",
",",
"endpoint",
",",
"query",
",",
"is_post",
"=",
"False",
")",
":",
"response",
"=",
"self",
".",
"_get_response",
"(",
"endpoint",
",",
"query",
",",
"is_post",
"=",
"is_post",
")",
"return",
"minidom",
".",
"parse... | Return False if connection could not be made.
Otherwise, return a minidom Document. | [
"Return",
"False",
"if",
"connection",
"could",
"not",
"be",
"made",
".",
"Otherwise",
"return",
"a",
"minidom",
"Document",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/base.py#L168-L174 |
azavea/python-omgeo | omgeo/services/base.py | GeocodeService.geocode | def geocode(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:rtype: tuple
:returns: post-processed list of Candidate objects and
and UpstreamResponseInfo object if an API call was made.
Examples:
Preprocessor throws out reque... | python | def geocode(self, pq):
"""
:arg PlaceQuery pq: PlaceQuery instance
:rtype: tuple
:returns: post-processed list of Candidate objects and
and UpstreamResponseInfo object if an API call was made.
Examples:
Preprocessor throws out reque... | [
"def",
"geocode",
"(",
"self",
",",
"pq",
")",
":",
"processed_pq",
"=",
"copy",
".",
"copy",
"(",
"pq",
")",
"for",
"p",
"in",
"self",
".",
"_preprocessors",
":",
"processed_pq",
"=",
"p",
".",
"process",
"(",
"processed_pq",
")",
"if",
"not",
"proc... | :arg PlaceQuery pq: PlaceQuery instance
:rtype: tuple
:returns: post-processed list of Candidate objects and
and UpstreamResponseInfo object if an API call was made.
Examples:
Preprocessor throws out request::
([], None)
... | [
":",
"arg",
"PlaceQuery",
"pq",
":",
"PlaceQuery",
"instance",
":",
"rtype",
":",
"tuple",
":",
"returns",
":",
"post",
"-",
"processed",
"list",
"of",
"Candidate",
"objects",
"and",
"and",
"UpstreamResponseInfo",
"object",
"if",
"an",
"API",
"call",
"was",
... | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/base.py#L184-L230 |
azavea/python-omgeo | omgeo/postprocessors.py | LocatorFilter.process | def process(self, candidates):
"""
:arg list candidates: list of Candidate instances
"""
for c in candidates[:]:
if c.locator not in self.good_locators:
# TODO: search string, i.e. find "EU_Street_Name" in "EU_Street_Name.GBR_StreetName"
candid... | python | def process(self, candidates):
"""
:arg list candidates: list of Candidate instances
"""
for c in candidates[:]:
if c.locator not in self.good_locators:
# TODO: search string, i.e. find "EU_Street_Name" in "EU_Street_Name.GBR_StreetName"
candid... | [
"def",
"process",
"(",
"self",
",",
"candidates",
")",
":",
"for",
"c",
"in",
"candidates",
"[",
":",
"]",
":",
"if",
"c",
".",
"locator",
"not",
"in",
"self",
".",
"good_locators",
":",
"# TODO: search string, i.e. find \"EU_Street_Name\" in \"EU_Street_Name.GBR_... | :arg list candidates: list of Candidate instances | [
":",
"arg",
"list",
"candidates",
":",
"list",
"of",
"Candidate",
"instances"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/postprocessors.py#L37-L46 |
azavea/python-omgeo | omgeo/postprocessors.py | LocatorSorter.process | def process(self, unordered_candidates):
"""
:arg list candidates: list of Candidate instances
"""
ordered_candidates = []
# make a new list of candidates in order of ordered_locators
for locator in self.ordered_locators:
for uc in unordered_candidates[:]:
... | python | def process(self, unordered_candidates):
"""
:arg list candidates: list of Candidate instances
"""
ordered_candidates = []
# make a new list of candidates in order of ordered_locators
for locator in self.ordered_locators:
for uc in unordered_candidates[:]:
... | [
"def",
"process",
"(",
"self",
",",
"unordered_candidates",
")",
":",
"ordered_candidates",
"=",
"[",
"]",
"# make a new list of candidates in order of ordered_locators",
"for",
"locator",
"in",
"self",
".",
"ordered_locators",
":",
"for",
"uc",
"in",
"unordered_candida... | :arg list candidates: list of Candidate instances | [
":",
"arg",
"list",
"candidates",
":",
"list",
"of",
"Candidate",
"instances"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/postprocessors.py#L65-L80 |
azavea/python-omgeo | omgeo/postprocessors.py | UseHighScoreIfAtLeast.process | def process(self, candidates):
"""
:arg list candidates: list of Candidates
:returns: list of Candidates where score is at least min_score,
if and only if one or more Candidates have at least min_score.
Otherwise, returns original list of Candidates.
"... | python | def process(self, candidates):
"""
:arg list candidates: list of Candidates
:returns: list of Candidates where score is at least min_score,
if and only if one or more Candidates have at least min_score.
Otherwise, returns original list of Candidates.
"... | [
"def",
"process",
"(",
"self",
",",
"candidates",
")",
":",
"high_score_candidates",
"=",
"[",
"c",
"for",
"c",
"in",
"candidates",
"if",
"c",
".",
"score",
">=",
"self",
".",
"min_score",
"]",
"if",
"high_score_candidates",
"!=",
"[",
"]",
":",
"return"... | :arg list candidates: list of Candidates
:returns: list of Candidates where score is at least min_score,
if and only if one or more Candidates have at least min_score.
Otherwise, returns original list of Candidates. | [
":",
"arg",
"list",
"candidates",
":",
"list",
"of",
"Candidates",
":",
"returns",
":",
"list",
"of",
"Candidates",
"where",
"score",
"is",
"at",
"least",
"min_score",
"if",
"and",
"only",
"if",
"one",
"or",
"more",
"Candidates",
"have",
"at",
"least",
"... | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/postprocessors.py#L140-L150 |
azavea/python-omgeo | omgeo/postprocessors.py | ScoreSorter.process | def process(self, candidates):
"""
:arg list candidates: list of Candidates
:returns: score-sorted list of Candidates
"""
return sorted(candidates, key=attrgetter('score'), reverse=self.reverse) | python | def process(self, candidates):
"""
:arg list candidates: list of Candidates
:returns: score-sorted list of Candidates
"""
return sorted(candidates, key=attrgetter('score'), reverse=self.reverse) | [
"def",
"process",
"(",
"self",
",",
"candidates",
")",
":",
"return",
"sorted",
"(",
"candidates",
",",
"key",
"=",
"attrgetter",
"(",
"'score'",
")",
",",
"reverse",
"=",
"self",
".",
"reverse",
")"
] | :arg list candidates: list of Candidates
:returns: score-sorted list of Candidates | [
":",
"arg",
"list",
"candidates",
":",
"list",
"of",
"Candidates",
":",
"returns",
":",
"score",
"-",
"sorted",
"list",
"of",
"Candidates"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/postprocessors.py#L165-L170 |
azavea/python-omgeo | omgeo/postprocessors.py | SnapPoints._get_distance | def _get_distance(self, pnt1, pnt2):
"""Get distance in meters between two lat/long points"""
lat1, lon1 = pnt1
lat2, lon2 = pnt2
radius = 6356752 # km
dlat = math.radians(lat2 - lat1)
dlon = math.radians(lon2 - lon1)
a = math.sin(dlat / 2) * math.sin(dlat / 2) +... | python | def _get_distance(self, pnt1, pnt2):
"""Get distance in meters between two lat/long points"""
lat1, lon1 = pnt1
lat2, lon2 = pnt2
radius = 6356752 # km
dlat = math.radians(lat2 - lat1)
dlon = math.radians(lon2 - lon1)
a = math.sin(dlat / 2) * math.sin(dlat / 2) +... | [
"def",
"_get_distance",
"(",
"self",
",",
"pnt1",
",",
"pnt2",
")",
":",
"lat1",
",",
"lon1",
"=",
"pnt1",
"lat2",
",",
"lon2",
"=",
"pnt2",
"radius",
"=",
"6356752",
"# km",
"dlat",
"=",
"math",
".",
"radians",
"(",
"lat2",
"-",
"lat1",
")",
"dlon... | Get distance in meters between two lat/long points | [
"Get",
"distance",
"in",
"meters",
"between",
"two",
"lat",
"/",
"long",
"points"
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/postprocessors.py#L567-L578 |
azavea/python-omgeo | omgeo/postprocessors.py | SnapPoints._points_within_distance | def _points_within_distance(self, pnt1, pnt2):
"""Returns true if lat/lon points are within given distance in metres."""
if self._get_distance(pnt1, pnt2) <= self.distance:
return True
return False | python | def _points_within_distance(self, pnt1, pnt2):
"""Returns true if lat/lon points are within given distance in metres."""
if self._get_distance(pnt1, pnt2) <= self.distance:
return True
return False | [
"def",
"_points_within_distance",
"(",
"self",
",",
"pnt1",
",",
"pnt2",
")",
":",
"if",
"self",
".",
"_get_distance",
"(",
"pnt1",
",",
"pnt2",
")",
"<=",
"self",
".",
"distance",
":",
"return",
"True",
"return",
"False"
] | Returns true if lat/lon points are within given distance in metres. | [
"Returns",
"true",
"if",
"lat",
"/",
"lon",
"points",
"are",
"within",
"given",
"distance",
"in",
"metres",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/postprocessors.py#L580-L584 |
azavea/python-omgeo | omgeo/services/google.py | Google._make_candidate_from_result | def _make_candidate_from_result(self, result):
""" Make a Candidate from a Google geocoder results dictionary. """
candidate = Candidate()
candidate.match_addr = result['formatted_address']
candidate.x = result['geometry']['location']['lng']
candidate.y = result['geometry']['loca... | python | def _make_candidate_from_result(self, result):
""" Make a Candidate from a Google geocoder results dictionary. """
candidate = Candidate()
candidate.match_addr = result['formatted_address']
candidate.x = result['geometry']['location']['lng']
candidate.y = result['geometry']['loca... | [
"def",
"_make_candidate_from_result",
"(",
"self",
",",
"result",
")",
":",
"candidate",
"=",
"Candidate",
"(",
")",
"candidate",
".",
"match_addr",
"=",
"result",
"[",
"'formatted_address'",
"]",
"candidate",
".",
"x",
"=",
"result",
"[",
"'geometry'",
"]",
... | Make a Candidate from a Google geocoder results dictionary. | [
"Make",
"a",
"Candidate",
"from",
"a",
"Google",
"geocoder",
"results",
"dictionary",
"."
] | train | https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/google.py#L54-L74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.