repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
klahnakoski/pyLibrary | mo_threads/threads.py | Thread.join | def join(self, till=None):
"""
RETURN THE RESULT {"response":r, "exception":e} OF THE THREAD EXECUTION (INCLUDING EXCEPTION, IF EXISTS)
"""
if self is Thread:
Log.error("Thread.join() is not a valid call, use t.join()")
with self.child_lock:
children = co... | python | def join(self, till=None):
"""
RETURN THE RESULT {"response":r, "exception":e} OF THE THREAD EXECUTION (INCLUDING EXCEPTION, IF EXISTS)
"""
if self is Thread:
Log.error("Thread.join() is not a valid call, use t.join()")
with self.child_lock:
children = co... | [
"def",
"join",
"(",
"self",
",",
"till",
"=",
"None",
")",
":",
"if",
"self",
"is",
"Thread",
":",
"Log",
".",
"error",
"(",
"\"Thread.join() is not a valid call, use t.join()\"",
")",
"with",
"self",
".",
"child_lock",
":",
"children",
"=",
"copy",
"(",
"... | RETURN THE RESULT {"response":r, "exception":e} OF THE THREAD EXECUTION (INCLUDING EXCEPTION, IF EXISTS) | [
"RETURN",
"THE",
"RESULT",
"{",
"response",
":",
"r",
"exception",
":",
"e",
"}",
"OF",
"THE",
"THREAD",
"EXECUTION",
"(",
"INCLUDING",
"EXCEPTION",
"IF",
"EXISTS",
")"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/threads.py#L314-L335 |
klahnakoski/pyLibrary | mo_dots/__init__.py | inverse | def inverse(d):
"""
reverse the k:v pairs
"""
output = {}
for k, v in unwrap(d).items():
output[v] = output.get(v, [])
output[v].append(k)
return output | python | def inverse(d):
"""
reverse the k:v pairs
"""
output = {}
for k, v in unwrap(d).items():
output[v] = output.get(v, [])
output[v].append(k)
return output | [
"def",
"inverse",
"(",
"d",
")",
":",
"output",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"unwrap",
"(",
"d",
")",
".",
"items",
"(",
")",
":",
"output",
"[",
"v",
"]",
"=",
"output",
".",
"get",
"(",
"v",
",",
"[",
"]",
")",
"output",
"... | reverse the k:v pairs | [
"reverse",
"the",
"k",
":",
"v",
"pairs"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L30-L38 |
klahnakoski/pyLibrary | mo_dots/__init__.py | zip | def zip(keys, values):
"""
CONVERT LIST OF KEY/VALUE PAIRS TO Data
PLEASE `import dot`, AND CALL `dot.zip()`
"""
output = Data()
for i, k in enumerate(keys):
if i >= len(values):
break
output[k] = values[i]
return output | python | def zip(keys, values):
"""
CONVERT LIST OF KEY/VALUE PAIRS TO Data
PLEASE `import dot`, AND CALL `dot.zip()`
"""
output = Data()
for i, k in enumerate(keys):
if i >= len(values):
break
output[k] = values[i]
return output | [
"def",
"zip",
"(",
"keys",
",",
"values",
")",
":",
"output",
"=",
"Data",
"(",
")",
"for",
"i",
",",
"k",
"in",
"enumerate",
"(",
"keys",
")",
":",
"if",
"i",
">=",
"len",
"(",
"values",
")",
":",
"break",
"output",
"[",
"k",
"]",
"=",
"valu... | CONVERT LIST OF KEY/VALUE PAIRS TO Data
PLEASE `import dot`, AND CALL `dot.zip()` | [
"CONVERT",
"LIST",
"OF",
"KEY",
"/",
"VALUE",
"PAIRS",
"TO",
"Data",
"PLEASE",
"import",
"dot",
"AND",
"CALL",
"dot",
".",
"zip",
"()"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L50-L60 |
klahnakoski/pyLibrary | mo_dots/__init__.py | tail_field | def tail_field(field):
"""
RETURN THE FIRST STEP IN PATH, ALONG WITH THE REMAINING TAIL
"""
if field == "." or field==None:
return ".", "."
elif "." in field:
if "\\." in field:
return tuple(k.replace("\a", ".") for k in field.replace("\\.", "\a").split(".", 1))
e... | python | def tail_field(field):
"""
RETURN THE FIRST STEP IN PATH, ALONG WITH THE REMAINING TAIL
"""
if field == "." or field==None:
return ".", "."
elif "." in field:
if "\\." in field:
return tuple(k.replace("\a", ".") for k in field.replace("\\.", "\a").split(".", 1))
e... | [
"def",
"tail_field",
"(",
"field",
")",
":",
"if",
"field",
"==",
"\".\"",
"or",
"field",
"==",
"None",
":",
"return",
"\".\"",
",",
"\".\"",
"elif",
"\".\"",
"in",
"field",
":",
"if",
"\"\\\\.\"",
"in",
"field",
":",
"return",
"tuple",
"(",
"k",
"."... | RETURN THE FIRST STEP IN PATH, ALONG WITH THE REMAINING TAIL | [
"RETURN",
"THE",
"FIRST",
"STEP",
"IN",
"PATH",
"ALONG",
"WITH",
"THE",
"REMAINING",
"TAIL"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L88-L100 |
klahnakoski/pyLibrary | mo_dots/__init__.py | split_field | def split_field(field):
"""
RETURN field AS ARRAY OF DOT-SEPARATED FIELDS
"""
if field == "." or field==None:
return []
elif is_text(field) and "." in field:
if field.startswith(".."):
remainder = field.lstrip(".")
back = len(field) - len(remainder) - 1
... | python | def split_field(field):
"""
RETURN field AS ARRAY OF DOT-SEPARATED FIELDS
"""
if field == "." or field==None:
return []
elif is_text(field) and "." in field:
if field.startswith(".."):
remainder = field.lstrip(".")
back = len(field) - len(remainder) - 1
... | [
"def",
"split_field",
"(",
"field",
")",
":",
"if",
"field",
"==",
"\".\"",
"or",
"field",
"==",
"None",
":",
"return",
"[",
"]",
"elif",
"is_text",
"(",
"field",
")",
"and",
"\".\"",
"in",
"field",
":",
"if",
"field",
".",
"startswith",
"(",
"\"..\"... | RETURN field AS ARRAY OF DOT-SEPARATED FIELDS | [
"RETURN",
"field",
"AS",
"ARRAY",
"OF",
"DOT",
"-",
"SEPARATED",
"FIELDS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L104-L118 |
klahnakoski/pyLibrary | mo_dots/__init__.py | join_field | def join_field(path):
"""
RETURN field SEQUENCE AS STRING
"""
output = ".".join([f.replace(".", "\\.") for f in path if f != None])
return output if output else "." | python | def join_field(path):
"""
RETURN field SEQUENCE AS STRING
"""
output = ".".join([f.replace(".", "\\.") for f in path if f != None])
return output if output else "." | [
"def",
"join_field",
"(",
"path",
")",
":",
"output",
"=",
"\".\"",
".",
"join",
"(",
"[",
"f",
".",
"replace",
"(",
"\".\"",
",",
"\"\\\\.\"",
")",
"for",
"f",
"in",
"path",
"if",
"f",
"!=",
"None",
"]",
")",
"return",
"output",
"if",
"output",
... | RETURN field SEQUENCE AS STRING | [
"RETURN",
"field",
"SEQUENCE",
"AS",
"STRING"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L121-L126 |
klahnakoski/pyLibrary | mo_dots/__init__.py | startswith_field | def startswith_field(field, prefix):
"""
RETURN True IF field PATH STRING STARTS WITH prefix PATH STRING
"""
if prefix.startswith("."):
return True
# f_back = len(field) - len(field.strip("."))
# p_back = len(prefix) - len(prefix.strip("."))
# if f_back > p_back:
... | python | def startswith_field(field, prefix):
"""
RETURN True IF field PATH STRING STARTS WITH prefix PATH STRING
"""
if prefix.startswith("."):
return True
# f_back = len(field) - len(field.strip("."))
# p_back = len(prefix) - len(prefix.strip("."))
# if f_back > p_back:
... | [
"def",
"startswith_field",
"(",
"field",
",",
"prefix",
")",
":",
"if",
"prefix",
".",
"startswith",
"(",
"\".\"",
")",
":",
"return",
"True",
"# f_back = len(field) - len(field.strip(\".\"))",
"# p_back = len(prefix) - len(prefix.strip(\".\"))",
"# if f_back > p_back:",
"#... | RETURN True IF field PATH STRING STARTS WITH prefix PATH STRING | [
"RETURN",
"True",
"IF",
"field",
"PATH",
"STRING",
"STARTS",
"WITH",
"prefix",
"PATH",
"STRING"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L147-L163 |
klahnakoski/pyLibrary | mo_dots/__init__.py | relative_field | def relative_field(field, parent):
"""
RETURN field PATH WITH RESPECT TO parent
"""
if parent==".":
return field
field_path = split_field(field)
parent_path = split_field(parent)
common = 0
for f, p in _builtin_zip(field_path, parent_path):
if f != p:
break
... | python | def relative_field(field, parent):
"""
RETURN field PATH WITH RESPECT TO parent
"""
if parent==".":
return field
field_path = split_field(field)
parent_path = split_field(parent)
common = 0
for f, p in _builtin_zip(field_path, parent_path):
if f != p:
break
... | [
"def",
"relative_field",
"(",
"field",
",",
"parent",
")",
":",
"if",
"parent",
"==",
"\".\"",
":",
"return",
"field",
"field_path",
"=",
"split_field",
"(",
"field",
")",
"parent_path",
"=",
"split_field",
"(",
"parent",
")",
"common",
"=",
"0",
"for",
... | RETURN field PATH WITH RESPECT TO parent | [
"RETURN",
"field",
"PATH",
"WITH",
"RESPECT",
"TO",
"parent"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L166-L185 |
klahnakoski/pyLibrary | mo_dots/__init__.py | _setdefault | def _setdefault(obj, key, value):
"""
DO NOT USE __dict__.setdefault(obj, key, value), IT DOES NOT CHECK FOR obj[key] == None
"""
v = obj.get(key)
if v == None:
obj[key] = value
return value
return v | python | def _setdefault(obj, key, value):
"""
DO NOT USE __dict__.setdefault(obj, key, value), IT DOES NOT CHECK FOR obj[key] == None
"""
v = obj.get(key)
if v == None:
obj[key] = value
return value
return v | [
"def",
"_setdefault",
"(",
"obj",
",",
"key",
",",
"value",
")",
":",
"v",
"=",
"obj",
".",
"get",
"(",
"key",
")",
"if",
"v",
"==",
"None",
":",
"obj",
"[",
"key",
"]",
"=",
"value",
"return",
"value",
"return",
"v"
] | DO NOT USE __dict__.setdefault(obj, key, value), IT DOES NOT CHECK FOR obj[key] == None | [
"DO",
"NOT",
"USE",
"__dict__",
".",
"setdefault",
"(",
"obj",
"key",
"value",
")",
"IT",
"DOES",
"NOT",
"CHECK",
"FOR",
"obj",
"[",
"key",
"]",
"==",
"None"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L198-L206 |
klahnakoski/pyLibrary | mo_dots/__init__.py | set_default | def set_default(*params):
"""
INPUT dicts IN PRIORITY ORDER
UPDATES FIRST dict WITH THE MERGE RESULT, WHERE MERGE RESULT IS DEFINED AS:
FOR EACH LEAF, RETURN THE HIGHEST PRIORITY LEAF VALUE
"""
p0 = params[0]
agg = p0 if p0 or _get(p0, CLASS) in data_types else {}
for p in params[1:]:
... | python | def set_default(*params):
"""
INPUT dicts IN PRIORITY ORDER
UPDATES FIRST dict WITH THE MERGE RESULT, WHERE MERGE RESULT IS DEFINED AS:
FOR EACH LEAF, RETURN THE HIGHEST PRIORITY LEAF VALUE
"""
p0 = params[0]
agg = p0 if p0 or _get(p0, CLASS) in data_types else {}
for p in params[1:]:
... | [
"def",
"set_default",
"(",
"*",
"params",
")",
":",
"p0",
"=",
"params",
"[",
"0",
"]",
"agg",
"=",
"p0",
"if",
"p0",
"or",
"_get",
"(",
"p0",
",",
"CLASS",
")",
"in",
"data_types",
"else",
"{",
"}",
"for",
"p",
"in",
"params",
"[",
"1",
":",
... | INPUT dicts IN PRIORITY ORDER
UPDATES FIRST dict WITH THE MERGE RESULT, WHERE MERGE RESULT IS DEFINED AS:
FOR EACH LEAF, RETURN THE HIGHEST PRIORITY LEAF VALUE | [
"INPUT",
"dicts",
"IN",
"PRIORITY",
"ORDER",
"UPDATES",
"FIRST",
"dict",
"WITH",
"THE",
"MERGE",
"RESULT",
"WHERE",
"MERGE",
"RESULT",
"IS",
"DEFINED",
"AS",
":",
"FOR",
"EACH",
"LEAF",
"RETURN",
"THE",
"HIGHEST",
"PRIORITY",
"LEAF",
"VALUE"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L209-L222 |
klahnakoski/pyLibrary | mo_dots/__init__.py | _all_default | def _all_default(d, default, seen=None):
"""
ANY VALUE NOT SET WILL BE SET BY THE default
THIS IS RECURSIVE
"""
if default is None:
return
if _get(default, CLASS) is Data:
default = object.__getattribute__(default, SLOT) # REACH IN AND GET THE dict
# Log = _late_import()... | python | def _all_default(d, default, seen=None):
"""
ANY VALUE NOT SET WILL BE SET BY THE default
THIS IS RECURSIVE
"""
if default is None:
return
if _get(default, CLASS) is Data:
default = object.__getattribute__(default, SLOT) # REACH IN AND GET THE dict
# Log = _late_import()... | [
"def",
"_all_default",
"(",
"d",
",",
"default",
",",
"seen",
"=",
"None",
")",
":",
"if",
"default",
"is",
"None",
":",
"return",
"if",
"_get",
"(",
"default",
",",
"CLASS",
")",
"is",
"Data",
":",
"default",
"=",
"object",
".",
"__getattribute__",
... | ANY VALUE NOT SET WILL BE SET BY THE default
THIS IS RECURSIVE | [
"ANY",
"VALUE",
"NOT",
"SET",
"WILL",
"BE",
"SET",
"BY",
"THE",
"default",
"THIS",
"IS",
"RECURSIVE"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L225-L268 |
klahnakoski/pyLibrary | mo_dots/__init__.py | _getdefault | def _getdefault(obj, key):
"""
obj MUST BE A DICT
key IS EXPECTED TO BE LITERAL (NO ESCAPING)
TRY BOTH ATTRIBUTE AND ITEM ACCESS, OR RETURN Null
"""
try:
return obj[key]
except Exception as f:
pass
try:
return getattr(obj, key)
except Exception as f:
... | python | def _getdefault(obj, key):
"""
obj MUST BE A DICT
key IS EXPECTED TO BE LITERAL (NO ESCAPING)
TRY BOTH ATTRIBUTE AND ITEM ACCESS, OR RETURN Null
"""
try:
return obj[key]
except Exception as f:
pass
try:
return getattr(obj, key)
except Exception as f:
... | [
"def",
"_getdefault",
"(",
"obj",
",",
"key",
")",
":",
"try",
":",
"return",
"obj",
"[",
"key",
"]",
"except",
"Exception",
"as",
"f",
":",
"pass",
"try",
":",
"return",
"getattr",
"(",
"obj",
",",
"key",
")",
"except",
"Exception",
"as",
"f",
":"... | obj MUST BE A DICT
key IS EXPECTED TO BE LITERAL (NO ESCAPING)
TRY BOTH ATTRIBUTE AND ITEM ACCESS, OR RETURN Null | [
"obj",
"MUST",
"BE",
"A",
"DICT",
"key",
"IS",
"EXPECTED",
"TO",
"BE",
"LITERAL",
"(",
"NO",
"ESCAPING",
")",
"TRY",
"BOTH",
"ATTRIBUTE",
"AND",
"ITEM",
"ACCESS",
"OR",
"RETURN",
"Null"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L271-L300 |
klahnakoski/pyLibrary | mo_dots/__init__.py | set_attr | def set_attr(obj, path, value):
"""
SAME AS object.__setattr__(), BUT USES DOT-DELIMITED path
RETURN OLD VALUE
"""
try:
return _set_attr(obj, split_field(path), value)
except Exception as e:
Log = get_logger()
if PATH_NOT_FOUND in e:
Log.warning(PATH_NOT_FOUND... | python | def set_attr(obj, path, value):
"""
SAME AS object.__setattr__(), BUT USES DOT-DELIMITED path
RETURN OLD VALUE
"""
try:
return _set_attr(obj, split_field(path), value)
except Exception as e:
Log = get_logger()
if PATH_NOT_FOUND in e:
Log.warning(PATH_NOT_FOUND... | [
"def",
"set_attr",
"(",
"obj",
",",
"path",
",",
"value",
")",
":",
"try",
":",
"return",
"_set_attr",
"(",
"obj",
",",
"split_field",
"(",
"path",
")",
",",
"value",
")",
"except",
"Exception",
"as",
"e",
":",
"Log",
"=",
"get_logger",
"(",
")",
"... | SAME AS object.__setattr__(), BUT USES DOT-DELIMITED path
RETURN OLD VALUE | [
"SAME",
"AS",
"object",
".",
"__setattr__",
"()",
"BUT",
"USES",
"DOT",
"-",
"DELIMITED",
"path",
"RETURN",
"OLD",
"VALUE"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L307-L319 |
klahnakoski/pyLibrary | mo_dots/__init__.py | get_attr | def get_attr(obj, path):
"""
SAME AS object.__getattr__(), BUT USES DOT-DELIMITED path
"""
try:
return _get_attr(obj, split_field(path))
except Exception as e:
Log = get_logger()
if PATH_NOT_FOUND in e:
Log.error(PATH_NOT_FOUND+": {{path}}", path=path, cause=e)
... | python | def get_attr(obj, path):
"""
SAME AS object.__getattr__(), BUT USES DOT-DELIMITED path
"""
try:
return _get_attr(obj, split_field(path))
except Exception as e:
Log = get_logger()
if PATH_NOT_FOUND in e:
Log.error(PATH_NOT_FOUND+": {{path}}", path=path, cause=e)
... | [
"def",
"get_attr",
"(",
"obj",
",",
"path",
")",
":",
"try",
":",
"return",
"_get_attr",
"(",
"obj",
",",
"split_field",
"(",
"path",
")",
")",
"except",
"Exception",
"as",
"e",
":",
"Log",
"=",
"get_logger",
"(",
")",
"if",
"PATH_NOT_FOUND",
"in",
"... | SAME AS object.__getattr__(), BUT USES DOT-DELIMITED path | [
"SAME",
"AS",
"object",
".",
"__getattr__",
"()",
"BUT",
"USES",
"DOT",
"-",
"DELIMITED",
"path"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L322-L333 |
klahnakoski/pyLibrary | mo_dots/__init__.py | wrap | def wrap(v):
"""
WRAP AS Data OBJECT FOR DATA PROCESSING: https://github.com/klahnakoski/mo-dots/tree/dev/docs
:param v: THE VALUE TO WRAP
:return: Data INSTANCE
"""
type_ = _get(v, CLASS)
if type_ is dict:
m = object.__new__(Data)
_set(m, SLOT, v)
return m
el... | python | def wrap(v):
"""
WRAP AS Data OBJECT FOR DATA PROCESSING: https://github.com/klahnakoski/mo-dots/tree/dev/docs
:param v: THE VALUE TO WRAP
:return: Data INSTANCE
"""
type_ = _get(v, CLASS)
if type_ is dict:
m = object.__new__(Data)
_set(m, SLOT, v)
return m
el... | [
"def",
"wrap",
"(",
"v",
")",
":",
"type_",
"=",
"_get",
"(",
"v",
",",
"CLASS",
")",
"if",
"type_",
"is",
"dict",
":",
"m",
"=",
"object",
".",
"__new__",
"(",
"Data",
")",
"_set",
"(",
"m",
",",
"SLOT",
",",
"v",
")",
"return",
"m",
"elif",... | WRAP AS Data OBJECT FOR DATA PROCESSING: https://github.com/klahnakoski/mo-dots/tree/dev/docs
:param v: THE VALUE TO WRAP
:return: Data INSTANCE | [
"WRAP",
"AS",
"Data",
"OBJECT",
"FOR",
"DATA",
"PROCESSING",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"klahnakoski",
"/",
"mo",
"-",
"dots",
"/",
"tree",
"/",
"dev",
"/",
"docs",
":",
"param",
"v",
":",
"THE",
"VALUE",
"TO",
"WRAP",
":",... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L435-L455 |
klahnakoski/pyLibrary | mo_dots/__init__.py | listwrap | def listwrap(value):
"""
PERFORMS THE FOLLOWING TRANSLATION
None -> []
value -> [value]
[...] -> [...] (unchanged list)
##MOTIVATION##
OFTEN IT IS NICE TO ALLOW FUNCTION PARAMETERS TO BE ASSIGNED A VALUE,
OR A list-OF-VALUES, OR NULL. CHECKING FOR WHICH THE CALLER USED IS
TEDIOUS.... | python | def listwrap(value):
"""
PERFORMS THE FOLLOWING TRANSLATION
None -> []
value -> [value]
[...] -> [...] (unchanged list)
##MOTIVATION##
OFTEN IT IS NICE TO ALLOW FUNCTION PARAMETERS TO BE ASSIGNED A VALUE,
OR A list-OF-VALUES, OR NULL. CHECKING FOR WHICH THE CALLER USED IS
TEDIOUS.... | [
"def",
"listwrap",
"(",
"value",
")",
":",
"if",
"value",
"==",
"None",
":",
"return",
"FlatList",
"(",
")",
"elif",
"is_list",
"(",
"value",
")",
":",
"return",
"wrap",
"(",
"value",
")",
"elif",
"isinstance",
"(",
"value",
",",
"set",
")",
":",
"... | PERFORMS THE FOLLOWING TRANSLATION
None -> []
value -> [value]
[...] -> [...] (unchanged list)
##MOTIVATION##
OFTEN IT IS NICE TO ALLOW FUNCTION PARAMETERS TO BE ASSIGNED A VALUE,
OR A list-OF-VALUES, OR NULL. CHECKING FOR WHICH THE CALLER USED IS
TEDIOUS. INSTEAD WE CAST FROM THOSE THRE... | [
"PERFORMS",
"THE",
"FOLLOWING",
"TRANSLATION",
"None",
"-",
">",
"[]",
"value",
"-",
">",
"[",
"value",
"]",
"[",
"...",
"]",
"-",
">",
"[",
"...",
"]",
"(",
"unchanged",
"list",
")"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L534-L569 |
klahnakoski/pyLibrary | mo_dots/__init__.py | unwraplist | def unwraplist(v):
"""
LISTS WITH ZERO AND ONE element MAP TO None AND element RESPECTIVELY
"""
if is_list(v):
if len(v) == 0:
return None
elif len(v) == 1:
return unwrap(v[0])
else:
return unwrap(v)
else:
return unwrap(v) | python | def unwraplist(v):
"""
LISTS WITH ZERO AND ONE element MAP TO None AND element RESPECTIVELY
"""
if is_list(v):
if len(v) == 0:
return None
elif len(v) == 1:
return unwrap(v[0])
else:
return unwrap(v)
else:
return unwrap(v) | [
"def",
"unwraplist",
"(",
"v",
")",
":",
"if",
"is_list",
"(",
"v",
")",
":",
"if",
"len",
"(",
"v",
")",
"==",
"0",
":",
"return",
"None",
"elif",
"len",
"(",
"v",
")",
"==",
"1",
":",
"return",
"unwrap",
"(",
"v",
"[",
"0",
"]",
")",
"els... | LISTS WITH ZERO AND ONE element MAP TO None AND element RESPECTIVELY | [
"LISTS",
"WITH",
"ZERO",
"AND",
"ONE",
"element",
"MAP",
"TO",
"None",
"AND",
"element",
"RESPECTIVELY"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L571-L583 |
klahnakoski/pyLibrary | mo_dots/__init__.py | tuplewrap | def tuplewrap(value):
"""
INTENDED TO TURN lists INTO tuples FOR USE AS KEYS
"""
if isinstance(value, (list, set, tuple) + generator_types):
return tuple(tuplewrap(v) if is_sequence(v) else v for v in value)
return unwrap(value), | python | def tuplewrap(value):
"""
INTENDED TO TURN lists INTO tuples FOR USE AS KEYS
"""
if isinstance(value, (list, set, tuple) + generator_types):
return tuple(tuplewrap(v) if is_sequence(v) else v for v in value)
return unwrap(value), | [
"def",
"tuplewrap",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"set",
",",
"tuple",
")",
"+",
"generator_types",
")",
":",
"return",
"tuple",
"(",
"tuplewrap",
"(",
"v",
")",
"if",
"is_sequence",
"(",
"v",
")",
... | INTENDED TO TURN lists INTO tuples FOR USE AS KEYS | [
"INTENDED",
"TO",
"TURN",
"lists",
"INTO",
"tuples",
"FOR",
"USE",
"AS",
"KEYS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/__init__.py#L586-L592 |
cathalgarvey/deadlock | deadlock/passwords/zxcvbn/scripts/build_keyboard_adjacency_graph.py | get_slanted_adjacent_coords | def get_slanted_adjacent_coords(x, y):
'''
returns the six adjacent coordinates on a standard keyboard, where each row is slanted to the right from the last.
adjacencies are clockwise, starting with key to the left, then two keys above, then right key, then two keys below.
(that is, only near-diagonal k... | python | def get_slanted_adjacent_coords(x, y):
'''
returns the six adjacent coordinates on a standard keyboard, where each row is slanted to the right from the last.
adjacencies are clockwise, starting with key to the left, then two keys above, then right key, then two keys below.
(that is, only near-diagonal k... | [
"def",
"get_slanted_adjacent_coords",
"(",
"x",
",",
"y",
")",
":",
"return",
"[",
"(",
"x",
"-",
"1",
",",
"y",
")",
",",
"(",
"x",
",",
"y",
"-",
"1",
")",
",",
"(",
"x",
"+",
"1",
",",
"y",
"-",
"1",
")",
",",
"(",
"x",
"+",
"1",
","... | returns the six adjacent coordinates on a standard keyboard, where each row is slanted to the right from the last.
adjacencies are clockwise, starting with key to the left, then two keys above, then right key, then two keys below.
(that is, only near-diagonal keys are adjacent, so g's coordinate is adjacent to ... | [
"returns",
"the",
"six",
"adjacent",
"coordinates",
"on",
"a",
"standard",
"keyboard",
"where",
"each",
"row",
"is",
"slanted",
"to",
"the",
"right",
"from",
"the",
"last",
".",
"adjacencies",
"are",
"clockwise",
"starting",
"with",
"key",
"to",
"the",
"left... | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/passwords/zxcvbn/scripts/build_keyboard_adjacency_graph.py#L38-L44 |
cathalgarvey/deadlock | deadlock/passwords/zxcvbn/scripts/build_keyboard_adjacency_graph.py | get_aligned_adjacent_coords | def get_aligned_adjacent_coords(x, y):
'''
returns the nine clockwise adjacent coordinates on a keypad, where each row is vertically aligned.
'''
return [(x-1, y), (x-1, y-1), (x, y-1), (x+1, y-1), (x+1, y), (x+1, y+1), (x, y+1), (x-1, y+1)] | python | def get_aligned_adjacent_coords(x, y):
'''
returns the nine clockwise adjacent coordinates on a keypad, where each row is vertically aligned.
'''
return [(x-1, y), (x-1, y-1), (x, y-1), (x+1, y-1), (x+1, y), (x+1, y+1), (x, y+1), (x-1, y+1)] | [
"def",
"get_aligned_adjacent_coords",
"(",
"x",
",",
"y",
")",
":",
"return",
"[",
"(",
"x",
"-",
"1",
",",
"y",
")",
",",
"(",
"x",
"-",
"1",
",",
"y",
"-",
"1",
")",
",",
"(",
"x",
",",
"y",
"-",
"1",
")",
",",
"(",
"x",
"+",
"1",
","... | returns the nine clockwise adjacent coordinates on a keypad, where each row is vertically aligned. | [
"returns",
"the",
"nine",
"clockwise",
"adjacent",
"coordinates",
"on",
"a",
"keypad",
"where",
"each",
"row",
"is",
"vertically",
"aligned",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/passwords/zxcvbn/scripts/build_keyboard_adjacency_graph.py#L46-L50 |
cathalgarvey/deadlock | deadlock/passwords/zxcvbn/scripts/build_keyboard_adjacency_graph.py | build_graph | def build_graph(layout_str, slanted):
'''
builds an adjacency graph as a dictionary: {character: [adjacent_characters]}.
adjacent characters occur in a clockwise order.
for example:
* on qwerty layout, 'g' maps to ['fF', 'tT', 'yY', 'hH', 'bB', 'vV']
* on keypad layout, '7' maps to [None, None, ... | python | def build_graph(layout_str, slanted):
'''
builds an adjacency graph as a dictionary: {character: [adjacent_characters]}.
adjacent characters occur in a clockwise order.
for example:
* on qwerty layout, 'g' maps to ['fF', 'tT', 'yY', 'hH', 'bB', 'vV']
* on keypad layout, '7' maps to [None, None, ... | [
"def",
"build_graph",
"(",
"layout_str",
",",
"slanted",
")",
":",
"position_table",
"=",
"{",
"}",
"# maps from tuple (x,y) -> characters at that position.",
"tokens",
"=",
"layout_str",
".",
"split",
"(",
")",
"token_size",
"=",
"len",
"(",
"tokens",
"[",
"0",
... | builds an adjacency graph as a dictionary: {character: [adjacent_characters]}.
adjacent characters occur in a clockwise order.
for example:
* on qwerty layout, 'g' maps to ['fF', 'tT', 'yY', 'hH', 'bB', 'vV']
* on keypad layout, '7' maps to [None, None, None, '=', '8', '5', '4', None] | [
"builds",
"an",
"adjacency",
"graph",
"as",
"a",
"dictionary",
":",
"{",
"character",
":",
"[",
"adjacent_characters",
"]",
"}",
".",
"adjacent",
"characters",
"occur",
"in",
"a",
"clockwise",
"order",
".",
"for",
"example",
":",
"*",
"on",
"qwerty",
"layo... | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/passwords/zxcvbn/scripts/build_keyboard_adjacency_graph.py#L52-L81 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/examples/calage_bdf_cn.py | calcul_ratios_calage | def calcul_ratios_calage(year_data, year_calage, data_bdf, data_cn):
'''
Fonction qui calcule les ratios de calage (bdf sur cn pour année de données) et de vieillissement
à partir des masses de comptabilité nationale et des masses de consommation de bdf.
'''
masses = data_cn.merge(
data_bdf,... | python | def calcul_ratios_calage(year_data, year_calage, data_bdf, data_cn):
'''
Fonction qui calcule les ratios de calage (bdf sur cn pour année de données) et de vieillissement
à partir des masses de comptabilité nationale et des masses de consommation de bdf.
'''
masses = data_cn.merge(
data_bdf,... | [
"def",
"calcul_ratios_calage",
"(",
"year_data",
",",
"year_calage",
",",
"data_bdf",
",",
"data_cn",
")",
":",
"masses",
"=",
"data_cn",
".",
"merge",
"(",
"data_bdf",
",",
"left_index",
"=",
"True",
",",
"right_index",
"=",
"True",
")",
"masses",
".",
"r... | Fonction qui calcule les ratios de calage (bdf sur cn pour année de données) et de vieillissement
à partir des masses de comptabilité nationale et des masses de consommation de bdf. | [
"Fonction",
"qui",
"calcule",
"les",
"ratios",
"de",
"calage",
"(",
"bdf",
"sur",
"cn",
"pour",
"année",
"de",
"données",
")",
"et",
"de",
"vieillissement",
"à",
"partir",
"des",
"masses",
"de",
"comptabilité",
"nationale",
"et",
"des",
"masses",
"de",
"co... | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/examples/calage_bdf_cn.py#L91-L110 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/examples/calage_bdf_cn.py | get_bdf_data_frames | def get_bdf_data_frames(depenses, year_data = None):
assert year_data is not None
'''
Récupère les dépenses de budget des familles et les agrège par poste
(en tenant compte des poids respectifs des ménages)
'''
depenses_by_grosposte = pandas.DataFrame()
for grosposte in range(1, 13):
... | python | def get_bdf_data_frames(depenses, year_data = None):
assert year_data is not None
'''
Récupère les dépenses de budget des familles et les agrège par poste
(en tenant compte des poids respectifs des ménages)
'''
depenses_by_grosposte = pandas.DataFrame()
for grosposte in range(1, 13):
... | [
"def",
"get_bdf_data_frames",
"(",
"depenses",
",",
"year_data",
"=",
"None",
")",
":",
"assert",
"year_data",
"is",
"not",
"None",
"depenses_by_grosposte",
"=",
"pandas",
".",
"DataFrame",
"(",
")",
"for",
"grosposte",
"in",
"range",
"(",
"1",
",",
"13",
... | Récupère les dépenses de budget des familles et les agrège par poste
(en tenant compte des poids respectifs des ménages) | [
"Récupère",
"les",
"dépenses",
"de",
"budget",
"des",
"familles",
"et",
"les",
"agrège",
"par",
"poste",
"(",
"en",
"tenant",
"compte",
"des",
"poids",
"respectifs",
"des",
"ménages",
")"
] | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/examples/calage_bdf_cn.py#L113-L141 |
CSIRO-enviro-informatics/pyldapi | pyldapi/helpers.py | _make_rofr_rdf | def _make_rofr_rdf(app, api_home_dir, api_uri):
"""
The setup function that creates the Register of Registers.
Do not call from outside setup
:param app: the Flask app containing this LDAPI
:type app: Flask app
:param api_uri: URI base of the API
:type api_uri: string
:return: none
... | python | def _make_rofr_rdf(app, api_home_dir, api_uri):
"""
The setup function that creates the Register of Registers.
Do not call from outside setup
:param app: the Flask app containing this LDAPI
:type app: Flask app
:param api_uri: URI base of the API
:type api_uri: string
:return: none
... | [
"def",
"_make_rofr_rdf",
"(",
"app",
",",
"api_home_dir",
",",
"api_uri",
")",
":",
"from",
"time",
"import",
"sleep",
"from",
"pyldapi",
"import",
"RegisterRenderer",
",",
"RegisterOfRegistersRenderer",
"try",
":",
"os",
".",
"remove",
"(",
"os",
".",
"path",... | The setup function that creates the Register of Registers.
Do not call from outside setup
:param app: the Flask app containing this LDAPI
:type app: Flask app
:param api_uri: URI base of the API
:type api_uri: string
:return: none
:rtype: None | [
"The",
"setup",
"function",
"that",
"creates",
"the",
"Register",
"of",
"Registers",
"."
] | train | https://github.com/CSIRO-enviro-informatics/pyldapi/blob/117ed61d2dcd58730f9ad7fefcbe49b5ddf138e0/pyldapi/helpers.py#L26-L87 |
CSIRO-enviro-informatics/pyldapi | pyldapi/helpers.py | get_filtered_register_graph | def get_filtered_register_graph(register_uri, g):
"""
Gets a filtered version (label, comment, contained item classes & subregisters only) of the each register for the
Register of Registers
:param register_uri: the public URI of the register
:type register_uri: string
:param g: the rdf graph to... | python | def get_filtered_register_graph(register_uri, g):
"""
Gets a filtered version (label, comment, contained item classes & subregisters only) of the each register for the
Register of Registers
:param register_uri: the public URI of the register
:type register_uri: string
:param g: the rdf graph to... | [
"def",
"get_filtered_register_graph",
"(",
"register_uri",
",",
"g",
")",
":",
"import",
"requests",
"from",
"pyldapi",
".",
"exceptions",
"import",
"ViewsFormatsException",
"assert",
"isinstance",
"(",
"g",
",",
"Graph",
")",
"logging",
".",
"debug",
"(",
"'ass... | Gets a filtered version (label, comment, contained item classes & subregisters only) of the each register for the
Register of Registers
:param register_uri: the public URI of the register
:type register_uri: string
:param g: the rdf graph to append registers to
:type g: Graph
:return: True if o... | [
"Gets",
"a",
"filtered",
"version",
"(",
"label",
"comment",
"contained",
"item",
"classes",
"&",
"subregisters",
"only",
")",
"of",
"the",
"each",
"register",
"for",
"the",
"Register",
"of",
"Registers"
] | train | https://github.com/CSIRO-enviro-informatics/pyldapi/blob/117ed61d2dcd58730f9ad7fefcbe49b5ddf138e0/pyldapi/helpers.py#L128-L152 |
ff0000/scarlet | scarlet/cache/admin.py | clear_cache_delete_selected | def clear_cache_delete_selected(modeladmin, request, queryset):
"""
A delete action that will invalidate cache after being called.
"""
result = delete_selected(modeladmin, request, queryset)
# A result of None means that the delete happened.
if not result and hasattr(modeladmin, 'invalidate_cac... | python | def clear_cache_delete_selected(modeladmin, request, queryset):
"""
A delete action that will invalidate cache after being called.
"""
result = delete_selected(modeladmin, request, queryset)
# A result of None means that the delete happened.
if not result and hasattr(modeladmin, 'invalidate_cac... | [
"def",
"clear_cache_delete_selected",
"(",
"modeladmin",
",",
"request",
",",
"queryset",
")",
":",
"result",
"=",
"delete_selected",
"(",
"modeladmin",
",",
"request",
",",
"queryset",
")",
"# A result of None means that the delete happened.",
"if",
"not",
"result",
... | A delete action that will invalidate cache after being called. | [
"A",
"delete",
"action",
"that",
"will",
"invalidate",
"cache",
"after",
"being",
"called",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/admin.py#L12-L22 |
ff0000/scarlet | scarlet/cache/admin.py | ModelAdmin.invalidate_cache | def invalidate_cache(self, obj=None, queryset=None,
extra=None, force_all=False):
"""
Method that should be called by all tiggers to invalidate the
cache for an item(s).
Should be overriden by inheriting classes to customize behavior.
"""
if sel... | python | def invalidate_cache(self, obj=None, queryset=None,
extra=None, force_all=False):
"""
Method that should be called by all tiggers to invalidate the
cache for an item(s).
Should be overriden by inheriting classes to customize behavior.
"""
if sel... | [
"def",
"invalidate_cache",
"(",
"self",
",",
"obj",
"=",
"None",
",",
"queryset",
"=",
"None",
",",
"extra",
"=",
"None",
",",
"force_all",
"=",
"False",
")",
":",
"if",
"self",
".",
"cache_manager",
":",
"if",
"queryset",
"!=",
"None",
":",
"force_all... | Method that should be called by all tiggers to invalidate the
cache for an item(s).
Should be overriden by inheriting classes to customize behavior. | [
"Method",
"that",
"should",
"be",
"called",
"by",
"all",
"tiggers",
"to",
"invalidate",
"the",
"cache",
"for",
"an",
"item",
"(",
"s",
")",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/admin.py#L49-L64 |
camsci/meteor-pi | src/observatoryControl/gpsd/client.py | gpscommon.connect | def connect(self, host, port):
"""Connect to a host on a given port.
If the hostname ends with a colon (`:') followed by a number, and
there is no port specified, that suffix will be stripped off and the
number interpreted as the port number to use.
"""
if not port and (h... | python | def connect(self, host, port):
"""Connect to a host on a given port.
If the hostname ends with a colon (`:') followed by a number, and
there is no port specified, that suffix will be stripped off and the
number interpreted as the port number to use.
"""
if not port and (h... | [
"def",
"connect",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"if",
"not",
"port",
"and",
"(",
"host",
".",
"find",
"(",
"':'",
")",
"==",
"host",
".",
"rfind",
"(",
"':'",
")",
")",
":",
"i",
"=",
"host",
".",
"rfind",
"(",
"':'",
")",
... | Connect to a host on a given port.
If the hostname ends with a colon (`:') followed by a number, and
there is no port specified, that suffix will be stripped off and the
number interpreted as the port number to use. | [
"Connect",
"to",
"a",
"host",
"on",
"a",
"given",
"port",
".",
"If",
"the",
"hostname",
"ends",
"with",
"a",
"colon",
"(",
":",
")",
"followed",
"by",
"a",
"number",
"and",
"there",
"is",
"no",
"port",
"specified",
"that",
"suffix",
"will",
"be",
"st... | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/client.py#L27-L56 |
camsci/meteor-pi | src/observatoryControl/gpsd/client.py | gpscommon.waiting | def waiting(self, timeout=0):
"Return True if data is ready for the client."
if self.linebuffer:
return True
(winput, woutput, wexceptions) = select.select((self.sock,), (), (), timeout)
return winput != [] | python | def waiting(self, timeout=0):
"Return True if data is ready for the client."
if self.linebuffer:
return True
(winput, woutput, wexceptions) = select.select((self.sock,), (), (), timeout)
return winput != [] | [
"def",
"waiting",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"if",
"self",
".",
"linebuffer",
":",
"return",
"True",
"(",
"winput",
",",
"woutput",
",",
"wexceptions",
")",
"=",
"select",
".",
"select",
"(",
"(",
"self",
".",
"sock",
",",
")"... | Return True if data is ready for the client. | [
"Return",
"True",
"if",
"data",
"is",
"ready",
"for",
"the",
"client",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/client.py#L66-L71 |
camsci/meteor-pi | src/observatoryControl/gpsd/client.py | gpscommon.read | def read(self):
"Wait for and read data being streamed from the daemon."
if self.verbose > 1:
sys.stderr.write("poll: reading from daemon...\n")
eol = self.linebuffer.find('\n')
if eol == -1:
frag = self.sock.recv(4096)
self.linebuffer += frag
... | python | def read(self):
"Wait for and read data being streamed from the daemon."
if self.verbose > 1:
sys.stderr.write("poll: reading from daemon...\n")
eol = self.linebuffer.find('\n')
if eol == -1:
frag = self.sock.recv(4096)
self.linebuffer += frag
... | [
"def",
"read",
"(",
"self",
")",
":",
"if",
"self",
".",
"verbose",
">",
"1",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"poll: reading from daemon...\\n\"",
")",
"eol",
"=",
"self",
".",
"linebuffer",
".",
"find",
"(",
"'\\n'",
")",
"if",
"eol",
... | Wait for and read data being streamed from the daemon. | [
"Wait",
"for",
"and",
"read",
"data",
"being",
"streamed",
"from",
"the",
"daemon",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/client.py#L73-L110 |
camsci/meteor-pi | src/observatoryControl/gpsd/client.py | gpscommon.send | def send(self, commands):
"Ship commands to the daemon."
if not commands.endswith("\n"):
commands += "\n"
self.sock.send(commands) | python | def send(self, commands):
"Ship commands to the daemon."
if not commands.endswith("\n"):
commands += "\n"
self.sock.send(commands) | [
"def",
"send",
"(",
"self",
",",
"commands",
")",
":",
"if",
"not",
"commands",
".",
"endswith",
"(",
"\"\\n\"",
")",
":",
"commands",
"+=",
"\"\\n\"",
"self",
".",
"sock",
".",
"send",
"(",
"commands",
")"
] | Ship commands to the daemon. | [
"Ship",
"commands",
"to",
"the",
"daemon",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/client.py#L116-L120 |
camsci/meteor-pi | src/observatoryControl/gpsd/client.py | gpsjson.stream | def stream(self, flags=0, devpath=None):
"Control streaming reports from the daemon,"
if flags & WATCH_DISABLE:
arg = '?WATCH={"enable":false'
if flags & WATCH_JSON:
arg += ',"json":false'
if flags & WATCH_NMEA:
arg += ',"nmea":false'
... | python | def stream(self, flags=0, devpath=None):
"Control streaming reports from the daemon,"
if flags & WATCH_DISABLE:
arg = '?WATCH={"enable":false'
if flags & WATCH_JSON:
arg += ',"json":false'
if flags & WATCH_NMEA:
arg += ',"nmea":false'
... | [
"def",
"stream",
"(",
"self",
",",
"flags",
"=",
"0",
",",
"devpath",
"=",
"None",
")",
":",
"if",
"flags",
"&",
"WATCH_DISABLE",
":",
"arg",
"=",
"'?WATCH={\"enable\":false'",
"if",
"flags",
"&",
"WATCH_JSON",
":",
"arg",
"+=",
"',\"json\":false'",
"if",
... | Control streaming reports from the daemon, | [
"Control",
"streaming",
"reports",
"from",
"the",
"daemon"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/client.py#L147-L179 |
ralphbean/raptorizemw | examples/tg2-raptorized/tg2raptorized/config/middleware.py | make_app | def make_app(global_conf, full_stack=True, **app_conf):
"""
Set tg2-raptorized up with the settings found in the PasteDeploy configuration
file used.
:param global_conf: The global settings for tg2-raptorized (those
defined under the ``[DEFAULT]`` section).
:type global_conf: dict
:... | python | def make_app(global_conf, full_stack=True, **app_conf):
"""
Set tg2-raptorized up with the settings found in the PasteDeploy configuration
file used.
:param global_conf: The global settings for tg2-raptorized (those
defined under the ``[DEFAULT]`` section).
:type global_conf: dict
:... | [
"def",
"make_app",
"(",
"global_conf",
",",
"full_stack",
"=",
"True",
",",
"*",
"*",
"app_conf",
")",
":",
"app",
"=",
"make_base_app",
"(",
"global_conf",
",",
"full_stack",
"=",
"True",
",",
"*",
"*",
"app_conf",
")",
"# Wrap your base TurboGears 2 applicat... | Set tg2-raptorized up with the settings found in the PasteDeploy configuration
file used.
:param global_conf: The global settings for tg2-raptorized (those
defined under the ``[DEFAULT]`` section).
:type global_conf: dict
:param full_stack: Should the whole TG2 stack be set up?
:type fu... | [
"Set",
"tg2",
"-",
"raptorized",
"up",
"with",
"the",
"settings",
"found",
"in",
"the",
"PasteDeploy",
"configuration",
"file",
"used",
".",
":",
"param",
"global_conf",
":",
"The",
"global",
"settings",
"for",
"tg2",
"-",
"raptorized",
"(",
"those",
"define... | train | https://github.com/ralphbean/raptorizemw/blob/aee001e1f17ee4b9ad27aac6dde21d8ff545144e/examples/tg2-raptorized/tg2raptorized/config/middleware.py#L16-L41 |
camsci/meteor-pi | src/observatoryControl/gpsd/misc.py | CalcRad | def CalcRad(lat):
"Radius of curvature in meters at specified latitude."
a = 6378.137
e2 = 0.081082 * 0.081082
# the radius of curvature of an ellipsoidal Earth in the plane of a
# meridian of latitude is given by
#
# R' = a * (1 - e^2) / (1 - e^2 * (sin(lat))^2)^(3/2)
#
# where a is... | python | def CalcRad(lat):
"Radius of curvature in meters at specified latitude."
a = 6378.137
e2 = 0.081082 * 0.081082
# the radius of curvature of an ellipsoidal Earth in the plane of a
# meridian of latitude is given by
#
# R' = a * (1 - e^2) / (1 - e^2 * (sin(lat))^2)^(3/2)
#
# where a is... | [
"def",
"CalcRad",
"(",
"lat",
")",
":",
"a",
"=",
"6378.137",
"e2",
"=",
"0.081082",
"*",
"0.081082",
"# the radius of curvature of an ellipsoidal Earth in the plane of a",
"# meridian of latitude is given by",
"#",
"# R' = a * (1 - e^2) / (1 - e^2 * (sin(lat))^2)^(3/2)",
"#",
... | Radius of curvature in meters at specified latitude. | [
"Radius",
"of",
"curvature",
"in",
"meters",
"at",
"specified",
"latitude",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/misc.py#L29-L52 |
camsci/meteor-pi | src/observatoryControl/gpsd/misc.py | EarthDistance | def EarthDistance((lat1, lon1), (lat2, lon2)):
"Distance in meters between two points specified in degrees."
x1 = CalcRad(lat1) * math.cos(Deg2Rad(lon1)) * math.sin(Deg2Rad(90-lat1))
x2 = CalcRad(lat2) * math.cos(Deg2Rad(lon2)) * math.sin(Deg2Rad(90-lat2))
y1 = CalcRad(lat1) * math.sin(Deg2Rad(lon1)) * ... | python | def EarthDistance((lat1, lon1), (lat2, lon2)):
"Distance in meters between two points specified in degrees."
x1 = CalcRad(lat1) * math.cos(Deg2Rad(lon1)) * math.sin(Deg2Rad(90-lat1))
x2 = CalcRad(lat2) * math.cos(Deg2Rad(lon2)) * math.sin(Deg2Rad(90-lat2))
y1 = CalcRad(lat1) * math.sin(Deg2Rad(lon1)) * ... | [
"def",
"EarthDistance",
"(",
"(",
"lat1",
",",
"lon1",
")",
",",
"(",
"lat2",
",",
"lon2",
")",
")",
":",
"x1",
"=",
"CalcRad",
"(",
"lat1",
")",
"*",
"math",
".",
"cos",
"(",
"Deg2Rad",
"(",
"lon1",
")",
")",
"*",
"math",
".",
"sin",
"(",
"D... | Distance in meters between two points specified in degrees. | [
"Distance",
"in",
"meters",
"between",
"two",
"points",
"specified",
"in",
"degrees",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/misc.py#L54-L69 |
camsci/meteor-pi | src/observatoryControl/gpsd/misc.py | MeterOffset | def MeterOffset((lat1, lon1), (lat2, lon2)):
"Return offset in meters of second arg from first."
dx = EarthDistance((lat1, lon1), (lat1, lon2))
dy = EarthDistance((lat1, lon1), (lat2, lon1))
if lat1 < lat2: dy *= -1
if lon1 < lon2: dx *= -1
return (dx, dy) | python | def MeterOffset((lat1, lon1), (lat2, lon2)):
"Return offset in meters of second arg from first."
dx = EarthDistance((lat1, lon1), (lat1, lon2))
dy = EarthDistance((lat1, lon1), (lat2, lon1))
if lat1 < lat2: dy *= -1
if lon1 < lon2: dx *= -1
return (dx, dy) | [
"def",
"MeterOffset",
"(",
"(",
"lat1",
",",
"lon1",
")",
",",
"(",
"lat2",
",",
"lon2",
")",
")",
":",
"dx",
"=",
"EarthDistance",
"(",
"(",
"lat1",
",",
"lon1",
")",
",",
"(",
"lat1",
",",
"lon2",
")",
")",
"dy",
"=",
"EarthDistance",
"(",
"(... | Return offset in meters of second arg from first. | [
"Return",
"offset",
"in",
"meters",
"of",
"second",
"arg",
"from",
"first",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/misc.py#L71-L77 |
camsci/meteor-pi | src/observatoryControl/gpsd/misc.py | isotime | def isotime(s):
"Convert timestamps in ISO8661 format to and from Unix time."
if type(s) == type(1):
return time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(s))
elif type(s) == type(1.0):
date = int(s)
msec = s - date
date = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(s))
... | python | def isotime(s):
"Convert timestamps in ISO8661 format to and from Unix time."
if type(s) == type(1):
return time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(s))
elif type(s) == type(1.0):
date = int(s)
msec = s - date
date = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(s))
... | [
"def",
"isotime",
"(",
"s",
")",
":",
"if",
"type",
"(",
"s",
")",
"==",
"type",
"(",
"1",
")",
":",
"return",
"time",
".",
"strftime",
"(",
"\"%Y-%m-%dT%H:%M:%S\"",
",",
"time",
".",
"gmtime",
"(",
"s",
")",
")",
"elif",
"type",
"(",
"s",
")",
... | Convert timestamps in ISO8661 format to and from Unix time. | [
"Convert",
"timestamps",
"in",
"ISO8661",
"format",
"to",
"and",
"from",
"Unix",
"time",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/misc.py#L79-L99 |
camsci/meteor-pi | src/pythonModules/meteorpi_server/meteorpi_server/__init__.py | MeteorApp.not_found | def not_found(entity_id=None, message='Entity not found'):
"""
Build a response to indicate that the requested entity was not found.
:param string message:
An optional message, defaults to 'Entity not found'
:param string entity_id:
An option ID of the entity req... | python | def not_found(entity_id=None, message='Entity not found'):
"""
Build a response to indicate that the requested entity was not found.
:param string message:
An optional message, defaults to 'Entity not found'
:param string entity_id:
An option ID of the entity req... | [
"def",
"not_found",
"(",
"entity_id",
"=",
"None",
",",
"message",
"=",
"'Entity not found'",
")",
":",
"resp",
"=",
"jsonify",
"(",
"{",
"'message'",
":",
"message",
",",
"'entity_id'",
":",
"entity_id",
"}",
")",
"resp",
".",
"status_code",
"=",
"404",
... | Build a response to indicate that the requested entity was not found.
:param string message:
An optional message, defaults to 'Entity not found'
:param string entity_id:
An option ID of the entity requested and which was not found
:return:
A flask Response ob... | [
"Build",
"a",
"response",
"to",
"indicate",
"that",
"the",
"requested",
"entity",
"was",
"not",
"found",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_server/meteorpi_server/__init__.py#L71-L84 |
camsci/meteor-pi | src/pythonModules/meteorpi_server/meteorpi_server/__init__.py | MeteorApp.requires_auth | def requires_auth(self, roles=None):
"""
Used to impose auth constraints on requests which require a logged in user with particular roles.
:param list[string] roles:
A list of :class:`string` representing roles the logged in user must have to perform this action. The user
... | python | def requires_auth(self, roles=None):
"""
Used to impose auth constraints on requests which require a logged in user with particular roles.
:param list[string] roles:
A list of :class:`string` representing roles the logged in user must have to perform this action. The user
... | [
"def",
"requires_auth",
"(",
"self",
",",
"roles",
"=",
"None",
")",
":",
"def",
"requires_auth_inner",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"auth",
"=",
"request"... | Used to impose auth constraints on requests which require a logged in user with particular roles.
:param list[string] roles:
A list of :class:`string` representing roles the logged in user must have to perform this action. The user
and password are passed in each request in the authoriz... | [
"Used",
"to",
"impose",
"auth",
"constraints",
"on",
"requests",
"which",
"require",
"a",
"logged",
"in",
"user",
"with",
"particular",
"roles",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_server/meteorpi_server/__init__.py#L104-L144 |
msikma/kanaconv | kanaconv/utils.py | switch_charset | def switch_charset(characters, target=''):
'''
Transforms an iterable of kana characters to its opposite script.
For example, it can turn [u'あ', u'い'] into [u'ア', u'イ'],
or {u'ホ': u'ボ} into {u'ほ': u'ぼ'}.
There are no safety checks--keep in mind that the correct source and target
values must be ... | python | def switch_charset(characters, target=''):
'''
Transforms an iterable of kana characters to its opposite script.
For example, it can turn [u'あ', u'い'] into [u'ア', u'イ'],
or {u'ホ': u'ボ} into {u'ほ': u'ぼ'}.
There are no safety checks--keep in mind that the correct source and target
values must be ... | [
"def",
"switch_charset",
"(",
"characters",
",",
"target",
"=",
"''",
")",
":",
"if",
"isinstance",
"(",
"characters",
",",
"dict",
")",
":",
"return",
"_switch_charset_dict",
"(",
"characters",
",",
"target",
")",
"else",
":",
"return",
"_switch_charset_list"... | Transforms an iterable of kana characters to its opposite script.
For example, it can turn [u'あ', u'い'] into [u'ア', u'イ'],
or {u'ホ': u'ボ} into {u'ほ': u'ぼ'}.
There are no safety checks--keep in mind that the correct source and target
values must be set, otherwise the resulting characters will be garbled... | [
"Transforms",
"an",
"iterable",
"of",
"kana",
"characters",
"to",
"its",
"opposite",
"script",
".",
"For",
"example",
"it",
"can",
"turn",
"[",
"u",
"あ",
"u",
"い",
"]",
"into",
"[",
"u",
"ア",
"u",
"イ",
"]",
"or",
"{",
"u",
"ホ",
":",
"u",
"ボ",
"... | train | https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/utils.py#L43-L55 |
msikma/kanaconv | kanaconv/utils.py | _switch_charset_dict | def _switch_charset_dict(characters, target=''):
'''
Switches the character set of the key/value pairs in a dictionary.
'''
offset_characters = {}
offset = block_offset * offsets[target]['direction']
for char in characters:
offset_key = chr(ord(char) + offset)
offset_value = chr(... | python | def _switch_charset_dict(characters, target=''):
'''
Switches the character set of the key/value pairs in a dictionary.
'''
offset_characters = {}
offset = block_offset * offsets[target]['direction']
for char in characters:
offset_key = chr(ord(char) + offset)
offset_value = chr(... | [
"def",
"_switch_charset_dict",
"(",
"characters",
",",
"target",
"=",
"''",
")",
":",
"offset_characters",
"=",
"{",
"}",
"offset",
"=",
"block_offset",
"*",
"offsets",
"[",
"target",
"]",
"[",
"'direction'",
"]",
"for",
"char",
"in",
"characters",
":",
"o... | Switches the character set of the key/value pairs in a dictionary. | [
"Switches",
"the",
"character",
"set",
"of",
"the",
"key",
"/",
"value",
"pairs",
"in",
"a",
"dictionary",
"."
] | train | https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/utils.py#L58-L69 |
msikma/kanaconv | kanaconv/utils.py | _switch_charset_list | def _switch_charset_list(characters, target=''):
'''
Switches the character set of a list. If a character does not have
an equivalent in the target script (e.g. ヹ when converting to hiragana),
the original character is kept.
'''
# Copy the list to avoid modifying the existing one.
characters... | python | def _switch_charset_list(characters, target=''):
'''
Switches the character set of a list. If a character does not have
an equivalent in the target script (e.g. ヹ when converting to hiragana),
the original character is kept.
'''
# Copy the list to avoid modifying the existing one.
characters... | [
"def",
"_switch_charset_list",
"(",
"characters",
",",
"target",
"=",
"''",
")",
":",
"# Copy the list to avoid modifying the existing one.",
"characters",
"=",
"characters",
"[",
":",
"]",
"offset",
"=",
"block_offset",
"*",
"offsets",
"[",
"target",
"]",
"[",
"'... | Switches the character set of a list. If a character does not have
an equivalent in the target script (e.g. ヹ when converting to hiragana),
the original character is kept. | [
"Switches",
"the",
"character",
"set",
"of",
"a",
"list",
".",
"If",
"a",
"character",
"does",
"not",
"have",
"an",
"equivalent",
"in",
"the",
"target",
"script",
"(",
"e",
".",
"g",
".",
"ヹ",
"when",
"converting",
"to",
"hiragana",
")",
"the",
"origin... | train | https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/utils.py#L72-L95 |
msikma/kanaconv | kanaconv/utils.py | kana_romaji_lt | def kana_romaji_lt(romaji, *kana):
'''
Generates a lookup table with the kana characters on the left side
and their rōmaji equivalents as the values.
For the consonant-vowel (cv) characters, we'll generate:
{u'か': ('ka', 'k', 'k', 'ā'),
u'が': ('ga', 'g', 'g', 'ā'),
[...]
Mu... | python | def kana_romaji_lt(romaji, *kana):
'''
Generates a lookup table with the kana characters on the left side
and their rōmaji equivalents as the values.
For the consonant-vowel (cv) characters, we'll generate:
{u'か': ('ka', 'k', 'k', 'ā'),
u'が': ('ga', 'g', 'g', 'ā'),
[...]
Mu... | [
"def",
"kana_romaji_lt",
"(",
"romaji",
",",
"*",
"kana",
")",
":",
"lt",
"=",
"{",
"}",
"for",
"kana_set",
"in",
"kana",
":",
"for",
"n",
"in",
"range",
"(",
"len",
"(",
"romaji",
")",
")",
":",
"ro",
"=",
"romaji",
"[",
"n",
"]",
"ka",
"=",
... | Generates a lookup table with the kana characters on the left side
and their rōmaji equivalents as the values.
For the consonant-vowel (cv) characters, we'll generate:
{u'か': ('ka', 'k', 'k', 'ā'),
u'が': ('ga', 'g', 'g', 'ā'),
[...]
Multiple kana character sets can be passed as res... | [
"Generates",
"a",
"lookup",
"table",
"with",
"the",
"kana",
"characters",
"on",
"the",
"left",
"side",
"and",
"their",
"rōmaji",
"equivalents",
"as",
"the",
"values",
"."
] | train | https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/utils.py#L112-L132 |
msikma/kanaconv | kanaconv/utils.py | fw_romaji_lt | def fw_romaji_lt(full, regular):
'''
Generates a lookup table with the fullwidth rōmaji characters
on the left side, and the regular rōmaji characters as the values.
'''
lt = {}
for n in range(len(full)):
fw = full[n]
reg = regular[n]
lt[fw] = reg
return lt | python | def fw_romaji_lt(full, regular):
'''
Generates a lookup table with the fullwidth rōmaji characters
on the left side, and the regular rōmaji characters as the values.
'''
lt = {}
for n in range(len(full)):
fw = full[n]
reg = regular[n]
lt[fw] = reg
return lt | [
"def",
"fw_romaji_lt",
"(",
"full",
",",
"regular",
")",
":",
"lt",
"=",
"{",
"}",
"for",
"n",
"in",
"range",
"(",
"len",
"(",
"full",
")",
")",
":",
"fw",
"=",
"full",
"[",
"n",
"]",
"reg",
"=",
"regular",
"[",
"n",
"]",
"lt",
"[",
"fw",
"... | Generates a lookup table with the fullwidth rōmaji characters
on the left side, and the regular rōmaji characters as the values. | [
"Generates",
"a",
"lookup",
"table",
"with",
"the",
"fullwidth",
"rōmaji",
"characters",
"on",
"the",
"left",
"side",
"and",
"the",
"regular",
"rōmaji",
"characters",
"as",
"the",
"values",
"."
] | train | https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/utils.py#L135-L146 |
ff0000/scarlet | scarlet/cache/views.py | CacheMixin.get_cache_prefix | def get_cache_prefix(self, prefix=''):
"""
Hook for any extra data you would like
to prepend to your cache key.
The default implementation ensures that ajax not non
ajax requests are cached separately. This can easily
be extended to differentiate on other criteria
... | python | def get_cache_prefix(self, prefix=''):
"""
Hook for any extra data you would like
to prepend to your cache key.
The default implementation ensures that ajax not non
ajax requests are cached separately. This can easily
be extended to differentiate on other criteria
... | [
"def",
"get_cache_prefix",
"(",
"self",
",",
"prefix",
"=",
"''",
")",
":",
"if",
"settings",
".",
"CACHE_MIDDLEWARE_KEY_PREFIX",
":",
"prefix",
"+=",
"settings",
".",
"CACHE_MIDDLEWARE_KEY_PREFIX",
"if",
"self",
".",
"request",
".",
"is_ajax",
"(",
")",
":",
... | Hook for any extra data you would like
to prepend to your cache key.
The default implementation ensures that ajax not non
ajax requests are cached separately. This can easily
be extended to differentiate on other criteria
like mobile os' for example. | [
"Hook",
"for",
"any",
"extra",
"data",
"you",
"would",
"like",
"to",
"prepend",
"to",
"your",
"cache",
"key",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/views.py#L61-L78 |
ff0000/scarlet | scarlet/cache/views.py | CacheMixin.get_vary_headers | def get_vary_headers(self, request, response):
"""
Hook for patching the vary header
"""
headers = []
accessed = False
try:
accessed = request.session.accessed
except AttributeError:
pass
if accessed:
headers.append("C... | python | def get_vary_headers(self, request, response):
"""
Hook for patching the vary header
"""
headers = []
accessed = False
try:
accessed = request.session.accessed
except AttributeError:
pass
if accessed:
headers.append("C... | [
"def",
"get_vary_headers",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"headers",
"=",
"[",
"]",
"accessed",
"=",
"False",
"try",
":",
"accessed",
"=",
"request",
".",
"session",
".",
"accessed",
"except",
"AttributeError",
":",
"pass",
"if",
... | Hook for patching the vary header | [
"Hook",
"for",
"patching",
"the",
"vary",
"header"
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/views.py#L80-L94 |
ff0000/scarlet | scarlet/cache/views.py | CacheView.get_as_string | def get_as_string(self, request, *args, **kwargs):
"""
Should only be used when inheriting from cms View.
Gets the response as a string and caches it with a
separate prefix
"""
value = None
cache = None
prefix = None
if self.should_cache():
... | python | def get_as_string(self, request, *args, **kwargs):
"""
Should only be used when inheriting from cms View.
Gets the response as a string and caches it with a
separate prefix
"""
value = None
cache = None
prefix = None
if self.should_cache():
... | [
"def",
"get_as_string",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"value",
"=",
"None",
"cache",
"=",
"None",
"prefix",
"=",
"None",
"if",
"self",
".",
"should_cache",
"(",
")",
":",
"prefix",
"=",
"\"%s:%s:str... | Should only be used when inheriting from cms View.
Gets the response as a string and caches it with a
separate prefix | [
"Should",
"only",
"be",
"used",
"when",
"inheriting",
"from",
"cms",
"View",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/views.py#L153-L177 |
ff0000/scarlet | scarlet/cache/views.py | CacheView.dispatch | def dispatch(self, request, *args, **kwargs):
"""
Overrides Django's default dispatch to provide caching.
If the should_cache method returns True, this will call
two functions get_cache_version and get_cache_prefix
the results of those two functions are combined and passed to
... | python | def dispatch(self, request, *args, **kwargs):
"""
Overrides Django's default dispatch to provide caching.
If the should_cache method returns True, this will call
two functions get_cache_version and get_cache_prefix
the results of those two functions are combined and passed to
... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"request",
"=",
"request",
"self",
".",
"args",
"=",
"args",
"self",
".",
"kwargs",
"=",
"kwargs",
"self",
".",
"cache_middleware",
"=",... | Overrides Django's default dispatch to provide caching.
If the should_cache method returns True, this will call
two functions get_cache_version and get_cache_prefix
the results of those two functions are combined and passed to
the standard django caching middleware. | [
"Overrides",
"Django",
"s",
"default",
"dispatch",
"to",
"provide",
"caching",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/views.py#L179-L211 |
ff0000/scarlet | scarlet/assets/crops.py | scale_and_crop | def scale_and_crop(im, crop_spec):
"""
Scale and Crop.
"""
im = im.crop((crop_spec.x, crop_spec.y, crop_spec.x2, crop_spec.y2))
if crop_spec.width and crop_spec.height:
im = im.resize((crop_spec.width, crop_spec.height),
resample=Image.ANTIALIAS)
return im | python | def scale_and_crop(im, crop_spec):
"""
Scale and Crop.
"""
im = im.crop((crop_spec.x, crop_spec.y, crop_spec.x2, crop_spec.y2))
if crop_spec.width and crop_spec.height:
im = im.resize((crop_spec.width, crop_spec.height),
resample=Image.ANTIALIAS)
return im | [
"def",
"scale_and_crop",
"(",
"im",
",",
"crop_spec",
")",
":",
"im",
"=",
"im",
".",
"crop",
"(",
"(",
"crop_spec",
".",
"x",
",",
"crop_spec",
".",
"y",
",",
"crop_spec",
".",
"x2",
",",
"crop_spec",
".",
"y2",
")",
")",
"if",
"crop_spec",
".",
... | Scale and Crop. | [
"Scale",
"and",
"Crop",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/crops.py#L223-L233 |
ff0000/scarlet | scarlet/assets/crops.py | CropConfig.get_crop_spec | def get_crop_spec(self, im, x=None, x2=None, y=None, y2=None):
"""
Returns the default crop points for this image.
"""
w, h = [float(v) for v in im.size]
upscale = self.upscale
if x is not None and x2 and y is not None and y2:
upscale = True
w = fl... | python | def get_crop_spec(self, im, x=None, x2=None, y=None, y2=None):
"""
Returns the default crop points for this image.
"""
w, h = [float(v) for v in im.size]
upscale = self.upscale
if x is not None and x2 and y is not None and y2:
upscale = True
w = fl... | [
"def",
"get_crop_spec",
"(",
"self",
",",
"im",
",",
"x",
"=",
"None",
",",
"x2",
"=",
"None",
",",
"y",
"=",
"None",
",",
"y2",
"=",
"None",
")",
":",
"w",
",",
"h",
"=",
"[",
"float",
"(",
"v",
")",
"for",
"v",
"in",
"im",
".",
"size",
... | Returns the default crop points for this image. | [
"Returns",
"the",
"default",
"crop",
"points",
"for",
"this",
"image",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/crops.py#L46-L94 |
ff0000/scarlet | scarlet/assets/crops.py | Cropper.create_crop | def create_crop(self, name, file_obj,
x=None, x2=None, y=None, y2=None):
"""
Generate Version for an Image.
value has to be a serverpath relative to MEDIA_ROOT.
Returns the spec for the crop that was created.
"""
if name not in self._registry:
... | python | def create_crop(self, name, file_obj,
x=None, x2=None, y=None, y2=None):
"""
Generate Version for an Image.
value has to be a serverpath relative to MEDIA_ROOT.
Returns the spec for the crop that was created.
"""
if name not in self._registry:
... | [
"def",
"create_crop",
"(",
"self",
",",
"name",
",",
"file_obj",
",",
"x",
"=",
"None",
",",
"x2",
"=",
"None",
",",
"y",
"=",
"None",
",",
"y2",
"=",
"None",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_registry",
":",
"return",
"file_obj... | Generate Version for an Image.
value has to be a serverpath relative to MEDIA_ROOT.
Returns the spec for the crop that was created. | [
"Generate",
"Version",
"for",
"an",
"Image",
".",
"value",
"has",
"to",
"be",
"a",
"serverpath",
"relative",
"to",
"MEDIA_ROOT",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/crops.py#L158-L185 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/build_survey_data/step_1_2_imputations_loyers_proprietaires.py | build_imputation_loyers_proprietaires | def build_imputation_loyers_proprietaires(temporary_store = None, year = None):
"""Build menage consumption by categorie fiscale dataframe """
assert temporary_store is not None
assert year is not None
# Load data
bdf_survey_collection = SurveyCollection.load(collection = 'budget_des_familles',
... | python | def build_imputation_loyers_proprietaires(temporary_store = None, year = None):
"""Build menage consumption by categorie fiscale dataframe """
assert temporary_store is not None
assert year is not None
# Load data
bdf_survey_collection = SurveyCollection.load(collection = 'budget_des_familles',
... | [
"def",
"build_imputation_loyers_proprietaires",
"(",
"temporary_store",
"=",
"None",
",",
"year",
"=",
"None",
")",
":",
"assert",
"temporary_store",
"is",
"not",
"None",
"assert",
"year",
"is",
"not",
"None",
"# Load data",
"bdf_survey_collection",
"=",
"SurveyColl... | Build menage consumption by categorie fiscale dataframe | [
"Build",
"menage",
"consumption",
"by",
"categorie",
"fiscale",
"dataframe"
] | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/build_survey_data/step_1_2_imputations_loyers_proprietaires.py#L50-L178 |
commonwealth-of-puerto-rico/libre | libre/apps/data_drivers/models.py | Source.get_functions_map | def get_functions_map(self):
"""Calculate the column name to data type conversion map"""
return dict([(column, DATA_TYPE_FUNCTIONS[data_type]) for column, data_type in self.columns.values_list('name', 'data_type')]) | python | def get_functions_map(self):
"""Calculate the column name to data type conversion map"""
return dict([(column, DATA_TYPE_FUNCTIONS[data_type]) for column, data_type in self.columns.values_list('name', 'data_type')]) | [
"def",
"get_functions_map",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"column",
",",
"DATA_TYPE_FUNCTIONS",
"[",
"data_type",
"]",
")",
"for",
"column",
",",
"data_type",
"in",
"self",
".",
"columns",
".",
"values_list",
"(",
"'name'",
",",
... | Calculate the column name to data type conversion map | [
"Calculate",
"the",
"column",
"name",
"to",
"data",
"type",
"conversion",
"map"
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/data_drivers/models.py#L226-L228 |
commonwealth-of-puerto-rico/libre | libre/apps/data_drivers/models.py | SourceSpreadsheet._convert_value | def _convert_value(self, item):
"""
Handle different value types for XLS. Item is a cell object.
"""
# Types:
# 0 = empty u''
# 1 = unicode text
# 2 = float (convert to int if possible, then convert to string)
# 3 = date (convert to unambiguous date/time s... | python | def _convert_value(self, item):
"""
Handle different value types for XLS. Item is a cell object.
"""
# Types:
# 0 = empty u''
# 1 = unicode text
# 2 = float (convert to int if possible, then convert to string)
# 3 = date (convert to unambiguous date/time s... | [
"def",
"_convert_value",
"(",
"self",
",",
"item",
")",
":",
"# Types:",
"# 0 = empty u''",
"# 1 = unicode text",
"# 2 = float (convert to int if possible, then convert to string)",
"# 3 = date (convert to unambiguous date/time string)",
"# 4 = boolean (convert to string \"0\" or \"1\")",
... | Handle different value types for XLS. Item is a cell object. | [
"Handle",
"different",
"value",
"types",
"for",
"XLS",
".",
"Item",
"is",
"a",
"cell",
"object",
"."
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/data_drivers/models.py#L341-L369 |
camsci/meteor-pi | src/observatoryControl/gpsd/gps.py | gps.read | def read(self):
"Read and interpret data from the daemon."
status = gpscommon.read(self)
if status <= 0:
return status
if self.response.startswith("{") and self.response.endswith("}\r\n"):
self.unpack(self.response)
self.__oldstyle_shim()
s... | python | def read(self):
"Read and interpret data from the daemon."
status = gpscommon.read(self)
if status <= 0:
return status
if self.response.startswith("{") and self.response.endswith("}\r\n"):
self.unpack(self.response)
self.__oldstyle_shim()
s... | [
"def",
"read",
"(",
"self",
")",
":",
"status",
"=",
"gpscommon",
".",
"read",
"(",
"self",
")",
"if",
"status",
"<=",
"0",
":",
"return",
"status",
"if",
"self",
".",
"response",
".",
"startswith",
"(",
"\"{\"",
")",
"and",
"self",
".",
"response",
... | Read and interpret data from the daemon. | [
"Read",
"and",
"interpret",
"data",
"from",
"the",
"daemon",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/gps.py#L296-L309 |
camsci/meteor-pi | src/observatoryControl/gpsd/gps.py | gps.stream | def stream(self, flags=0, devpath=None):
"Ask gpsd to stream reports at your client."
if (flags & (WATCH_JSON|WATCH_OLDSTYLE|WATCH_NMEA|WATCH_RAW)) == 0:
flags |= WATCH_JSON
if flags & WATCH_DISABLE:
if flags & WATCH_OLDSTYLE:
arg = "w-"
if... | python | def stream(self, flags=0, devpath=None):
"Ask gpsd to stream reports at your client."
if (flags & (WATCH_JSON|WATCH_OLDSTYLE|WATCH_NMEA|WATCH_RAW)) == 0:
flags |= WATCH_JSON
if flags & WATCH_DISABLE:
if flags & WATCH_OLDSTYLE:
arg = "w-"
if... | [
"def",
"stream",
"(",
"self",
",",
"flags",
"=",
"0",
",",
"devpath",
"=",
"None",
")",
":",
"if",
"(",
"flags",
"&",
"(",
"WATCH_JSON",
"|",
"WATCH_OLDSTYLE",
"|",
"WATCH_NMEA",
"|",
"WATCH_RAW",
")",
")",
"==",
"0",
":",
"flags",
"|=",
"WATCH_JSON"... | Ask gpsd to stream reports at your client. | [
"Ask",
"gpsd",
"to",
"stream",
"reports",
"at",
"your",
"client",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/gps.py#L319-L338 |
d0ugal/retrace | src/retrace.py | retry | def retry(*dargs, **dkwargs):
"""
The retry decorator. Can be passed all the arguments that are accepted by
Retry.__init__.
"""
# support both @retry and @retry() as valid syntax
if len(dargs) == 1 and callable(dargs[0]):
def wrap_simple(f):
@_wraps(f)
def wrappe... | python | def retry(*dargs, **dkwargs):
"""
The retry decorator. Can be passed all the arguments that are accepted by
Retry.__init__.
"""
# support both @retry and @retry() as valid syntax
if len(dargs) == 1 and callable(dargs[0]):
def wrap_simple(f):
@_wraps(f)
def wrappe... | [
"def",
"retry",
"(",
"*",
"dargs",
",",
"*",
"*",
"dkwargs",
")",
":",
"# support both @retry and @retry() as valid syntax",
"if",
"len",
"(",
"dargs",
")",
"==",
"1",
"and",
"callable",
"(",
"dargs",
"[",
"0",
"]",
")",
":",
"def",
"wrap_simple",
"(",
"... | The retry decorator. Can be passed all the arguments that are accepted by
Retry.__init__. | [
"The",
"retry",
"decorator",
".",
"Can",
"be",
"passed",
"all",
"the",
"arguments",
"that",
"are",
"accepted",
"by",
"Retry",
".",
"__init__",
"."
] | train | https://github.com/d0ugal/retrace/blob/eb3eb30c0c4eeefe20babc06c6b23d43d42fd990/src/retrace.py#L181-L207 |
kedpter/secret_miner | src/secret_miner/cli.py | main | def main():
"""miner running secretly on cpu or gpu"""
# if no arg, run secret miner
if (len(sys.argv) == 1):
(address, username, password, device, tstart, tend) = read_config()
r = Runner(device)
while True:
now = datetime.datetime.now()
start = get_time_by... | python | def main():
"""miner running secretly on cpu or gpu"""
# if no arg, run secret miner
if (len(sys.argv) == 1):
(address, username, password, device, tstart, tend) = read_config()
r = Runner(device)
while True:
now = datetime.datetime.now()
start = get_time_by... | [
"def",
"main",
"(",
")",
":",
"# if no arg, run secret miner",
"if",
"(",
"len",
"(",
"sys",
".",
"argv",
")",
"==",
"1",
")",
":",
"(",
"address",
",",
"username",
",",
"password",
",",
"device",
",",
"tstart",
",",
"tend",
")",
"=",
"read_config",
... | miner running secretly on cpu or gpu | [
"miner",
"running",
"secretly",
"on",
"cpu",
"or",
"gpu"
] | train | https://github.com/kedpter/secret_miner/blob/3b4ebe58e11fb688d7e8928ebaa2871fc43717e4/src/secret_miner/cli.py#L287-L323 |
kedpter/secret_miner | src/secret_miner/cli.py | Runner.run_miner_if_free | def run_miner_if_free(self):
"""TODO: docstring"""
(address, username, password, device, tstart, tend) = read_config()
if self.dtype == 0:
self.run_miner_cmd = [
cpu_miner_path, '-o', address, '-O', '{}:{}'.format(
username, password)
... | python | def run_miner_if_free(self):
"""TODO: docstring"""
(address, username, password, device, tstart, tend) = read_config()
if self.dtype == 0:
self.run_miner_cmd = [
cpu_miner_path, '-o', address, '-O', '{}:{}'.format(
username, password)
... | [
"def",
"run_miner_if_free",
"(",
"self",
")",
":",
"(",
"address",
",",
"username",
",",
"password",
",",
"device",
",",
"tstart",
",",
"tend",
")",
"=",
"read_config",
"(",
")",
"if",
"self",
".",
"dtype",
"==",
"0",
":",
"self",
".",
"run_miner_cmd",... | TODO: docstring | [
"TODO",
":",
"docstring"
] | train | https://github.com/kedpter/secret_miner/blob/3b4ebe58e11fb688d7e8928ebaa2871fc43717e4/src/secret_miner/cli.py#L160-L186 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/generators.py | first_from_generator | def first_from_generator(generator):
"""Pull the first value from a generator and return it, closing the generator
:param generator:
A generator, this will be mapped onto a list and the first item extracted.
:return:
None if there are no items, or the first item otherwise.
:internal:
... | python | def first_from_generator(generator):
"""Pull the first value from a generator and return it, closing the generator
:param generator:
A generator, this will be mapped onto a list and the first item extracted.
:return:
None if there are no items, or the first item otherwise.
:internal:
... | [
"def",
"first_from_generator",
"(",
"generator",
")",
":",
"try",
":",
"result",
"=",
"next",
"(",
"generator",
")",
"except",
"StopIteration",
":",
"result",
"=",
"None",
"finally",
":",
"generator",
".",
"close",
"(",
")",
"return",
"result"
] | Pull the first value from a generator and return it, closing the generator
:param generator:
A generator, this will be mapped onto a list and the first item extracted.
:return:
None if there are no items, or the first item otherwise.
:internal: | [
"Pull",
"the",
"first",
"value",
"from",
"a",
"generator",
"and",
"return",
"it",
"closing",
"the",
"generator"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/generators.py#L28-L43 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/generators.py | MeteorDatabaseGenerators.file_generator | def file_generator(self, sql, sql_args):
"""Generator for FileRecord
:param sql:
A SQL statement which must return rows describing files.
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A generator which produc... | python | def file_generator(self, sql, sql_args):
"""Generator for FileRecord
:param sql:
A SQL statement which must return rows describing files.
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A generator which produc... | [
"def",
"file_generator",
"(",
"self",
",",
"sql",
",",
"sql_args",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"sql",
",",
"sql_args",
")",
"results",
"=",
"self",
".",
"con",
".",
"fetchall",
"(",
")",
"output",
"=",
"[",
"]",
"for",
"resul... | Generator for FileRecord
:param sql:
A SQL statement which must return rows describing files.
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A generator which produces FileRecord instances from the supplied SQL, closi... | [
"Generator",
"for",
"FileRecord"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/generators.py#L72-L108 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/generators.py | MeteorDatabaseGenerators.observation_generator | def observation_generator(self, sql, sql_args):
"""Generator for Observation
:param sql:
A SQL statement which must return rows describing observations
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A generato... | python | def observation_generator(self, sql, sql_args):
"""Generator for Observation
:param sql:
A SQL statement which must return rows describing observations
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A generato... | [
"def",
"observation_generator",
"(",
"self",
",",
"sql",
",",
"sql_args",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"sql",
",",
"sql_args",
")",
"results",
"=",
"self",
".",
"con",
".",
"fetchall",
"(",
")",
"output",
"=",
"[",
"]",
"for",
... | Generator for Observation
:param sql:
A SQL statement which must return rows describing observations
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A generator which produces Event instances from the supplied SQL, clo... | [
"Generator",
"for",
"Observation"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/generators.py#L110-L153 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/generators.py | MeteorDatabaseGenerators.obsgroup_generator | def obsgroup_generator(self, sql, sql_args):
"""Generator for ObservationGroup
:param sql:
A SQL statement which must return rows describing observation groups
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A ... | python | def obsgroup_generator(self, sql, sql_args):
"""Generator for ObservationGroup
:param sql:
A SQL statement which must return rows describing observation groups
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A ... | [
"def",
"obsgroup_generator",
"(",
"self",
",",
"sql",
",",
"sql_args",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"sql",
",",
"sql_args",
")",
"results",
"=",
"self",
".",
"con",
".",
"fetchall",
"(",
")",
"output",
"=",
"[",
"]",
"for",
"r... | Generator for ObservationGroup
:param sql:
A SQL statement which must return rows describing observation groups
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A generator which produces Event instances from the suppli... | [
"Generator",
"for",
"ObservationGroup"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/generators.py#L155-L198 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/generators.py | MeteorDatabaseGenerators.obstory_metadata_generator | def obstory_metadata_generator(self, sql, sql_args):
"""
Generator for :class:`meteorpi_model.CameraStatus`
:param sql:
A SQL statement which must return rows describing obstory metadata
:param sql_args:
Any arguments required to populate the query provided in 's... | python | def obstory_metadata_generator(self, sql, sql_args):
"""
Generator for :class:`meteorpi_model.CameraStatus`
:param sql:
A SQL statement which must return rows describing obstory metadata
:param sql_args:
Any arguments required to populate the query provided in 's... | [
"def",
"obstory_metadata_generator",
"(",
"self",
",",
"sql",
",",
"sql_args",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"sql",
",",
"sql_args",
")",
"results",
"=",
"self",
".",
"con",
".",
"fetchall",
"(",
")",
"output",
"=",
"[",
"]",
"fo... | Generator for :class:`meteorpi_model.CameraStatus`
:param sql:
A SQL statement which must return rows describing obstory metadata
:param sql_args:
Any arguments required to populate the query provided in 'sql'
:return:
A generator which produces :class:`meteo... | [
"Generator",
"for",
":",
"class",
":",
"meteorpi_model",
".",
"CameraStatus"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/generators.py#L200-L230 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/generators.py | MeteorDatabaseGenerators.export_configuration_generator | def export_configuration_generator(self, sql, sql_args):
"""
Generator for :class:`meteorpi_model.ExportConfiguration`
:param sql:
A SQL statement which must return rows describing export configurations
:param sql_args:
Any variables required to populate the quer... | python | def export_configuration_generator(self, sql, sql_args):
"""
Generator for :class:`meteorpi_model.ExportConfiguration`
:param sql:
A SQL statement which must return rows describing export configurations
:param sql_args:
Any variables required to populate the quer... | [
"def",
"export_configuration_generator",
"(",
"self",
",",
"sql",
",",
"sql_args",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"sql",
",",
"sql_args",
")",
"results",
"=",
"self",
".",
"con",
".",
"fetchall",
"(",
")",
"output",
"=",
"[",
"]",
... | Generator for :class:`meteorpi_model.ExportConfiguration`
:param sql:
A SQL statement which must return rows describing export configurations
:param sql_args:
Any variables required to populate the query provided in 'sql'
:return:
A generator which produces :... | [
"Generator",
"for",
":",
"class",
":",
"meteorpi_model",
".",
"ExportConfiguration"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/generators.py#L232-L261 |
dacker-team/pyred | pyred/send.py | send_to_redshift | def send_to_redshift(
instance,
data,
replace=True,
batch_size=1000,
types=None,
primary_key=(),
create_boolean=False):
"""
data = {
"table_name" : 'name_of_the_redshift_schema' + '.' + 'name_of_the_redshift_table' #Must already exist,
"co... | python | def send_to_redshift(
instance,
data,
replace=True,
batch_size=1000,
types=None,
primary_key=(),
create_boolean=False):
"""
data = {
"table_name" : 'name_of_the_redshift_schema' + '.' + 'name_of_the_redshift_table' #Must already exist,
"co... | [
"def",
"send_to_redshift",
"(",
"instance",
",",
"data",
",",
"replace",
"=",
"True",
",",
"batch_size",
"=",
"1000",
",",
"types",
"=",
"None",
",",
"primary_key",
"=",
"(",
")",
",",
"create_boolean",
"=",
"False",
")",
":",
"connection_kwargs",
"=",
"... | data = {
"table_name" : 'name_of_the_redshift_schema' + '.' + 'name_of_the_redshift_table' #Must already exist,
"columns_name" : [first_column_name,second_column_name,...,last_column_name],
"rows" : [[first_raw_value,second_raw_value,...,last_raw_value],...]
} | [
"data",
"=",
"{",
"table_name",
":",
"name_of_the_redshift_schema",
"+",
".",
"+",
"name_of_the_redshift_table",
"#Must",
"already",
"exist",
"columns_name",
":",
"[",
"first_column_name",
"second_column_name",
"...",
"last_column_name",
"]",
"rows",
":",
"[[",
"first... | train | https://github.com/dacker-team/pyred/blob/ef842f2fcea51b1619b3bf0ad8a1a09b77c18863/pyred/send.py#L11-L109 |
delfick/nose-of-yeti | noseOfYeti/tokeniser/containers.py | acceptable | def acceptable(value, capitalize=False):
"""Convert a string into something that can be used as a valid python variable name"""
name = regexes['punctuation'].sub("", regexes['joins'].sub("_", value))
# Clean up irregularities in underscores.
name = regexes['repeated_underscore'].sub("_", name.strip('_')... | python | def acceptable(value, capitalize=False):
"""Convert a string into something that can be used as a valid python variable name"""
name = regexes['punctuation'].sub("", regexes['joins'].sub("_", value))
# Clean up irregularities in underscores.
name = regexes['repeated_underscore'].sub("_", name.strip('_')... | [
"def",
"acceptable",
"(",
"value",
",",
"capitalize",
"=",
"False",
")",
":",
"name",
"=",
"regexes",
"[",
"'punctuation'",
"]",
".",
"sub",
"(",
"\"\"",
",",
"regexes",
"[",
"'joins'",
"]",
".",
"sub",
"(",
"\"_\"",
",",
"value",
")",
")",
"# Clean ... | Convert a string into something that can be used as a valid python variable name | [
"Convert",
"a",
"string",
"into",
"something",
"that",
"can",
"be",
"used",
"as",
"a",
"valid",
"python",
"variable",
"name"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/containers.py#L10-L25 |
delfick/nose-of-yeti | noseOfYeti/tokeniser/containers.py | Group.kls_name | def kls_name(self):
"""Determine python name for group"""
# Determine kls for group
if not self.parent or not self.parent.name:
return 'Test{0}'.format(self.name)
else:
use = self.parent.kls_name
if use.startswith('Test'):
use = use[4:]... | python | def kls_name(self):
"""Determine python name for group"""
# Determine kls for group
if not self.parent or not self.parent.name:
return 'Test{0}'.format(self.name)
else:
use = self.parent.kls_name
if use.startswith('Test'):
use = use[4:]... | [
"def",
"kls_name",
"(",
"self",
")",
":",
"# Determine kls for group",
"if",
"not",
"self",
".",
"parent",
"or",
"not",
"self",
".",
"parent",
".",
"name",
":",
"return",
"'Test{0}'",
".",
"format",
"(",
"self",
".",
"name",
")",
"else",
":",
"use",
"=... | Determine python name for group | [
"Determine",
"python",
"name",
"for",
"group"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/containers.py#L143-L153 |
delfick/nose-of-yeti | noseOfYeti/tokeniser/containers.py | Group.super_kls | def super_kls(self):
"""
Determine what kls this group inherits from
If default kls should be used, then None is returned
"""
if not self.kls and self.parent and self.parent.name:
return self.parent.kls_name
return self.kls | python | def super_kls(self):
"""
Determine what kls this group inherits from
If default kls should be used, then None is returned
"""
if not self.kls and self.parent and self.parent.name:
return self.parent.kls_name
return self.kls | [
"def",
"super_kls",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"kls",
"and",
"self",
".",
"parent",
"and",
"self",
".",
"parent",
".",
"name",
":",
"return",
"self",
".",
"parent",
".",
"kls_name",
"return",
"self",
".",
"kls"
] | Determine what kls this group inherits from
If default kls should be used, then None is returned | [
"Determine",
"what",
"kls",
"this",
"group",
"inherits",
"from",
"If",
"default",
"kls",
"should",
"be",
"used",
"then",
"None",
"is",
"returned"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/containers.py#L156-L163 |
delfick/nose-of-yeti | noseOfYeti/tokeniser/containers.py | Group.start_group | def start_group(self, scol, typ):
"""Start a new group"""
return Group(parent=self, level=scol, typ=typ) | python | def start_group(self, scol, typ):
"""Start a new group"""
return Group(parent=self, level=scol, typ=typ) | [
"def",
"start_group",
"(",
"self",
",",
"scol",
",",
"typ",
")",
":",
"return",
"Group",
"(",
"parent",
"=",
"self",
",",
"level",
"=",
"scol",
",",
"typ",
"=",
"typ",
")"
] | Start a new group | [
"Start",
"a",
"new",
"group"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/containers.py#L165-L167 |
delfick/nose-of-yeti | noseOfYeti/tokeniser/containers.py | Group.start_single | def start_single(self, typ, scol):
"""Start a new single"""
self.starting_single = True
single = self.single = Single(typ=typ, group=self, indent=(scol - self.level))
self.singles.append(single)
return single | python | def start_single(self, typ, scol):
"""Start a new single"""
self.starting_single = True
single = self.single = Single(typ=typ, group=self, indent=(scol - self.level))
self.singles.append(single)
return single | [
"def",
"start_single",
"(",
"self",
",",
"typ",
",",
"scol",
")",
":",
"self",
".",
"starting_single",
"=",
"True",
"single",
"=",
"self",
".",
"single",
"=",
"Single",
"(",
"typ",
"=",
"typ",
",",
"group",
"=",
"self",
",",
"indent",
"=",
"(",
"sc... | Start a new single | [
"Start",
"a",
"new",
"single"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/containers.py#L169-L174 |
delfick/nose-of-yeti | noseOfYeti/tokeniser/containers.py | Group.modify_kls | def modify_kls(self, name):
"""Add a part to what will end up being the kls' superclass"""
if self.kls is None:
self.kls = name
else:
self.kls += name | python | def modify_kls(self, name):
"""Add a part to what will end up being the kls' superclass"""
if self.kls is None:
self.kls = name
else:
self.kls += name | [
"def",
"modify_kls",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"kls",
"is",
"None",
":",
"self",
".",
"kls",
"=",
"name",
"else",
":",
"self",
".",
"kls",
"+=",
"name"
] | Add a part to what will end up being the kls' superclass | [
"Add",
"a",
"part",
"to",
"what",
"will",
"end",
"up",
"being",
"the",
"kls",
"superclass"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/containers.py#L181-L186 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm.get_field_list | def get_field_list(self):
"""
Retrieve list of all fields currently configured
"""
list_out = []
for field in self.fields:
list_out.append(field)
return list_out | python | def get_field_list(self):
"""
Retrieve list of all fields currently configured
"""
list_out = []
for field in self.fields:
list_out.append(field)
return list_out | [
"def",
"get_field_list",
"(",
"self",
")",
":",
"list_out",
"=",
"[",
"]",
"for",
"field",
"in",
"self",
".",
"fields",
":",
"list_out",
".",
"append",
"(",
"field",
")",
"return",
"list_out"
] | Retrieve list of all fields currently configured | [
"Retrieve",
"list",
"of",
"all",
"fields",
"currently",
"configured"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L86-L95 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm.data_lookup_method | def data_lookup_method(fields_list, mongo_db_obj, hist, record,
lookup_type):
"""
Method to lookup the replacement value given a single input value from
the same field.
:param dict fields_list: Fields configurations
:param MongoClient mongo_db_obj: Mon... | python | def data_lookup_method(fields_list, mongo_db_obj, hist, record,
lookup_type):
"""
Method to lookup the replacement value given a single input value from
the same field.
:param dict fields_list: Fields configurations
:param MongoClient mongo_db_obj: Mon... | [
"def",
"data_lookup_method",
"(",
"fields_list",
",",
"mongo_db_obj",
",",
"hist",
",",
"record",
",",
"lookup_type",
")",
":",
"if",
"hist",
"is",
"None",
":",
"hist",
"=",
"{",
"}",
"for",
"field",
"in",
"record",
":",
"if",
"record",
"[",
"field",
"... | Method to lookup the replacement value given a single input value from
the same field.
:param dict fields_list: Fields configurations
:param MongoClient mongo_db_obj: MongoDB collection object
:param dict hist: existing input of history values object
:param dict record: values t... | [
"Method",
"to",
"lookup",
"the",
"replacement",
"value",
"given",
"a",
"single",
"input",
"value",
"from",
"the",
"same",
"field",
"."
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L98-L131 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm.data_regex_method | def data_regex_method(fields_list, mongo_db_obj, hist, record, lookup_type):
"""
Method to lookup the replacement value based on regular expressions.
:param dict fields_list: Fields configurations
:param MongoClient mongo_db_obj: MongoDB collection object
:param dict hist: exist... | python | def data_regex_method(fields_list, mongo_db_obj, hist, record, lookup_type):
"""
Method to lookup the replacement value based on regular expressions.
:param dict fields_list: Fields configurations
:param MongoClient mongo_db_obj: MongoDB collection object
:param dict hist: exist... | [
"def",
"data_regex_method",
"(",
"fields_list",
",",
"mongo_db_obj",
",",
"hist",
",",
"record",
",",
"lookup_type",
")",
":",
"if",
"hist",
"is",
"None",
":",
"hist",
"=",
"{",
"}",
"for",
"field",
"in",
"record",
":",
"if",
"record",
"[",
"field",
"]... | Method to lookup the replacement value based on regular expressions.
:param dict fields_list: Fields configurations
:param MongoClient mongo_db_obj: MongoDB collection object
:param dict hist: existing input of history values object
:param dict record: values to validate
:param ... | [
"Method",
"to",
"lookup",
"the",
"replacement",
"value",
"based",
"on",
"regular",
"expressions",
"."
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L134-L165 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm._val_fs_regex | def _val_fs_regex(self, record, hist=None):
"""
Perform field-specific validation regex
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
"""
record, hist = self.data_regex_method(fields_list=self.fields,
... | python | def _val_fs_regex(self, record, hist=None):
"""
Perform field-specific validation regex
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
"""
record, hist = self.data_regex_method(fields_list=self.fields,
... | [
"def",
"_val_fs_regex",
"(",
"self",
",",
"record",
",",
"hist",
"=",
"None",
")",
":",
"record",
",",
"hist",
"=",
"self",
".",
"data_regex_method",
"(",
"fields_list",
"=",
"self",
".",
"fields",
",",
"mongo_db_obj",
"=",
"self",
".",
"mongo",
",",
"... | Perform field-specific validation regex
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values | [
"Perform",
"field",
"-",
"specific",
"validation",
"regex"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L214-L227 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm._norm_lookup | def _norm_lookup(self, record, hist=None):
"""
Perform generic validation lookup
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
"""
record, hist = self.data_lookup_method(fields_list=self.fields,
... | python | def _norm_lookup(self, record, hist=None):
"""
Perform generic validation lookup
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
"""
record, hist = self.data_lookup_method(fields_list=self.fields,
... | [
"def",
"_norm_lookup",
"(",
"self",
",",
"record",
",",
"hist",
"=",
"None",
")",
":",
"record",
",",
"hist",
"=",
"self",
".",
"data_lookup_method",
"(",
"fields_list",
"=",
"self",
".",
"fields",
",",
"mongo_db_obj",
"=",
"self",
".",
"mongo",
",",
"... | Perform generic validation lookup
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values | [
"Perform",
"generic",
"validation",
"lookup"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L229-L242 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm._norm_include | def _norm_include(self, record, hist=None):
"""
Normalization 'normIncludes' replace 'almost' values based on at least
one of the following: includes strings, excludes strings, starts with
string, ends with string
:param dict record: dictionary of values to validate
:par... | python | def _norm_include(self, record, hist=None):
"""
Normalization 'normIncludes' replace 'almost' values based on at least
one of the following: includes strings, excludes strings, starts with
string, ends with string
:param dict record: dictionary of values to validate
:par... | [
"def",
"_norm_include",
"(",
"self",
",",
"record",
",",
"hist",
"=",
"None",
")",
":",
"if",
"hist",
"is",
"None",
":",
"hist",
"=",
"{",
"}",
"for",
"field",
"in",
"record",
":",
"if",
"record",
"[",
"field",
"]",
"!=",
"''",
"and",
"record",
"... | Normalization 'normIncludes' replace 'almost' values based on at least
one of the following: includes strings, excludes strings, starts with
string, ends with string
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values | [
"Normalization",
"normIncludes",
"replace",
"almost",
"values",
"based",
"on",
"at",
"least",
"one",
"of",
"the",
"following",
":",
"includes",
"strings",
"excludes",
"strings",
"starts",
"with",
"string",
"ends",
"with",
"string"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L259-L289 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm._derive | def _derive(self, record, hist=None):
"""
Derivation filters like 'deriveValue' to replace given input values
from one or more fields. In case 'copyValue' copy value to the target
field from given an input value from one field. 'deriveRegex' replace
given an input value from one ... | python | def _derive(self, record, hist=None):
"""
Derivation filters like 'deriveValue' to replace given input values
from one or more fields. In case 'copyValue' copy value to the target
field from given an input value from one field. 'deriveRegex' replace
given an input value from one ... | [
"def",
"_derive",
"(",
"self",
",",
"record",
",",
"hist",
"=",
"None",
")",
":",
"def",
"check_derive_options",
"(",
"option",
",",
"derive_set_config",
")",
":",
"\"\"\"\n Check derive option is exist into options list and return relevant\n flag.\n ... | Derivation filters like 'deriveValue' to replace given input values
from one or more fields. In case 'copyValue' copy value to the target
field from given an input value from one field. 'deriveRegex' replace
given an input value from one field, derive target field value using
regular exp... | [
"Derivation",
"filters",
"like",
"deriveValue",
"to",
"replace",
"given",
"input",
"values",
"from",
"one",
"or",
"more",
"fields",
".",
"In",
"case",
"copyValue",
"copy",
"value",
"to",
"the",
"target",
"field",
"from",
"given",
"an",
"input",
"value",
"fro... | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L291-L425 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm._apply_udfs | def _apply_udfs(self, record, hist, udf_type):
"""
Excute user define processes, user-defined functionalty is designed to
applyies custome trasformations to data.
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
"""
... | python | def _apply_udfs(self, record, hist, udf_type):
"""
Excute user define processes, user-defined functionalty is designed to
applyies custome trasformations to data.
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
"""
... | [
"def",
"_apply_udfs",
"(",
"self",
",",
"record",
",",
"hist",
",",
"udf_type",
")",
":",
"def",
"function_executor",
"(",
"func",
",",
"*",
"args",
")",
":",
"\"\"\"\n Execute user define function\n :param python method func: Function obj\n ... | Excute user define processes, user-defined functionalty is designed to
applyies custome trasformations to data.
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values | [
"Excute",
"user",
"define",
"processes",
"user",
"-",
"defined",
"functionalty",
"is",
"designed",
"to",
"applyies",
"custome",
"trasformations",
"to",
"data",
"."
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L427-L463 |
rh-marketingops/dwm | dwm/dwmmain.py | Dwm.run | def run(self, record, hist=None):
"""
By passing the input record to be cleaned, and returns the input record
after cleaning with history(dictionary).
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
:return:
... | python | def run(self, record, hist=None):
"""
By passing the input record to be cleaned, and returns the input record
after cleaning with history(dictionary).
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
:return:
... | [
"def",
"run",
"(",
"self",
",",
"record",
",",
"hist",
"=",
"None",
")",
":",
"if",
"hist",
"is",
"None",
":",
"hist",
"=",
"{",
"}",
"if",
"record",
":",
"# Run user-defined functions for beforeGenericValLookup",
"record",
",",
"hist",
"=",
"self",
".",
... | By passing the input record to be cleaned, and returns the input record
after cleaning with history(dictionary).
:param dict record: dictionary of values to validate
:param dict hist: existing input of history values
:return: | [
"By",
"passing",
"the",
"input",
"record",
"to",
"be",
"cleaned",
"and",
"returns",
"the",
"input",
"record",
"after",
"cleaning",
"with",
"history",
"(",
"dictionary",
")",
"."
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/dwmmain.py#L465-L550 |
rafaelsierra/django-json-mixin-form | src/sierra/dj/mixins/forms.py | JSONFormMixin._get_field_error_dict | def _get_field_error_dict(self, field):
'''Returns the dict containing the field errors information'''
return {
'name': field.html_name,
'id': 'id_{}'.format(field.html_name), # This may be a problem
'errors': field.errors,
} | python | def _get_field_error_dict(self, field):
'''Returns the dict containing the field errors information'''
return {
'name': field.html_name,
'id': 'id_{}'.format(field.html_name), # This may be a problem
'errors': field.errors,
} | [
"def",
"_get_field_error_dict",
"(",
"self",
",",
"field",
")",
":",
"return",
"{",
"'name'",
":",
"field",
".",
"html_name",
",",
"'id'",
":",
"'id_{}'",
".",
"format",
"(",
"field",
".",
"html_name",
")",
",",
"# This may be a problem",
"'errors'",
":",
... | Returns the dict containing the field errors information | [
"Returns",
"the",
"dict",
"containing",
"the",
"field",
"errors",
"information"
] | train | https://github.com/rafaelsierra/django-json-mixin-form/blob/004149a1077eba8c072ebbfb6eb6b86a57564ecf/src/sierra/dj/mixins/forms.py#L52-L58 |
rafaelsierra/django-json-mixin-form | src/sierra/dj/mixins/forms.py | JSONFormMixin.get_hidden_fields_errors | def get_hidden_fields_errors(self, form):
'''Returns a dict to add in response when something is wrong with hidden fields'''
if not self.include_hidden_fields or form.is_valid():
return {}
response = {self.hidden_field_error_key:{}}
for field in form.hidden_fields():
... | python | def get_hidden_fields_errors(self, form):
'''Returns a dict to add in response when something is wrong with hidden fields'''
if not self.include_hidden_fields or form.is_valid():
return {}
response = {self.hidden_field_error_key:{}}
for field in form.hidden_fields():
... | [
"def",
"get_hidden_fields_errors",
"(",
"self",
",",
"form",
")",
":",
"if",
"not",
"self",
".",
"include_hidden_fields",
"or",
"form",
".",
"is_valid",
"(",
")",
":",
"return",
"{",
"}",
"response",
"=",
"{",
"self",
".",
"hidden_field_error_key",
":",
"{... | Returns a dict to add in response when something is wrong with hidden fields | [
"Returns",
"a",
"dict",
"to",
"add",
"in",
"response",
"when",
"something",
"is",
"wrong",
"with",
"hidden",
"fields"
] | train | https://github.com/rafaelsierra/django-json-mixin-form/blob/004149a1077eba8c072ebbfb6eb6b86a57564ecf/src/sierra/dj/mixins/forms.py#L61-L71 |
rafaelsierra/django-json-mixin-form | src/sierra/dj/mixins/forms.py | JSONFormMixin.form_invalid | def form_invalid(self, form):
'''Builds the JSON for the errors'''
response = {self.errors_key: {}}
response[self.non_field_errors_key] = form.non_field_errors()
response.update(self.get_hidden_fields_errors(form))
for field in form.visible_fields():
if field.errors:... | python | def form_invalid(self, form):
'''Builds the JSON for the errors'''
response = {self.errors_key: {}}
response[self.non_field_errors_key] = form.non_field_errors()
response.update(self.get_hidden_fields_errors(form))
for field in form.visible_fields():
if field.errors:... | [
"def",
"form_invalid",
"(",
"self",
",",
"form",
")",
":",
"response",
"=",
"{",
"self",
".",
"errors_key",
":",
"{",
"}",
"}",
"response",
"[",
"self",
".",
"non_field_errors_key",
"]",
"=",
"form",
".",
"non_field_errors",
"(",
")",
"response",
".",
... | Builds the JSON for the errors | [
"Builds",
"the",
"JSON",
"for",
"the",
"errors"
] | train | https://github.com/rafaelsierra/django-json-mixin-form/blob/004149a1077eba8c072ebbfb6eb6b86a57564ecf/src/sierra/dj/mixins/forms.py#L84-L97 |
inveniosoftware/invenio-collections | invenio_collections/alembic/97faa437d867_create_collections_tables.py | upgrade | def upgrade():
"""Upgrade database."""
op.create_table(
'collection',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('dbquery', sa.Text(), nullable=True),
sa.Column('rgt', sa.Integer(), nullable=False),
... | python | def upgrade():
"""Upgrade database."""
op.create_table(
'collection',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('dbquery', sa.Text(), nullable=True),
sa.Column('rgt', sa.Integer(), nullable=False),
... | [
"def",
"upgrade",
"(",
")",
":",
"op",
".",
"create_table",
"(",
"'collection'",
",",
"sa",
".",
"Column",
"(",
"'id'",
",",
"sa",
".",
"Integer",
"(",
")",
",",
"nullable",
"=",
"False",
")",
",",
"sa",
".",
"Column",
"(",
"'name'",
",",
"sa",
"... | Upgrade database. | [
"Upgrade",
"database",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/alembic/97faa437d867_create_collections_tables.py#L36-L60 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_env | def do_env(self, line):
"""
env {environment-name}
"""
if not line:
print "use: env {environment-name}"
else:
if not set_environment(line):
print "no configuration for environment %s" % line
else:
self.do_login('... | python | def do_env(self, line):
"""
env {environment-name}
"""
if not line:
print "use: env {environment-name}"
else:
if not set_environment(line):
print "no configuration for environment %s" % line
else:
self.do_login('... | [
"def",
"do_env",
"(",
"self",
",",
"line",
")",
":",
"if",
"not",
"line",
":",
"print",
"\"use: env {environment-name}\"",
"else",
":",
"if",
"not",
"set_environment",
"(",
"line",
")",
":",
"print",
"\"no configuration for environment %s\"",
"%",
"line",
"else"... | env {environment-name} | [
"env",
"{",
"environment",
"-",
"name",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L262-L272 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_schema | def do_schema(self, line):
"""
schema
schema --clear
schema filed_name field_type
"""
args = self.getargs(line)
if not args:
for k in sorted(self.schema):
print "%s\t%s" % (k, self.schema[k])
elif args[0] == "--clear":
... | python | def do_schema(self, line):
"""
schema
schema --clear
schema filed_name field_type
"""
args = self.getargs(line)
if not args:
for k in sorted(self.schema):
print "%s\t%s" % (k, self.schema[k])
elif args[0] == "--clear":
... | [
"def",
"do_schema",
"(",
"self",
",",
"line",
")",
":",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"if",
"not",
"args",
":",
"for",
"k",
"in",
"sorted",
"(",
"self",
".",
"schema",
")",
":",
"print",
"\"%s\\t%s\"",
"%",
"(",
"k",
",",... | schema
schema --clear
schema filed_name field_type | [
"schema"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L274-L296 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_login | def do_login(self, line):
"login aws-acces-key aws-secret"
if line:
args = self.getargs(line)
self.conn = boto.connect_dynamodb(
aws_access_key_id=args[0],
aws_secret_access_key=args[1])
else:
self.conn = boto.connect_dynamodb(... | python | def do_login(self, line):
"login aws-acces-key aws-secret"
if line:
args = self.getargs(line)
self.conn = boto.connect_dynamodb(
aws_access_key_id=args[0],
aws_secret_access_key=args[1])
else:
self.conn = boto.connect_dynamodb(... | [
"def",
"do_login",
"(",
"self",
",",
"line",
")",
":",
"if",
"line",
":",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"self",
".",
"conn",
"=",
"boto",
".",
"connect_dynamodb",
"(",
"aws_access_key_id",
"=",
"args",
"[",
"0",
"]",
",",
"... | login aws-acces-key aws-secret | [
"login",
"aws",
"-",
"acces",
"-",
"key",
"aws",
"-",
"secret"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L298-L309 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_describe | def do_describe(self, line):
"describe [-c] {tablename}..."
args = self.getargs(line)
if '-c' in args:
create_info = True
args.remove('-c')
else:
create_info = False
if not args:
if self.table:
args = [self.table.n... | python | def do_describe(self, line):
"describe [-c] {tablename}..."
args = self.getargs(line)
if '-c' in args:
create_info = True
args.remove('-c')
else:
create_info = False
if not args:
if self.table:
args = [self.table.n... | [
"def",
"do_describe",
"(",
"self",
",",
"line",
")",
":",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"if",
"'-c'",
"in",
"args",
":",
"create_info",
"=",
"True",
"args",
".",
"remove",
"(",
"'-c'",
")",
"else",
":",
"create_info",
"=",
... | describe [-c] {tablename}... | [
"describe",
"[",
"-",
"c",
"]",
"{",
"tablename",
"}",
"..."
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L317-L354 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_use | def do_use(self, line):
"use {tablename}"
self.table = self.conn.get_table(line)
self.pprint(self.conn.describe_table(self.table.name))
self.prompt = "%s> " % self.table.name | python | def do_use(self, line):
"use {tablename}"
self.table = self.conn.get_table(line)
self.pprint(self.conn.describe_table(self.table.name))
self.prompt = "%s> " % self.table.name | [
"def",
"do_use",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"table",
"=",
"self",
".",
"conn",
".",
"get_table",
"(",
"line",
")",
"self",
".",
"pprint",
"(",
"self",
".",
"conn",
".",
"describe_table",
"(",
"self",
".",
"table",
".",
"name",... | use {tablename} | [
"use",
"{",
"tablename",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L356-L360 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_create | def do_create(self, line):
"create {tablename} [-c rc,wc] {hkey}[:{type} {rkey}:{type}]"
args = self.getargs(line)
rc = wc = 5
name = args.pop(0) # tablename
if args[0] == "-c": # capacity
args.pop(0) # skyp -c
capacity = args.pop(0).strip()
... | python | def do_create(self, line):
"create {tablename} [-c rc,wc] {hkey}[:{type} {rkey}:{type}]"
args = self.getargs(line)
rc = wc = 5
name = args.pop(0) # tablename
if args[0] == "-c": # capacity
args.pop(0) # skyp -c
capacity = args.pop(0).strip()
... | [
"def",
"do_create",
"(",
"self",
",",
"line",
")",
":",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"rc",
"=",
"wc",
"=",
"5",
"name",
"=",
"args",
".",
"pop",
"(",
"0",
")",
"# tablename",
"if",
"args",
"[",
"0",
"]",
"==",
"\"-c\""... | create {tablename} [-c rc,wc] {hkey}[:{type} {rkey}:{type}] | [
"create",
"{",
"tablename",
"}",
"[",
"-",
"c",
"rc",
"wc",
"]",
"{",
"hkey",
"}",
"[",
":",
"{",
"type",
"}",
"{",
"rkey",
"}",
":",
"{",
"type",
"}",
"]"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L362-L389 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_drop | def do_drop(self, line):
"drop {tablename}"
self.conn.delete_table(self.conn.get_table(line)) | python | def do_drop(self, line):
"drop {tablename}"
self.conn.delete_table(self.conn.get_table(line)) | [
"def",
"do_drop",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"conn",
".",
"delete_table",
"(",
"self",
".",
"conn",
".",
"get_table",
"(",
"line",
")",
")"
] | drop {tablename} | [
"drop",
"{",
"tablename",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L391-L393 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_refresh | def do_refresh(self, line):
"refresh {table_name}"
table = self.get_table(line)
table.refresh(True)
self.pprint(self.conn.describe_table(table.name)) | python | def do_refresh(self, line):
"refresh {table_name}"
table = self.get_table(line)
table.refresh(True)
self.pprint(self.conn.describe_table(table.name)) | [
"def",
"do_refresh",
"(",
"self",
",",
"line",
")",
":",
"table",
"=",
"self",
".",
"get_table",
"(",
"line",
")",
"table",
".",
"refresh",
"(",
"True",
")",
"self",
".",
"pprint",
"(",
"self",
".",
"conn",
".",
"describe_table",
"(",
"table",
".",
... | refresh {table_name} | [
"refresh",
"{",
"table_name",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L395-L399 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_capacity | def do_capacity(self, line):
"capacity {tablename} {read_units} {write_units}"
args = self.getargs(line)
table = self.get_table(args[0])
read_units = int(args[1])
write_units = int(args[2])
desc = self.conn.describe_table(table.name)
prov = desc['Table']['Provis... | python | def do_capacity(self, line):
"capacity {tablename} {read_units} {write_units}"
args = self.getargs(line)
table = self.get_table(args[0])
read_units = int(args[1])
write_units = int(args[2])
desc = self.conn.describe_table(table.name)
prov = desc['Table']['Provis... | [
"def",
"do_capacity",
"(",
"self",
",",
"line",
")",
":",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"table",
"=",
"self",
".",
"get_table",
"(",
"args",
"[",
"0",
"]",
")",
"read_units",
"=",
"int",
"(",
"args",
"[",
"1",
"]",
")",
... | capacity {tablename} {read_units} {write_units} | [
"capacity",
"{",
"tablename",
"}",
"{",
"read_units",
"}",
"{",
"write_units",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L401-L438 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_rm | def do_rm(self, line):
"rm [:tablename] [!fieldname:expectedvalue] [-v] {haskkey [rangekey]}"
table, line = self.get_table_params(line)
expected, line = self.get_expected(line)
args = self.getargs(line)
if "-v" in args:
ret = "ALL_OLD"
args.remove("-v")
... | python | def do_rm(self, line):
"rm [:tablename] [!fieldname:expectedvalue] [-v] {haskkey [rangekey]}"
table, line = self.get_table_params(line)
expected, line = self.get_expected(line)
args = self.getargs(line)
if "-v" in args:
ret = "ALL_OLD"
args.remove("-v")
... | [
"def",
"do_rm",
"(",
"self",
",",
"line",
")",
":",
"table",
",",
"line",
"=",
"self",
".",
"get_table_params",
"(",
"line",
")",
"expected",
",",
"line",
"=",
"self",
".",
"get_expected",
"(",
"line",
")",
"args",
"=",
"self",
".",
"getargs",
"(",
... | rm [:tablename] [!fieldname:expectedvalue] [-v] {haskkey [rangekey]} | [
"rm",
"[",
":",
"tablename",
"]",
"[",
"!fieldname",
":",
"expectedvalue",
"]",
"[",
"-",
"v",
"]",
"{",
"haskkey",
"[",
"rangekey",
"]",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L579-L600 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_scan | def do_scan(self, line):
"""
scan [:tablename] [--batch=#] [-{max}] [--count|-c] [--array|-a] [+filter_attribute:filter_value] [attributes,...]
if filter_value contains '=' it's interpreted as {conditional}={value} where condtional is:
eq (equal value)
ne {value} (not e... | python | def do_scan(self, line):
"""
scan [:tablename] [--batch=#] [-{max}] [--count|-c] [--array|-a] [+filter_attribute:filter_value] [attributes,...]
if filter_value contains '=' it's interpreted as {conditional}={value} where condtional is:
eq (equal value)
ne {value} (not e... | [
"def",
"do_scan",
"(",
"self",
",",
"line",
")",
":",
"table",
",",
"line",
"=",
"self",
".",
"get_table_params",
"(",
"line",
")",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"scan_filter",
"=",
"{",
"}",
"count",
"=",
"False",
"as_array"... | scan [:tablename] [--batch=#] [-{max}] [--count|-c] [--array|-a] [+filter_attribute:filter_value] [attributes,...]
if filter_value contains '=' it's interpreted as {conditional}={value} where condtional is:
eq (equal value)
ne {value} (not equal value)
le (less or equal the... | [
"scan",
"[",
":",
"tablename",
"]",
"[",
"--",
"batch",
"=",
"#",
"]",
"[",
"-",
"{",
"max",
"}",
"]",
"[",
"--",
"count|",
"-",
"c",
"]",
"[",
"--",
"array|",
"-",
"a",
"]",
"[",
"+",
"filter_attribute",
":",
"filter_value",
"]",
"[",
"attribu... | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L629-L759 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_query | def do_query(self, line):
"""
query [:tablename] [-r] [--count|-c] [--array|-a] [-{max}] [{rkey-condition}] hkey [attributes,...]
where rkey-condition:
--eq={key} (equal key)
--ne={key} (not equal key)
--le={key} (less or equal than key)
--lt={key... | python | def do_query(self, line):
"""
query [:tablename] [-r] [--count|-c] [--array|-a] [-{max}] [{rkey-condition}] hkey [attributes,...]
where rkey-condition:
--eq={key} (equal key)
--ne={key} (not equal key)
--le={key} (less or equal than key)
--lt={key... | [
"def",
"do_query",
"(",
"self",
",",
"line",
")",
":",
"table",
",",
"line",
"=",
"self",
".",
"get_table_params",
"(",
"line",
")",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"condition",
"=",
"None",
"count",
"=",
"False",
"as_array",
"... | query [:tablename] [-r] [--count|-c] [--array|-a] [-{max}] [{rkey-condition}] hkey [attributes,...]
where rkey-condition:
--eq={key} (equal key)
--ne={key} (not equal key)
--le={key} (less or equal than key)
--lt={key} (less than key)
--ge={key} (grea... | [
"query",
"[",
":",
"tablename",
"]",
"[",
"-",
"r",
"]",
"[",
"--",
"count|",
"-",
"c",
"]",
"[",
"--",
"array|",
"-",
"a",
"]",
"[",
"-",
"{",
"max",
"}",
"]",
"[",
"{",
"rkey",
"-",
"condition",
"}",
"]",
"hkey",
"[",
"attributes",
"...",
... | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L761-L887 |
raff/dynash | dynash/dynash.py | DynamoDBShell.do_rmall | def do_rmall(self, line):
"remove [tablename...] yes"
args = self.getargs(line)
if args and args[-1] == "yes":
args.pop()
if not args:
args = [self.table.name]
while args:
table = self.conn.get_table(args.pop(0))
... | python | def do_rmall(self, line):
"remove [tablename...] yes"
args = self.getargs(line)
if args and args[-1] == "yes":
args.pop()
if not args:
args = [self.table.name]
while args:
table = self.conn.get_table(args.pop(0))
... | [
"def",
"do_rmall",
"(",
"self",
",",
"line",
")",
":",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"if",
"args",
"and",
"args",
"[",
"-",
"1",
"]",
"==",
"\"yes\"",
":",
"args",
".",
"pop",
"(",
")",
"if",
"not",
"args",
":",
"args",... | remove [tablename...] yes | [
"remove",
"[",
"tablename",
"...",
"]",
"yes"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash/dynash.py#L889-L906 |
maoaiz/django-admin-conf-vars | django_admin_conf_vars/global_vars.py | VariablesManager.getAll | def getAll(self):
'''Return a dictionary with all variables'''
if not bool(len(self.ATTRIBUTES)):
self.load_attributes()
return eval(str(self.ATTRIBUTES)) | python | def getAll(self):
'''Return a dictionary with all variables'''
if not bool(len(self.ATTRIBUTES)):
self.load_attributes()
return eval(str(self.ATTRIBUTES)) | [
"def",
"getAll",
"(",
"self",
")",
":",
"if",
"not",
"bool",
"(",
"len",
"(",
"self",
".",
"ATTRIBUTES",
")",
")",
":",
"self",
".",
"load_attributes",
"(",
")",
"return",
"eval",
"(",
"str",
"(",
"self",
".",
"ATTRIBUTES",
")",
")"
] | Return a dictionary with all variables | [
"Return",
"a",
"dictionary",
"with",
"all",
"variables"
] | train | https://github.com/maoaiz/django-admin-conf-vars/blob/f18ddb62647719e3612ea87ee866fb27b901ac27/django_admin_conf_vars/global_vars.py#L30-L35 |
maoaiz/django-admin-conf-vars | django_admin_conf_vars/global_vars.py | VariablesManager.set | def set(self, name, default=0, editable=True, description=""):
'''Define a variable in DB and in memory'''
var, created = ConfigurationVariable.objects.get_or_create(name=name)
if created:
var.value = default
if not editable:
var.value = default
var.ed... | python | def set(self, name, default=0, editable=True, description=""):
'''Define a variable in DB and in memory'''
var, created = ConfigurationVariable.objects.get_or_create(name=name)
if created:
var.value = default
if not editable:
var.value = default
var.ed... | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"default",
"=",
"0",
",",
"editable",
"=",
"True",
",",
"description",
"=",
"\"\"",
")",
":",
"var",
",",
"created",
"=",
"ConfigurationVariable",
".",
"objects",
".",
"get_or_create",
"(",
"name",
"=",
"nam... | Define a variable in DB and in memory | [
"Define",
"a",
"variable",
"in",
"DB",
"and",
"in",
"memory"
] | train | https://github.com/maoaiz/django-admin-conf-vars/blob/f18ddb62647719e3612ea87ee866fb27b901ac27/django_admin_conf_vars/global_vars.py#L37-L53 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.