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 |
|---|---|---|---|---|---|---|---|---|---|---|
mirukan/lunafind | lunafind/attridict.py | AttrIndexedDict.map | def map(self, method: str, *args, _threaded: bool = True, **kwargs
) -> "AttrIndexedDict":
"For all stored items, run a method they possess."
work = lambda item: getattr(item, method)(*args, **kwargs)
if _threaded:
pool = ThreadPool(int(config.CFG["GENERAL"]["parallel_re... | python | def map(self, method: str, *args, _threaded: bool = True, **kwargs
) -> "AttrIndexedDict":
"For all stored items, run a method they possess."
work = lambda item: getattr(item, method)(*args, **kwargs)
if _threaded:
pool = ThreadPool(int(config.CFG["GENERAL"]["parallel_re... | [
"def",
"map",
"(",
"self",
",",
"method",
":",
"str",
",",
"*",
"args",
",",
"_threaded",
":",
"bool",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
"->",
"\"AttrIndexedDict\"",
":",
"work",
"=",
"lambda",
"item",
":",
"getattr",
"(",
"item",
",",
"me... | For all stored items, run a method they possess. | [
"For",
"all",
"stored",
"items",
"run",
"a",
"method",
"they",
"possess",
"."
] | train | https://github.com/mirukan/lunafind/blob/77bdfe02df98a7f74d0ae795fee3b1729218995d/lunafind/attridict.py#L43-L65 |
mirukan/lunafind | lunafind/attridict.py | AttrIndexedDict.put | def put(self, *items) -> "AttrIndexedDict":
"Add items to the dict that will be indexed by self.attr."
for item in items:
self.data[getattr(item, self.attr)] = item
return self | python | def put(self, *items) -> "AttrIndexedDict":
"Add items to the dict that will be indexed by self.attr."
for item in items:
self.data[getattr(item, self.attr)] = item
return self | [
"def",
"put",
"(",
"self",
",",
"*",
"items",
")",
"->",
"\"AttrIndexedDict\"",
":",
"for",
"item",
"in",
"items",
":",
"self",
".",
"data",
"[",
"getattr",
"(",
"item",
",",
"self",
".",
"attr",
")",
"]",
"=",
"item",
"return",
"self"
] | Add items to the dict that will be indexed by self.attr. | [
"Add",
"items",
"to",
"the",
"dict",
"that",
"will",
"be",
"indexed",
"by",
"self",
".",
"attr",
"."
] | train | https://github.com/mirukan/lunafind/blob/77bdfe02df98a7f74d0ae795fee3b1729218995d/lunafind/attridict.py#L72-L76 |
JackNova/tplink | tplink/cli.py | main | def main(host, password, username):
"""Console script for tplink."""
client = tplink.TpLinkClient(password)
devices = client.get_connected_devices()
click.echo(json.dumps(devices, indent=4))
return 0 | python | def main(host, password, username):
"""Console script for tplink."""
client = tplink.TpLinkClient(password)
devices = client.get_connected_devices()
click.echo(json.dumps(devices, indent=4))
return 0 | [
"def",
"main",
"(",
"host",
",",
"password",
",",
"username",
")",
":",
"client",
"=",
"tplink",
".",
"TpLinkClient",
"(",
"password",
")",
"devices",
"=",
"client",
".",
"get_connected_devices",
"(",
")",
"click",
".",
"echo",
"(",
"json",
".",
"dumps",... | Console script for tplink. | [
"Console",
"script",
"for",
"tplink",
"."
] | train | https://github.com/JackNova/tplink/blob/999861807a5205f67cbd9bec86490d3bc8664ebf/tplink/cli.py#L17-L22 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_login | def do_login(self, line):
"login aws-acces-key aws-secret"
if line:
args = self.getargs(line)
self.connect(args[0], args[1])
else:
self.connect()
self.do_tables('') | python | def do_login(self, line):
"login aws-acces-key aws-secret"
if line:
args = self.getargs(line)
self.connect(args[0], args[1])
else:
self.connect()
self.do_tables('') | [
"def",
"do_login",
"(",
"self",
",",
"line",
")",
":",
"if",
"line",
":",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"self",
".",
"connect",
"(",
"args",
"[",
"0",
"]",
",",
"args",
"[",
"1",
"]",
")",
"else",
":",
"self",
".",
"c... | login aws-acces-key aws-secret | [
"login",
"aws",
"-",
"acces",
"-",
"key",
"aws",
"-",
"secret"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L360-L368 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_tables | def do_tables(self, line):
"List tables"
self.tables = self.conn.list_tables().get('TableNames')
print "\nAvailable tables:"
self.pprint(self.tables) | python | def do_tables(self, line):
"List tables"
self.tables = self.conn.list_tables().get('TableNames')
print "\nAvailable tables:"
self.pprint(self.tables) | [
"def",
"do_tables",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"tables",
"=",
"self",
".",
"conn",
".",
"list_tables",
"(",
")",
".",
"get",
"(",
"'TableNames'",
")",
"print",
"\"\\nAvailable tables:\"",
"self",
".",
"pprint",
"(",
"self",
".",
"... | List tables | [
"List",
"tables"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L370-L374 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.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.... | 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.... | [
"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/dynash2/dynash2.py#L376-L420 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_use | def do_use(self, line):
"use {tablename}"
self.table = boto.dynamodb2.table.Table(line, connection=self.conn)
self.pprint(self.table.describe())
self.prompt = "%s> " % self.table.table_name | python | def do_use(self, line):
"use {tablename}"
self.table = boto.dynamodb2.table.Table(line, connection=self.conn)
self.pprint(self.table.describe())
self.prompt = "%s> " % self.table.table_name | [
"def",
"do_use",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"table",
"=",
"boto",
".",
"dynamodb2",
".",
"table",
".",
"Table",
"(",
"line",
",",
"connection",
"=",
"self",
".",
"conn",
")",
"self",
".",
"pprint",
"(",
"self",
".",
"table",
... | use {tablename} | [
"use",
"{",
"tablename",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L422-L426 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.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/dynash2/dynash2.py#L428-L457 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_refresh | def do_refresh(self, line):
"refresh {table_name}"
table = self.get_table(line)
while True:
desc = table.describe()
status = desc['Table']['TableStatus']
if status == 'ACTIVE':
break
else:
print status, "..."
... | python | def do_refresh(self, line):
"refresh {table_name}"
table = self.get_table(line)
while True:
desc = table.describe()
status = desc['Table']['TableStatus']
if status == 'ACTIVE':
break
else:
print status, "..."
... | [
"def",
"do_refresh",
"(",
"self",
",",
"line",
")",
":",
"table",
"=",
"self",
".",
"get_table",
"(",
"line",
")",
"while",
"True",
":",
"desc",
"=",
"table",
".",
"describe",
"(",
")",
"status",
"=",
"desc",
"[",
"'Table'",
"]",
"[",
"'TableStatus'"... | refresh {table_name} | [
"refresh",
"{",
"table_name",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L463-L477 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_capacity | def do_capacity(self, line):
"capacity [tablename] {read_units} {write_units}"
table, line = self.get_table_params(line)
args = self.getargs(line)
read_units = int(args[0])
write_units = int(args[1])
desc = table.describe()
prov = desc['Table']['ProvisionedThrou... | python | def do_capacity(self, line):
"capacity [tablename] {read_units} {write_units}"
table, line = self.get_table_params(line)
args = self.getargs(line)
read_units = int(args[0])
write_units = int(args[1])
desc = table.describe()
prov = desc['Table']['ProvisionedThrou... | [
"def",
"do_capacity",
"(",
"self",
",",
"line",
")",
":",
"table",
",",
"line",
"=",
"self",
".",
"get_table_params",
"(",
"line",
")",
"args",
"=",
"self",
".",
"getargs",
"(",
"line",
")",
"read_units",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
")"... | capacity [tablename] {read_units} {write_units} | [
"capacity",
"[",
"tablename",
"]",
"{",
"read_units",
"}",
"{",
"write_units",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L479-L522 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_put | def do_put(self, line):
"put [:tablename] [!fieldname:expectedvalue] {json-body} [{json-body}, {json-body}...]"
table, line = self.get_table_params(line)
expected, line = self.get_expected(line)
if expected:
print "expected: not yet implemented"
return
if... | python | def do_put(self, line):
"put [:tablename] [!fieldname:expectedvalue] {json-body} [{json-body}, {json-body}...]"
table, line = self.get_table_params(line)
expected, line = self.get_expected(line)
if expected:
print "expected: not yet implemented"
return
if... | [
"def",
"do_put",
"(",
"self",
",",
"line",
")",
":",
"table",
",",
"line",
"=",
"self",
".",
"get_table_params",
"(",
"line",
")",
"expected",
",",
"line",
"=",
"self",
".",
"get_expected",
"(",
"line",
")",
"if",
"expected",
":",
"print",
"\"expected:... | put [:tablename] [!fieldname:expectedvalue] {json-body} [{json-body}, {json-body}...] | [
"put",
"[",
":",
"tablename",
"]",
"[",
"!fieldname",
":",
"expectedvalue",
"]",
"{",
"json",
"-",
"body",
"}",
"[",
"{",
"json",
"-",
"body",
"}",
"{",
"json",
"-",
"body",
"}",
"...",
"]"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L524-L552 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_import | def do_import(self, line):
"import [:tablename] filename|list"
table, line = self.get_table_params(line)
if line[0] == '[':
list = self.get_list(line)
else:
with open(line) as f:
list = self.get_list(f.read())
items = 0
consumed = ... | python | def do_import(self, line):
"import [:tablename] filename|list"
table, line = self.get_table_params(line)
if line[0] == '[':
list = self.get_list(line)
else:
with open(line) as f:
list = self.get_list(f.read())
items = 0
consumed = ... | [
"def",
"do_import",
"(",
"self",
",",
"line",
")",
":",
"table",
",",
"line",
"=",
"self",
".",
"get_table_params",
"(",
"line",
")",
"if",
"line",
"[",
"0",
"]",
"==",
"'['",
":",
"list",
"=",
"self",
".",
"get_list",
"(",
"line",
")",
"else",
"... | import [:tablename] filename|list | [
"import",
"[",
":",
"tablename",
"]",
"filename|list"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L554-L572 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2._todo_do_update | def _todo_do_update(self, line):
"update [:tablename] {hashkey[,rangekey]} [!fieldname:expectedvalue] [-add|-delete] [+ALL_OLD|ALL_NEW|UPDATED_OLD|UPDATED_NEW] {attributes}"
table, line = self.get_table_params(line)
hkey, line = line.split(" ", 1)
expected, attr = self.get_expected(line)... | python | def _todo_do_update(self, line):
"update [:tablename] {hashkey[,rangekey]} [!fieldname:expectedvalue] [-add|-delete] [+ALL_OLD|ALL_NEW|UPDATED_OLD|UPDATED_NEW] {attributes}"
table, line = self.get_table_params(line)
hkey, line = line.split(" ", 1)
expected, attr = self.get_expected(line)... | [
"def",
"_todo_do_update",
"(",
"self",
",",
"line",
")",
":",
"table",
",",
"line",
"=",
"self",
".",
"get_table_params",
"(",
"line",
")",
"hkey",
",",
"line",
"=",
"line",
".",
"split",
"(",
"\" \"",
",",
"1",
")",
"expected",
",",
"attr",
"=",
"... | update [:tablename] {hashkey[,rangekey]} [!fieldname:expectedvalue] [-add|-delete] [+ALL_OLD|ALL_NEW|UPDATED_OLD|UPDATED_NEW] {attributes} | [
"update",
"[",
":",
"tablename",
"]",
"{",
"hashkey",
"[",
"rangekey",
"]",
"}",
"[",
"!fieldname",
":",
"expectedvalue",
"]",
"[",
"-",
"add|",
"-",
"delete",
"]",
"[",
"+",
"ALL_OLD|ALL_NEW|UPDATED_OLD|UPDATED_NEW",
"]",
"{",
"attributes",
"}"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L574-L617 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_get | def do_get(self, line):
"""
get [:tablename] {haskkey} [rangekey]
or
get [:tablename] ((hkey,rkey), (hkey,rkey)...)
"""
table, line = self.get_table_params(line)
if line.startswith('(') or line.startswith('[') or "," in line:
print "batch: not yet i... | python | def do_get(self, line):
"""
get [:tablename] {haskkey} [rangekey]
or
get [:tablename] ((hkey,rkey), (hkey,rkey)...)
"""
table, line = self.get_table_params(line)
if line.startswith('(') or line.startswith('[') or "," in line:
print "batch: not yet i... | [
"def",
"do_get",
"(",
"self",
",",
"line",
")",
":",
"table",
",",
"line",
"=",
"self",
".",
"get_table_params",
"(",
"line",
")",
"if",
"line",
".",
"startswith",
"(",
"'('",
")",
"or",
"line",
".",
"startswith",
"(",
"'['",
")",
"or",
"\",\"",
"i... | get [:tablename] {haskkey} [rangekey]
or
get [:tablename] ((hkey,rkey), (hkey,rkey)...) | [
"get",
"[",
":",
"tablename",
"]",
"{",
"haskkey",
"}",
"[",
"rangekey",
"]",
"or",
"get",
"[",
":",
"tablename",
"]",
"((",
"hkey",
"rkey",
")",
"(",
"hkey",
"rkey",
")",
"...",
")"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L619-L675 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.do_scan | def do_scan(self, line):
"""
scan [:tablename] [--batch=#] [-{max}] [+filter_attribute=filter_value] [attributes,...]
filter_attribute is either the field name to filter on or a field name with a conditional, as specified in boto's documentation,
in the form of {name}__{conditional} whe... | python | def do_scan(self, line):
"""
scan [:tablename] [--batch=#] [-{max}] [+filter_attribute=filter_value] [attributes,...]
filter_attribute is either the field name to filter on or a field name with a conditional, as specified in boto's documentation,
in the form of {name}__{conditional} whe... | [
"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}] [+filter_attribute=filter_value] [attributes,...]
filter_attribute is either the field name to filter on or a field name with a conditional, as specified in boto's documentation,
in the form of {name}__{conditional} where conditional is:
eq (equal val... | [
"scan",
"[",
":",
"tablename",
"]",
"[",
"--",
"batch",
"=",
"#",
"]",
"[",
"-",
"{",
"max",
"}",
"]",
"[",
"+",
"filter_attribute",
"=",
"filter_value",
"]",
"[",
"attributes",
"...",
"]"
] | train | https://github.com/raff/dynash/blob/a2b4fab67dd85ceaa9c1bb7604ebc1768a7fc28e/dynash2/dynash2.py#L727-L851 |
raff/dynash | dynash2/dynash2.py | DynamoDBShell2.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.table_name]
while args:
table = boto.dynamodb2.table.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.table_name]
while args:
table = boto.dynamodb2.table.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/dynash2/dynash2.py#L981-L998 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/examples/utils_example.py | simulate | def simulate(simulated_variables, year):
'''
Construction de la DataFrame à partir de laquelle sera faite l'analyse des données
'''
input_data_frame = get_input_data_frame(year)
TaxBenefitSystem = openfisca_france_indirect_taxation.init_country()
tax_benefit_system = TaxBenefitSystem()
surv... | python | def simulate(simulated_variables, year):
'''
Construction de la DataFrame à partir de laquelle sera faite l'analyse des données
'''
input_data_frame = get_input_data_frame(year)
TaxBenefitSystem = openfisca_france_indirect_taxation.init_country()
tax_benefit_system = TaxBenefitSystem()
surv... | [
"def",
"simulate",
"(",
"simulated_variables",
",",
"year",
")",
":",
"input_data_frame",
"=",
"get_input_data_frame",
"(",
"year",
")",
"TaxBenefitSystem",
"=",
"openfisca_france_indirect_taxation",
".",
"init_country",
"(",
")",
"tax_benefit_system",
"=",
"TaxBenefitS... | Construction de la DataFrame à partir de laquelle sera faite l'analyse des données | [
"Construction",
"de",
"la",
"DataFrame",
"à",
"partir",
"de",
"laquelle",
"sera",
"faite",
"l",
"analyse",
"des",
"données"
] | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/examples/utils_example.py#L39-L58 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/examples/utils_example.py | wavg | def wavg(groupe, var):
'''
Fonction qui calcule la moyenne pondérée par groupe d'une variable
'''
d = groupe[var]
w = groupe['pondmen']
return (d * w).sum() / w.sum() | python | def wavg(groupe, var):
'''
Fonction qui calcule la moyenne pondérée par groupe d'une variable
'''
d = groupe[var]
w = groupe['pondmen']
return (d * w).sum() / w.sum() | [
"def",
"wavg",
"(",
"groupe",
",",
"var",
")",
":",
"d",
"=",
"groupe",
"[",
"var",
"]",
"w",
"=",
"groupe",
"[",
"'pondmen'",
"]",
"return",
"(",
"d",
"*",
"w",
")",
".",
"sum",
"(",
")",
"/",
"w",
".",
"sum",
"(",
")"
] | Fonction qui calcule la moyenne pondérée par groupe d'une variable | [
"Fonction",
"qui",
"calcule",
"la",
"moyenne",
"pondérée",
"par",
"groupe",
"d",
"une",
"variable"
] | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/examples/utils_example.py#L107-L113 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/examples/utils_example.py | collapse | def collapse(dataframe, groupe, var):
'''
Pour une variable, fonction qui calcule la moyenne pondérée au sein de chaque groupe.
'''
grouped = dataframe.groupby([groupe])
var_weighted_grouped = grouped.apply(lambda x: wavg(groupe = x, var = var))
return var_weighted_grouped | python | def collapse(dataframe, groupe, var):
'''
Pour une variable, fonction qui calcule la moyenne pondérée au sein de chaque groupe.
'''
grouped = dataframe.groupby([groupe])
var_weighted_grouped = grouped.apply(lambda x: wavg(groupe = x, var = var))
return var_weighted_grouped | [
"def",
"collapse",
"(",
"dataframe",
",",
"groupe",
",",
"var",
")",
":",
"grouped",
"=",
"dataframe",
".",
"groupby",
"(",
"[",
"groupe",
"]",
")",
"var_weighted_grouped",
"=",
"grouped",
".",
"apply",
"(",
"lambda",
"x",
":",
"wavg",
"(",
"groupe",
"... | Pour une variable, fonction qui calcule la moyenne pondérée au sein de chaque groupe. | [
"Pour",
"une",
"variable",
"fonction",
"qui",
"calcule",
"la",
"moyenne",
"pondérée",
"au",
"sein",
"de",
"chaque",
"groupe",
"."
] | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/examples/utils_example.py#L116-L122 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/examples/utils_example.py | df_weighted_average_grouped | def df_weighted_average_grouped(dataframe, groupe, varlist):
'''
Agrège les résultats de weighted_average_grouped() en une unique dataframe pour la liste de variable 'varlist'.
'''
return DataFrame(
dict([
(var, collapse(dataframe, groupe, var)) for var in varlist
])
... | python | def df_weighted_average_grouped(dataframe, groupe, varlist):
'''
Agrège les résultats de weighted_average_grouped() en une unique dataframe pour la liste de variable 'varlist'.
'''
return DataFrame(
dict([
(var, collapse(dataframe, groupe, var)) for var in varlist
])
... | [
"def",
"df_weighted_average_grouped",
"(",
"dataframe",
",",
"groupe",
",",
"varlist",
")",
":",
"return",
"DataFrame",
"(",
"dict",
"(",
"[",
"(",
"var",
",",
"collapse",
"(",
"dataframe",
",",
"groupe",
",",
"var",
")",
")",
"for",
"var",
"in",
"varlis... | Agrège les résultats de weighted_average_grouped() en une unique dataframe pour la liste de variable 'varlist'. | [
"Agrège",
"les",
"résultats",
"de",
"weighted_average_grouped",
"()",
"en",
"une",
"unique",
"dataframe",
"pour",
"la",
"liste",
"de",
"variable",
"varlist",
"."
] | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/examples/utils_example.py#L125-L133 |
ericmjl/pyflatten | pyflatten/__init__.py | flatten | def flatten(value):
"""value can be any nesting of tuples, arrays, dicts.
returns 1D numpy array and an unflatten function."""
if isinstance(value, np.ndarray):
def unflatten(vector):
return np.reshape(vector, value.shape)
return np.ravel(value), unflatten
elif isinstance... | python | def flatten(value):
"""value can be any nesting of tuples, arrays, dicts.
returns 1D numpy array and an unflatten function."""
if isinstance(value, np.ndarray):
def unflatten(vector):
return np.reshape(vector, value.shape)
return np.ravel(value), unflatten
elif isinstance... | [
"def",
"flatten",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"np",
".",
"ndarray",
")",
":",
"def",
"unflatten",
"(",
"vector",
")",
":",
"return",
"np",
".",
"reshape",
"(",
"vector",
",",
"value",
".",
"shape",
")",
"return",
... | value can be any nesting of tuples, arrays, dicts.
returns 1D numpy array and an unflatten function. | [
"value",
"can",
"be",
"any",
"nesting",
"of",
"tuples",
"arrays",
"dicts",
".",
"returns",
"1D",
"numpy",
"array",
"and",
"an",
"unflatten",
"function",
"."
] | train | https://github.com/ericmjl/pyflatten/blob/2a8f4a9a3164e4799a4086abe4c69cc89afc3b67/pyflatten/__init__.py#L14-L74 |
ff0000/scarlet | scarlet/versioning/views.py | switch_state | def switch_state(request):
"""
Switch the default version state in
the session.
"""
if request.session.get(SESSION_KEY):
request.session[SESSION_KEY] = False
else:
request.session[SESSION_KEY] = True
# Get redirect location
# Don't go to non local paths
url = reques... | python | def switch_state(request):
"""
Switch the default version state in
the session.
"""
if request.session.get(SESSION_KEY):
request.session[SESSION_KEY] = False
else:
request.session[SESSION_KEY] = True
# Get redirect location
# Don't go to non local paths
url = reques... | [
"def",
"switch_state",
"(",
"request",
")",
":",
"if",
"request",
".",
"session",
".",
"get",
"(",
"SESSION_KEY",
")",
":",
"request",
".",
"session",
"[",
"SESSION_KEY",
"]",
"=",
"False",
"else",
":",
"request",
".",
"session",
"[",
"SESSION_KEY",
"]",... | Switch the default version state in
the session. | [
"Switch",
"the",
"default",
"version",
"state",
"in",
"the",
"session",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/views.py#L5-L21 |
ff0000/scarlet | scarlet/scheduling/fields.py | JSONField.get_db_prep_value | def get_db_prep_value(self, value, connection, prepared=False):
"""Convert JSON object to a string"""
if isinstance(value, basestring):
return value
return json.dumps(value, **self.dump_kwargs) | python | def get_db_prep_value(self, value, connection, prepared=False):
"""Convert JSON object to a string"""
if isinstance(value, basestring):
return value
return json.dumps(value, **self.dump_kwargs) | [
"def",
"get_db_prep_value",
"(",
"self",
",",
"value",
",",
"connection",
",",
"prepared",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"basestring",
")",
":",
"return",
"value",
"return",
"json",
".",
"dumps",
"(",
"value",
",",
"*",
... | Convert JSON object to a string | [
"Convert",
"JSON",
"object",
"to",
"a",
"string"
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/scheduling/fields.py#L42-L46 |
rh-marketingops/dwm | dwm/helpers.py | _CollectHistory_ | def _CollectHistory_(lookupType, fromVal, toVal, using={}, pattern=''):
"""
Return a dictionary detailing what, if any, change was made to a record field
:param string lookupType: what cleaning rule made the change; one of: genericLookup, genericRegex, fieldSpecificLookup, fieldSpecificRegex, normLookup, n... | python | def _CollectHistory_(lookupType, fromVal, toVal, using={}, pattern=''):
"""
Return a dictionary detailing what, if any, change was made to a record field
:param string lookupType: what cleaning rule made the change; one of: genericLookup, genericRegex, fieldSpecificLookup, fieldSpecificRegex, normLookup, n... | [
"def",
"_CollectHistory_",
"(",
"lookupType",
",",
"fromVal",
",",
"toVal",
",",
"using",
"=",
"{",
"}",
",",
"pattern",
"=",
"''",
")",
":",
"histObj",
"=",
"{",
"}",
"if",
"fromVal",
"!=",
"toVal",
":",
"histObj",
"[",
"lookupType",
"]",
"=",
"{",
... | Return a dictionary detailing what, if any, change was made to a record field
:param string lookupType: what cleaning rule made the change; one of: genericLookup, genericRegex, fieldSpecificLookup, fieldSpecificRegex, normLookup, normRegex, normIncludes, deriveValue, copyValue, deriveRegex
:param string fromVa... | [
"Return",
"a",
"dictionary",
"detailing",
"what",
"if",
"any",
"change",
"was",
"made",
"to",
"a",
"record",
"field"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/helpers.py#L6-L27 |
rh-marketingops/dwm | dwm/helpers.py | _CollectHistoryAgg_ | def _CollectHistoryAgg_(contactHist, fieldHistObj, fieldName):
"""
Return updated history dictionary with new field change
:param dict contactHist: Existing contact history dictionary
:param dict fieldHistObj: Output of _CollectHistory_
:param string fieldName: field name
"""
if fieldHistO... | python | def _CollectHistoryAgg_(contactHist, fieldHistObj, fieldName):
"""
Return updated history dictionary with new field change
:param dict contactHist: Existing contact history dictionary
:param dict fieldHistObj: Output of _CollectHistory_
:param string fieldName: field name
"""
if fieldHistO... | [
"def",
"_CollectHistoryAgg_",
"(",
"contactHist",
",",
"fieldHistObj",
",",
"fieldName",
")",
":",
"if",
"fieldHistObj",
"!=",
"{",
"}",
":",
"if",
"fieldName",
"not",
"in",
"contactHist",
".",
"keys",
"(",
")",
":",
"contactHist",
"[",
"fieldName",
"]",
"... | Return updated history dictionary with new field change
:param dict contactHist: Existing contact history dictionary
:param dict fieldHistObj: Output of _CollectHistory_
:param string fieldName: field name | [
"Return",
"updated",
"history",
"dictionary",
"with",
"new",
"field",
"change"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/helpers.py#L29-L44 |
rh-marketingops/dwm | dwm/helpers.py | _DataClean_ | def _DataClean_(fieldVal):
"""
Return 'cleaned' value to standardize lookups (convert to uppercase, remove leading/trailing whitespace, carriage returns, line breaks, and unprintable characters)
:param string fieldVal: field value
"""
fieldValNew = fieldVal
fieldValNew = fieldValNew.upper()
... | python | def _DataClean_(fieldVal):
"""
Return 'cleaned' value to standardize lookups (convert to uppercase, remove leading/trailing whitespace, carriage returns, line breaks, and unprintable characters)
:param string fieldVal: field value
"""
fieldValNew = fieldVal
fieldValNew = fieldValNew.upper()
... | [
"def",
"_DataClean_",
"(",
"fieldVal",
")",
":",
"fieldValNew",
"=",
"fieldVal",
"fieldValNew",
"=",
"fieldValNew",
".",
"upper",
"(",
")",
"fieldValNew",
"=",
"fieldValNew",
".",
"strip",
"(",
")",
"fieldValNew",
"=",
"re",
".",
"sub",
"(",
"\"[\\s\\n\\t]+\... | Return 'cleaned' value to standardize lookups (convert to uppercase, remove leading/trailing whitespace, carriage returns, line breaks, and unprintable characters)
:param string fieldVal: field value | [
"Return",
"cleaned",
"value",
"to",
"standardize",
"lookups",
"(",
"convert",
"to",
"uppercase",
"remove",
"leading",
"/",
"trailing",
"whitespace",
"carriage",
"returns",
"line",
"breaks",
"and",
"unprintable",
"characters",
")"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/helpers.py#L46-L61 |
rh-marketingops/dwm | dwm/helpers.py | _RunUserDefinedFunctions_ | def _RunUserDefinedFunctions_(config, data, histObj, position, namespace=__name__):
"""
Return a single updated data record and history object after running user-defined functions
:param dict config: DWM configuration (see DataDictionary)
:param dict data: single record (dictionary) to which user-defin... | python | def _RunUserDefinedFunctions_(config, data, histObj, position, namespace=__name__):
"""
Return a single updated data record and history object after running user-defined functions
:param dict config: DWM configuration (see DataDictionary)
:param dict data: single record (dictionary) to which user-defin... | [
"def",
"_RunUserDefinedFunctions_",
"(",
"config",
",",
"data",
",",
"histObj",
",",
"position",
",",
"namespace",
"=",
"__name__",
")",
":",
"udfConfig",
"=",
"config",
"[",
"'userDefinedFunctions'",
"]",
"if",
"position",
"in",
"udfConfig",
":",
"posConfig",
... | Return a single updated data record and history object after running user-defined functions
:param dict config: DWM configuration (see DataDictionary)
:param dict data: single record (dictionary) to which user-defined functions should be applied
:param dict histObj: History object to which changes should b... | [
"Return",
"a",
"single",
"updated",
"data",
"record",
"and",
"history",
"object",
"after",
"running",
"user",
"-",
"defined",
"functions"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/helpers.py#L63-L86 |
camsci/meteor-pi | src/observatoryControl/gpsd/fake.py | FakeGPS.feed | def feed(self):
"Feed a line from the contents of the GPS log to the daemon."
line = self.testload.sentences[self.index % len(self.testload.sentences)]
if "%Delay:" in line:
# Delay specified number of seconds
delay = line.split()[1]
time.sleep(int(delay))
... | python | def feed(self):
"Feed a line from the contents of the GPS log to the daemon."
line = self.testload.sentences[self.index % len(self.testload.sentences)]
if "%Delay:" in line:
# Delay specified number of seconds
delay = line.split()[1]
time.sleep(int(delay))
... | [
"def",
"feed",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"testload",
".",
"sentences",
"[",
"self",
".",
"index",
"%",
"len",
"(",
"self",
".",
"testload",
".",
"sentences",
")",
"]",
"if",
"\"%Delay:\"",
"in",
"line",
":",
"# Delay specified nu... | Feed a line from the contents of the GPS log to the daemon. | [
"Feed",
"a",
"line",
"from",
"the",
"contents",
"of",
"the",
"GPS",
"log",
"to",
"the",
"daemon",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/fake.py#L166-L178 |
camsci/meteor-pi | src/observatoryControl/gpsd/fake.py | DaemonInstance.spawn | def spawn(self, options, port, background=False, prefix=""):
"Spawn a daemon instance."
self.spawncmd = None
# Look for gpsd in GPSD_HOME env variable
if os.environ.get('GPSD_HOME'):
for path in os.environ['GPSD_HOME'].split(':'):
_spawncmd = "%s/gpsd" % path
... | python | def spawn(self, options, port, background=False, prefix=""):
"Spawn a daemon instance."
self.spawncmd = None
# Look for gpsd in GPSD_HOME env variable
if os.environ.get('GPSD_HOME'):
for path in os.environ['GPSD_HOME'].split(':'):
_spawncmd = "%s/gpsd" % path
... | [
"def",
"spawn",
"(",
"self",
",",
"options",
",",
"port",
",",
"background",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
":",
"self",
".",
"spawncmd",
"=",
"None",
"# Look for gpsd in GPSD_HOME env variable",
"if",
"os",
".",
"environ",
".",
"get",
"(",... | Spawn a daemon instance. | [
"Spawn",
"a",
"daemon",
"instance",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/fake.py#L295-L329 |
camsci/meteor-pi | src/observatoryControl/gpsd/fake.py | DaemonInstance.wait_pid | def wait_pid(self):
"Wait for the daemon, get its PID and a control-socket connection."
while True:
try:
fp = open(self.pidfile)
except IOError:
time.sleep(0.1)
continue
try:
fp.seek(0)
pi... | python | def wait_pid(self):
"Wait for the daemon, get its PID and a control-socket connection."
while True:
try:
fp = open(self.pidfile)
except IOError:
time.sleep(0.1)
continue
try:
fp.seek(0)
pi... | [
"def",
"wait_pid",
"(",
"self",
")",
":",
"while",
"True",
":",
"try",
":",
"fp",
"=",
"open",
"(",
"self",
".",
"pidfile",
")",
"except",
"IOError",
":",
"time",
".",
"sleep",
"(",
"0.1",
")",
"continue",
"try",
":",
"fp",
".",
"seek",
"(",
"0",... | Wait for the daemon, get its PID and a control-socket connection. | [
"Wait",
"for",
"the",
"daemon",
"get",
"its",
"PID",
"and",
"a",
"control",
"-",
"socket",
"connection",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/fake.py#L330-L346 |
camsci/meteor-pi | src/observatoryControl/gpsd/fake.py | DaemonInstance.add_device | def add_device(self, path):
"Add a device to the daemon's internal search list."
if self.__get_control_socket():
self.sock.sendall("+%s\r\n\x00" % path)
self.sock.recv(12)
self.sock.close() | python | def add_device(self, path):
"Add a device to the daemon's internal search list."
if self.__get_control_socket():
self.sock.sendall("+%s\r\n\x00" % path)
self.sock.recv(12)
self.sock.close() | [
"def",
"add_device",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"__get_control_socket",
"(",
")",
":",
"self",
".",
"sock",
".",
"sendall",
"(",
"\"+%s\\r\\n\\x00\"",
"%",
"path",
")",
"self",
".",
"sock",
".",
"recv",
"(",
"12",
")",
"se... | Add a device to the daemon's internal search list. | [
"Add",
"a",
"device",
"to",
"the",
"daemon",
"s",
"internal",
"search",
"list",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/fake.py#L366-L371 |
camsci/meteor-pi | src/observatoryControl/gpsd/fake.py | DaemonInstance.remove_device | def remove_device(self, path):
"Remove a device from the daemon's internal search list."
if self.__get_control_socket():
self.sock.sendall("-%s\r\n\x00" % path)
self.sock.recv(12)
self.sock.close() | python | def remove_device(self, path):
"Remove a device from the daemon's internal search list."
if self.__get_control_socket():
self.sock.sendall("-%s\r\n\x00" % path)
self.sock.recv(12)
self.sock.close() | [
"def",
"remove_device",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"__get_control_socket",
"(",
")",
":",
"self",
".",
"sock",
".",
"sendall",
"(",
"\"-%s\\r\\n\\x00\"",
"%",
"path",
")",
"self",
".",
"sock",
".",
"recv",
"(",
"12",
")",
... | Remove a device from the daemon's internal search list. | [
"Remove",
"a",
"device",
"from",
"the",
"daemon",
"s",
"internal",
"search",
"list",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/fake.py#L372-L377 |
camsci/meteor-pi | src/observatoryControl/gpsd/fake.py | DaemonInstance.kill | def kill(self):
"Kill the daemon instance."
if self.pid:
try:
os.kill(self.pid, signal.SIGTERM)
# Raises an OSError for ESRCH when we've killed it.
while True:
os.kill(self.pid, signal.SIGTERM)
time.sleep... | python | def kill(self):
"Kill the daemon instance."
if self.pid:
try:
os.kill(self.pid, signal.SIGTERM)
# Raises an OSError for ESRCH when we've killed it.
while True:
os.kill(self.pid, signal.SIGTERM)
time.sleep... | [
"def",
"kill",
"(",
"self",
")",
":",
"if",
"self",
".",
"pid",
":",
"try",
":",
"os",
".",
"kill",
"(",
"self",
".",
"pid",
",",
"signal",
".",
"SIGTERM",
")",
"# Raises an OSError for ESRCH when we've killed it.",
"while",
"True",
":",
"os",
".",
"kill... | Kill the daemon instance. | [
"Kill",
"the",
"daemon",
"instance",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/observatoryControl/gpsd/fake.py#L378-L389 |
klahnakoski/pyLibrary | jx_base/dimensions.py | addParts | def addParts(parentPart, childPath, count, index):
"""
BUILD A hierarchy BY REPEATEDLY CALLING self METHOD WITH VARIOUS childPaths
count IS THE NUMBER FOUND FOR self PATH
"""
if index == None:
index = 0
if index == len(childPath):
return
c = childPath[index]
parentPart.co... | python | def addParts(parentPart, childPath, count, index):
"""
BUILD A hierarchy BY REPEATEDLY CALLING self METHOD WITH VARIOUS childPaths
count IS THE NUMBER FOUND FOR self PATH
"""
if index == None:
index = 0
if index == len(childPath):
return
c = childPath[index]
parentPart.co... | [
"def",
"addParts",
"(",
"parentPart",
",",
"childPath",
",",
"count",
",",
"index",
")",
":",
"if",
"index",
"==",
"None",
":",
"index",
"=",
"0",
"if",
"index",
"==",
"len",
"(",
"childPath",
")",
":",
"return",
"c",
"=",
"childPath",
"[",
"index",
... | BUILD A hierarchy BY REPEATEDLY CALLING self METHOD WITH VARIOUS childPaths
count IS THE NUMBER FOUND FOR self PATH | [
"BUILD",
"A",
"hierarchy",
"BY",
"REPEATEDLY",
"CALLING",
"self",
"METHOD",
"WITH",
"VARIOUS",
"childPaths",
"count",
"IS",
"THE",
"NUMBER",
"FOUND",
"FOR",
"self",
"PATH"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/dimensions.py#L302-L322 |
klahnakoski/pyLibrary | mo_math/crypto.py | encrypt | def encrypt(text, _key, salt=None):
"""
RETURN {"salt":s, "length":l, "data":d} -> JSON -> UTF8
"""
if is_text(text):
encoding = 'utf8'
data = bytearray(text.encode("utf8"))
elif is_binary(text):
encoding = None
if PY2:
data = bytearray(text)
else... | python | def encrypt(text, _key, salt=None):
"""
RETURN {"salt":s, "length":l, "data":d} -> JSON -> UTF8
"""
if is_text(text):
encoding = 'utf8'
data = bytearray(text.encode("utf8"))
elif is_binary(text):
encoding = None
if PY2:
data = bytearray(text)
else... | [
"def",
"encrypt",
"(",
"text",
",",
"_key",
",",
"salt",
"=",
"None",
")",
":",
"if",
"is_text",
"(",
"text",
")",
":",
"encoding",
"=",
"'utf8'",
"data",
"=",
"bytearray",
"(",
"text",
".",
"encode",
"(",
"\"utf8\"",
")",
")",
"elif",
"is_binary",
... | RETURN {"salt":s, "length":l, "data":d} -> JSON -> UTF8 | [
"RETURN",
"{",
"salt",
":",
"s",
"length",
":",
"l",
"data",
":",
"d",
"}",
"-",
">",
"JSON",
"-",
">",
"UTF8"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/crypto.py#L25-L71 |
klahnakoski/pyLibrary | mo_math/crypto.py | decrypt | def decrypt(data, _key):
"""
ACCEPT BYTES -> UTF8 -> JSON -> {"salt":s, "length":l, "data":d}
"""
# Key and iv have not been generated or provided, bail out
if _key is None:
Log.error("Expecting a key")
_input = get_module("mo_json").json2value(data.decode('utf8'), leaves=False, flexibl... | python | def decrypt(data, _key):
"""
ACCEPT BYTES -> UTF8 -> JSON -> {"salt":s, "length":l, "data":d}
"""
# Key and iv have not been generated or provided, bail out
if _key is None:
Log.error("Expecting a key")
_input = get_module("mo_json").json2value(data.decode('utf8'), leaves=False, flexibl... | [
"def",
"decrypt",
"(",
"data",
",",
"_key",
")",
":",
"# Key and iv have not been generated or provided, bail out",
"if",
"_key",
"is",
"None",
":",
"Log",
".",
"error",
"(",
"\"Expecting a key\"",
")",
"_input",
"=",
"get_module",
"(",
"\"mo_json\"",
")",
".",
... | ACCEPT BYTES -> UTF8 -> JSON -> {"salt":s, "length":l, "data":d} | [
"ACCEPT",
"BYTES",
"-",
">",
"UTF8",
"-",
">",
"JSON",
"-",
">",
"{",
"salt",
":",
"s",
"length",
":",
"l",
"data",
":",
"d",
"}"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/crypto.py#L74-L99 |
ff0000/scarlet | scarlet/cms/widgets.py | APIChoiceWidget.get_qs | def get_qs(self):
"""
Returns a mapping that will be used to generate
the query string for the api url. Any values
in the the `limit_choices_to` specified on the
foreign key field and any arguments specified on
self.extra_query_kwargs are converted to a format
tha... | python | def get_qs(self):
"""
Returns a mapping that will be used to generate
the query string for the api url. Any values
in the the `limit_choices_to` specified on the
foreign key field and any arguments specified on
self.extra_query_kwargs are converted to a format
tha... | [
"def",
"get_qs",
"(",
"self",
")",
":",
"qs",
"=",
"url_params_from_lookup_dict",
"(",
"self",
".",
"rel",
".",
"limit_choices_to",
")",
"if",
"not",
"qs",
":",
"qs",
"=",
"{",
"}",
"if",
"self",
".",
"extra_query_kwargs",
":",
"qs",
".",
"update",
"("... | Returns a mapping that will be used to generate
the query string for the api url. Any values
in the the `limit_choices_to` specified on the
foreign key field and any arguments specified on
self.extra_query_kwargs are converted to a format
that can be used in a query string and re... | [
"Returns",
"a",
"mapping",
"that",
"will",
"be",
"used",
"to",
"generate",
"the",
"query",
"string",
"for",
"the",
"api",
"url",
".",
"Any",
"values",
"in",
"the",
"the",
"limit_choices_to",
"specified",
"on",
"the",
"foreign",
"key",
"field",
"and",
"any"... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/widgets.py#L460-L476 |
ff0000/scarlet | scarlet/cms/widgets.py | APIChoiceWidget.get_api_link | def get_api_link(self):
"""
Adds a query string to the api url. At minimum adds the type=choices
argument so that the return format is json. Any other filtering
arguments calculated by the `get_qs` method are then added to the
url. It is up to the destination url to respect them ... | python | def get_api_link(self):
"""
Adds a query string to the api url. At minimum adds the type=choices
argument so that the return format is json. Any other filtering
arguments calculated by the `get_qs` method are then added to the
url. It is up to the destination url to respect them ... | [
"def",
"get_api_link",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_api_link",
"if",
"url",
":",
"qs",
"=",
"self",
".",
"get_qs",
"(",
")",
"url",
"=",
"\"%s?type=choices\"",
"%",
"url",
"if",
"qs",
":",
"url",
"=",
"\"%s&%s\"",
"%",
"(",
... | Adds a query string to the api url. At minimum adds the type=choices
argument so that the return format is json. Any other filtering
arguments calculated by the `get_qs` method are then added to the
url. It is up to the destination url to respect them as filters. | [
"Adds",
"a",
"query",
"string",
"to",
"the",
"api",
"url",
".",
"At",
"minimum",
"adds",
"the",
"type",
"=",
"choices",
"argument",
"so",
"that",
"the",
"return",
"format",
"is",
"json",
".",
"Any",
"other",
"filtering",
"arguments",
"calculated",
"by",
... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/widgets.py#L509-L525 |
ff0000/scarlet | scarlet/cms/widgets.py | APIChoiceWidget.label_for_value | def label_for_value(self, value, key=None):
"""
Looks up the current value of the field and returns
a unicode representation. Default implementation does a lookup
on the target model and if a match is found calls force_unicode
on that object. Otherwise a blank string is returned.... | python | def label_for_value(self, value, key=None):
"""
Looks up the current value of the field and returns
a unicode representation. Default implementation does a lookup
on the target model and if a match is found calls force_unicode
on that object. Otherwise a blank string is returned.... | [
"def",
"label_for_value",
"(",
"self",
",",
"value",
",",
"key",
"=",
"None",
")",
":",
"if",
"not",
"key",
":",
"key",
"=",
"self",
".",
"rel",
".",
"get_related_field",
"(",
")",
".",
"name",
"if",
"value",
"is",
"not",
"None",
":",
"try",
":",
... | Looks up the current value of the field and returns
a unicode representation. Default implementation does a lookup
on the target model and if a match is found calls force_unicode
on that object. Otherwise a blank string is returned. | [
"Looks",
"up",
"the",
"current",
"value",
"of",
"the",
"field",
"and",
"returns",
"a",
"unicode",
"representation",
".",
"Default",
"implementation",
"does",
"a",
"lookup",
"on",
"the",
"target",
"model",
"and",
"if",
"a",
"match",
"is",
"found",
"calls",
... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/widgets.py#L537-L553 |
ff0000/scarlet | scarlet/cms/widgets.py | APIManyChoiceWidget.update_links | def update_links(self, request, admin_site=None):
"""
Called to update the widget's urls. Tries to find the
bundle for the model that this foreign key points to and then
asks it for the urls for adding and listing and sets them on
this widget instance. The urls are only set if re... | python | def update_links(self, request, admin_site=None):
"""
Called to update the widget's urls. Tries to find the
bundle for the model that this foreign key points to and then
asks it for the urls for adding and listing and sets them on
this widget instance. The urls are only set if re... | [
"def",
"update_links",
"(",
"self",
",",
"request",
",",
"admin_site",
"=",
"None",
")",
":",
"if",
"admin_site",
":",
"bundle",
"=",
"admin_site",
".",
"get_bundle_for_model",
"(",
"self",
".",
"model",
".",
"to",
")",
"if",
"bundle",
":",
"self",
".",
... | Called to update the widget's urls. Tries to find the
bundle for the model that this foreign key points to and then
asks it for the urls for adding and listing and sets them on
this widget instance. The urls are only set if request.user
has permissions on that url.
:param reques... | [
"Called",
"to",
"update",
"the",
"widget",
"s",
"urls",
".",
"Tries",
"to",
"find",
"the",
"bundle",
"for",
"the",
"model",
"that",
"this",
"foreign",
"key",
"points",
"to",
"and",
"then",
"asks",
"it",
"for",
"the",
"urls",
"for",
"adding",
"and",
"li... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/widgets.py#L640-L660 |
jeremyschulman/halutz | halutz/class_factory.py | SchemaObjectFactory.schema_class | def schema_class(self, object_schema, model_name, classes=False):
"""
Create a object-class based on the object_schema. Use
this class to create specific instances, and validate the
data values. See the "python-jsonschema-objects" package
for details on further usage.
... | python | def schema_class(self, object_schema, model_name, classes=False):
"""
Create a object-class based on the object_schema. Use
this class to create specific instances, and validate the
data values. See the "python-jsonschema-objects" package
for details on further usage.
... | [
"def",
"schema_class",
"(",
"self",
",",
"object_schema",
",",
"model_name",
",",
"classes",
"=",
"False",
")",
":",
"# if not model_name:",
"# model_name = SchemaObjectFactory.schema_model_name(object_schema)",
"cls_bldr",
"=",
"ClassBuilder",
"(",
"self",
".",
"reso... | Create a object-class based on the object_schema. Use
this class to create specific instances, and validate the
data values. See the "python-jsonschema-objects" package
for details on further usage.
Parameters
----------
object_schema : dict
The JSON-schema... | [
"Create",
"a",
"object",
"-",
"class",
"based",
"on",
"the",
"object_schema",
".",
"Use",
"this",
"class",
"to",
"create",
"specific",
"instances",
"and",
"validate",
"the",
"data",
"values",
".",
"See",
"the",
"python",
"-",
"jsonschema",
"-",
"objects",
... | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/class_factory.py#L45-L90 |
jeremyschulman/halutz | halutz/class_factory.py | SchemaObjectFactory.__model_class | def __model_class(self, model_name):
""" this method is used by the lru_cache, do not call directly """
build_schema = deepcopy(self.definitions[model_name])
return self.schema_class(build_schema, model_name) | python | def __model_class(self, model_name):
""" this method is used by the lru_cache, do not call directly """
build_schema = deepcopy(self.definitions[model_name])
return self.schema_class(build_schema, model_name) | [
"def",
"__model_class",
"(",
"self",
",",
"model_name",
")",
":",
"build_schema",
"=",
"deepcopy",
"(",
"self",
".",
"definitions",
"[",
"model_name",
"]",
")",
"return",
"self",
".",
"schema_class",
"(",
"build_schema",
",",
"model_name",
")"
] | this method is used by the lru_cache, do not call directly | [
"this",
"method",
"is",
"used",
"by",
"the",
"lru_cache",
"do",
"not",
"call",
"directly"
] | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/class_factory.py#L92-L95 |
cathalgarvey/deadlock | deadlock/passwords/zxcvbn/scoring.py | binom | def binom(n, k):
"""
Returns binomial coefficient (n choose k).
"""
# http://blog.plover.com/math/choose.html
if k > n:
return 0
if k == 0:
return 1
result = 1
for denom in range(1, k + 1):
result *= n
result /= denom
n -= 1
return result | python | def binom(n, k):
"""
Returns binomial coefficient (n choose k).
"""
# http://blog.plover.com/math/choose.html
if k > n:
return 0
if k == 0:
return 1
result = 1
for denom in range(1, k + 1):
result *= n
result /= denom
n -= 1
return result | [
"def",
"binom",
"(",
"n",
",",
"k",
")",
":",
"# http://blog.plover.com/math/choose.html",
"if",
"k",
">",
"n",
":",
"return",
"0",
"if",
"k",
"==",
"0",
":",
"return",
"1",
"result",
"=",
"1",
"for",
"denom",
"in",
"range",
"(",
"1",
",",
"k",
"+"... | Returns binomial coefficient (n choose k). | [
"Returns",
"binomial",
"coefficient",
"(",
"n",
"choose",
"k",
")",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/passwords/zxcvbn/scoring.py#L7-L21 |
cathalgarvey/deadlock | deadlock/passwords/zxcvbn/scoring.py | minimum_entropy_match_sequence | def minimum_entropy_match_sequence(password, matches):
"""
Returns minimum entropy
Takes a list of overlapping matches, returns the non-overlapping sublist with
minimum entropy. O(nm) dp alg for length-n password with m candidate matches.
"""
bruteforce_cardinality = calc_bruteforce_cardinality... | python | def minimum_entropy_match_sequence(password, matches):
"""
Returns minimum entropy
Takes a list of overlapping matches, returns the non-overlapping sublist with
minimum entropy. O(nm) dp alg for length-n password with m candidate matches.
"""
bruteforce_cardinality = calc_bruteforce_cardinality... | [
"def",
"minimum_entropy_match_sequence",
"(",
"password",
",",
"matches",
")",
":",
"bruteforce_cardinality",
"=",
"calc_bruteforce_cardinality",
"(",
"password",
")",
"# e.g. 26 for lowercase",
"up_to_k",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"password",
")",
"# min... | Returns minimum entropy
Takes a list of overlapping matches, returns the non-overlapping sublist with
minimum entropy. O(nm) dp alg for length-n password with m candidate matches. | [
"Returns",
"minimum",
"entropy"
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/passwords/zxcvbn/scoring.py#L43-L119 |
cathalgarvey/deadlock | deadlock/passwords/zxcvbn/scoring.py | round_to_x_digits | def round_to_x_digits(number, digits):
"""
Returns 'number' rounded to 'digits' digits.
"""
return round(number * math.pow(10, digits)) / math.pow(10, digits) | python | def round_to_x_digits(number, digits):
"""
Returns 'number' rounded to 'digits' digits.
"""
return round(number * math.pow(10, digits)) / math.pow(10, digits) | [
"def",
"round_to_x_digits",
"(",
"number",
",",
"digits",
")",
":",
"return",
"round",
"(",
"number",
"*",
"math",
".",
"pow",
"(",
"10",
",",
"digits",
")",
")",
"/",
"math",
".",
"pow",
"(",
"10",
",",
"digits",
")"
] | Returns 'number' rounded to 'digits' digits. | [
"Returns",
"number",
"rounded",
"to",
"digits",
"digits",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/passwords/zxcvbn/scoring.py#L122-L126 |
klahnakoski/pyLibrary | jx_python/containers/cube.py | Cube.values | def values(self):
"""
TRY NOT TO USE THIS, IT IS SLOW
"""
matrix = self.data.values()[0] # CANONICAL REPRESENTATIVE
if matrix.num == 0:
return
e_names = self.edges.name
s_names = self.select.name
parts = [e.domain.partitions.value if e.domain.... | python | def values(self):
"""
TRY NOT TO USE THIS, IT IS SLOW
"""
matrix = self.data.values()[0] # CANONICAL REPRESENTATIVE
if matrix.num == 0:
return
e_names = self.edges.name
s_names = self.select.name
parts = [e.domain.partitions.value if e.domain.... | [
"def",
"values",
"(",
"self",
")",
":",
"matrix",
"=",
"self",
".",
"data",
".",
"values",
"(",
")",
"[",
"0",
"]",
"# CANONICAL REPRESENTATIVE",
"if",
"matrix",
".",
"num",
"==",
"0",
":",
"return",
"e_names",
"=",
"self",
".",
"edges",
".",
"name",... | TRY NOT TO USE THIS, IT IS SLOW | [
"TRY",
"NOT",
"TO",
"USE",
"THIS",
"IT",
"IS",
"SLOW"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/containers/cube.py#L123-L140 |
klahnakoski/pyLibrary | jx_python/containers/cube.py | Cube.forall | def forall(self, method):
"""
TODO: I AM NOT HAPPY THAT THIS WILL NOT WORK WELL WITH WINDOW FUNCTIONS
THE parts GIVE NO INDICATION OF NEXT ITEM OR PREVIOUS ITEM LIKE rownum
DOES. MAYBE ALGEBRAIC EDGES SHOULD BE LOOPED DIFFERENTLY? ON THE
OTHER HAND, MAYBE WINDOW FUNCTIONS ARE R... | python | def forall(self, method):
"""
TODO: I AM NOT HAPPY THAT THIS WILL NOT WORK WELL WITH WINDOW FUNCTIONS
THE parts GIVE NO INDICATION OF NEXT ITEM OR PREVIOUS ITEM LIKE rownum
DOES. MAYBE ALGEBRAIC EDGES SHOULD BE LOOPED DIFFERENTLY? ON THE
OTHER HAND, MAYBE WINDOW FUNCTIONS ARE R... | [
"def",
"forall",
"(",
"self",
",",
"method",
")",
":",
"if",
"not",
"self",
".",
"is_value",
":",
"Log",
".",
"error",
"(",
"\"Not dealing with this case yet\"",
")",
"matrix",
"=",
"self",
".",
"data",
".",
"values",
"(",
")",
"[",
"0",
"]",
"parts",
... | TODO: I AM NOT HAPPY THAT THIS WILL NOT WORK WELL WITH WINDOW FUNCTIONS
THE parts GIVE NO INDICATION OF NEXT ITEM OR PREVIOUS ITEM LIKE rownum
DOES. MAYBE ALGEBRAIC EDGES SHOULD BE LOOPED DIFFERENTLY? ON THE
OTHER HAND, MAYBE WINDOW FUNCTIONS ARE RESPONSIBLE FOR THIS COMPLICATION
MAR 2... | [
"TODO",
":",
"I",
"AM",
"NOT",
"HAPPY",
"THAT",
"THIS",
"WILL",
"NOT",
"WORK",
"WELL",
"WITH",
"WINDOW",
"FUNCTIONS",
"THE",
"parts",
"GIVE",
"NO",
"INDICATION",
"OF",
"NEXT",
"ITEM",
"OR",
"PREVIOUS",
"ITEM",
"LIKE",
"rownum",
"DOES",
".",
"MAYBE",
"ALG... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/containers/cube.py#L260-L279 |
klahnakoski/pyLibrary | jx_python/containers/cube.py | Cube._groupby | def _groupby(self, edges):
"""
RETURNS LIST OF (coord, values) TUPLES, WHERE
coord IS THE INDEX INTO self CUBE (-1 INDEX FOR COORDINATES NOT GROUPED BY)
values ALL VALUES THAT BELONG TO THE SLICE
"""
edges = FlatList([n for e in edges for n in _normalize_edge(e)]... | python | def _groupby(self, edges):
"""
RETURNS LIST OF (coord, values) TUPLES, WHERE
coord IS THE INDEX INTO self CUBE (-1 INDEX FOR COORDINATES NOT GROUPED BY)
values ALL VALUES THAT BELONG TO THE SLICE
"""
edges = FlatList([n for e in edges for n in _normalize_edge(e)]... | [
"def",
"_groupby",
"(",
"self",
",",
"edges",
")",
":",
"edges",
"=",
"FlatList",
"(",
"[",
"n",
"for",
"e",
"in",
"edges",
"for",
"n",
"in",
"_normalize_edge",
"(",
"e",
")",
"]",
")",
"stacked",
"=",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"... | RETURNS LIST OF (coord, values) TUPLES, WHERE
coord IS THE INDEX INTO self CUBE (-1 INDEX FOR COORDINATES NOT GROUPED BY)
values ALL VALUES THAT BELONG TO THE SLICE | [
"RETURNS",
"LIST",
"OF",
"(",
"coord",
"values",
")",
"TUPLES",
"WHERE",
"coord",
"IS",
"THE",
"INDEX",
"INTO",
"self",
"CUBE",
"(",
"-",
"1",
"INDEX",
"FOR",
"COORDINATES",
"NOT",
"GROUPED",
"BY",
")",
"values",
"ALL",
"VALUES",
"THAT",
"BELONG",
"TO",
... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/containers/cube.py#L300-L350 |
jeremyschulman/halutz | halutz/client.py | Client.save_swagger_spec | def save_swagger_spec(self, filepath=None):
"""
Saves a copy of the origin_spec to a local file in JSON format
"""
if filepath is True or filepath is None:
filepath = self.file_spec.format(server=self.server)
json.dump(self.origin_spec, open(filepath, 'w+'), indent=3... | python | def save_swagger_spec(self, filepath=None):
"""
Saves a copy of the origin_spec to a local file in JSON format
"""
if filepath is True or filepath is None:
filepath = self.file_spec.format(server=self.server)
json.dump(self.origin_spec, open(filepath, 'w+'), indent=3... | [
"def",
"save_swagger_spec",
"(",
"self",
",",
"filepath",
"=",
"None",
")",
":",
"if",
"filepath",
"is",
"True",
"or",
"filepath",
"is",
"None",
":",
"filepath",
"=",
"self",
".",
"file_spec",
".",
"format",
"(",
"server",
"=",
"self",
".",
"server",
"... | Saves a copy of the origin_spec to a local file in JSON format | [
"Saves",
"a",
"copy",
"of",
"the",
"origin_spec",
"to",
"a",
"local",
"file",
"in",
"JSON",
"format"
] | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/client.py#L89-L96 |
jeremyschulman/halutz | halutz/client.py | Client.load_swagger_spec | def load_swagger_spec(self, filepath=None):
"""
Loads the origin_spec from a local JSON file. If `filepath`
is not provided, then the class `file_spec` format will be used
to create the file-path value.
"""
if filepath is True or filepath is None:
filepath = ... | python | def load_swagger_spec(self, filepath=None):
"""
Loads the origin_spec from a local JSON file. If `filepath`
is not provided, then the class `file_spec` format will be used
to create the file-path value.
"""
if filepath is True or filepath is None:
filepath = ... | [
"def",
"load_swagger_spec",
"(",
"self",
",",
"filepath",
"=",
"None",
")",
":",
"if",
"filepath",
"is",
"True",
"or",
"filepath",
"is",
"None",
":",
"filepath",
"=",
"self",
".",
"file_spec",
".",
"format",
"(",
"server",
"=",
"self",
".",
"server",
"... | Loads the origin_spec from a local JSON file. If `filepath`
is not provided, then the class `file_spec` format will be used
to create the file-path value. | [
"Loads",
"the",
"origin_spec",
"from",
"a",
"local",
"JSON",
"file",
".",
"If",
"filepath",
"is",
"not",
"provided",
"then",
"the",
"class",
"file_spec",
"format",
"will",
"be",
"used",
"to",
"create",
"the",
"file",
"-",
"path",
"value",
"."
] | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/client.py#L98-L107 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/param/preprocessing.py | preprocess_legislation | def preprocess_legislation(legislation_json):
'''
Preprocess the legislation parameters to add prices and amounts from national accounts
'''
import os
import pkg_resources
import pandas as pd
# Add fuel prices to the tree
default_config_files_directory = os.path.join(
pkg_resou... | python | def preprocess_legislation(legislation_json):
'''
Preprocess the legislation parameters to add prices and amounts from national accounts
'''
import os
import pkg_resources
import pandas as pd
# Add fuel prices to the tree
default_config_files_directory = os.path.join(
pkg_resou... | [
"def",
"preprocess_legislation",
"(",
"legislation_json",
")",
":",
"import",
"os",
"import",
"pkg_resources",
"import",
"pandas",
"as",
"pd",
"# Add fuel prices to the tree",
"default_config_files_directory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pkg_resources",
... | Preprocess the legislation parameters to add prices and amounts from national accounts | [
"Preprocess",
"the",
"legislation",
"parameters",
"to",
"add",
"prices",
"and",
"amounts",
"from",
"national",
"accounts"
] | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/param/preprocessing.py#L29-L475 |
SkyLothar/requests-aliyun | aliyunauth/oss.py | OssAuth.set_more_headers | def set_more_headers(self, req, extra_headers=None):
"""Set content-type, content-md5, date to the request
Returns a new `PreparedRequest`
:param req: the origin unsigned request
:param extra_headers: extra headers you want to set, pass as dict
"""
oss_url = url.URL(req.... | python | def set_more_headers(self, req, extra_headers=None):
"""Set content-type, content-md5, date to the request
Returns a new `PreparedRequest`
:param req: the origin unsigned request
:param extra_headers: extra headers you want to set, pass as dict
"""
oss_url = url.URL(req.... | [
"def",
"set_more_headers",
"(",
"self",
",",
"req",
",",
"extra_headers",
"=",
"None",
")",
":",
"oss_url",
"=",
"url",
".",
"URL",
"(",
"req",
".",
"url",
")",
"req",
".",
"headers",
".",
"update",
"(",
"extra_headers",
"or",
"{",
"}",
")",
"# set c... | Set content-type, content-md5, date to the request
Returns a new `PreparedRequest`
:param req: the origin unsigned request
:param extra_headers: extra headers you want to set, pass as dict | [
"Set",
"content",
"-",
"type",
"content",
"-",
"md5",
"date",
"to",
"the",
"request",
"Returns",
"a",
"new",
"PreparedRequest"
] | train | https://github.com/SkyLothar/requests-aliyun/blob/43f6646dcf7f09691ae997b09d365ad9e76386cf/aliyunauth/oss.py#L105-L144 |
SkyLothar/requests-aliyun | aliyunauth/oss.py | OssAuth.get_signature | def get_signature(self, req):
"""calculate the signature of the oss request
Returns the signatue
"""
oss_url = url.URL(req.url)
oss_headers = [
"{0}:{1}\n".format(key, val)
for key, val in req.headers.lower_items()
if key.startswith(self.X_OSS... | python | def get_signature(self, req):
"""calculate the signature of the oss request
Returns the signatue
"""
oss_url = url.URL(req.url)
oss_headers = [
"{0}:{1}\n".format(key, val)
for key, val in req.headers.lower_items()
if key.startswith(self.X_OSS... | [
"def",
"get_signature",
"(",
"self",
",",
"req",
")",
":",
"oss_url",
"=",
"url",
".",
"URL",
"(",
"req",
".",
"url",
")",
"oss_headers",
"=",
"[",
"\"{0}:{1}\\n\"",
".",
"format",
"(",
"key",
",",
"val",
")",
"for",
"key",
",",
"val",
"in",
"req",... | calculate the signature of the oss request
Returns the signatue | [
"calculate",
"the",
"signature",
"of",
"the",
"oss",
"request",
"Returns",
"the",
"signatue"
] | train | https://github.com/SkyLothar/requests-aliyun/blob/43f6646dcf7f09691ae997b09d365ad9e76386cf/aliyunauth/oss.py#L146-L191 |
klahnakoski/pyLibrary | jx_python/namespace/rename.py | Rename.convert | def convert(self, expr):
"""
EXPAND INSTANCES OF name TO value
"""
if expr is True or expr == None or expr is False:
return expr
elif is_number(expr):
return expr
elif expr == ".":
return "."
elif is_variable_name(expr):
... | python | def convert(self, expr):
"""
EXPAND INSTANCES OF name TO value
"""
if expr is True or expr == None or expr is False:
return expr
elif is_number(expr):
return expr
elif expr == ".":
return "."
elif is_variable_name(expr):
... | [
"def",
"convert",
"(",
"self",
",",
"expr",
")",
":",
"if",
"expr",
"is",
"True",
"or",
"expr",
"==",
"None",
"or",
"expr",
"is",
"False",
":",
"return",
"expr",
"elif",
"is_number",
"(",
"expr",
")",
":",
"return",
"expr",
"elif",
"expr",
"==",
"\... | EXPAND INSTANCES OF name TO value | [
"EXPAND",
"INSTANCES",
"OF",
"name",
"TO",
"value"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/namespace/rename.py#L39-L70 |
klahnakoski/pyLibrary | jx_python/namespace/rename.py | Rename._convert_clause | def _convert_clause(self, clause):
"""
JSON QUERY EXPRESSIONS HAVE MANY CLAUSES WITH SIMILAR COLUMN DELCARATIONS
"""
clause = wrap(clause)
if clause == None:
return None
elif is_data(clause):
return set_default({"value": self.convert(clause.value)... | python | def _convert_clause(self, clause):
"""
JSON QUERY EXPRESSIONS HAVE MANY CLAUSES WITH SIMILAR COLUMN DELCARATIONS
"""
clause = wrap(clause)
if clause == None:
return None
elif is_data(clause):
return set_default({"value": self.convert(clause.value)... | [
"def",
"_convert_clause",
"(",
"self",
",",
"clause",
")",
":",
"clause",
"=",
"wrap",
"(",
"clause",
")",
"if",
"clause",
"==",
"None",
":",
"return",
"None",
"elif",
"is_data",
"(",
"clause",
")",
":",
"return",
"set_default",
"(",
"{",
"\"value\"",
... | JSON QUERY EXPRESSIONS HAVE MANY CLAUSES WITH SIMILAR COLUMN DELCARATIONS | [
"JSON",
"QUERY",
"EXPRESSIONS",
"HAVE",
"MANY",
"CLAUSES",
"WITH",
"SIMILAR",
"COLUMN",
"DELCARATIONS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/namespace/rename.py#L119-L130 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_obstory_ids | def get_obstory_ids(self):
"""
Retrieve the IDs of all obstorys.
:return:
A list of obstory IDs for all obstorys
"""
self.con.execute('SELECT publicId FROM archive_observatories;')
return map(lambda row: row['publicId'], self.con.fetchall()) | python | def get_obstory_ids(self):
"""
Retrieve the IDs of all obstorys.
:return:
A list of obstory IDs for all obstorys
"""
self.con.execute('SELECT publicId FROM archive_observatories;')
return map(lambda row: row['publicId'], self.con.fetchall()) | [
"def",
"get_obstory_ids",
"(",
"self",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT publicId FROM archive_observatories;'",
")",
"return",
"map",
"(",
"lambda",
"row",
":",
"row",
"[",
"'publicId'",
"]",
",",
"self",
".",
"con",
".",
"fetchall... | Retrieve the IDs of all obstorys.
:return:
A list of obstory IDs for all obstorys | [
"Retrieve",
"the",
"IDs",
"of",
"all",
"obstorys",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L163-L171 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.has_obstory_metadata | def has_obstory_metadata(self, status_id):
"""
Check for the presence of the given metadata item
:param string status_id:
The metadata item ID
:return:
True if we have a metadata item with this ID, False otherwise
"""
self.con.execute('SELECT 1 FR... | python | def has_obstory_metadata(self, status_id):
"""
Check for the presence of the given metadata item
:param string status_id:
The metadata item ID
:return:
True if we have a metadata item with this ID, False otherwise
"""
self.con.execute('SELECT 1 FR... | [
"def",
"has_obstory_metadata",
"(",
"self",
",",
"status_id",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT 1 FROM archive_metadata WHERE publicId=%s;'",
",",
"(",
"status_id",
",",
")",
")",
"return",
"len",
"(",
"self",
".",
"con",
".",
"fetcha... | Check for the presence of the given metadata item
:param string status_id:
The metadata item ID
:return:
True if we have a metadata item with this ID, False otherwise | [
"Check",
"for",
"the",
"presence",
"of",
"the",
"given",
"metadata",
"item"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L178-L188 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.has_file_id | def has_file_id(self, repository_fname):
"""
Check for the presence of the given file_id
:param string repository_fname:
The file ID
:return:
True if we have a :class:`meteorpi_model.FileRecord` with this ID, False otherwise
"""
self.con.execute('... | python | def has_file_id(self, repository_fname):
"""
Check for the presence of the given file_id
:param string repository_fname:
The file ID
:return:
True if we have a :class:`meteorpi_model.FileRecord` with this ID, False otherwise
"""
self.con.execute('... | [
"def",
"has_file_id",
"(",
"self",
",",
"repository_fname",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT 1 FROM archive_files WHERE repositoryFname = %s'",
",",
"(",
"repository_fname",
",",
")",
")",
"return",
"len",
"(",
"self",
".",
"con",
".",... | Check for the presence of the given file_id
:param string repository_fname:
The file ID
:return:
True if we have a :class:`meteorpi_model.FileRecord` with this ID, False otherwise | [
"Check",
"for",
"the",
"presence",
"of",
"the",
"given",
"file_id"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L333-L343 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_file | def get_file(self, repository_fname):
"""
Retrieve an existing :class:`meteorpi_model.FileRecord` by its ID
:param string repository_fname:
The file ID
:return:
A :class:`meteorpi_model.FileRecord` instance, or None if not found
"""
search = mp.Fi... | python | def get_file(self, repository_fname):
"""
Retrieve an existing :class:`meteorpi_model.FileRecord` by its ID
:param string repository_fname:
The file ID
:return:
A :class:`meteorpi_model.FileRecord` instance, or None if not found
"""
search = mp.Fi... | [
"def",
"get_file",
"(",
"self",
",",
"repository_fname",
")",
":",
"search",
"=",
"mp",
".",
"FileRecordSearch",
"(",
"repository_fname",
"=",
"repository_fname",
")",
"b",
"=",
"search_files_sql_builder",
"(",
"search",
")",
"sql",
"=",
"b",
".",
"get_select_... | Retrieve an existing :class:`meteorpi_model.FileRecord` by its ID
:param string repository_fname:
The file ID
:return:
A :class:`meteorpi_model.FileRecord` instance, or None if not found | [
"Retrieve",
"an",
"existing",
":",
"class",
":",
"meteorpi_model",
".",
"FileRecord",
"by",
"its",
"ID"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L354-L373 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.search_files | def search_files(self, search):
"""
Search for :class:`meteorpi_model.FileRecord` entities
:param search:
an instance of :class:`meteorpi_model.FileRecordSearch` used to constrain the observations returned from
the DB
:return:
a structure of {count:in... | python | def search_files(self, search):
"""
Search for :class:`meteorpi_model.FileRecord` entities
:param search:
an instance of :class:`meteorpi_model.FileRecordSearch` used to constrain the observations returned from
the DB
:return:
a structure of {count:in... | [
"def",
"search_files",
"(",
"self",
",",
"search",
")",
":",
"b",
"=",
"search_files_sql_builder",
"(",
"search",
")",
"sql",
"=",
"b",
".",
"get_select_sql",
"(",
"columns",
"=",
"'f.uid, o.publicId AS observationId, f.mimeType, '",
"'f.fileName, s2.name AS semanticTyp... | Search for :class:`meteorpi_model.FileRecord` entities
:param search:
an instance of :class:`meteorpi_model.FileRecordSearch` used to constrain the observations returned from
the DB
:return:
a structure of {count:int total rows of an unrestricted search, observations... | [
"Search",
"for",
":",
"class",
":",
"meteorpi_model",
".",
"FileRecord",
"entities"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L375-L401 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.register_file | def register_file(self, observation_id, user_id, file_path, file_time, mime_type, semantic_type,
file_md5=None, file_meta=None):
"""
Register a file in the database, also moving the file into the file store. Returns the corresponding FileRecord
object.
:param obser... | python | def register_file(self, observation_id, user_id, file_path, file_time, mime_type, semantic_type,
file_md5=None, file_meta=None):
"""
Register a file in the database, also moving the file into the file store. Returns the corresponding FileRecord
object.
:param obser... | [
"def",
"register_file",
"(",
"self",
",",
"observation_id",
",",
"user_id",
",",
"file_path",
",",
"file_time",
",",
"mime_type",
",",
"semantic_type",
",",
"file_md5",
"=",
"None",
",",
"file_meta",
"=",
"None",
")",
":",
"if",
"file_meta",
"is",
"None",
... | Register a file in the database, also moving the file into the file store. Returns the corresponding FileRecord
object.
:param observation_id:
The publicId of the observation this file belongs to
:param string user_id:
The ID of the user who created this file
:pa... | [
"Register",
"a",
"file",
"in",
"the",
"database",
"also",
"moving",
"the",
"file",
"into",
"the",
"file",
"store",
".",
"Returns",
"the",
"corresponding",
"FileRecord",
"object",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L403-L489 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.has_observation_id | def has_observation_id(self, observation_id):
"""
Check for the presence of the given observation_id
:param string observation_id:
The observation ID
:return:
True if we have a :class:`meteorpi_model.Observation` with this Id, False otherwise
"""
... | python | def has_observation_id(self, observation_id):
"""
Check for the presence of the given observation_id
:param string observation_id:
The observation ID
:return:
True if we have a :class:`meteorpi_model.Observation` with this Id, False otherwise
"""
... | [
"def",
"has_observation_id",
"(",
"self",
",",
"observation_id",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT 1 FROM archive_observations WHERE publicId = %s'",
",",
"(",
"observation_id",
",",
")",
")",
"return",
"len",
"(",
"self",
".",
"con",
"... | Check for the presence of the given observation_id
:param string observation_id:
The observation ID
:return:
True if we have a :class:`meteorpi_model.Observation` with this Id, False otherwise | [
"Check",
"for",
"the",
"presence",
"of",
"the",
"given",
"observation_id"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L551-L561 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_observation | def get_observation(self, observation_id):
"""
Retrieve an existing :class:`meteorpi_model.Observation` by its ID
:param string observation_id:
UUID of the observation
:return:
A :class:`meteorpi_model.Observation` instance, or None if not found
"""
... | python | def get_observation(self, observation_id):
"""
Retrieve an existing :class:`meteorpi_model.Observation` by its ID
:param string observation_id:
UUID of the observation
:return:
A :class:`meteorpi_model.Observation` instance, or None if not found
"""
... | [
"def",
"get_observation",
"(",
"self",
",",
"observation_id",
")",
":",
"search",
"=",
"mp",
".",
"ObservationSearch",
"(",
"observation_id",
"=",
"observation_id",
")",
"b",
"=",
"search_observations_sql_builder",
"(",
"search",
")",
"sql",
"=",
"b",
".",
"ge... | Retrieve an existing :class:`meteorpi_model.Observation` by its ID
:param string observation_id:
UUID of the observation
:return:
A :class:`meteorpi_model.Observation` instance, or None if not found | [
"Retrieve",
"an",
"existing",
":",
"class",
":",
"meteorpi_model",
".",
"Observation",
"by",
"its",
"ID"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L580-L597 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.search_observations | def search_observations(self, search):
"""
Search for :class:`meteorpi_model.Observation` entities
:param search:
an instance of :class:`meteorpi_model.ObservationSearch` used to constrain the observations returned from
the DB
:return:
a structure of ... | python | def search_observations(self, search):
"""
Search for :class:`meteorpi_model.Observation` entities
:param search:
an instance of :class:`meteorpi_model.ObservationSearch` used to constrain the observations returned from
the DB
:return:
a structure of ... | [
"def",
"search_observations",
"(",
"self",
",",
"search",
")",
":",
"b",
"=",
"search_observations_sql_builder",
"(",
"search",
")",
"sql",
"=",
"b",
".",
"get_select_sql",
"(",
"columns",
"=",
"'l.publicId AS obstory_id, l.name AS obstory_name, '",
"'o.obsTime, s.name ... | Search for :class:`meteorpi_model.Observation` entities
:param search:
an instance of :class:`meteorpi_model.ObservationSearch` used to constrain the observations returned from
the DB
:return:
a structure of {count:int total rows of an unrestricted search, observatio... | [
"Search",
"for",
":",
"class",
":",
"meteorpi_model",
".",
"Observation",
"entities"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L599-L623 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.register_observation | def register_observation(self, obstory_name, user_id, obs_time, obs_type, obs_meta=None):
"""
Register a new observation, updating the database and returning the corresponding Observation object
:param string obstory_name:
The ID of the obstory which produced this observation
... | python | def register_observation(self, obstory_name, user_id, obs_time, obs_type, obs_meta=None):
"""
Register a new observation, updating the database and returning the corresponding Observation object
:param string obstory_name:
The ID of the obstory which produced this observation
... | [
"def",
"register_observation",
"(",
"self",
",",
"obstory_name",
",",
"user_id",
",",
"obs_time",
",",
"obs_type",
",",
"obs_meta",
"=",
"None",
")",
":",
"if",
"obs_meta",
"is",
"None",
":",
"obs_meta",
"=",
"[",
"]",
"# Get obstory id from name",
"obstory",
... | Register a new observation, updating the database and returning the corresponding Observation object
:param string obstory_name:
The ID of the obstory which produced this observation
:param string user_id:
The ID of the user who created this observation
:param float obs_... | [
"Register",
"a",
"new",
"observation",
"updating",
"the",
"database",
"and",
"returning",
"the",
"corresponding",
"Observation",
"object"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L625-L673 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.has_obsgroup_id | def has_obsgroup_id(self, group_id):
"""
Check for the presence of the given group_id
:param string group_id:
The group ID
:return:
True if we have a :class:`meteorpi_model.ObservationGroup` with this Id, False otherwise
"""
self.con.execute('SELE... | python | def has_obsgroup_id(self, group_id):
"""
Check for the presence of the given group_id
:param string group_id:
The group ID
:return:
True if we have a :class:`meteorpi_model.ObservationGroup` with this Id, False otherwise
"""
self.con.execute('SELE... | [
"def",
"has_obsgroup_id",
"(",
"self",
",",
"group_id",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT 1 FROM archive_obs_groups WHERE publicId = %s'",
",",
"(",
"group_id",
",",
")",
")",
"return",
"len",
"(",
"self",
".",
"con",
".",
"fetchall",... | Check for the presence of the given group_id
:param string group_id:
The group ID
:return:
True if we have a :class:`meteorpi_model.ObservationGroup` with this Id, False otherwise | [
"Check",
"for",
"the",
"presence",
"of",
"the",
"given",
"group_id"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L749-L759 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_obsgroup | def get_obsgroup(self, group_id):
"""
Retrieve an existing :class:`meteorpi_model.ObservationGroup` by its ID
:param string group_id:
UUID of the observation
:return:
A :class:`meteorpi_model.Observation` instance, or None if not found
"""
search ... | python | def get_obsgroup(self, group_id):
"""
Retrieve an existing :class:`meteorpi_model.ObservationGroup` by its ID
:param string group_id:
UUID of the observation
:return:
A :class:`meteorpi_model.Observation` instance, or None if not found
"""
search ... | [
"def",
"get_obsgroup",
"(",
"self",
",",
"group_id",
")",
":",
"search",
"=",
"mp",
".",
"ObservationGroupSearch",
"(",
"group_id",
"=",
"group_id",
")",
"b",
"=",
"search_obsgroups_sql_builder",
"(",
"search",
")",
"sql",
"=",
"b",
".",
"get_select_sql",
"(... | Retrieve an existing :class:`meteorpi_model.ObservationGroup` by its ID
:param string group_id:
UUID of the observation
:return:
A :class:`meteorpi_model.Observation` instance, or None if not found | [
"Retrieve",
"an",
"existing",
":",
"class",
":",
"meteorpi_model",
".",
"ObservationGroup",
"by",
"its",
"ID"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L764-L781 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.search_obsgroups | def search_obsgroups(self, search):
"""
Search for :class:`meteorpi_model.ObservationGroup` entities
:param search:
an instance of :class:`meteorpi_model.ObservationGroupSearch` used to constrain the observations returned
from the DB
:return:
a struct... | python | def search_obsgroups(self, search):
"""
Search for :class:`meteorpi_model.ObservationGroup` entities
:param search:
an instance of :class:`meteorpi_model.ObservationGroupSearch` used to constrain the observations returned
from the DB
:return:
a struct... | [
"def",
"search_obsgroups",
"(",
"self",
",",
"search",
")",
":",
"b",
"=",
"search_obsgroups_sql_builder",
"(",
"search",
")",
"sql",
"=",
"b",
".",
"get_select_sql",
"(",
"columns",
"=",
"'g.uid, g.time, g.setAtTime, g.setByUser, g.publicId, g.title,'",
"'s.name AS sem... | Search for :class:`meteorpi_model.ObservationGroup` entities
:param search:
an instance of :class:`meteorpi_model.ObservationGroupSearch` used to constrain the observations returned
from the DB
:return:
a structure of {count:int total rows of an unrestricted search, ... | [
"Search",
"for",
":",
"class",
":",
"meteorpi_model",
".",
"ObservationGroup",
"entities"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L783-L807 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.register_obsgroup | def register_obsgroup(self, title, user_id, semantic_type, obs_time, set_time, obs=None, grp_meta=None):
"""
Register a new observation, updating the database and returning the corresponding Observation object
:param string title:
The title of this observation group
:param s... | python | def register_obsgroup(self, title, user_id, semantic_type, obs_time, set_time, obs=None, grp_meta=None):
"""
Register a new observation, updating the database and returning the corresponding Observation object
:param string title:
The title of this observation group
:param s... | [
"def",
"register_obsgroup",
"(",
"self",
",",
"title",
",",
"user_id",
",",
"semantic_type",
",",
"obs_time",
",",
"set_time",
",",
"obs",
"=",
"None",
",",
"grp_meta",
"=",
"None",
")",
":",
"if",
"grp_meta",
"is",
"None",
":",
"grp_meta",
"=",
"[",
"... | Register a new observation, updating the database and returning the corresponding Observation object
:param string title:
The title of this observation group
:param string user_id:
The ID of the user who created this observation
:param float obs_time:
The UTC... | [
"Register",
"a",
"new",
"observation",
"updating",
"the",
"database",
"and",
"returning",
"the",
"corresponding",
"Observation",
"object"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L809-L864 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_user | def get_user(self, user_id, password):
"""
Retrieve a user record
:param user_id:
the user ID
:param password:
password
:return:
A :class:`meteorpi_model.User` if everything is correct
:raises:
ValueError if the user is fou... | python | def get_user(self, user_id, password):
"""
Retrieve a user record
:param user_id:
the user ID
:param password:
password
:return:
A :class:`meteorpi_model.User` if everything is correct
:raises:
ValueError if the user is fou... | [
"def",
"get_user",
"(",
"self",
",",
"user_id",
",",
"password",
")",
":",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT uid, pwHash FROM archive_users WHERE userId = %s;'",
",",
"(",
"user_id",
",",
")",
")",
"results",
"=",
"self",
".",
"con",
".",
"fe... | Retrieve a user record
:param user_id:
the user ID
:param password:
password
:return:
A :class:`meteorpi_model.User` if everything is correct
:raises:
ValueError if the user is found but password is incorrect or if the user is not found. | [
"Retrieve",
"a",
"user",
"record"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L915-L941 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_users | def get_users(self):
"""
Retrieve all users in the system
:return:
A list of :class:`meteorpi_model.User`
"""
output = []
self.con.execute('SELECT userId, uid FROM archive_users;')
results = self.con.fetchall()
for result in results:
... | python | def get_users(self):
"""
Retrieve all users in the system
:return:
A list of :class:`meteorpi_model.User`
"""
output = []
self.con.execute('SELECT userId, uid FROM archive_users;')
results = self.con.fetchall()
for result in results:
... | [
"def",
"get_users",
"(",
"self",
")",
":",
"output",
"=",
"[",
"]",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT userId, uid FROM archive_users;'",
")",
"results",
"=",
"self",
".",
"con",
".",
"fetchall",
"(",
")",
"for",
"result",
"in",
"results",
... | Retrieve all users in the system
:return:
A list of :class:`meteorpi_model.User` | [
"Retrieve",
"all",
"users",
"in",
"the",
"system"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L943-L960 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.create_or_update_user | def create_or_update_user(self, user_id, password, roles):
"""
Create a new user record, or update an existing one
:param user_id:
user ID to update or create
:param password:
new password, or None to leave unchanged
:param roles:
new roles, o... | python | def create_or_update_user(self, user_id, password, roles):
"""
Create a new user record, or update an existing one
:param user_id:
user ID to update or create
:param password:
new password, or None to leave unchanged
:param roles:
new roles, o... | [
"def",
"create_or_update_user",
"(",
"self",
",",
"user_id",
",",
"password",
",",
"roles",
")",
":",
"action",
"=",
"\"update\"",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT 1 FROM archive_users WHERE userId = %s;'",
",",
"(",
"user_id",
",",
")",
")",
... | Create a new user record, or update an existing one
:param user_id:
user ID to update or create
:param password:
new password, or None to leave unchanged
:param roles:
new roles, or None to leave unchanged
:return:
the action taken, one of... | [
"Create",
"a",
"new",
"user",
"record",
"or",
"update",
"an",
"existing",
"one"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L962-L1011 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_export_configuration | def get_export_configuration(self, config_id):
"""
Retrieve the ExportConfiguration with the given ID
:param string config_id:
ID for which to search
:return:
a :class:`meteorpi_model.ExportConfiguration` or None, or no match was found.
"""
sql = ... | python | def get_export_configuration(self, config_id):
"""
Retrieve the ExportConfiguration with the given ID
:param string config_id:
ID for which to search
:return:
a :class:`meteorpi_model.ExportConfiguration` or None, or no match was found.
"""
sql = ... | [
"def",
"get_export_configuration",
"(",
"self",
",",
"config_id",
")",
":",
"sql",
"=",
"(",
"'SELECT uid, exportConfigId, exportType, searchString, targetURL, '",
"'targetUser, targetPassword, exportName, description, active '",
"'FROM archive_exportConfig WHERE exportConfigId = %s'",
"... | Retrieve the ExportConfiguration with the given ID
:param string config_id:
ID for which to search
:return:
a :class:`meteorpi_model.ExportConfiguration` or None, or no match was found. | [
"Retrieve",
"the",
"ExportConfiguration",
"with",
"the",
"given",
"ID"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L1023-L1037 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_export_configurations | def get_export_configurations(self):
"""
Retrieve all ExportConfigurations held in this db
:return: a list of all :class:`meteorpi_model.ExportConfiguration` on this server
"""
sql = (
'SELECT uid, exportConfigId, exportType, searchString, targetURL, '
't... | python | def get_export_configurations(self):
"""
Retrieve all ExportConfigurations held in this db
:return: a list of all :class:`meteorpi_model.ExportConfiguration` on this server
"""
sql = (
'SELECT uid, exportConfigId, exportType, searchString, targetURL, '
't... | [
"def",
"get_export_configurations",
"(",
"self",
")",
":",
"sql",
"=",
"(",
"'SELECT uid, exportConfigId, exportType, searchString, targetURL, '",
"'targetUser, targetPassword, exportName, description, active '",
"'FROM archive_exportConfig ORDER BY uid DESC'",
")",
"return",
"list",
"... | Retrieve all ExportConfigurations held in this db
:return: a list of all :class:`meteorpi_model.ExportConfiguration` on this server | [
"Retrieve",
"all",
"ExportConfigurations",
"held",
"in",
"this",
"db"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L1039-L1049 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.create_or_update_export_configuration | def create_or_update_export_configuration(self, export_config):
"""
Create a new file export configuration or update an existing one
:param ExportConfiguration export_config:
a :class:`meteorpi_model.ExportConfiguration` containing the specification for the export. If this
... | python | def create_or_update_export_configuration(self, export_config):
"""
Create a new file export configuration or update an existing one
:param ExportConfiguration export_config:
a :class:`meteorpi_model.ExportConfiguration` containing the specification for the export. If this
... | [
"def",
"create_or_update_export_configuration",
"(",
"self",
",",
"export_config",
")",
":",
"search_string",
"=",
"json",
".",
"dumps",
"(",
"obj",
"=",
"export_config",
".",
"search",
".",
"as_dict",
"(",
")",
")",
"user_id",
"=",
"export_config",
".",
"user... | Create a new file export configuration or update an existing one
:param ExportConfiguration export_config:
a :class:`meteorpi_model.ExportConfiguration` containing the specification for the export. If this
doesn't include a 'config_id' field it will be inserted as a new record in the da... | [
"Create",
"a",
"new",
"file",
"export",
"configuration",
"or",
"update",
"an",
"existing",
"one"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L1051-L1092 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.mark_entities_to_export | def mark_entities_to_export(self, export_config):
"""
Apply the specified :class:`meteorpi_model.ExportConfiguration` to the database, running its contained query and
creating rows in t_observationExport or t_fileExport for matching entities.
:param ExportConfiguration export_config:
... | python | def mark_entities_to_export(self, export_config):
"""
Apply the specified :class:`meteorpi_model.ExportConfiguration` to the database, running its contained query and
creating rows in t_observationExport or t_fileExport for matching entities.
:param ExportConfiguration export_config:
... | [
"def",
"mark_entities_to_export",
"(",
"self",
",",
"export_config",
")",
":",
"# Retrieve the internal ID of the export configuration, failing if it hasn't been stored",
"self",
".",
"con",
".",
"execute",
"(",
"'SELECT uid FROM archive_exportConfig WHERE exportConfigID = %s;'",
","... | Apply the specified :class:`meteorpi_model.ExportConfiguration` to the database, running its contained query and
creating rows in t_observationExport or t_fileExport for matching entities.
:param ExportConfiguration export_config:
An instance of :class:`meteorpi_model.ExportConfiguration` t... | [
"Apply",
"the",
"specified",
":",
"class",
":",
"meteorpi_model",
".",
"ExportConfiguration",
"to",
"the",
"database",
"running",
"its",
"contained",
"query",
"and",
"creating",
"rows",
"in",
"t_observationExport",
"or",
"t_fileExport",
"for",
"matching",
"entities"... | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L1102-L1173 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_next_entity_to_export | def get_next_entity_to_export(self):
"""
Examines the archive_observationExport and archive_metadataExport tables, and builds
either a :class:`meteorpi_db.ObservationExportTask` or a :class:`meteorpi_db.MetadataExportTask` as appropriate.
These task objects can be used to retrieve the un... | python | def get_next_entity_to_export(self):
"""
Examines the archive_observationExport and archive_metadataExport tables, and builds
either a :class:`meteorpi_db.ObservationExportTask` or a :class:`meteorpi_db.MetadataExportTask` as appropriate.
These task objects can be used to retrieve the un... | [
"def",
"get_next_entity_to_export",
"(",
"self",
")",
":",
"# If the queue of items waiting to export is old, delete it and fetch a new list from the database",
"if",
"self",
".",
"export_queue_valid_until",
"<",
"time",
".",
"time",
"(",
")",
":",
"self",
".",
"export_queue_... | Examines the archive_observationExport and archive_metadataExport tables, and builds
either a :class:`meteorpi_db.ObservationExportTask` or a :class:`meteorpi_db.MetadataExportTask` as appropriate.
These task objects can be used to retrieve the underlying entity and export configuration, and to update t... | [
"Examines",
"the",
"archive_observationExport",
"and",
"archive_metadataExport",
"tables",
"and",
"builds",
"either",
"a",
":",
"class",
":",
"meteorpi_db",
".",
"ObservationExportTask",
"or",
"a",
":",
"class",
":",
"meteorpi_db",
".",
"MetadataExportTask",
"as",
"... | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L1175-L1266 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/__init__.py | MeteorDatabase.get_high_water_mark | def get_high_water_mark(self, mark_type, obstory_name=None):
"""
Retrieves the high water mark for a given obstory, defaulting to the current installation ID
:param string mark_type:
The type of high water mark to set
:param string obstory_name:
The obstory ID to... | python | def get_high_water_mark(self, mark_type, obstory_name=None):
"""
Retrieves the high water mark for a given obstory, defaulting to the current installation ID
:param string mark_type:
The type of high water mark to set
:param string obstory_name:
The obstory ID to... | [
"def",
"get_high_water_mark",
"(",
"self",
",",
"mark_type",
",",
"obstory_name",
"=",
"None",
")",
":",
"if",
"obstory_name",
"is",
"None",
":",
"obstory_name",
"=",
"self",
".",
"obstory_name",
"obstory",
"=",
"self",
".",
"get_obstory_from_name",
"(",
"obst... | Retrieves the high water mark for a given obstory, defaulting to the current installation ID
:param string mark_type:
The type of high water mark to set
:param string obstory_name:
The obstory ID to check for, or the default installation ID if not specified
:return:
... | [
"Retrieves",
"the",
"high",
"water",
"mark",
"for",
"a",
"given",
"obstory",
"defaulting",
"to",
"the",
"current",
"installation",
"ID"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L1278-L1300 |
klahnakoski/pyLibrary | mo_dots/lists.py | FlatList.get | def get(self, key):
"""
simple `select`
"""
if not Log:
_late_import()
return FlatList(vals=[unwrap(coalesce(_datawrap(v), Null)[key]) for v in _get_list(self)]) | python | def get(self, key):
"""
simple `select`
"""
if not Log:
_late_import()
return FlatList(vals=[unwrap(coalesce(_datawrap(v), Null)[key]) for v in _get_list(self)]) | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"if",
"not",
"Log",
":",
"_late_import",
"(",
")",
"return",
"FlatList",
"(",
"vals",
"=",
"[",
"unwrap",
"(",
"coalesce",
"(",
"_datawrap",
"(",
"v",
")",
",",
"Null",
")",
"[",
"key",
"]",
")",
... | simple `select` | [
"simple",
"select"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/lists.py#L108-L114 |
klahnakoski/pyLibrary | mo_dots/lists.py | FlatList.right | def right(self, num=None):
"""
WITH SLICES BEING FLAT, WE NEED A SIMPLE WAY TO SLICE FROM THE RIGHT [-num:]
"""
if num == None:
return FlatList([_get_list(self)[-1]])
if num <= 0:
return Null
return FlatList(_get_list(self)[-num:]) | python | def right(self, num=None):
"""
WITH SLICES BEING FLAT, WE NEED A SIMPLE WAY TO SLICE FROM THE RIGHT [-num:]
"""
if num == None:
return FlatList([_get_list(self)[-1]])
if num <= 0:
return Null
return FlatList(_get_list(self)[-num:]) | [
"def",
"right",
"(",
"self",
",",
"num",
"=",
"None",
")",
":",
"if",
"num",
"==",
"None",
":",
"return",
"FlatList",
"(",
"[",
"_get_list",
"(",
"self",
")",
"[",
"-",
"1",
"]",
"]",
")",
"if",
"num",
"<=",
"0",
":",
"return",
"Null",
"return"... | WITH SLICES BEING FLAT, WE NEED A SIMPLE WAY TO SLICE FROM THE RIGHT [-num:] | [
"WITH",
"SLICES",
"BEING",
"FLAT",
"WE",
"NEED",
"A",
"SIMPLE",
"WAY",
"TO",
"SLICE",
"FROM",
"THE",
"RIGHT",
"[",
"-",
"num",
":",
"]"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/lists.py#L226-L235 |
klahnakoski/pyLibrary | mo_dots/lists.py | FlatList.left | def left(self, num=None):
"""
NOT REQUIRED, BUT EXISTS AS OPPOSITE OF right()
"""
if num == None:
return FlatList([_get_list(self)[0]])
if num <= 0:
return Null
return FlatList(_get_list(self)[:num]) | python | def left(self, num=None):
"""
NOT REQUIRED, BUT EXISTS AS OPPOSITE OF right()
"""
if num == None:
return FlatList([_get_list(self)[0]])
if num <= 0:
return Null
return FlatList(_get_list(self)[:num]) | [
"def",
"left",
"(",
"self",
",",
"num",
"=",
"None",
")",
":",
"if",
"num",
"==",
"None",
":",
"return",
"FlatList",
"(",
"[",
"_get_list",
"(",
"self",
")",
"[",
"0",
"]",
"]",
")",
"if",
"num",
"<=",
"0",
":",
"return",
"Null",
"return",
"Fla... | NOT REQUIRED, BUT EXISTS AS OPPOSITE OF right() | [
"NOT",
"REQUIRED",
"BUT",
"EXISTS",
"AS",
"OPPOSITE",
"OF",
"right",
"()"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/lists.py#L237-L246 |
klahnakoski/pyLibrary | mo_dots/lists.py | FlatList.not_right | def not_right(self, num):
"""
WITH SLICES BEING FLAT, WE NEED A SIMPLE WAY TO SLICE FROM THE LEFT [:-num:]
"""
if num == None:
return FlatList([_get_list(self)[:-1:]])
if num <= 0:
return FlatList.EMPTY
return FlatList(_get_list(self)[:-num:]) | python | def not_right(self, num):
"""
WITH SLICES BEING FLAT, WE NEED A SIMPLE WAY TO SLICE FROM THE LEFT [:-num:]
"""
if num == None:
return FlatList([_get_list(self)[:-1:]])
if num <= 0:
return FlatList.EMPTY
return FlatList(_get_list(self)[:-num:]) | [
"def",
"not_right",
"(",
"self",
",",
"num",
")",
":",
"if",
"num",
"==",
"None",
":",
"return",
"FlatList",
"(",
"[",
"_get_list",
"(",
"self",
")",
"[",
":",
"-",
"1",
":",
"]",
"]",
")",
"if",
"num",
"<=",
"0",
":",
"return",
"FlatList",
"."... | WITH SLICES BEING FLAT, WE NEED A SIMPLE WAY TO SLICE FROM THE LEFT [:-num:] | [
"WITH",
"SLICES",
"BEING",
"FLAT",
"WE",
"NEED",
"A",
"SIMPLE",
"WAY",
"TO",
"SLICE",
"FROM",
"THE",
"LEFT",
"[",
":",
"-",
"num",
":",
"]"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/lists.py#L248-L257 |
klahnakoski/pyLibrary | mo_dots/lists.py | FlatList.not_left | def not_left(self, num):
"""
NOT REQUIRED, EXISTS AS OPPOSITE OF not_right()
"""
if num == None:
return FlatList([_get_list(self)[-1]])
if num <= 0:
return self
return FlatList(_get_list(self)[num::]) | python | def not_left(self, num):
"""
NOT REQUIRED, EXISTS AS OPPOSITE OF not_right()
"""
if num == None:
return FlatList([_get_list(self)[-1]])
if num <= 0:
return self
return FlatList(_get_list(self)[num::]) | [
"def",
"not_left",
"(",
"self",
",",
"num",
")",
":",
"if",
"num",
"==",
"None",
":",
"return",
"FlatList",
"(",
"[",
"_get_list",
"(",
"self",
")",
"[",
"-",
"1",
"]",
"]",
")",
"if",
"num",
"<=",
"0",
":",
"return",
"self",
"return",
"FlatList"... | NOT REQUIRED, EXISTS AS OPPOSITE OF not_right() | [
"NOT",
"REQUIRED",
"EXISTS",
"AS",
"OPPOSITE",
"OF",
"not_right",
"()"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/lists.py#L259-L268 |
jmoiron/par2ools | par2ools/fileutil.py | baseglob | def baseglob(pat, base):
"""Given a pattern and a base, return files that match the glob pattern
and also contain the base."""
return [f for f in glob(pat) if f.startswith(base)] | python | def baseglob(pat, base):
"""Given a pattern and a base, return files that match the glob pattern
and also contain the base."""
return [f for f in glob(pat) if f.startswith(base)] | [
"def",
"baseglob",
"(",
"pat",
",",
"base",
")",
":",
"return",
"[",
"f",
"for",
"f",
"in",
"glob",
"(",
"pat",
")",
"if",
"f",
".",
"startswith",
"(",
"base",
")",
"]"
] | Given a pattern and a base, return files that match the glob pattern
and also contain the base. | [
"Given",
"a",
"pattern",
"and",
"a",
"base",
"return",
"files",
"that",
"match",
"the",
"glob",
"pattern",
"and",
"also",
"contain",
"the",
"base",
"."
] | train | https://github.com/jmoiron/par2ools/blob/3a9a71c8d0cadecb56bff711b2c2db9b3acb496c/par2ools/fileutil.py#L27-L30 |
jmoiron/par2ools | par2ools/fileutil.py | cibaseglob | def cibaseglob(pat, base):
"""Case insensitive baseglob. Note that it's not *actually* case
insensitive, since glob is insensitive or not based on local semantics.
Instead, it tries the original version, an upper() version, a lower()
version, and a swapcase() version of the glob."""
results = []
... | python | def cibaseglob(pat, base):
"""Case insensitive baseglob. Note that it's not *actually* case
insensitive, since glob is insensitive or not based on local semantics.
Instead, it tries the original version, an upper() version, a lower()
version, and a swapcase() version of the glob."""
results = []
... | [
"def",
"cibaseglob",
"(",
"pat",
",",
"base",
")",
":",
"results",
"=",
"[",
"]",
"for",
"func",
"in",
"(",
"str",
",",
"str",
".",
"upper",
",",
"str",
".",
"lower",
",",
"str",
".",
"swapcase",
")",
":",
"results",
"+=",
"baseglob",
"(",
"func"... | Case insensitive baseglob. Note that it's not *actually* case
insensitive, since glob is insensitive or not based on local semantics.
Instead, it tries the original version, an upper() version, a lower()
version, and a swapcase() version of the glob. | [
"Case",
"insensitive",
"baseglob",
".",
"Note",
"that",
"it",
"s",
"not",
"*",
"actually",
"*",
"case",
"insensitive",
"since",
"glob",
"is",
"insensitive",
"or",
"not",
"based",
"on",
"local",
"semantics",
".",
"Instead",
"it",
"tries",
"the",
"original",
... | train | https://github.com/jmoiron/par2ools/blob/3a9a71c8d0cadecb56bff711b2c2db9b3acb496c/par2ools/fileutil.py#L32-L40 |
jmoiron/par2ools | par2ools/fileutil.py | dircolorize | def dircolorize(path, name_only=True):
"""Use user dircolors settings to colorize a string which is a path.
If name_only is True, it does this by the name rules (*.x) only; it
will not check the filesystem to colorize things like pipes, block devs,
doors, etc."""
if not name_only:
raise NotI... | python | def dircolorize(path, name_only=True):
"""Use user dircolors settings to colorize a string which is a path.
If name_only is True, it does this by the name rules (*.x) only; it
will not check the filesystem to colorize things like pipes, block devs,
doors, etc."""
if not name_only:
raise NotI... | [
"def",
"dircolorize",
"(",
"path",
",",
"name_only",
"=",
"True",
")",
":",
"if",
"not",
"name_only",
":",
"raise",
"NotImplemented",
"(",
"\"Filesystem checking not implemented.\"",
")",
"for",
"k",
",",
"regex",
"in",
"colorremap",
".",
"iteritems",
"(",
")"... | Use user dircolors settings to colorize a string which is a path.
If name_only is True, it does this by the name rules (*.x) only; it
will not check the filesystem to colorize things like pipes, block devs,
doors, etc. | [
"Use",
"user",
"dircolors",
"settings",
"to",
"colorize",
"a",
"string",
"which",
"is",
"a",
"path",
".",
"If",
"name_only",
"is",
"True",
"it",
"does",
"this",
"by",
"the",
"name",
"rules",
"(",
"*",
".",
"x",
")",
"only",
";",
"it",
"will",
"not",
... | train | https://github.com/jmoiron/par2ools/blob/3a9a71c8d0cadecb56bff711b2c2db9b3acb496c/par2ools/fileutil.py#L42-L52 |
klahnakoski/pyLibrary | pyLibrary/env/git.py | get_revision | def get_revision():
"""
GET THE CURRENT GIT REVISION
"""
proc = Process("git log", ["git", "log", "-1"])
try:
while True:
line = proc.stdout.pop().strip().decode('utf8')
if not line:
continue
if line.startswith("commit "):
... | python | def get_revision():
"""
GET THE CURRENT GIT REVISION
"""
proc = Process("git log", ["git", "log", "-1"])
try:
while True:
line = proc.stdout.pop().strip().decode('utf8')
if not line:
continue
if line.startswith("commit "):
... | [
"def",
"get_revision",
"(",
")",
":",
"proc",
"=",
"Process",
"(",
"\"git log\"",
",",
"[",
"\"git\"",
",",
"\"log\"",
",",
"\"-1\"",
"]",
")",
"try",
":",
"while",
"True",
":",
"line",
"=",
"proc",
".",
"stdout",
".",
"pop",
"(",
")",
".",
"strip"... | GET THE CURRENT GIT REVISION | [
"GET",
"THE",
"CURRENT",
"GIT",
"REVISION"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/git.py#L20-L35 |
klahnakoski/pyLibrary | pyLibrary/env/git.py | get_remote_revision | def get_remote_revision(url, branch):
"""
GET REVISION OF A REMOTE BRANCH
"""
proc = Process("git remote revision", ["git", "ls-remote", url, "refs/heads/" + branch])
try:
while True:
raw_line = proc.stdout.pop()
line = raw_line.strip().decode('utf8')
if ... | python | def get_remote_revision(url, branch):
"""
GET REVISION OF A REMOTE BRANCH
"""
proc = Process("git remote revision", ["git", "ls-remote", url, "refs/heads/" + branch])
try:
while True:
raw_line = proc.stdout.pop()
line = raw_line.strip().decode('utf8')
if ... | [
"def",
"get_remote_revision",
"(",
"url",
",",
"branch",
")",
":",
"proc",
"=",
"Process",
"(",
"\"git remote revision\"",
",",
"[",
"\"git\"",
",",
"\"ls-remote\"",
",",
"url",
",",
"\"refs/heads/\"",
"+",
"branch",
"]",
")",
"try",
":",
"while",
"True",
... | GET REVISION OF A REMOTE BRANCH | [
"GET",
"REVISION",
"OF",
"A",
"REMOTE",
"BRANCH"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/git.py#L39-L56 |
klahnakoski/pyLibrary | pyLibrary/env/git.py | get_branch | def get_branch():
"""
GET THE CURRENT GIT BRANCH
"""
proc = Process("git status", ["git", "status"])
try:
while True:
raw_line = proc.stdout.pop()
line = raw_line.decode('utf8').strip()
if line.startswith("On branch "):
return line[10:]
... | python | def get_branch():
"""
GET THE CURRENT GIT BRANCH
"""
proc = Process("git status", ["git", "status"])
try:
while True:
raw_line = proc.stdout.pop()
line = raw_line.decode('utf8').strip()
if line.startswith("On branch "):
return line[10:]
... | [
"def",
"get_branch",
"(",
")",
":",
"proc",
"=",
"Process",
"(",
"\"git status\"",
",",
"[",
"\"git\"",
",",
"\"status\"",
"]",
")",
"try",
":",
"while",
"True",
":",
"raw_line",
"=",
"proc",
".",
"stdout",
".",
"pop",
"(",
")",
"line",
"=",
"raw_lin... | GET THE CURRENT GIT BRANCH | [
"GET",
"THE",
"CURRENT",
"GIT",
"BRANCH"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/git.py#L60-L76 |
klahnakoski/pyLibrary | jx_elasticsearch/es52/expressions.py | _normalize | def _normalize(esfilter):
"""
TODO: DO NOT USE Data, WE ARE SPENDING TOO MUCH TIME WRAPPING/UNWRAPPING
REALLY, WE JUST COLLAPSE CASCADING `and` AND `or` FILTERS
"""
if esfilter == MATCH_ALL or esfilter == MATCH_NONE or esfilter.isNormal:
return esfilter
# Log.note("from: " + convert.val... | python | def _normalize(esfilter):
"""
TODO: DO NOT USE Data, WE ARE SPENDING TOO MUCH TIME WRAPPING/UNWRAPPING
REALLY, WE JUST COLLAPSE CASCADING `and` AND `or` FILTERS
"""
if esfilter == MATCH_ALL or esfilter == MATCH_NONE or esfilter.isNormal:
return esfilter
# Log.note("from: " + convert.val... | [
"def",
"_normalize",
"(",
"esfilter",
")",
":",
"if",
"esfilter",
"==",
"MATCH_ALL",
"or",
"esfilter",
"==",
"MATCH_NONE",
"or",
"esfilter",
".",
"isNormal",
":",
"return",
"esfilter",
"# Log.note(\"from: \" + convert.value2json(esfilter))",
"isDiff",
"=",
"True",
"... | TODO: DO NOT USE Data, WE ARE SPENDING TOO MUCH TIME WRAPPING/UNWRAPPING
REALLY, WE JUST COLLAPSE CASCADING `and` AND `or` FILTERS | [
"TODO",
":",
"DO",
"NOT",
"USE",
"Data",
"WE",
"ARE",
"SPENDING",
"TOO",
"MUCH",
"TIME",
"WRAPPING",
"/",
"UNWRAPPING",
"REALLY",
"WE",
"JUST",
"COLLAPSE",
"CASCADING",
"and",
"AND",
"or",
"FILTERS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/expressions.py#L512-L651 |
klahnakoski/pyLibrary | jx_elasticsearch/es52/expressions.py | split_expression_by_depth | def split_expression_by_depth(where, schema, output=None, var_to_depth=None):
"""
:param where: EXPRESSION TO INSPECT
:param schema: THE SCHEMA
:param output:
:param var_to_depth: MAP FROM EACH VARIABLE NAME TO THE DEPTH
:return:
"""
"""
It is unfortunate that ES can not handle expre... | python | def split_expression_by_depth(where, schema, output=None, var_to_depth=None):
"""
:param where: EXPRESSION TO INSPECT
:param schema: THE SCHEMA
:param output:
:param var_to_depth: MAP FROM EACH VARIABLE NAME TO THE DEPTH
:return:
"""
"""
It is unfortunate that ES can not handle expre... | [
"def",
"split_expression_by_depth",
"(",
"where",
",",
"schema",
",",
"output",
"=",
"None",
",",
"var_to_depth",
"=",
"None",
")",
":",
"\"\"\"\n It is unfortunate that ES can not handle expressions that\n span nested indexes. This will split your where clause\n returning ... | :param where: EXPRESSION TO INSPECT
:param schema: THE SCHEMA
:param output:
:param var_to_depth: MAP FROM EACH VARIABLE NAME TO THE DEPTH
:return: | [
":",
"param",
"where",
":",
"EXPRESSION",
"TO",
"INSPECT",
":",
"param",
"schema",
":",
"THE",
"SCHEMA",
":",
"param",
"output",
":",
":",
"param",
"var_to_depth",
":",
"MAP",
"FROM",
"EACH",
"VARIABLE",
"NAME",
"TO",
"THE",
"DEPTH",
":",
"return",
":"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/expressions.py#L654-L691 |
klahnakoski/pyLibrary | jx_elasticsearch/es52/expressions.py | split_expression_by_path | def split_expression_by_path(
where, schema, output=None, var_to_columns=None, lang=Language
):
"""
:param where: EXPRESSION TO INSPECT
:param schema: THE SCHEMA
:param output: THE MAP FROM PATH TO EXPRESSION WE WANT UPDATED
:param var_to_columns: MAP FROM EACH VARIABLE NAME TO THE DEPTH
:re... | python | def split_expression_by_path(
where, schema, output=None, var_to_columns=None, lang=Language
):
"""
:param where: EXPRESSION TO INSPECT
:param schema: THE SCHEMA
:param output: THE MAP FROM PATH TO EXPRESSION WE WANT UPDATED
:param var_to_columns: MAP FROM EACH VARIABLE NAME TO THE DEPTH
:re... | [
"def",
"split_expression_by_path",
"(",
"where",
",",
"schema",
",",
"output",
"=",
"None",
",",
"var_to_columns",
"=",
"None",
",",
"lang",
"=",
"Language",
")",
":",
"if",
"var_to_columns",
"is",
"None",
":",
"var_to_columns",
"=",
"{",
"v",
".",
"var",
... | :param where: EXPRESSION TO INSPECT
:param schema: THE SCHEMA
:param output: THE MAP FROM PATH TO EXPRESSION WE WANT UPDATED
:param var_to_columns: MAP FROM EACH VARIABLE NAME TO THE DEPTH
:return: output: A MAP FROM PATH TO EXPRESSION | [
":",
"param",
"where",
":",
"EXPRESSION",
"TO",
"INSPECT",
":",
"param",
"schema",
":",
"THE",
"SCHEMA",
":",
"param",
"output",
":",
"THE",
"MAP",
"FROM",
"PATH",
"TO",
"EXPRESSION",
"WE",
"WANT",
"UPDATED",
":",
"param",
"var_to_columns",
":",
"MAP",
"... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/expressions.py#L694-L732 |
CSIRO-enviro-informatics/pyldapi | pyldapi/renderer.py | Renderer._get_accept_languages_in_order | def _get_accept_languages_in_order(self):
"""
Reads an Accept HTTP header and returns an array of Media Type string in descending weighted order
:return: List of URIs of accept profiles in descending request order
:rtype: list
"""
try:
# split the header into... | python | def _get_accept_languages_in_order(self):
"""
Reads an Accept HTTP header and returns an array of Media Type string in descending weighted order
:return: List of URIs of accept profiles in descending request order
:rtype: list
"""
try:
# split the header into... | [
"def",
"_get_accept_languages_in_order",
"(",
"self",
")",
":",
"try",
":",
"# split the header into individual URIs, with weights still attached",
"profiles",
"=",
"self",
".",
"request",
".",
"headers",
"[",
"'Accept-Language'",
"]",
".",
"split",
"(",
"','",
")",
"... | Reads an Accept HTTP header and returns an array of Media Type string in descending weighted order
:return: List of URIs of accept profiles in descending request order
:rtype: list | [
"Reads",
"an",
"Accept",
"HTTP",
"header",
"and",
"returns",
"an",
"array",
"of",
"Media",
"Type",
"string",
"in",
"descending",
"weighted",
"order"
] | train | https://github.com/CSIRO-enviro-informatics/pyldapi/blob/117ed61d2dcd58730f9ad7fefcbe49b5ddf138e0/pyldapi/renderer.py#L158-L180 |
maxpeng/cmWalk | cmwalk/cmwalk.py | CmWalk.readCfgJson | def readCfgJson(cls, working_path):
"""Read cmWalk configuration data of a working directory from a json file.
:param working_path: working path for reading the configuration data.
:return: the configuration data represented in a json object, None if the configuration files does not
... | python | def readCfgJson(cls, working_path):
"""Read cmWalk configuration data of a working directory from a json file.
:param working_path: working path for reading the configuration data.
:return: the configuration data represented in a json object, None if the configuration files does not
... | [
"def",
"readCfgJson",
"(",
"cls",
",",
"working_path",
")",
":",
"cfg_json_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"working_path",
",",
"cls",
".",
"CFG_JSON_FILENAME",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"cfg_json_filename",
")"... | Read cmWalk configuration data of a working directory from a json file.
:param working_path: working path for reading the configuration data.
:return: the configuration data represented in a json object, None if the configuration files does not
exist. | [
"Read",
"cmWalk",
"configuration",
"data",
"of",
"a",
"working",
"directory",
"from",
"a",
"json",
"file",
"."
] | train | https://github.com/maxpeng/cmWalk/blob/3914f84eb987d8bcece2e11246cfb3e5d5ee0daa/cmwalk/cmwalk.py#L39-L52 |
maxpeng/cmWalk | cmwalk/cmwalk.py | CmWalk.genTopLevelDirCMakeListsFile | def genTopLevelDirCMakeListsFile(self, working_path, subdirs, files, cfg):
"""
Generate top level CMakeLists.txt.
:param working_path: current working directory
:param subdirs: a list of subdirectories of current working directory.
:param files: a list of files in current workin... | python | def genTopLevelDirCMakeListsFile(self, working_path, subdirs, files, cfg):
"""
Generate top level CMakeLists.txt.
:param working_path: current working directory
:param subdirs: a list of subdirectories of current working directory.
:param files: a list of files in current workin... | [
"def",
"genTopLevelDirCMakeListsFile",
"(",
"self",
",",
"working_path",
",",
"subdirs",
",",
"files",
",",
"cfg",
")",
":",
"fnameOut",
"=",
"os",
".",
"path",
".",
"join",
"(",
"working_path",
",",
"'CMakeLists.txt'",
")",
"template",
"=",
"self",
".",
"... | Generate top level CMakeLists.txt.
:param working_path: current working directory
:param subdirs: a list of subdirectories of current working directory.
:param files: a list of files in current working directory.
:return: the full path name of generated CMakeLists.txt. | [
"Generate",
"top",
"level",
"CMakeLists",
".",
"txt",
"."
] | train | https://github.com/maxpeng/cmWalk/blob/3914f84eb987d8bcece2e11246cfb3e5d5ee0daa/cmwalk/cmwalk.py#L55-L73 |
maxpeng/cmWalk | cmwalk/cmwalk.py | CmWalk.genSubDirCMakeListsFile | def genSubDirCMakeListsFile(self, working_path, addToCompilerIncludeDirectories, subdirs, files):
"""
Generate CMakeLists.txt in subdirectories.
:param working_path: current working directory
:param subdirs: a list of subdirectories of current working directory.
:param files: a ... | python | def genSubDirCMakeListsFile(self, working_path, addToCompilerIncludeDirectories, subdirs, files):
"""
Generate CMakeLists.txt in subdirectories.
:param working_path: current working directory
:param subdirs: a list of subdirectories of current working directory.
:param files: a ... | [
"def",
"genSubDirCMakeListsFile",
"(",
"self",
",",
"working_path",
",",
"addToCompilerIncludeDirectories",
",",
"subdirs",
",",
"files",
")",
":",
"fnameOut",
"=",
"os",
".",
"path",
".",
"join",
"(",
"working_path",
",",
"'CMakeLists.txt'",
")",
"template",
"=... | Generate CMakeLists.txt in subdirectories.
:param working_path: current working directory
:param subdirs: a list of subdirectories of current working directory.
:param files: a list of files in current working directory.
:return: the full path name of generated CMakeLists.txt. | [
"Generate",
"CMakeLists",
".",
"txt",
"in",
"subdirectories",
"."
] | train | https://github.com/maxpeng/cmWalk/blob/3914f84eb987d8bcece2e11246cfb3e5d5ee0daa/cmwalk/cmwalk.py#L76-L93 |
ff0000/scarlet | scarlet/versioning/view_mixins.py | PreviewableObject.get_object | def get_object(self, queryset=None):
"""
Returns the object the view is displaying.
Copied from SingleObjectMixin except that this allows
us to lookup preview objects.
"""
schema = manager.get_schema()
vid = None
if self.request.GET.get('vid') and self.r... | python | def get_object(self, queryset=None):
"""
Returns the object the view is displaying.
Copied from SingleObjectMixin except that this allows
us to lookup preview objects.
"""
schema = manager.get_schema()
vid = None
if self.request.GET.get('vid') and self.r... | [
"def",
"get_object",
"(",
"self",
",",
"queryset",
"=",
"None",
")",
":",
"schema",
"=",
"manager",
".",
"get_schema",
"(",
")",
"vid",
"=",
"None",
"if",
"self",
".",
"request",
".",
"GET",
".",
"get",
"(",
"'vid'",
")",
"and",
"self",
".",
"reque... | Returns the object the view is displaying.
Copied from SingleObjectMixin except that this allows
us to lookup preview objects. | [
"Returns",
"the",
"object",
"the",
"view",
"is",
"displaying",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/view_mixins.py#L13-L64 |
tetframework/Tonnikala | tonnikala/loader.py | handle_exception | def handle_exception(exc_info=None, source_hint=None, tb_override=_NO):
"""Exception handling helper. This is used internally to either raise
rewritten exceptions or return a rendered traceback for the template.
"""
global _make_traceback
if exc_info is None: # pragma: no cover
exc_info =... | python | def handle_exception(exc_info=None, source_hint=None, tb_override=_NO):
"""Exception handling helper. This is used internally to either raise
rewritten exceptions or return a rendered traceback for the template.
"""
global _make_traceback
if exc_info is None: # pragma: no cover
exc_info =... | [
"def",
"handle_exception",
"(",
"exc_info",
"=",
"None",
",",
"source_hint",
"=",
"None",
",",
"tb_override",
"=",
"_NO",
")",
":",
"global",
"_make_traceback",
"if",
"exc_info",
"is",
"None",
":",
"# pragma: no cover",
"exc_info",
"=",
"sys",
".",
"exc_info",... | Exception handling helper. This is used internally to either raise
rewritten exceptions or return a rendered traceback for the template. | [
"Exception",
"handling",
"helper",
".",
"This",
"is",
"used",
"internally",
"to",
"either",
"raise",
"rewritten",
"exceptions",
"or",
"return",
"a",
"rendered",
"traceback",
"for",
"the",
"template",
"."
] | train | https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/loader.py#L71-L93 |
tetframework/Tonnikala | tonnikala/loader.py | FileLoader._maybe_purge_cache | def _maybe_purge_cache(self):
"""
If enough time since last check has elapsed, check if any
of the cached templates has changed. If any of the template
files were deleted, remove that file only. If any were
changed, then purge the entire cache.
"""
if self._last_... | python | def _maybe_purge_cache(self):
"""
If enough time since last check has elapsed, check if any
of the cached templates has changed. If any of the template
files were deleted, remove that file only. If any were
changed, then purge the entire cache.
"""
if self._last_... | [
"def",
"_maybe_purge_cache",
"(",
"self",
")",
":",
"if",
"self",
".",
"_last_reload_check",
"+",
"MIN_CHECK_INTERVAL",
">",
"time",
".",
"time",
"(",
")",
":",
"return",
"for",
"name",
",",
"tmpl",
"in",
"list",
"(",
"self",
".",
"cache",
".",
"items",
... | If enough time since last check has elapsed, check if any
of the cached templates has changed. If any of the template
files were deleted, remove that file only. If any were
changed, then purge the entire cache. | [
"If",
"enough",
"time",
"since",
"last",
"check",
"has",
"elapsed",
"check",
"if",
"any",
"of",
"the",
"cached",
"templates",
"has",
"changed",
".",
"If",
"any",
"of",
"the",
"template",
"files",
"were",
"deleted",
"remove",
"that",
"file",
"only",
".",
... | train | https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/loader.py#L231-L251 |
tetframework/Tonnikala | tonnikala/loader.py | FileLoader.load | def load(self, name):
"""
If not yet in the cache, load the named template and compiles it,
placing it into the cache.
If in cache, return the cached template.
"""
if self.reload:
self._maybe_purge_cache()
template = self.cache.get(name)
if ... | python | def load(self, name):
"""
If not yet in the cache, load the named template and compiles it,
placing it into the cache.
If in cache, return the cached template.
"""
if self.reload:
self._maybe_purge_cache()
template = self.cache.get(name)
if ... | [
"def",
"load",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"reload",
":",
"self",
".",
"_maybe_purge_cache",
"(",
")",
"template",
"=",
"self",
".",
"cache",
".",
"get",
"(",
"name",
")",
"if",
"template",
":",
"return",
"template",
"path"... | If not yet in the cache, load the named template and compiles it,
placing it into the cache.
If in cache, return the cached template. | [
"If",
"not",
"yet",
"in",
"the",
"cache",
"load",
"the",
"named",
"template",
"and",
"compiles",
"it",
"placing",
"it",
"into",
"the",
"cache",
"."
] | train | https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/loader.py#L253-L281 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.