repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
skioo/django-customer-billing | billing/total.py | Total.nonzero_monies | def nonzero_monies(self):
"""Get a list of the underlying ``Money`` instances that are not zero
Returns:
([Money]): A list of zero or more money instances. Currencies will be unique.
"""
return [copy.copy(m) for m in self._money_obs if m.amount != 0] | python | def nonzero_monies(self):
"""Get a list of the underlying ``Money`` instances that are not zero
Returns:
([Money]): A list of zero or more money instances. Currencies will be unique.
"""
return [copy.copy(m) for m in self._money_obs if m.amount != 0] | [
"def",
"nonzero_monies",
"(",
"self",
")",
":",
"return",
"[",
"copy",
".",
"copy",
"(",
"m",
")",
"for",
"m",
"in",
"self",
".",
"_money_obs",
"if",
"m",
".",
"amount",
"!=",
"0",
"]"
] | Get a list of the underlying ``Money`` instances that are not zero
Returns:
([Money]): A list of zero or more money instances. Currencies will be unique. | [
"Get",
"a",
"list",
"of",
"the",
"underlying",
"Money",
"instances",
"that",
"are",
"not",
"zero"
] | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/total.py#L117-L123 | train | Returns a list of the underlying Money instances that are not zero |
chemreac/block_diag_ilu | python_prototype/demo.py | main | def main(N=32, n=32, ndiag=1, main_diag_factor=1.0, off_diag_factor=1.0,
base_seed=0, seed_range=1, fact_pow2_min=4, fact_pow2_max=18,
plot=False, npows=0, scan_ndiag=False, savefig='None'):
"""
Ax = b
"""
npows = npows or fact_pow2_max - fact_pow2_min
factors = np.linspace(fact_p... | python | def main(N=32, n=32, ndiag=1, main_diag_factor=1.0, off_diag_factor=1.0,
base_seed=0, seed_range=1, fact_pow2_min=4, fact_pow2_max=18,
plot=False, npows=0, scan_ndiag=False, savefig='None'):
"""
Ax = b
"""
npows = npows or fact_pow2_max - fact_pow2_min
factors = np.linspace(fact_p... | [
"def",
"main",
"(",
"N",
"=",
"32",
",",
"n",
"=",
"32",
",",
"ndiag",
"=",
"1",
",",
"main_diag_factor",
"=",
"1.0",
",",
"off_diag_factor",
"=",
"1.0",
",",
"base_seed",
"=",
"0",
",",
"seed_range",
"=",
"1",
",",
"fact_pow2_min",
"=",
"4",
",",
... | Ax = b | [
"Ax",
"=",
"b"
] | 3be507f3f90c4c6e6c9576d56f83f84167ce3b52 | https://github.com/chemreac/block_diag_ilu/blob/3be507f3f90c4c6e6c9576d56f83f84167ce3b52/python_prototype/demo.py#L66-L205 | train | This function is used to plot the test system. |
lashex/pyutu | pyutu/cli.py | index | def index(pc):
"""
Show details about the Pricing API Index.
"""
click.echo("Format Version: {0}".format(pc.idx['formatVersion']))
click.echo("Publication Date: {0}".format(pc.idx['publicationDate']))
olist = ''
for i,o in enumerate(pc.idx['offers']):
if i < len(pc.idx['offers']) - 1... | python | def index(pc):
"""
Show details about the Pricing API Index.
"""
click.echo("Format Version: {0}".format(pc.idx['formatVersion']))
click.echo("Publication Date: {0}".format(pc.idx['publicationDate']))
olist = ''
for i,o in enumerate(pc.idx['offers']):
if i < len(pc.idx['offers']) - 1... | [
"def",
"index",
"(",
"pc",
")",
":",
"click",
".",
"echo",
"(",
"\"Format Version: {0}\"",
".",
"format",
"(",
"pc",
".",
"idx",
"[",
"'formatVersion'",
"]",
")",
")",
"click",
".",
"echo",
"(",
"\"Publication Date: {0}\"",
".",
"format",
"(",
"pc",
".",... | Show details about the Pricing API Index. | [
"Show",
"details",
"about",
"the",
"Pricing",
"API",
"Index",
"."
] | 22a9e2e5473e316aa6fffe67f0069b2a7757a441 | https://github.com/lashex/pyutu/blob/22a9e2e5473e316aa6fffe67f0069b2a7757a441/pyutu/cli.py#L36-L49 | train | Show details about the Pricing API Index. |
lashex/pyutu | pyutu/cli.py | product | def product(pc, service, attrib, sku):
"""
Get a list of a service's products.
The list will be in the given region, matching the specific terms and
any given attribute filters or a SKU.
"""
pc.service = service.lower()
pc.sku = sku
pc.add_attributes(attribs=attrib)
click.echo("Servi... | python | def product(pc, service, attrib, sku):
"""
Get a list of a service's products.
The list will be in the given region, matching the specific terms and
any given attribute filters or a SKU.
"""
pc.service = service.lower()
pc.sku = sku
pc.add_attributes(attribs=attrib)
click.echo("Servi... | [
"def",
"product",
"(",
"pc",
",",
"service",
",",
"attrib",
",",
"sku",
")",
":",
"pc",
".",
"service",
"=",
"service",
".",
"lower",
"(",
")",
"pc",
".",
"sku",
"=",
"sku",
"pc",
".",
"add_attributes",
"(",
"attribs",
"=",
"attrib",
")",
"click",
... | Get a list of a service's products.
The list will be in the given region, matching the specific terms and
any given attribute filters or a SKU. | [
"Get",
"a",
"list",
"of",
"a",
"service",
"s",
"products",
".",
"The",
"list",
"will",
"be",
"in",
"the",
"given",
"region",
"matching",
"the",
"specific",
"terms",
"and",
"any",
"given",
"attribute",
"filters",
"or",
"a",
"SKU",
"."
] | 22a9e2e5473e316aa6fffe67f0069b2a7757a441 | https://github.com/lashex/pyutu/blob/22a9e2e5473e316aa6fffe67f0069b2a7757a441/pyutu/cli.py#L60-L82 | train | Get a list of a service s products. |
lashex/pyutu | pyutu/cli.py | price | def price(pc, service, attrib, sku):
"""
Get a list of a service's prices.
The list will be in the given region, matching the specific terms and
any given attribute filters or a SKU.
"""
pc.service = service.lower()
pc.sku = sku
pc.add_attributes(attribs=attrib)
click.echo("Service A... | python | def price(pc, service, attrib, sku):
"""
Get a list of a service's prices.
The list will be in the given region, matching the specific terms and
any given attribute filters or a SKU.
"""
pc.service = service.lower()
pc.sku = sku
pc.add_attributes(attribs=attrib)
click.echo("Service A... | [
"def",
"price",
"(",
"pc",
",",
"service",
",",
"attrib",
",",
"sku",
")",
":",
"pc",
".",
"service",
"=",
"service",
".",
"lower",
"(",
")",
"pc",
".",
"sku",
"=",
"sku",
"pc",
".",
"add_attributes",
"(",
"attribs",
"=",
"attrib",
")",
"click",
... | Get a list of a service's prices.
The list will be in the given region, matching the specific terms and
any given attribute filters or a SKU. | [
"Get",
"a",
"list",
"of",
"a",
"service",
"s",
"prices",
".",
"The",
"list",
"will",
"be",
"in",
"the",
"given",
"region",
"matching",
"the",
"specific",
"terms",
"and",
"any",
"given",
"attribute",
"filters",
"or",
"a",
"SKU",
"."
] | 22a9e2e5473e316aa6fffe67f0069b2a7757a441 | https://github.com/lashex/pyutu/blob/22a9e2e5473e316aa6fffe67f0069b2a7757a441/pyutu/cli.py#L93-L116 | train | Get a list of a service s prices. |
romanorac/discomll | discomll/ensemble/distributed_weighted_forest_rand.py | map_init | def map_init(interface, params):
"""Intialize random number generator with given seed `params.seed`."""
import numpy as np
import random
np.random.seed(params['seed'])
random.seed(params['seed'])
return params | python | def map_init(interface, params):
"""Intialize random number generator with given seed `params.seed`."""
import numpy as np
import random
np.random.seed(params['seed'])
random.seed(params['seed'])
return params | [
"def",
"map_init",
"(",
"interface",
",",
"params",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"random",
"np",
".",
"random",
".",
"seed",
"(",
"params",
"[",
"'seed'",
"]",
")",
"random",
".",
"seed",
"(",
"params",
"[",
"'seed'",
"]",
")",
... | Intialize random number generator with given seed `params.seed`. | [
"Intialize",
"random",
"number",
"generator",
"with",
"given",
"seed",
"params",
".",
"seed",
"."
] | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/ensemble/distributed_weighted_forest_rand.py#L38-L44 | train | Intialize random number generator with given seed params. seed. |
davidfokkema/artist | artist/utils.py | create_graph_name | def create_graph_name(suffix='', dirname=None):
"""Create a graph name using the name of the caller.
:param suffix: optional suffix to add to name
:param dirname: optional directory name
:return: path for the named graph
:rtype: string
"""
if suffix:
suffix = '-%s' % suffix
ca... | python | def create_graph_name(suffix='', dirname=None):
"""Create a graph name using the name of the caller.
:param suffix: optional suffix to add to name
:param dirname: optional directory name
:return: path for the named graph
:rtype: string
"""
if suffix:
suffix = '-%s' % suffix
ca... | [
"def",
"create_graph_name",
"(",
"suffix",
"=",
"''",
",",
"dirname",
"=",
"None",
")",
":",
"if",
"suffix",
":",
"suffix",
"=",
"'-%s'",
"%",
"suffix",
"caller",
"=",
"get_callers_name",
"(",
"level",
"=",
"3",
")",
"name",
"=",
"'%s%s%s%s'",
"%",
"("... | Create a graph name using the name of the caller.
:param suffix: optional suffix to add to name
:param dirname: optional directory name
:return: path for the named graph
:rtype: string | [
"Create",
"a",
"graph",
"name",
"using",
"the",
"name",
"of",
"the",
"caller",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/utils.py#L51-L67 | train | Create a graph name using the name of the caller. |
davidfokkema/artist | artist/utils.py | save_graph | def save_graph(graph, suffix='', dirname=None, pdf=False):
"""Save a graph using caller's name.
:type graph: GraphArtist instance
:param suffix: optional suffix to add to name
:param dirname: optional directory name
:param pdf: if True, the saved graph is additionally rendered and
saved as ... | python | def save_graph(graph, suffix='', dirname=None, pdf=False):
"""Save a graph using caller's name.
:type graph: GraphArtist instance
:param suffix: optional suffix to add to name
:param dirname: optional directory name
:param pdf: if True, the saved graph is additionally rendered and
saved as ... | [
"def",
"save_graph",
"(",
"graph",
",",
"suffix",
"=",
"''",
",",
"dirname",
"=",
"None",
",",
"pdf",
"=",
"False",
")",
":",
"name",
"=",
"create_graph_name",
"(",
"suffix",
",",
"dirname",
")",
"graph",
".",
"save",
"(",
"name",
")",
"if",
"pdf",
... | Save a graph using caller's name.
:type graph: GraphArtist instance
:param suffix: optional suffix to add to name
:param dirname: optional directory name
:param pdf: if True, the saved graph is additionally rendered and
saved as a pdf, alongside the LaTeX file. | [
"Save",
"a",
"graph",
"using",
"caller",
"s",
"name",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/utils.py#L70-L83 | train | Save a graph as LaTeX file. |
davidfokkema/artist | artist/utils.py | save_data | def save_data(data, suffix='', dirname=None):
"""Save a dataset using caller's name.
:param data: a list or numpy array containing the data
:param suffix: optional suffix to add to name
:param dirname: optional directory name
"""
if type(data) == list:
data = np.array(data).T
name... | python | def save_data(data, suffix='', dirname=None):
"""Save a dataset using caller's name.
:param data: a list or numpy array containing the data
:param suffix: optional suffix to add to name
:param dirname: optional directory name
"""
if type(data) == list:
data = np.array(data).T
name... | [
"def",
"save_data",
"(",
"data",
",",
"suffix",
"=",
"''",
",",
"dirname",
"=",
"None",
")",
":",
"if",
"type",
"(",
"data",
")",
"==",
"list",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
")",
".",
"T",
"name",
"=",
"create_graph_name",
"(... | Save a dataset using caller's name.
:param data: a list or numpy array containing the data
:param suffix: optional suffix to add to name
:param dirname: optional directory name | [
"Save",
"a",
"dataset",
"using",
"caller",
"s",
"name",
"."
] | 26ae7987522622710f2910980770c50012fda47d | https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/utils.py#L86-L98 | train | Save a dataset using caller s name. |
PythonOptimizers/cygenja | cygenja/filters/type_filters.py | cysparse_type_to_real_sum_cysparse_type | def cysparse_type_to_real_sum_cysparse_type(cysparse_type):
"""
Returns the best **real** type for a **real** sum for a given type.
For instance:
INT32_t -> FLOAT64_t
Args:
cysparse_type:
"""
r_type = None
if cysparse_type in ['INT32_t', 'UINT32_t', 'INT64_t', 'UINT64_t... | python | def cysparse_type_to_real_sum_cysparse_type(cysparse_type):
"""
Returns the best **real** type for a **real** sum for a given type.
For instance:
INT32_t -> FLOAT64_t
Args:
cysparse_type:
"""
r_type = None
if cysparse_type in ['INT32_t', 'UINT32_t', 'INT64_t', 'UINT64_t... | [
"def",
"cysparse_type_to_real_sum_cysparse_type",
"(",
"cysparse_type",
")",
":",
"r_type",
"=",
"None",
"if",
"cysparse_type",
"in",
"[",
"'INT32_t'",
",",
"'UINT32_t'",
",",
"'INT64_t'",
",",
"'UINT64_t'",
"]",
":",
"r_type",
"=",
"'FLOAT64_t'",
"elif",
"cyspars... | Returns the best **real** type for a **real** sum for a given type.
For instance:
INT32_t -> FLOAT64_t
Args:
cysparse_type: | [
"Returns",
"the",
"best",
"**",
"real",
"**",
"type",
"for",
"a",
"**",
"real",
"**",
"sum",
"for",
"a",
"given",
"type",
"."
] | a9ef91cdfa8452beeeec4f050f928b830379f91c | https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/filters/type_filters.py#L64-L94 | train | Returns the best real type for a given type. |
PythonOptimizers/cygenja | cygenja/filters/type_filters.py | cysparse_real_type_from_real_cysparse_complex_type | def cysparse_real_type_from_real_cysparse_complex_type(cysparse_type):
"""
Returns the **real** type for the real or imaginary part of a **real** complex type.
For instance:
COMPLEX128_t -> FLOAT64_t
Args:
cysparse:
"""
r_type = None
if cysparse_type in ['COMPLEX64_t']:
... | python | def cysparse_real_type_from_real_cysparse_complex_type(cysparse_type):
"""
Returns the **real** type for the real or imaginary part of a **real** complex type.
For instance:
COMPLEX128_t -> FLOAT64_t
Args:
cysparse:
"""
r_type = None
if cysparse_type in ['COMPLEX64_t']:
... | [
"def",
"cysparse_real_type_from_real_cysparse_complex_type",
"(",
"cysparse_type",
")",
":",
"r_type",
"=",
"None",
"if",
"cysparse_type",
"in",
"[",
"'COMPLEX64_t'",
"]",
":",
"r_type",
"=",
"'FLOAT32_t'",
"elif",
"cysparse_type",
"in",
"[",
"'COMPLEX128_t'",
"]",
... | Returns the **real** type for the real or imaginary part of a **real** complex type.
For instance:
COMPLEX128_t -> FLOAT64_t
Args:
cysparse: | [
"Returns",
"the",
"**",
"real",
"**",
"type",
"for",
"the",
"real",
"or",
"imaginary",
"part",
"of",
"a",
"**",
"real",
"**",
"complex",
"type",
"."
] | a9ef91cdfa8452beeeec4f050f928b830379f91c | https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/filters/type_filters.py#L97-L120 | train | Returns the real type for the real or imaginary part of a complex type. |
klen/zeta-library | zetalibrary/parser.py | Parser.read | def read(path, savedir):
" Read file from path "
if path.startswith('http://'):
name = op.basename(path)
save_path = op.join(savedir, name)
if not op.exists(save_path):
src = urllib2.urlopen(path).read()
try:
open(sa... | python | def read(path, savedir):
" Read file from path "
if path.startswith('http://'):
name = op.basename(path)
save_path = op.join(savedir, name)
if not op.exists(save_path):
src = urllib2.urlopen(path).read()
try:
open(sa... | [
"def",
"read",
"(",
"path",
",",
"savedir",
")",
":",
"if",
"path",
".",
"startswith",
"(",
"'http://'",
")",
":",
"name",
"=",
"op",
".",
"basename",
"(",
"path",
")",
"save_path",
"=",
"op",
".",
"join",
"(",
"savedir",
",",
"name",
")",
"if",
... | Read file from path | [
"Read",
"file",
"from",
"path"
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/parser.py#L25-L37 | train | Read file from path |
klen/zeta-library | zetalibrary/parser.py | Parser.parse_imports | def parse_imports(self, src):
" Parse imports from source. "
result = []
def child(obj):
result.append(obj.group(1))
src = self.import_re.sub(child, src)
return src, result | python | def parse_imports(self, src):
" Parse imports from source. "
result = []
def child(obj):
result.append(obj.group(1))
src = self.import_re.sub(child, src)
return src, result | [
"def",
"parse_imports",
"(",
"self",
",",
"src",
")",
":",
"result",
"=",
"[",
"]",
"def",
"child",
"(",
"obj",
")",
":",
"result",
".",
"append",
"(",
"obj",
".",
"group",
"(",
"1",
")",
")",
"src",
"=",
"self",
".",
"import_re",
".",
"sub",
"... | Parse imports from source. | [
"Parse",
"imports",
"from",
"source",
"."
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/parser.py#L43-L50 | train | Parse imports from source. |
carta/ldap_tools | src/ldap_tools/audit.py | API.by_user | def by_user(self): # pragma: no cover
"""
Display group membership sorted by group.
Returns:
Array with a dictionary of group membership.
For example: {'test.user': ['testgroup', 'testgroup2']}
"""
users = [i for i in self.__get_users()]
use... | python | def by_user(self): # pragma: no cover
"""
Display group membership sorted by group.
Returns:
Array with a dictionary of group membership.
For example: {'test.user': ['testgroup', 'testgroup2']}
"""
users = [i for i in self.__get_users()]
use... | [
"def",
"by_user",
"(",
"self",
")",
":",
"# pragma: no cover",
"users",
"=",
"[",
"i",
"for",
"i",
"in",
"self",
".",
"__get_users",
"(",
")",
"]",
"user_groups",
"=",
"{",
"}",
"group_results",
"=",
"{",
"tuple",
"(",
"value",
")",
":",
"key",
"for"... | Display group membership sorted by group.
Returns:
Array with a dictionary of group membership.
For example: {'test.user': ['testgroup', 'testgroup2']} | [
"Display",
"group",
"membership",
"sorted",
"by",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/audit.py#L13-L34 | train | Display group membership sorted by group. |
carta/ldap_tools | src/ldap_tools/audit.py | API.by_group | def by_group(self): # pragma: no cover
"""
Display group membership sorted by group.
Returns:
Array with a dictionary of group membership.
For example: {'testgroup': ['test.user', 'test.user2']}
"""
group_membership = {}
for record in self._... | python | def by_group(self): # pragma: no cover
"""
Display group membership sorted by group.
Returns:
Array with a dictionary of group membership.
For example: {'testgroup': ['test.user', 'test.user2']}
"""
group_membership = {}
for record in self._... | [
"def",
"by_group",
"(",
"self",
")",
":",
"# pragma: no cover",
"group_membership",
"=",
"{",
"}",
"for",
"record",
"in",
"self",
".",
"__get_groups_with_membership",
"(",
")",
":",
"group_membership",
"[",
"record",
".",
"cn",
".",
"value",
"]",
"=",
"[",
... | Display group membership sorted by group.
Returns:
Array with a dictionary of group membership.
For example: {'testgroup': ['test.user', 'test.user2']} | [
"Display",
"group",
"membership",
"sorted",
"by",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/audit.py#L36-L50 | train | Display group membership sorted by group. |
carta/ldap_tools | src/ldap_tools/audit.py | API.__get_users | def __get_users(self): # pragma: no cover
"""Get user list."""
filter = ['(objectclass=posixAccount)']
results = self.client.search(filter, ['uid'])
for result in results:
yield result.uid.value | python | def __get_users(self): # pragma: no cover
"""Get user list."""
filter = ['(objectclass=posixAccount)']
results = self.client.search(filter, ['uid'])
for result in results:
yield result.uid.value | [
"def",
"__get_users",
"(",
"self",
")",
":",
"# pragma: no cover",
"filter",
"=",
"[",
"'(objectclass=posixAccount)'",
"]",
"results",
"=",
"self",
".",
"client",
".",
"search",
"(",
"filter",
",",
"[",
"'uid'",
"]",
")",
"for",
"result",
"in",
"results",
... | Get user list. | [
"Get",
"user",
"list",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/audit.py#L63-L68 | train | Get user list. |
carta/ldap_tools | src/ldap_tools/audit.py | CLI.by_user | def by_user(config):
"""Display LDAP group membership sorted by user."""
client = Client()
client.prepare_connection()
audit_api = API(client)
CLI.parse_membership('Groups by User', audit_api.by_user()) | python | def by_user(config):
"""Display LDAP group membership sorted by user."""
client = Client()
client.prepare_connection()
audit_api = API(client)
CLI.parse_membership('Groups by User', audit_api.by_user()) | [
"def",
"by_user",
"(",
"config",
")",
":",
"client",
"=",
"Client",
"(",
")",
"client",
".",
"prepare_connection",
"(",
")",
"audit_api",
"=",
"API",
"(",
"client",
")",
"CLI",
".",
"parse_membership",
"(",
"'Groups by User'",
",",
"audit_api",
".",
"by_us... | Display LDAP group membership sorted by user. | [
"Display",
"LDAP",
"group",
"membership",
"sorted",
"by",
"user",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/audit.py#L82-L87 | train | Display LDAP group membership sorted by user. |
carta/ldap_tools | src/ldap_tools/audit.py | CLI.raw | def raw(config): # pragma: no cover
"""Dump the contents of LDAP to console in raw format."""
client = Client()
client.prepare_connection()
audit_api = API(client)
print(audit_api.raw()) | python | def raw(config): # pragma: no cover
"""Dump the contents of LDAP to console in raw format."""
client = Client()
client.prepare_connection()
audit_api = API(client)
print(audit_api.raw()) | [
"def",
"raw",
"(",
"config",
")",
":",
"# pragma: no cover",
"client",
"=",
"Client",
"(",
")",
"client",
".",
"prepare_connection",
"(",
")",
"audit_api",
"=",
"API",
"(",
"client",
")",
"print",
"(",
"audit_api",
".",
"raw",
"(",
")",
")"
] | Dump the contents of LDAP to console in raw format. | [
"Dump",
"the",
"contents",
"of",
"LDAP",
"to",
"console",
"in",
"raw",
"format",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/audit.py#L100-L105 | train | Dump the contents of LDAP to console in raw format. |
carta/ldap_tools | src/ldap_tools/audit.py | CLI.parse_membership | def parse_membership(header_string, membership): # pragma: no cover
"""Print membership for #by_group and #by_user."""
print(header_string, "\n{}".format('=' * len(header_string)))
for key, values in membership.items():
if values is None:
continue
print('... | python | def parse_membership(header_string, membership): # pragma: no cover
"""Print membership for #by_group and #by_user."""
print(header_string, "\n{}".format('=' * len(header_string)))
for key, values in membership.items():
if values is None:
continue
print('... | [
"def",
"parse_membership",
"(",
"header_string",
",",
"membership",
")",
":",
"# pragma: no cover",
"print",
"(",
"header_string",
",",
"\"\\n{}\"",
".",
"format",
"(",
"'='",
"*",
"len",
"(",
"header_string",
")",
")",
")",
"for",
"key",
",",
"values",
"in"... | Print membership for #by_group and #by_user. | [
"Print",
"membership",
"for",
"#by_group",
"and",
"#by_user",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/audit.py#L107-L115 | train | Print membership for by_group and by_user. |
djaodjin/djaodjin-deployutils | deployutils/apps/django/backends/jwt_session_store.py | SessionStore.prepare | def prepare(session_data={}, #pylint: disable=dangerous-default-value
passphrase=None):
"""
Returns *session_dict* as a base64 encrypted json string.
"""
if passphrase is None:
passphrase = settings.DJAODJIN_SECRET_KEY
return encode(session_data, pass... | python | def prepare(session_data={}, #pylint: disable=dangerous-default-value
passphrase=None):
"""
Returns *session_dict* as a base64 encrypted json string.
"""
if passphrase is None:
passphrase = settings.DJAODJIN_SECRET_KEY
return encode(session_data, pass... | [
"def",
"prepare",
"(",
"session_data",
"=",
"{",
"}",
",",
"#pylint: disable=dangerous-default-value",
"passphrase",
"=",
"None",
")",
":",
"if",
"passphrase",
"is",
"None",
":",
"passphrase",
"=",
"settings",
".",
"DJAODJIN_SECRET_KEY",
"return",
"encode",
"(",
... | Returns *session_dict* as a base64 encrypted json string. | [
"Returns",
"*",
"session_dict",
"*",
"as",
"a",
"base64",
"encrypted",
"json",
"string",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/backends/jwt_session_store.py#L60-L69 | train | Returns the session_data as a base64 encrypted json string. |
djaodjin/djaodjin-deployutils | deployutils/apps/django/backends/jwt_session_store.py | SessionStore.load | def load(self):
"""
We load the data from the key itself instead of fetching from
some external data store. Opposite of _get_session_key(),
raises BadSignature if signature fails.
"""
session_data = {}
try:
session_data = decode(self.session_key,
... | python | def load(self):
"""
We load the data from the key itself instead of fetching from
some external data store. Opposite of _get_session_key(),
raises BadSignature if signature fails.
"""
session_data = {}
try:
session_data = decode(self.session_key,
... | [
"def",
"load",
"(",
"self",
")",
":",
"session_data",
"=",
"{",
"}",
"try",
":",
"session_data",
"=",
"decode",
"(",
"self",
".",
"session_key",
",",
"settings",
".",
"DJAODJIN_SECRET_KEY",
")",
"self",
".",
"_session_key_data",
".",
"update",
"(",
"sessio... | We load the data from the key itself instead of fetching from
some external data store. Opposite of _get_session_key(),
raises BadSignature if signature fails. | [
"We",
"load",
"the",
"data",
"from",
"the",
"key",
"itself",
"instead",
"of",
"fetching",
"from",
"some",
"external",
"data",
"store",
".",
"Opposite",
"of",
"_get_session_key",
"()",
"raises",
"BadSignature",
"if",
"signature",
"fails",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/backends/jwt_session_store.py#L71-L102 | train | Load the session data from the key itself if it exists. |
skioo/django-customer-billing | billing/psp.py | charge_credit_card | def charge_credit_card(credit_card_psp_object: Model, amount: Money, client_ref: str) -> Tuple[bool, Model]:
"""
:param credit_card_psp_object: an instance representing the credit card in the psp
:param amount: the amount to charge
:param client_ref: a reference that will appear on the customer's credit... | python | def charge_credit_card(credit_card_psp_object: Model, amount: Money, client_ref: str) -> Tuple[bool, Model]:
"""
:param credit_card_psp_object: an instance representing the credit card in the psp
:param amount: the amount to charge
:param client_ref: a reference that will appear on the customer's credit... | [
"def",
"charge_credit_card",
"(",
"credit_card_psp_object",
":",
"Model",
",",
"amount",
":",
"Money",
",",
"client_ref",
":",
"str",
")",
"->",
"Tuple",
"[",
"bool",
",",
"Model",
"]",
":",
"logger",
".",
"debug",
"(",
"'charge-credit-card'",
",",
"credit_c... | :param credit_card_psp_object: an instance representing the credit card in the psp
:param amount: the amount to charge
:param client_ref: a reference that will appear on the customer's credit card report
:return: a tuple (success, payment_psp_object) | [
":",
"param",
"credit_card_psp_object",
":",
"an",
"instance",
"representing",
"the",
"credit",
"card",
"in",
"the",
"psp",
":",
"param",
"amount",
":",
"the",
"amount",
"to",
"charge",
":",
"param",
"client_ref",
":",
"a",
"reference",
"that",
"will",
"appe... | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/psp.py#L16-L28 | train | charge a credit card in a psp |
skioo/django-customer-billing | billing/psp.py | refund_payment | def refund_payment(payment_psp_object: Model, amount: Money, client_ref: str) -> Tuple[bool, Model]:
"""
:param payment_psp_object: an instance representing the original payment in the psp
:param amount: the amount to refund
:param client_ref: a reference that will appear on the customer's credit card s... | python | def refund_payment(payment_psp_object: Model, amount: Money, client_ref: str) -> Tuple[bool, Model]:
"""
:param payment_psp_object: an instance representing the original payment in the psp
:param amount: the amount to refund
:param client_ref: a reference that will appear on the customer's credit card s... | [
"def",
"refund_payment",
"(",
"payment_psp_object",
":",
"Model",
",",
"amount",
":",
"Money",
",",
"client_ref",
":",
"str",
")",
"->",
"Tuple",
"[",
"bool",
",",
"Model",
"]",
":",
"logger",
".",
"debug",
"(",
"'refund-payment'",
",",
"payment_psp_object",... | :param payment_psp_object: an instance representing the original payment in the psp
:param amount: the amount to refund
:param client_ref: a reference that will appear on the customer's credit card statement
:return: a tuple (success, refund_psp_object) | [
":",
"param",
"payment_psp_object",
":",
"an",
"instance",
"representing",
"the",
"original",
"payment",
"in",
"the",
"psp",
":",
"param",
"amount",
":",
"the",
"amount",
"to",
"refund",
":",
"param",
"client_ref",
":",
"a",
"reference",
"that",
"will",
"app... | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/psp.py#L31-L42 | train | Refund a payment in the psp using the given amount. |
skioo/django-customer-billing | billing/psp.py | PSP.charge_credit_card | def charge_credit_card(self, credit_card_psp_object: Model, amount: Money, client_ref: str) -> Tuple[bool, Model]:
"""
:param credit_card_psp_object: an instance representing the credit card in the psp
:param amount: the amount to charge
:param client_ref: a reference that will appear on... | python | def charge_credit_card(self, credit_card_psp_object: Model, amount: Money, client_ref: str) -> Tuple[bool, Model]:
"""
:param credit_card_psp_object: an instance representing the credit card in the psp
:param amount: the amount to charge
:param client_ref: a reference that will appear on... | [
"def",
"charge_credit_card",
"(",
"self",
",",
"credit_card_psp_object",
":",
"Model",
",",
"amount",
":",
"Money",
",",
"client_ref",
":",
"str",
")",
"->",
"Tuple",
"[",
"bool",
",",
"Model",
"]",
":",
"pass"
] | :param credit_card_psp_object: an instance representing the credit card in the psp
:param amount: the amount to charge
:param client_ref: a reference that will appear on the customer's credit card report
:return: a tuple (success, payment_psp_object) | [
":",
"param",
"credit_card_psp_object",
":",
"an",
"instance",
"representing",
"the",
"credit",
"card",
"in",
"the",
"psp",
":",
"param",
"amount",
":",
"the",
"amount",
"to",
"charge",
":",
"param",
"client_ref",
":",
"a",
"reference",
"that",
"will",
"appe... | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/psp.py#L58-L65 | train | charge credit card in the psp to the amount |
skioo/django-customer-billing | billing/psp.py | PSP.refund_payment | def refund_payment(self, payment_psp_object: Model, amount: Money, client_ref: str) -> Tuple[bool, Model]:
"""
:param payment_psp_object: an instance representing the original payment in the psp
:param amount: the amount to refund
:param client_ref: a reference that will appear on the cu... | python | def refund_payment(self, payment_psp_object: Model, amount: Money, client_ref: str) -> Tuple[bool, Model]:
"""
:param payment_psp_object: an instance representing the original payment in the psp
:param amount: the amount to refund
:param client_ref: a reference that will appear on the cu... | [
"def",
"refund_payment",
"(",
"self",
",",
"payment_psp_object",
":",
"Model",
",",
"amount",
":",
"Money",
",",
"client_ref",
":",
"str",
")",
"->",
"Tuple",
"[",
"bool",
",",
"Model",
"]",
":",
"pass"
] | :param payment_psp_object: an instance representing the original payment in the psp
:param amount: the amount to refund
:param client_ref: a reference that will appear on the customer's credit card statement
:return: a tuple (success, refund_psp_object) | [
":",
"param",
"payment_psp_object",
":",
"an",
"instance",
"representing",
"the",
"original",
"payment",
"in",
"the",
"psp",
":",
"param",
"amount",
":",
"the",
"amount",
"to",
"refund",
":",
"param",
"client_ref",
":",
"a",
"reference",
"that",
"will",
"app... | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/psp.py#L67-L74 | train | Refund a payment in the psp
and return the refund_psp_object |
Genida/dependenpy | src/dependenpy/cli.py | get_parser | def get_parser():
"""Return a parser for the command-line arguments."""
parser = argparse.ArgumentParser(
add_help=False,
description='Command line tool for dependenpy Python package.')
mxg = parser.add_mutually_exclusive_group(required=False)
parser.add_argument(
'packages', me... | python | def get_parser():
"""Return a parser for the command-line arguments."""
parser = argparse.ArgumentParser(
add_help=False,
description='Command line tool for dependenpy Python package.')
mxg = parser.add_mutually_exclusive_group(required=False)
parser.add_argument(
'packages', me... | [
"def",
"get_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"add_help",
"=",
"False",
",",
"description",
"=",
"'Command line tool for dependenpy Python package.'",
")",
"mxg",
"=",
"parser",
".",
"add_mutually_exclusive_group",
"(",
"... | Return a parser for the command-line arguments. | [
"Return",
"a",
"parser",
"for",
"the",
"command",
"-",
"line",
"arguments",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/cli.py#L28-L79 | train | Return a parser for the command - line arguments. |
Genida/dependenpy | src/dependenpy/cli.py | main | def main(args=None):
"""
Main function.
This function is the command line entry point.
Args:
args (list of str): the arguments passed to the program.
Returns:
int: return code being 0 (OK), 1 (dsm empty) or 2 (error).
"""
parser = get_parser()
args = parser.parse_args(... | python | def main(args=None):
"""
Main function.
This function is the command line entry point.
Args:
args (list of str): the arguments passed to the program.
Returns:
int: return code being 0 (OK), 1 (dsm empty) or 2 (error).
"""
parser = get_parser()
args = parser.parse_args(... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"parser",
"=",
"get_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
"args",
"=",
"args",
")",
"if",
"not",
"(",
"args",
".",
"matrix",
"or",
"args",
".",
"dependencies",
"or",
"ar... | Main function.
This function is the command line entry point.
Args:
args (list of str): the arguments passed to the program.
Returns:
int: return code being 0 (OK), 1 (dsm empty) or 2 (error). | [
"Main",
"function",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/cli.py#L82-L151 | train | This function is the main function of the DSM command line entry point. It is the main function of the DSM command line interface. It is the main function of the DSM command line interface. |
klichukb/django-migrate-sql | migrate_sql/operations.py | MigrateSQLMixin.get_sql_state | def get_sql_state(self, state):
"""
Get SQLStateGraph from state.
"""
if not hasattr(state, 'sql_state'):
setattr(state, 'sql_state', SQLStateGraph())
return state.sql_state | python | def get_sql_state(self, state):
"""
Get SQLStateGraph from state.
"""
if not hasattr(state, 'sql_state'):
setattr(state, 'sql_state', SQLStateGraph())
return state.sql_state | [
"def",
"get_sql_state",
"(",
"self",
",",
"state",
")",
":",
"if",
"not",
"hasattr",
"(",
"state",
",",
"'sql_state'",
")",
":",
"setattr",
"(",
"state",
",",
"'sql_state'",
",",
"SQLStateGraph",
"(",
")",
")",
"return",
"state",
".",
"sql_state"
] | Get SQLStateGraph from state. | [
"Get",
"SQLStateGraph",
"from",
"state",
"."
] | be48ff2c9283404e3d951128c459c3496d1ba25d | https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/operations.py#L12-L18 | train | Get SQLStateGraph from state. |
smnorris/bcdata | bcdata/wfs.py | get_sortkey | def get_sortkey(table):
"""Get a field to sort by
"""
# Just pick the first column in the table in alphabetical order.
# Ideally we would get the primary key from bcdc api, but it doesn't
# seem to be available
wfs = WebFeatureService(url=bcdata.OWS_URL, version="2.0.0")
return sorted(wfs.ge... | python | def get_sortkey(table):
"""Get a field to sort by
"""
# Just pick the first column in the table in alphabetical order.
# Ideally we would get the primary key from bcdc api, but it doesn't
# seem to be available
wfs = WebFeatureService(url=bcdata.OWS_URL, version="2.0.0")
return sorted(wfs.ge... | [
"def",
"get_sortkey",
"(",
"table",
")",
":",
"# Just pick the first column in the table in alphabetical order.",
"# Ideally we would get the primary key from bcdc api, but it doesn't",
"# seem to be available",
"wfs",
"=",
"WebFeatureService",
"(",
"url",
"=",
"bcdata",
".",
"OWS_... | Get a field to sort by | [
"Get",
"a",
"field",
"to",
"sort",
"by"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L26-L33 | train | Get a field to sort by
|
smnorris/bcdata | bcdata/wfs.py | check_cache | def check_cache(path):
"""Return true if the cache file holding list of all datasets
does not exist or is older than 30 days
"""
if not os.path.exists(path):
return True
else:
# check the age
mod_date = datetime.fromtimestamp(os.path.getmtime(path))
if mod_date < (dat... | python | def check_cache(path):
"""Return true if the cache file holding list of all datasets
does not exist or is older than 30 days
"""
if not os.path.exists(path):
return True
else:
# check the age
mod_date = datetime.fromtimestamp(os.path.getmtime(path))
if mod_date < (dat... | [
"def",
"check_cache",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"True",
"else",
":",
"# check the age",
"mod_date",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"os",
".",
"path",
".",
"getmti... | Return true if the cache file holding list of all datasets
does not exist or is older than 30 days | [
"Return",
"true",
"if",
"the",
"cache",
"file",
"holding",
"list",
"of",
"all",
"datasets",
"does",
"not",
"exist",
"or",
"is",
"older",
"than",
"30",
"days"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L36-L48 | train | Return true if the cache file holding list of all datasets
does not exist or is older than 30 days |
smnorris/bcdata | bcdata/wfs.py | bcdc_package_show | def bcdc_package_show(package):
"""Query DataBC Catalogue API about given package
"""
params = {"id": package}
r = requests.get(bcdata.BCDC_API_URL + "package_show", params=params)
if r.status_code != 200:
raise ValueError("{d} is not present in DataBC API list".format(d=package))
return... | python | def bcdc_package_show(package):
"""Query DataBC Catalogue API about given package
"""
params = {"id": package}
r = requests.get(bcdata.BCDC_API_URL + "package_show", params=params)
if r.status_code != 200:
raise ValueError("{d} is not present in DataBC API list".format(d=package))
return... | [
"def",
"bcdc_package_show",
"(",
"package",
")",
":",
"params",
"=",
"{",
"\"id\"",
":",
"package",
"}",
"r",
"=",
"requests",
".",
"get",
"(",
"bcdata",
".",
"BCDC_API_URL",
"+",
"\"package_show\"",
",",
"params",
"=",
"params",
")",
"if",
"r",
".",
"... | Query DataBC Catalogue API about given package | [
"Query",
"DataBC",
"Catalogue",
"API",
"about",
"given",
"package"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L51-L58 | train | Query DataBC Catalogue API about given package
|
smnorris/bcdata | bcdata/wfs.py | list_tables | def list_tables(refresh=False, cache_file=None):
"""Return a list of all datasets available via WFS
"""
# default cache listing all objects available is
# ~/.bcdata
if not cache_file:
cache_file = os.path.join(str(Path.home()), ".bcdata")
# regenerate the cache if:
# - the cache fil... | python | def list_tables(refresh=False, cache_file=None):
"""Return a list of all datasets available via WFS
"""
# default cache listing all objects available is
# ~/.bcdata
if not cache_file:
cache_file = os.path.join(str(Path.home()), ".bcdata")
# regenerate the cache if:
# - the cache fil... | [
"def",
"list_tables",
"(",
"refresh",
"=",
"False",
",",
"cache_file",
"=",
"None",
")",
":",
"# default cache listing all objects available is",
"# ~/.bcdata",
"if",
"not",
"cache_file",
":",
"cache_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"str",
"(",
... | Return a list of all datasets available via WFS | [
"Return",
"a",
"list",
"of",
"all",
"datasets",
"available",
"via",
"WFS"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L70-L91 | train | Return a list of all datasets available via WFS
|
smnorris/bcdata | bcdata/wfs.py | get_count | def get_count(dataset, query=None):
"""Ask DataBC WFS how many features there are in a table/query
"""
# https://gis.stackexchange.com/questions/45101/only-return-the-numberoffeatures-in-a-wfs-query
table = validate_name(dataset)
payload = {
"service": "WFS",
"version": "2.0.0",
... | python | def get_count(dataset, query=None):
"""Ask DataBC WFS how many features there are in a table/query
"""
# https://gis.stackexchange.com/questions/45101/only-return-the-numberoffeatures-in-a-wfs-query
table = validate_name(dataset)
payload = {
"service": "WFS",
"version": "2.0.0",
... | [
"def",
"get_count",
"(",
"dataset",
",",
"query",
"=",
"None",
")",
":",
"# https://gis.stackexchange.com/questions/45101/only-return-the-numberoffeatures-in-a-wfs-query",
"table",
"=",
"validate_name",
"(",
"dataset",
")",
"payload",
"=",
"{",
"\"service\"",
":",
"\"WFS\... | Ask DataBC WFS how many features there are in a table/query | [
"Ask",
"DataBC",
"WFS",
"how",
"many",
"features",
"there",
"are",
"in",
"a",
"table",
"/",
"query"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L94-L110 | train | Ask DataBC WFS how many features there are in a table |
smnorris/bcdata | bcdata/wfs.py | make_request | def make_request(parameters):
"""Submit a getfeature request to DataBC WFS and return features
"""
r = requests.get(bcdata.WFS_URL, params=parameters)
return r.json()["features"] | python | def make_request(parameters):
"""Submit a getfeature request to DataBC WFS and return features
"""
r = requests.get(bcdata.WFS_URL, params=parameters)
return r.json()["features"] | [
"def",
"make_request",
"(",
"parameters",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"bcdata",
".",
"WFS_URL",
",",
"params",
"=",
"parameters",
")",
"return",
"r",
".",
"json",
"(",
")",
"[",
"\"features\"",
"]"
] | Submit a getfeature request to DataBC WFS and return features | [
"Submit",
"a",
"getfeature",
"request",
"to",
"DataBC",
"WFS",
"and",
"return",
"features"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L113-L117 | train | Submit a getfeature request to DataBC WFS and return features
|
smnorris/bcdata | bcdata/wfs.py | define_request | def define_request(
dataset, query=None, crs="epsg:4326", bounds=None, sortby=None, pagesize=10000
):
"""Define the getfeature request parameters required to download a dataset
References:
- http://www.opengeospatial.org/standards/wfs
- http://docs.geoserver.org/stable/en/user/services/wfs/vendor.h... | python | def define_request(
dataset, query=None, crs="epsg:4326", bounds=None, sortby=None, pagesize=10000
):
"""Define the getfeature request parameters required to download a dataset
References:
- http://www.opengeospatial.org/standards/wfs
- http://docs.geoserver.org/stable/en/user/services/wfs/vendor.h... | [
"def",
"define_request",
"(",
"dataset",
",",
"query",
"=",
"None",
",",
"crs",
"=",
"\"epsg:4326\"",
",",
"bounds",
"=",
"None",
",",
"sortby",
"=",
"None",
",",
"pagesize",
"=",
"10000",
")",
":",
"# validate the table name and find out how many features it hold... | Define the getfeature request parameters required to download a dataset
References:
- http://www.opengeospatial.org/standards/wfs
- http://docs.geoserver.org/stable/en/user/services/wfs/vendor.html
- http://docs.geoserver.org/latest/en/user/tutorials/cql/cql_tutorial.html | [
"Define",
"the",
"getfeature",
"request",
"parameters",
"required",
"to",
"download",
"a",
"dataset"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L120-L167 | train | Define the getfeature request parameters required to download a dataset. |
smnorris/bcdata | bcdata/wfs.py | get_data | def get_data(
dataset,
query=None,
crs="epsg:4326",
bounds=None,
sortby=None,
pagesize=10000,
max_workers=5,
):
"""Get GeoJSON featurecollection from DataBC WFS
"""
param_dicts = define_request(dataset, query, crs, bounds, sortby, pagesize)
with ThreadPoolExecutor(max_worker... | python | def get_data(
dataset,
query=None,
crs="epsg:4326",
bounds=None,
sortby=None,
pagesize=10000,
max_workers=5,
):
"""Get GeoJSON featurecollection from DataBC WFS
"""
param_dicts = define_request(dataset, query, crs, bounds, sortby, pagesize)
with ThreadPoolExecutor(max_worker... | [
"def",
"get_data",
"(",
"dataset",
",",
"query",
"=",
"None",
",",
"crs",
"=",
"\"epsg:4326\"",
",",
"bounds",
"=",
"None",
",",
"sortby",
"=",
"None",
",",
"pagesize",
"=",
"10000",
",",
"max_workers",
"=",
"5",
",",
")",
":",
"param_dicts",
"=",
"d... | Get GeoJSON featurecollection from DataBC WFS | [
"Get",
"GeoJSON",
"featurecollection",
"from",
"DataBC",
"WFS"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L170-L189 | train | Get GeoJSON featurecollection from DataBC WFS
|
smnorris/bcdata | bcdata/wfs.py | get_features | def get_features(
dataset,
query=None,
crs="epsg:4326",
bounds=None,
sortby=None,
pagesize=10000,
max_workers=5,
):
"""Yield features from DataBC WFS
"""
param_dicts = define_request(dataset, query, crs, bounds, sortby, pagesize)
with ThreadPoolExecutor(max_workers=max_worke... | python | def get_features(
dataset,
query=None,
crs="epsg:4326",
bounds=None,
sortby=None,
pagesize=10000,
max_workers=5,
):
"""Yield features from DataBC WFS
"""
param_dicts = define_request(dataset, query, crs, bounds, sortby, pagesize)
with ThreadPoolExecutor(max_workers=max_worke... | [
"def",
"get_features",
"(",
"dataset",
",",
"query",
"=",
"None",
",",
"crs",
"=",
"\"epsg:4326\"",
",",
"bounds",
"=",
"None",
",",
"sortby",
"=",
"None",
",",
"pagesize",
"=",
"10000",
",",
"max_workers",
"=",
"5",
",",
")",
":",
"param_dicts",
"=",
... | Yield features from DataBC WFS | [
"Yield",
"features",
"from",
"DataBC",
"WFS"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L192-L208 | train | Yield features from DataBC WFS
|
pneff/wsgiservice | wsgiservice/routing.py | Router._get_sorted | def _get_sorted(self, resources):
"""Order the resources by priority - the most specific paths come
first.
:param resources: List of :class:`wsgiservice.resource.Resource`
classes to be served by this application.
"""
tmp = []
for resource in re... | python | def _get_sorted(self, resources):
"""Order the resources by priority - the most specific paths come
first.
:param resources: List of :class:`wsgiservice.resource.Resource`
classes to be served by this application.
"""
tmp = []
for resource in re... | [
"def",
"_get_sorted",
"(",
"self",
",",
"resources",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"resource",
"in",
"resources",
":",
"path",
"=",
"resource",
".",
"_path",
"# Each slash counts as 10 priority, each variable takes one away",
"priority",
"=",
"path",
".",... | Order the resources by priority - the most specific paths come
first.
:param resources: List of :class:`wsgiservice.resource.Resource`
classes to be served by this application. | [
"Order",
"the",
"resources",
"by",
"priority",
"-",
"the",
"most",
"specific",
"paths",
"come",
"first",
"."
] | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/routing.py#L24-L37 | train | Order the resources by priority - the most specific paths come
AttributeNames first. |
pneff/wsgiservice | wsgiservice/routing.py | Router._compile | def _compile(self, resources):
"""Compiles a list of match functions (using regular expressions) for
the paths. Returns a list of two-item tuples consisting of the match
function and the resource class. The list is in the same order as the
resources parameter.
:param resources: ... | python | def _compile(self, resources):
"""Compiles a list of match functions (using regular expressions) for
the paths. Returns a list of two-item tuples consisting of the match
function and the resource class. The list is in the same order as the
resources parameter.
:param resources: ... | [
"def",
"_compile",
"(",
"self",
",",
"resources",
")",
":",
"routes",
"=",
"[",
"]",
"search_vars",
"=",
"re",
".",
"compile",
"(",
"r'\\{(\\w+)\\}'",
")",
".",
"finditer",
"for",
"resource",
"in",
"resources",
":",
"# Compile regular expression for each path",
... | Compiles a list of match functions (using regular expressions) for
the paths. Returns a list of two-item tuples consisting of the match
function and the resource class. The list is in the same order as the
resources parameter.
:param resources: List of :class:`wsgiservice.resource.Resou... | [
"Compiles",
"a",
"list",
"of",
"match",
"functions",
"(",
"using",
"regular",
"expressions",
")",
"for",
"the",
"paths",
".",
"Returns",
"a",
"list",
"of",
"two",
"-",
"item",
"tuples",
"consisting",
"of",
"the",
"match",
"function",
"and",
"the",
"resourc... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/routing.py#L39-L63 | train | Compiles a list of match functions using regular expressions for the paths. Returns a list of two - item tuples consisting of the match function and the resource class. |
mkoura/dump2polarion | dump2polarion/exporters/transform_projects.py | set_cfme_caselevel | def set_cfme_caselevel(testcase, caselevels):
"""Converts tier to caselevel."""
tier = testcase.get("caselevel")
if tier is None:
return
try:
caselevel = caselevels[int(tier)]
except IndexError:
# invalid value
caselevel = "component"
except ValueError:
#... | python | def set_cfme_caselevel(testcase, caselevels):
"""Converts tier to caselevel."""
tier = testcase.get("caselevel")
if tier is None:
return
try:
caselevel = caselevels[int(tier)]
except IndexError:
# invalid value
caselevel = "component"
except ValueError:
#... | [
"def",
"set_cfme_caselevel",
"(",
"testcase",
",",
"caselevels",
")",
":",
"tier",
"=",
"testcase",
".",
"get",
"(",
"\"caselevel\"",
")",
"if",
"tier",
"is",
"None",
":",
"return",
"try",
":",
"caselevel",
"=",
"caselevels",
"[",
"int",
"(",
"tier",
")"... | Converts tier to caselevel. | [
"Converts",
"tier",
"to",
"caselevel",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform_projects.py#L22-L37 | train | Converts tier to caselevel. |
mkoura/dump2polarion | dump2polarion/exporters/transform_projects.py | get_xunit_transform_cfme | def get_xunit_transform_cfme(config):
"""Return result transformation function for CFME."""
skip_searches = [
"SKIPME:",
"Skipping due to these blockers",
"BZ ?[0-9]+",
"GH ?#?[0-9]+",
"GH#ManageIQ",
]
skips = re.compile("(" + ")|(".join(skip_searches) + ")")
... | python | def get_xunit_transform_cfme(config):
"""Return result transformation function for CFME."""
skip_searches = [
"SKIPME:",
"Skipping due to these blockers",
"BZ ?[0-9]+",
"GH ?#?[0-9]+",
"GH#ManageIQ",
]
skips = re.compile("(" + ")|(".join(skip_searches) + ")")
... | [
"def",
"get_xunit_transform_cfme",
"(",
"config",
")",
":",
"skip_searches",
"=",
"[",
"\"SKIPME:\"",
",",
"\"Skipping due to these blockers\"",
",",
"\"BZ ?[0-9]+\"",
",",
"\"GH ?#?[0-9]+\"",
",",
"\"GH#ManageIQ\"",
",",
"]",
"skips",
"=",
"re",
".",
"compile",
"("... | Return result transformation function for CFME. | [
"Return",
"result",
"transformation",
"function",
"for",
"CFME",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform_projects.py#L40-L81 | train | Return a function that transforms the CFME result into a single object. |
mkoura/dump2polarion | dump2polarion/exporters/transform_projects.py | get_requirements_transform_cfme | def get_requirements_transform_cfme(config):
"""Return requirement transformation function for CFME."""
def requirement_transform(requirement):
"""Requirements transform for CFME."""
requirement = copy.deepcopy(requirement)
if "id" in requirement:
del requirement["id"]
... | python | def get_requirements_transform_cfme(config):
"""Return requirement transformation function for CFME."""
def requirement_transform(requirement):
"""Requirements transform for CFME."""
requirement = copy.deepcopy(requirement)
if "id" in requirement:
del requirement["id"]
... | [
"def",
"get_requirements_transform_cfme",
"(",
"config",
")",
":",
"def",
"requirement_transform",
"(",
"requirement",
")",
":",
"\"\"\"Requirements transform for CFME.\"\"\"",
"requirement",
"=",
"copy",
".",
"deepcopy",
"(",
"requirement",
")",
"if",
"\"id\"",
"in",
... | Return requirement transformation function for CFME. | [
"Return",
"requirement",
"transformation",
"function",
"for",
"CFME",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform_projects.py#L110-L122 | train | Returns a function that returns a copy of the requirements dict for CFME. |
mkoura/dump2polarion | dump2polarion/exporters/transform_projects.py | get_xunit_transform_cmp | def get_xunit_transform_cmp(config):
"""Return result transformation function for CFME."""
skip_searches = [
"SKIPME:",
"Skipping due to these blockers",
"BZ ?[0-9]+",
"GH ?#?[0-9]+",
"GH#ManageIQ",
]
skips = re.compile("(" + ")|(".join(skip_searches) + ")")
... | python | def get_xunit_transform_cmp(config):
"""Return result transformation function for CFME."""
skip_searches = [
"SKIPME:",
"Skipping due to these blockers",
"BZ ?[0-9]+",
"GH ?#?[0-9]+",
"GH#ManageIQ",
]
skips = re.compile("(" + ")|(".join(skip_searches) + ")")
... | [
"def",
"get_xunit_transform_cmp",
"(",
"config",
")",
":",
"skip_searches",
"=",
"[",
"\"SKIPME:\"",
",",
"\"Skipping due to these blockers\"",
",",
"\"BZ ?[0-9]+\"",
",",
"\"GH ?#?[0-9]+\"",
",",
"\"GH#ManageIQ\"",
",",
"]",
"skips",
"=",
"re",
".",
"compile",
"(",... | Return result transformation function for CFME. | [
"Return",
"result",
"transformation",
"function",
"for",
"CFME",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform_projects.py#L126-L175 | train | Return a function that transforms the result of CFME to XUnit. |
mkoura/dump2polarion | dump2polarion/exporters/transform_projects.py | get_requirements_transform_cloudtp | def get_requirements_transform_cloudtp(config):
"""Return requirement transformation function for CLOUDTP."""
def requirement_transform(requirement):
"""Requirements transform for CLOUDTP."""
requirement = copy.deepcopy(requirement)
if "id" in requirement:
del requirement["... | python | def get_requirements_transform_cloudtp(config):
"""Return requirement transformation function for CLOUDTP."""
def requirement_transform(requirement):
"""Requirements transform for CLOUDTP."""
requirement = copy.deepcopy(requirement)
if "id" in requirement:
del requirement["... | [
"def",
"get_requirements_transform_cloudtp",
"(",
"config",
")",
":",
"def",
"requirement_transform",
"(",
"requirement",
")",
":",
"\"\"\"Requirements transform for CLOUDTP.\"\"\"",
"requirement",
"=",
"copy",
".",
"deepcopy",
"(",
"requirement",
")",
"if",
"\"id\"",
"... | Return requirement transformation function for CLOUDTP. | [
"Return",
"requirement",
"transformation",
"function",
"for",
"CLOUDTP",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/transform_projects.py#L179-L196 | train | Returns a function that transforms the given requirements dictionary into CLOUDTP. |
oz123/blogit | blogit/blogit.py | render_archive | def render_archive(entries):
"""Creates the archive page"""
context = GLOBAL_TEMPLATE_CONTEXT.copy()
context['entries'] = entries
_render(context, 'archive_index.html',
os.path.join(CONFIG['output_to'], 'archive/index.html')), | python | def render_archive(entries):
"""Creates the archive page"""
context = GLOBAL_TEMPLATE_CONTEXT.copy()
context['entries'] = entries
_render(context, 'archive_index.html',
os.path.join(CONFIG['output_to'], 'archive/index.html')), | [
"def",
"render_archive",
"(",
"entries",
")",
":",
"context",
"=",
"GLOBAL_TEMPLATE_CONTEXT",
".",
"copy",
"(",
")",
"context",
"[",
"'entries'",
"]",
"=",
"entries",
"_render",
"(",
"context",
",",
"'archive_index.html'",
",",
"os",
".",
"path",
".",
"join"... | Creates the archive page | [
"Creates",
"the",
"archive",
"page"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L349-L354 | train | Creates the archive page |
oz123/blogit | blogit/blogit.py | find_new_posts_and_pages | def find_new_posts_and_pages(db):
"""Walk content dir, put each post and page in the database"""
Q = Query()
for root, dirs, files in os.walk(CONFIG['content_root']):
for filename in sorted([f for f in files if
f.endswith(('md', 'markdown'))]):
fullpath = ... | python | def find_new_posts_and_pages(db):
"""Walk content dir, put each post and page in the database"""
Q = Query()
for root, dirs, files in os.walk(CONFIG['content_root']):
for filename in sorted([f for f in files if
f.endswith(('md', 'markdown'))]):
fullpath = ... | [
"def",
"find_new_posts_and_pages",
"(",
"db",
")",
":",
"Q",
"=",
"Query",
"(",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"CONFIG",
"[",
"'content_root'",
"]",
")",
":",
"for",
"filename",
"in",
"sorted",
"(",
"[",
... | Walk content dir, put each post and page in the database | [
"Walk",
"content",
"dir",
"put",
"each",
"post",
"and",
"page",
"in",
"the",
"database"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L357-L381 | train | Walk content dir and put each post and page in the database |
oz123/blogit | blogit/blogit.py | _get_last_entries | def _get_last_entries(db, qty):
"""get all entries and the last qty entries"""
doc_ids = [post.doc_id for post in db.posts.all()]
doc_ids = sorted(doc_ids, reverse=True)
# bug: here we shoud only render doc_ids[:qty]
# but we can't use mtimes for sorting. We'll need to add ptime for the
# databa... | python | def _get_last_entries(db, qty):
"""get all entries and the last qty entries"""
doc_ids = [post.doc_id for post in db.posts.all()]
doc_ids = sorted(doc_ids, reverse=True)
# bug: here we shoud only render doc_ids[:qty]
# but we can't use mtimes for sorting. We'll need to add ptime for the
# databa... | [
"def",
"_get_last_entries",
"(",
"db",
",",
"qty",
")",
":",
"doc_ids",
"=",
"[",
"post",
".",
"doc_id",
"for",
"post",
"in",
"db",
".",
"posts",
".",
"all",
"(",
")",
"]",
"doc_ids",
"=",
"sorted",
"(",
"doc_ids",
",",
"reverse",
"=",
"True",
")",... | get all entries and the last qty entries | [
"get",
"all",
"entries",
"and",
"the",
"last",
"qty",
"entries"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L384-L396 | train | get all entries and the last qty entries |
oz123/blogit | blogit/blogit.py | update_index | def update_index(entries):
"""find the last 10 entries in the database and create the main
page.
Each entry in has an doc_id, so we only get the last 10 doc_ids.
This method also updates the ATOM feed.
"""
context = GLOBAL_TEMPLATE_CONTEXT.copy()
context['entries'] = entries
context['la... | python | def update_index(entries):
"""find the last 10 entries in the database and create the main
page.
Each entry in has an doc_id, so we only get the last 10 doc_ids.
This method also updates the ATOM feed.
"""
context = GLOBAL_TEMPLATE_CONTEXT.copy()
context['entries'] = entries
context['la... | [
"def",
"update_index",
"(",
"entries",
")",
":",
"context",
"=",
"GLOBAL_TEMPLATE_CONTEXT",
".",
"copy",
"(",
")",
"context",
"[",
"'entries'",
"]",
"=",
"entries",
"context",
"[",
"'last_build'",
"]",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")"... | find the last 10 entries in the database and create the main
page.
Each entry in has an doc_id, so we only get the last 10 doc_ids.
This method also updates the ATOM feed. | [
"find",
"the",
"last",
"10",
"entries",
"in",
"the",
"database",
"and",
"create",
"the",
"main",
"page",
".",
"Each",
"entry",
"in",
"has",
"an",
"doc_id",
"so",
"we",
"only",
"get",
"the",
"last",
"10",
"doc_ids",
"."
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L399-L413 | train | update the index with the last 10 entries in the database |
oz123/blogit | blogit/blogit.py | build | def build(config):
"""Incremental build of the website"""
logger.info("\nRendering website now...\n")
logger.info("entries:")
tags = dict()
entries = list()
for post, post_id in find_new_posts_and_pages(DB):
# this method will also parse the post's tags and
# update the db collec... | python | def build(config):
"""Incremental build of the website"""
logger.info("\nRendering website now...\n")
logger.info("entries:")
tags = dict()
entries = list()
for post, post_id in find_new_posts_and_pages(DB):
# this method will also parse the post's tags and
# update the db collec... | [
"def",
"build",
"(",
"config",
")",
":",
"logger",
".",
"info",
"(",
"\"\\nRendering website now...\\n\"",
")",
"logger",
".",
"info",
"(",
"\"entries:\"",
")",
"tags",
"=",
"dict",
"(",
")",
"entries",
"=",
"list",
"(",
")",
"for",
"post",
",",
"post_id... | Incremental build of the website | [
"Incremental",
"build",
"of",
"the",
"website"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L423-L464 | train | Incremental build of the website |
oz123/blogit | blogit/blogit.py | preview | def preview(): # pragma: no coverage
"""launch an HTTP to preview the website"""
Handler = http.server.SimpleHTTPRequestHandler
socketserver.TCPServer.allow_reuse_address = True
port = CONFIG['http_port']
httpd = socketserver.TCPServer(("", port), Handler)
os.chdir(CONFIG['output_to'])
try:... | python | def preview(): # pragma: no coverage
"""launch an HTTP to preview the website"""
Handler = http.server.SimpleHTTPRequestHandler
socketserver.TCPServer.allow_reuse_address = True
port = CONFIG['http_port']
httpd = socketserver.TCPServer(("", port), Handler)
os.chdir(CONFIG['output_to'])
try:... | [
"def",
"preview",
"(",
")",
":",
"# pragma: no coverage",
"Handler",
"=",
"http",
".",
"server",
".",
"SimpleHTTPRequestHandler",
"socketserver",
".",
"TCPServer",
".",
"allow_reuse_address",
"=",
"True",
"port",
"=",
"CONFIG",
"[",
"'http_port'",
"]",
"httpd",
... | launch an HTTP to preview the website | [
"launch",
"an",
"HTTP",
"to",
"preview",
"the",
"website"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L467-L480 | train | launch an HTTP to preview the website |
oz123/blogit | blogit/blogit.py | new_post | def new_post(GITDIRECTORY=CONFIG['output_to'], kind=KINDS['writing']): # pragma: no coverage # noqa
"""
This function should create a template for a new post with a title
read from the user input.
Most other fields should be defaults.
TODO: update this function
"""
title = input("Give the ... | python | def new_post(GITDIRECTORY=CONFIG['output_to'], kind=KINDS['writing']): # pragma: no coverage # noqa
"""
This function should create a template for a new post with a title
read from the user input.
Most other fields should be defaults.
TODO: update this function
"""
title = input("Give the ... | [
"def",
"new_post",
"(",
"GITDIRECTORY",
"=",
"CONFIG",
"[",
"'output_to'",
"]",
",",
"kind",
"=",
"KINDS",
"[",
"'writing'",
"]",
")",
":",
"# pragma: no coverage # noqa",
"title",
"=",
"input",
"(",
"\"Give the title of the post: \"",
")",
"while",
"':'",
"in",... | This function should create a template for a new post with a title
read from the user input.
Most other fields should be defaults.
TODO: update this function | [
"This",
"function",
"should",
"create",
"a",
"template",
"for",
"a",
"new",
"post",
"with",
"a",
"title",
"read",
"from",
"the",
"user",
"input",
".",
"Most",
"other",
"fields",
"should",
"be",
"defaults",
".",
"TODO",
":",
"update",
"this",
"function"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L497-L537 | train | Create a new post with the given title author and date. |
oz123/blogit | blogit/blogit.py | Tag.entries | def entries(self):
"""return the actual lists of entries tagged with"""
Tags = Query()
tag = self.table.get(Tags.name == self.name)
posts = tag['post_ids']
for id in posts:
post = self.db.posts.get(doc_id=id)
if not post: # pragma: no coverage
... | python | def entries(self):
"""return the actual lists of entries tagged with"""
Tags = Query()
tag = self.table.get(Tags.name == self.name)
posts = tag['post_ids']
for id in posts:
post = self.db.posts.get(doc_id=id)
if not post: # pragma: no coverage
... | [
"def",
"entries",
"(",
"self",
")",
":",
"Tags",
"=",
"Query",
"(",
")",
"tag",
"=",
"self",
".",
"table",
".",
"get",
"(",
"Tags",
".",
"name",
"==",
"self",
".",
"name",
")",
"posts",
"=",
"tag",
"[",
"'post_ids'",
"]",
"for",
"id",
"in",
"po... | return the actual lists of entries tagged with | [
"return",
"the",
"actual",
"lists",
"of",
"entries",
"tagged",
"with"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L142-L152 | train | return the actual lists of entries tagged with |
oz123/blogit | blogit/blogit.py | Tag.render | def render(self):
"""Render html page and atom feed"""
context = GLOBAL_TEMPLATE_CONTEXT.copy()
context['tag'] = self
entries = list(self.entries)
entries.sort(key=operator.attrgetter('date'), reverse=True)
context['entries'] = entries
# render html page
... | python | def render(self):
"""Render html page and atom feed"""
context = GLOBAL_TEMPLATE_CONTEXT.copy()
context['tag'] = self
entries = list(self.entries)
entries.sort(key=operator.attrgetter('date'), reverse=True)
context['entries'] = entries
# render html page
... | [
"def",
"render",
"(",
"self",
")",
":",
"context",
"=",
"GLOBAL_TEMPLATE_CONTEXT",
".",
"copy",
"(",
")",
"context",
"[",
"'tag'",
"]",
"=",
"self",
"entries",
"=",
"list",
"(",
"self",
".",
"entries",
")",
"entries",
".",
"sort",
"(",
"key",
"=",
"o... | Render html page and atom feed | [
"Render",
"html",
"page",
"and",
"atom",
"feed"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L154-L173 | train | Render the html page and atom feed |
oz123/blogit | blogit/blogit.py | Entry.tags | def tags(self):
"""this property is always called after prepare"""
if 'tags' in self.header:
tags = [Tag(t) for t in self.header['tags']]
list(map(lambda t: setattr(t, 'posts', [self.id]), tags))
return tags
else:
return [] | python | def tags(self):
"""this property is always called after prepare"""
if 'tags' in self.header:
tags = [Tag(t) for t in self.header['tags']]
list(map(lambda t: setattr(t, 'posts', [self.id]), tags))
return tags
else:
return [] | [
"def",
"tags",
"(",
"self",
")",
":",
"if",
"'tags'",
"in",
"self",
".",
"header",
":",
"tags",
"=",
"[",
"Tag",
"(",
"t",
")",
"for",
"t",
"in",
"self",
".",
"header",
"[",
"'tags'",
"]",
"]",
"list",
"(",
"map",
"(",
"lambda",
"t",
":",
"se... | this property is always called after prepare | [
"this",
"property",
"is",
"always",
"called",
"after",
"prepare"
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L276-L283 | train | this property is always called after prepare |
oz123/blogit | blogit/blogit.py | Entry.prepare | def prepare(self):
self.body_html = markdown(
codecs.open(self.abspath, 'r').read(),
extras=['fenced-code-blocks', 'hilite', 'tables', 'metadata'])
self.header = self.body_html.metadata
"""a blog post without tags causes an error ..."""
if 'tags' in self.header:... | python | def prepare(self):
self.body_html = markdown(
codecs.open(self.abspath, 'r').read(),
extras=['fenced-code-blocks', 'hilite', 'tables', 'metadata'])
self.header = self.body_html.metadata
"""a blog post without tags causes an error ..."""
if 'tags' in self.header:... | [
"def",
"prepare",
"(",
"self",
")",
":",
"self",
".",
"body_html",
"=",
"markdown",
"(",
"codecs",
".",
"open",
"(",
"self",
".",
"abspath",
",",
"'r'",
")",
".",
"read",
"(",
")",
",",
"extras",
"=",
"[",
"'fenced-code-blocks'",
",",
"'hilite'",
","... | a blog post without tags causes an error ... | [
"a",
"blog",
"post",
"without",
"tags",
"causes",
"an",
"error",
"..."
] | 15b94969fa43aaf8dc677a8184b144ae8c0f7700 | https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L285-L323 | train | Prepare the object for use in the blog. |
openearth/mmi-python | mmi/cli.py | tracker | def tracker():
"""start a tracker to register running models"""
application = mmi.tracker.app()
application.listen(22222)
logger.info('serving at port 22222')
tornado.ioloop.IOLoop.instance().start() | python | def tracker():
"""start a tracker to register running models"""
application = mmi.tracker.app()
application.listen(22222)
logger.info('serving at port 22222')
tornado.ioloop.IOLoop.instance().start() | [
"def",
"tracker",
"(",
")",
":",
"application",
"=",
"mmi",
".",
"tracker",
".",
"app",
"(",
")",
"application",
".",
"listen",
"(",
"22222",
")",
"logger",
".",
"info",
"(",
"'serving at port 22222'",
")",
"tornado",
".",
"ioloop",
".",
"IOLoop",
".",
... | start a tracker to register running models | [
"start",
"a",
"tracker",
"to",
"register",
"running",
"models"
] | a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d | https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/cli.py#L26-L31 | train | start a tracker to register running models |
openearth/mmi-python | mmi/cli.py | runner | def runner(
engine,
configfile,
output_vars,
interval,
pause,
mpi,
tracker,
port,
bmi_class
):
"""
run a BMI compatible model
"""
# keep track of info
# update mpi information or use rank 0
runner = mmi.runner.Runner(
... | python | def runner(
engine,
configfile,
output_vars,
interval,
pause,
mpi,
tracker,
port,
bmi_class
):
"""
run a BMI compatible model
"""
# keep track of info
# update mpi information or use rank 0
runner = mmi.runner.Runner(
... | [
"def",
"runner",
"(",
"engine",
",",
"configfile",
",",
"output_vars",
",",
"interval",
",",
"pause",
",",
"mpi",
",",
"tracker",
",",
"port",
",",
"bmi_class",
")",
":",
"# keep track of info",
"# update mpi information or use rank 0",
"runner",
"=",
"mmi",
"."... | run a BMI compatible model | [
"run",
"a",
"BMI",
"compatible",
"model"
] | a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d | https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/cli.py#L77-L104 | train | run a BMI compatible model
|
ckcollab/polished | polished/backends/mixins/polisher.py | PolisherMixin.do_extra_polishing | def do_extra_polishing(self):
'''
Goes over each EXTRA_POLISH_FUNCTION to see if it applies to this page, if so, calls it
'''
for f in self.EXTRA_POLISH_FUNCTIONS:
if not hasattr(f, 'polish_commit_indexes'):
if hasattr(f, 'polish_urls') and self.URL in f.polis... | python | def do_extra_polishing(self):
'''
Goes over each EXTRA_POLISH_FUNCTION to see if it applies to this page, if so, calls it
'''
for f in self.EXTRA_POLISH_FUNCTIONS:
if not hasattr(f, 'polish_commit_indexes'):
if hasattr(f, 'polish_urls') and self.URL in f.polis... | [
"def",
"do_extra_polishing",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"EXTRA_POLISH_FUNCTIONS",
":",
"if",
"not",
"hasattr",
"(",
"f",
",",
"'polish_commit_indexes'",
")",
":",
"if",
"hasattr",
"(",
"f",
",",
"'polish_urls'",
")",
"and",
"self... | Goes over each EXTRA_POLISH_FUNCTION to see if it applies to this page, if so, calls it | [
"Goes",
"over",
"each",
"EXTRA_POLISH_FUNCTION",
"to",
"see",
"if",
"it",
"applies",
"to",
"this",
"page",
"if",
"so",
"calls",
"it"
] | 5a00b2fbe569bc957d1647c0849fd344db29b644 | https://github.com/ckcollab/polished/blob/5a00b2fbe569bc957d1647c0849fd344db29b644/polished/backends/mixins/polisher.py#L30-L45 | train | Calls EXTRA_POLISH_FUNCTIONS to see if they applies to this page and if so calls it
|
skioo/django-customer-billing | billing/models.py | total_amount | def total_amount(qs) -> Total:
"""Sums the amounts of the objects in the queryset, keeping each currency separate.
:param qs: A querystring containing objects that have an amount field of type Money.
:return: A Total object.
"""
aggregate = qs.values('amount_currency').annotate(sum=Sum('amount'))
... | python | def total_amount(qs) -> Total:
"""Sums the amounts of the objects in the queryset, keeping each currency separate.
:param qs: A querystring containing objects that have an amount field of type Money.
:return: A Total object.
"""
aggregate = qs.values('amount_currency').annotate(sum=Sum('amount'))
... | [
"def",
"total_amount",
"(",
"qs",
")",
"->",
"Total",
":",
"aggregate",
"=",
"qs",
".",
"values",
"(",
"'amount_currency'",
")",
".",
"annotate",
"(",
"sum",
"=",
"Sum",
"(",
"'amount'",
")",
")",
"return",
"Total",
"(",
"Money",
"(",
"amount",
"=",
... | Sums the amounts of the objects in the queryset, keeping each currency separate.
:param qs: A querystring containing objects that have an amount field of type Money.
:return: A Total object. | [
"Sums",
"the",
"amounts",
"of",
"the",
"objects",
"in",
"the",
"queryset",
"keeping",
"each",
"currency",
"separate",
".",
":",
"param",
"qs",
":",
"A",
"querystring",
"containing",
"objects",
"that",
"have",
"an",
"amount",
"field",
"of",
"type",
"Money",
... | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/models.py#L22-L28 | train | Sums the amounts of the objects in the queryset keeping each currency separate. |
skioo/django-customer-billing | billing/models.py | Invoice.total_charges | def total_charges(self):
"""
Represents the 'goods' acquired in the invoice.
"""
selected_charges = Charge.objects \
.filter(invoice=self) \
.charges() \
.exclude(product_code=CARRIED_FORWARD)
return total_amount(selected_charges) | python | def total_charges(self):
"""
Represents the 'goods' acquired in the invoice.
"""
selected_charges = Charge.objects \
.filter(invoice=self) \
.charges() \
.exclude(product_code=CARRIED_FORWARD)
return total_amount(selected_charges) | [
"def",
"total_charges",
"(",
"self",
")",
":",
"selected_charges",
"=",
"Charge",
".",
"objects",
".",
"filter",
"(",
"invoice",
"=",
"self",
")",
".",
"charges",
"(",
")",
".",
"exclude",
"(",
"product_code",
"=",
"CARRIED_FORWARD",
")",
"return",
"total_... | Represents the 'goods' acquired in the invoice. | [
"Represents",
"the",
"goods",
"acquired",
"in",
"the",
"invoice",
"."
] | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/models.py#L123-L131 | train | Returns the total amount of charges acquired in the invoice. |
skioo/django-customer-billing | billing/models.py | Invoice.due | def due(self):
"""
The amount due for this invoice. Takes into account all entities in the invoice.
Can be < 0 if the invoice was overpaid.
"""
invoice_charges = Charge.objects.filter(invoice=self)
invoice_transactions = Transaction.successful.filter(invoice=self)
... | python | def due(self):
"""
The amount due for this invoice. Takes into account all entities in the invoice.
Can be < 0 if the invoice was overpaid.
"""
invoice_charges = Charge.objects.filter(invoice=self)
invoice_transactions = Transaction.successful.filter(invoice=self)
... | [
"def",
"due",
"(",
"self",
")",
":",
"invoice_charges",
"=",
"Charge",
".",
"objects",
".",
"filter",
"(",
"invoice",
"=",
"self",
")",
"invoice_transactions",
"=",
"Transaction",
".",
"successful",
".",
"filter",
"(",
"invoice",
"=",
"self",
")",
"return"... | The amount due for this invoice. Takes into account all entities in the invoice.
Can be < 0 if the invoice was overpaid. | [
"The",
"amount",
"due",
"for",
"this",
"invoice",
".",
"Takes",
"into",
"account",
"all",
"entities",
"in",
"the",
"invoice",
".",
"Can",
"be",
"<",
"0",
"if",
"the",
"invoice",
"was",
"overpaid",
"."
] | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/models.py#L133-L140 | train | Returns the amount of due for this invoice. |
darvid/biome | setup.py | setup | def setup():
"""Package setup entrypoint."""
install_requirements = ["attrdict"]
if sys.version_info[:2] < (3, 4):
install_requirements.append("pathlib")
setup_requirements = ['six', 'setuptools>=17.1', 'setuptools_scm']
needs_sphinx = {
'build_sphinx',
'docs',
'uploa... | python | def setup():
"""Package setup entrypoint."""
install_requirements = ["attrdict"]
if sys.version_info[:2] < (3, 4):
install_requirements.append("pathlib")
setup_requirements = ['six', 'setuptools>=17.1', 'setuptools_scm']
needs_sphinx = {
'build_sphinx',
'docs',
'uploa... | [
"def",
"setup",
"(",
")",
":",
"install_requirements",
"=",
"[",
"\"attrdict\"",
"]",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
"<",
"(",
"3",
",",
"4",
")",
":",
"install_requirements",
".",
"append",
"(",
"\"pathlib\"",
")",
"setup_requirem... | Package setup entrypoint. | [
"Package",
"setup",
"entrypoint",
"."
] | e1f1945165df9def31af42e5e13b623e1de97f01 | https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/setup.py#L25-L68 | train | A function that sets up the package. |
rehandalal/flask-funnel | flask_funnel/extensions.py | preprocessor | def preprocessor(accepts, exports, flag=None):
"""Decorator to add a new preprocessor"""
def decorator(f):
preprocessors.append((accepts, exports, flag, f))
return f
return decorator | python | def preprocessor(accepts, exports, flag=None):
"""Decorator to add a new preprocessor"""
def decorator(f):
preprocessors.append((accepts, exports, flag, f))
return f
return decorator | [
"def",
"preprocessor",
"(",
"accepts",
",",
"exports",
",",
"flag",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"preprocessors",
".",
"append",
"(",
"(",
"accepts",
",",
"exports",
",",
"flag",
",",
"f",
")",
")",
"return",
"f",
... | Decorator to add a new preprocessor | [
"Decorator",
"to",
"add",
"a",
"new",
"preprocessor"
] | b635cf52d1c9133c748aab7465edd7caef48e433 | https://github.com/rehandalal/flask-funnel/blob/b635cf52d1c9133c748aab7465edd7caef48e433/flask_funnel/extensions.py#L13-L18 | train | Decorator to add a new preprocessor |
rehandalal/flask-funnel | flask_funnel/extensions.py | postprocessor | def postprocessor(accepts, flag=None):
"""Decorator to add a new postprocessor"""
def decorator(f):
postprocessors.append((accepts, flag, f))
return f
return decorator | python | def postprocessor(accepts, flag=None):
"""Decorator to add a new postprocessor"""
def decorator(f):
postprocessors.append((accepts, flag, f))
return f
return decorator | [
"def",
"postprocessor",
"(",
"accepts",
",",
"flag",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"postprocessors",
".",
"append",
"(",
"(",
"accepts",
",",
"flag",
",",
"f",
")",
")",
"return",
"f",
"return",
"decorator"
] | Decorator to add a new postprocessor | [
"Decorator",
"to",
"add",
"a",
"new",
"postprocessor"
] | b635cf52d1c9133c748aab7465edd7caef48e433 | https://github.com/rehandalal/flask-funnel/blob/b635cf52d1c9133c748aab7465edd7caef48e433/flask_funnel/extensions.py#L21-L26 | train | Decorator to add a new postprocessor |
rehandalal/flask-funnel | flask_funnel/extensions.py | coffee | def coffee(input, output, **kw):
"""Process CoffeeScript files"""
subprocess.call([current_app.config.get('COFFEE_BIN'),
'-c', '-o', output, input]) | python | def coffee(input, output, **kw):
"""Process CoffeeScript files"""
subprocess.call([current_app.config.get('COFFEE_BIN'),
'-c', '-o', output, input]) | [
"def",
"coffee",
"(",
"input",
",",
"output",
",",
"*",
"*",
"kw",
")",
":",
"subprocess",
".",
"call",
"(",
"[",
"current_app",
".",
"config",
".",
"get",
"(",
"'COFFEE_BIN'",
")",
",",
"'-c'",
",",
"'-o'",
",",
"output",
",",
"input",
"]",
")"
] | Process CoffeeScript files | [
"Process",
"CoffeeScript",
"files"
] | b635cf52d1c9133c748aab7465edd7caef48e433 | https://github.com/rehandalal/flask-funnel/blob/b635cf52d1c9133c748aab7465edd7caef48e433/flask_funnel/extensions.py#L30-L33 | train | Process CoffeeScript files |
rehandalal/flask-funnel | flask_funnel/extensions.py | stylus | def stylus(input, output, **kw):
"""Process Stylus (.styl) files"""
stdin = open(input, 'r')
stdout = open(output, 'w')
cmd = '%s --include %s' % (current_app.config.get('STYLUS_BIN'),
os.path.abspath(os.path.dirname(input)))
subprocess.call(cmd, shell=True, stdin=stdi... | python | def stylus(input, output, **kw):
"""Process Stylus (.styl) files"""
stdin = open(input, 'r')
stdout = open(output, 'w')
cmd = '%s --include %s' % (current_app.config.get('STYLUS_BIN'),
os.path.abspath(os.path.dirname(input)))
subprocess.call(cmd, shell=True, stdin=stdi... | [
"def",
"stylus",
"(",
"input",
",",
"output",
",",
"*",
"*",
"kw",
")",
":",
"stdin",
"=",
"open",
"(",
"input",
",",
"'r'",
")",
"stdout",
"=",
"open",
"(",
"output",
",",
"'w'",
")",
"cmd",
"=",
"'%s --include %s'",
"%",
"(",
"current_app",
".",
... | Process Stylus (.styl) files | [
"Process",
"Stylus",
"(",
".",
"styl",
")",
"files"
] | b635cf52d1c9133c748aab7465edd7caef48e433 | https://github.com/rehandalal/flask-funnel/blob/b635cf52d1c9133c748aab7465edd7caef48e433/flask_funnel/extensions.py#L50-L56 | train | Process Stylus files |
rehandalal/flask-funnel | flask_funnel/extensions.py | autoprefixer | def autoprefixer(input, **kw):
"""Run autoprefixer"""
cmd = '%s -b "%s" %s' % (current_app.config.get('AUTOPREFIXER_BIN'),
current_app.config.get('AUTOPREFIXER_BROWSERS'),
input)
subprocess.call(cmd, shell=True) | python | def autoprefixer(input, **kw):
"""Run autoprefixer"""
cmd = '%s -b "%s" %s' % (current_app.config.get('AUTOPREFIXER_BIN'),
current_app.config.get('AUTOPREFIXER_BROWSERS'),
input)
subprocess.call(cmd, shell=True) | [
"def",
"autoprefixer",
"(",
"input",
",",
"*",
"*",
"kw",
")",
":",
"cmd",
"=",
"'%s -b \"%s\" %s'",
"%",
"(",
"current_app",
".",
"config",
".",
"get",
"(",
"'AUTOPREFIXER_BIN'",
")",
",",
"current_app",
".",
"config",
".",
"get",
"(",
"'AUTOPREFIXER_BROW... | Run autoprefixer | [
"Run",
"autoprefixer"
] | b635cf52d1c9133c748aab7465edd7caef48e433 | https://github.com/rehandalal/flask-funnel/blob/b635cf52d1c9133c748aab7465edd7caef48e433/flask_funnel/extensions.py#L60-L65 | train | Run autoprefixer on the input |
skioo/django-customer-billing | billing/actions/charges.py | cancel_charge | def cancel_charge(charge_id: str) -> None:
"""
Cancels an existing charge.
If the charge was already cancelled then an Exception is raised.
If it is not in an invoice then the charge is deleted,
otherwise a Credit object is created to reverse the Charge.
:param charge_id: The id of the charge... | python | def cancel_charge(charge_id: str) -> None:
"""
Cancels an existing charge.
If the charge was already cancelled then an Exception is raised.
If it is not in an invoice then the charge is deleted,
otherwise a Credit object is created to reverse the Charge.
:param charge_id: The id of the charge... | [
"def",
"cancel_charge",
"(",
"charge_id",
":",
"str",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"'cancelling-charge'",
",",
"charge_id",
"=",
"charge_id",
")",
"with",
"transaction",
".",
"atomic",
"(",
")",
":",
"charge",
"=",
"Charge",
".",
"... | Cancels an existing charge.
If the charge was already cancelled then an Exception is raised.
If it is not in an invoice then the charge is deleted,
otherwise a Credit object is created to reverse the Charge.
:param charge_id: The id of the charge to cancel. | [
"Cancels",
"an",
"existing",
"charge",
"."
] | 6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d | https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/actions/charges.py#L16-L46 | train | Cancels an existing charge. |
pneff/wsgiservice | wsgiservice/application.py | get_app | def get_app(defs, add_help=True):
"""Small wrapper function to returns an instance of :class:`Application`
which serves the objects in the defs. Usually this is called with return
value globals() from the module where the resources are defined. The
returned WSGI application will serve all subclasses of
... | python | def get_app(defs, add_help=True):
"""Small wrapper function to returns an instance of :class:`Application`
which serves the objects in the defs. Usually this is called with return
value globals() from the module where the resources are defined. The
returned WSGI application will serve all subclasses of
... | [
"def",
"get_app",
"(",
"defs",
",",
"add_help",
"=",
"True",
")",
":",
"def",
"is_resource",
"(",
"d",
")",
":",
"try",
":",
"if",
"issubclass",
"(",
"d",
",",
"wsgiservice",
".",
"Resource",
")",
"and",
"hasattr",
"(",
"d",
",",
"'_path'",
")",
":... | Small wrapper function to returns an instance of :class:`Application`
which serves the objects in the defs. Usually this is called with return
value globals() from the module where the resources are defined. The
returned WSGI application will serve all subclasses of
:class:`wsgiservice.Resource` found i... | [
"Small",
"wrapper",
"function",
"to",
"returns",
"an",
"instance",
"of",
":",
"class",
":",
"Application",
"which",
"serves",
"the",
"objects",
"in",
"the",
"defs",
".",
"Usually",
"this",
"is",
"called",
"with",
"return",
"value",
"globals",
"()",
"from",
... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/application.py#L106-L134 | train | Small wrapper function to return an instance of WSGI application which serves all resources in the defs. |
pneff/wsgiservice | wsgiservice/application.py | Application._log_request | def _log_request(self, request):
"""Log the most important parts of this request.
:param request: Object representing the current request.
:type request: :class:`webob.Request`
"""
msg = []
for d in self.LOG_DATA:
val = getattr(request, d)
if val:... | python | def _log_request(self, request):
"""Log the most important parts of this request.
:param request: Object representing the current request.
:type request: :class:`webob.Request`
"""
msg = []
for d in self.LOG_DATA:
val = getattr(request, d)
if val:... | [
"def",
"_log_request",
"(",
"self",
",",
"request",
")",
":",
"msg",
"=",
"[",
"]",
"for",
"d",
"in",
"self",
".",
"LOG_DATA",
":",
"val",
"=",
"getattr",
"(",
"request",
",",
"d",
")",
"if",
"val",
":",
"msg",
".",
"append",
"(",
"d",
"+",
"':... | Log the most important parts of this request.
:param request: Object representing the current request.
:type request: :class:`webob.Request` | [
"Log",
"the",
"most",
"important",
"parts",
"of",
"this",
"request",
"."
] | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/application.py#L66-L80 | train | Log the most important parts of this request. |
pneff/wsgiservice | wsgiservice/application.py | Application._handle_request | def _handle_request(self, request):
"""Finds the resource to which a request maps and then calls it.
Instantiates, fills and returns a :class:`webob.Response` object. If
no resource matches the request, a 404 status is set on the response
object.
:param request: Object represent... | python | def _handle_request(self, request):
"""Finds the resource to which a request maps and then calls it.
Instantiates, fills and returns a :class:`webob.Response` object. If
no resource matches the request, a 404 status is set on the response
object.
:param request: Object represent... | [
"def",
"_handle_request",
"(",
"self",
",",
"request",
")",
":",
"response",
"=",
"webob",
".",
"Response",
"(",
"request",
"=",
"request",
")",
"path",
"=",
"request",
".",
"path_info",
"parsed",
"=",
"self",
".",
"_urlmap",
"(",
"path",
")",
"if",
"p... | Finds the resource to which a request maps and then calls it.
Instantiates, fills and returns a :class:`webob.Response` object. If
no resource matches the request, a 404 status is set on the response
object.
:param request: Object representing the current request.
:type request:... | [
"Finds",
"the",
"resource",
"to",
"which",
"a",
"request",
"maps",
"and",
"then",
"calls",
"it",
".",
"Instantiates",
"fills",
"and",
"returns",
"a",
":",
"class",
":",
"webob",
".",
"Response",
"object",
".",
"If",
"no",
"resource",
"matches",
"the",
"r... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/application.py#L82-L103 | train | Handles the request. |
MikaSoftware/py-mortgagekit | mortgagekit/calculator.py | MortgageCalculator.get_mortgage_payment_per_payment_frequency | def get_mortgage_payment_per_payment_frequency(self):
"""
Function will return the amount paid per payment based on the frequency.
"""
# Calculate the interest rate per the payment parameters:
r = self.get_interest_rate_per_payment_frequency()
# Calculate the total numbe... | python | def get_mortgage_payment_per_payment_frequency(self):
"""
Function will return the amount paid per payment based on the frequency.
"""
# Calculate the interest rate per the payment parameters:
r = self.get_interest_rate_per_payment_frequency()
# Calculate the total numbe... | [
"def",
"get_mortgage_payment_per_payment_frequency",
"(",
"self",
")",
":",
"# Calculate the interest rate per the payment parameters:",
"r",
"=",
"self",
".",
"get_interest_rate_per_payment_frequency",
"(",
")",
"# Calculate the total number of payments given the parameters:",
"n",
... | Function will return the amount paid per payment based on the frequency. | [
"Function",
"will",
"return",
"the",
"amount",
"paid",
"per",
"payment",
"based",
"on",
"the",
"frequency",
"."
] | 27697d2c12afdd56308f1012e25bb231c1e24ecf | https://github.com/MikaSoftware/py-mortgagekit/blob/27697d2c12afdd56308f1012e25bb231c1e24ecf/mortgagekit/calculator.py#L103-L133 | train | Function will return the amount paid per payment based on the frequency of the payment. |
SpringerPE/python-cfconfigurator | cfconfigurator/cf.py | CF.info | def info(self):
"""Gets info endpoint. Used to perform login auth."""
url = self.api_url + self.info_url
resp = self.session.get(url)
if resp.status_code != 200:
error = {'description': "Info HTTP response not valid"}
raise CFException(error, resp.status_code)
... | python | def info(self):
"""Gets info endpoint. Used to perform login auth."""
url = self.api_url + self.info_url
resp = self.session.get(url)
if resp.status_code != 200:
error = {'description': "Info HTTP response not valid"}
raise CFException(error, resp.status_code)
... | [
"def",
"info",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"api_url",
"+",
"self",
".",
"info_url",
"resp",
"=",
"self",
".",
"session",
".",
"get",
"(",
"url",
")",
"if",
"resp",
".",
"status_code",
"!=",
"200",
":",
"error",
"=",
"{",
"'des... | Gets info endpoint. Used to perform login auth. | [
"Gets",
"info",
"endpoint",
".",
"Used",
"to",
"perform",
"login",
"auth",
"."
] | 198b4e00cd9e362abee726c0242c1d5f986eb073 | https://github.com/SpringerPE/python-cfconfigurator/blob/198b4e00cd9e362abee726c0242c1d5f986eb073/cfconfigurator/cf.py#L90-L102 | train | Gets info endpoint. Used to perform login auth. |
SpringerPE/python-cfconfigurator | cfconfigurator/cf.py | CF.login | def login(self, username=None, password=''):
"""Performs login with the provided credentials"""
self.username = username
self.password = password
return self._login() | python | def login(self, username=None, password=''):
"""Performs login with the provided credentials"""
self.username = username
self.password = password
return self._login() | [
"def",
"login",
"(",
"self",
",",
"username",
"=",
"None",
",",
"password",
"=",
"''",
")",
":",
"self",
".",
"username",
"=",
"username",
"self",
".",
"password",
"=",
"password",
"return",
"self",
".",
"_login",
"(",
")"
] | Performs login with the provided credentials | [
"Performs",
"login",
"with",
"the",
"provided",
"credentials"
] | 198b4e00cd9e362abee726c0242c1d5f986eb073 | https://github.com/SpringerPE/python-cfconfigurator/blob/198b4e00cd9e362abee726c0242c1d5f986eb073/cfconfigurator/cf.py#L104-L108 | train | Performs a login with the provided credentials |
SpringerPE/python-cfconfigurator | cfconfigurator/cf.py | CF.clean_blobstore_cache | def clean_blobstore_cache(self):
"""Deletes all of the existing buildpack caches in the blobstore"""
url = self.api_url + self.blobstores_builpack_cache_url
resp, rcode = self.request('DELETE', url)
if rcode != 202:
raise CFException(resp, rcode)
return resp | python | def clean_blobstore_cache(self):
"""Deletes all of the existing buildpack caches in the blobstore"""
url = self.api_url + self.blobstores_builpack_cache_url
resp, rcode = self.request('DELETE', url)
if rcode != 202:
raise CFException(resp, rcode)
return resp | [
"def",
"clean_blobstore_cache",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"api_url",
"+",
"self",
".",
"blobstores_builpack_cache_url",
"resp",
",",
"rcode",
"=",
"self",
".",
"request",
"(",
"'DELETE'",
",",
"url",
")",
"if",
"rcode",
"!=",
"202",
... | Deletes all of the existing buildpack caches in the blobstore | [
"Deletes",
"all",
"of",
"the",
"existing",
"buildpack",
"caches",
"in",
"the",
"blobstore"
] | 198b4e00cd9e362abee726c0242c1d5f986eb073 | https://github.com/SpringerPE/python-cfconfigurator/blob/198b4e00cd9e362abee726c0242c1d5f986eb073/cfconfigurator/cf.py#L192-L198 | train | Deletes all buildpack caches in the blobstore |
marcosfelt/cheminventory_python | cheminventory/api.py | ChemInventory.search | def search(self, query, locations: list=None):
'''Search using the CAS number, barcode or chemical name
'''
cas_number = re.search(r"\b[1-9]{1}[0-9]{1,5}-\d{2}-\d\b", str(query))
if cas_number:
query = cas_number[0]
search_type = 'cas'
else:
... | python | def search(self, query, locations: list=None):
'''Search using the CAS number, barcode or chemical name
'''
cas_number = re.search(r"\b[1-9]{1}[0-9]{1,5}-\d{2}-\d\b", str(query))
if cas_number:
query = cas_number[0]
search_type = 'cas'
else:
... | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"locations",
":",
"list",
"=",
"None",
")",
":",
"cas_number",
"=",
"re",
".",
"search",
"(",
"r\"\\b[1-9]{1}[0-9]{1,5}-\\d{2}-\\d\\b\"",
",",
"str",
"(",
"query",
")",
")",
"if",
"cas_number",
":",
"query",... | Search using the CAS number, barcode or chemical name | [
"Search",
"using",
"the",
"CAS",
"number",
"barcode",
"or",
"chemical",
"name"
] | fa7d67a3741ba7095b30377ac52842997a649012 | https://github.com/marcosfelt/cheminventory_python/blob/fa7d67a3741ba7095b30377ac52842997a649012/cheminventory/api.py#L44-L90 | train | Search using the CAS number barcode or chemical name
|
marcosfelt/cheminventory_python | cheminventory/api.py | ChemInventory.get_groups | def get_groups(self):
'''Retrieve groups listed in ChemInventory'''
resp = self._post('general-retrievelocations', 'locations')
final_resp = []
if resp['groupinfo']:
for group in resp['groupinfo']:
final_resp.append(Group(
name=group.get('n... | python | def get_groups(self):
'''Retrieve groups listed in ChemInventory'''
resp = self._post('general-retrievelocations', 'locations')
final_resp = []
if resp['groupinfo']:
for group in resp['groupinfo']:
final_resp.append(Group(
name=group.get('n... | [
"def",
"get_groups",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_post",
"(",
"'general-retrievelocations'",
",",
"'locations'",
")",
"final_resp",
"=",
"[",
"]",
"if",
"resp",
"[",
"'groupinfo'",
"]",
":",
"for",
"group",
"in",
"resp",
"[",
"'grou... | Retrieve groups listed in ChemInventory | [
"Retrieve",
"groups",
"listed",
"in",
"ChemInventory"
] | fa7d67a3741ba7095b30377ac52842997a649012 | https://github.com/marcosfelt/cheminventory_python/blob/fa7d67a3741ba7095b30377ac52842997a649012/cheminventory/api.py#L120-L130 | train | Retrieve groups listed in ChemInventory |
marcosfelt/cheminventory_python | cheminventory/api.py | ChemInventory.get_locations | def get_locations(self, filter_to_my_group=False):
"""Retrieve Locations listed in ChemInventory"""
resp = self._post('general-retrievelocations', 'locations')
groups = {}
if resp['groupinfo']:
for group in resp['groupinfo']:
groups[group['id']] = Group(
... | python | def get_locations(self, filter_to_my_group=False):
"""Retrieve Locations listed in ChemInventory"""
resp = self._post('general-retrievelocations', 'locations')
groups = {}
if resp['groupinfo']:
for group in resp['groupinfo']:
groups[group['id']] = Group(
... | [
"def",
"get_locations",
"(",
"self",
",",
"filter_to_my_group",
"=",
"False",
")",
":",
"resp",
"=",
"self",
".",
"_post",
"(",
"'general-retrievelocations'",
",",
"'locations'",
")",
"groups",
"=",
"{",
"}",
"if",
"resp",
"[",
"'groupinfo'",
"]",
":",
"fo... | Retrieve Locations listed in ChemInventory | [
"Retrieve",
"Locations",
"listed",
"in",
"ChemInventory"
] | fa7d67a3741ba7095b30377ac52842997a649012 | https://github.com/marcosfelt/cheminventory_python/blob/fa7d67a3741ba7095b30377ac52842997a649012/cheminventory/api.py#L132-L161 | train | Retrieve Locations listed in ChemInventory |
marcosfelt/cheminventory_python | cheminventory/api.py | ChemInventory.get_containers | def get_containers(self, include_only=[]):
"""Download all the containers owned by a group
Arguments
---------
include_only: List containg `Group` or `Location` objects
Search only over a list of groups or locations
"""
locations = self.get_locations... | python | def get_containers(self, include_only=[]):
"""Download all the containers owned by a group
Arguments
---------
include_only: List containg `Group` or `Location` objects
Search only over a list of groups or locations
"""
locations = self.get_locations... | [
"def",
"get_containers",
"(",
"self",
",",
"include_only",
"=",
"[",
"]",
")",
":",
"locations",
"=",
"self",
".",
"get_locations",
"(",
")",
"if",
"len",
"(",
"locations",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"No locations for containers exist... | Download all the containers owned by a group
Arguments
---------
include_only: List containg `Group` or `Location` objects
Search only over a list of groups or locations | [
"Download",
"all",
"the",
"containers",
"owned",
"by",
"a",
"group"
] | fa7d67a3741ba7095b30377ac52842997a649012 | https://github.com/marcosfelt/cheminventory_python/blob/fa7d67a3741ba7095b30377ac52842997a649012/cheminventory/api.py#L163-L189 | train | Download all the containers owned by a group or location |
mkoura/dump2polarion | dump2polarion/utils.py | get_unicode_str | def get_unicode_str(obj):
"""Makes sure obj is a unicode string."""
if isinstance(obj, six.text_type):
return obj
if isinstance(obj, six.binary_type):
return obj.decode("utf-8", errors="ignore")
return six.text_type(obj) | python | def get_unicode_str(obj):
"""Makes sure obj is a unicode string."""
if isinstance(obj, six.text_type):
return obj
if isinstance(obj, six.binary_type):
return obj.decode("utf-8", errors="ignore")
return six.text_type(obj) | [
"def",
"get_unicode_str",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"six",
".",
"text_type",
")",
":",
"return",
"obj",
"if",
"isinstance",
"(",
"obj",
",",
"six",
".",
"binary_type",
")",
":",
"return",
"obj",
".",
"decode",
"(",
"\... | Makes sure obj is a unicode string. | [
"Makes",
"sure",
"obj",
"is",
"a",
"unicode",
"string",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L30-L36 | train | Makes sure obj is a unicode string. |
mkoura/dump2polarion | dump2polarion/utils.py | init_log | def init_log(log_level):
"""Initializes logging."""
log_level = log_level or "INFO"
logging.basicConfig(
format="%(name)s:%(levelname)s:%(message)s",
level=getattr(logging, log_level.upper(), logging.INFO),
) | python | def init_log(log_level):
"""Initializes logging."""
log_level = log_level or "INFO"
logging.basicConfig(
format="%(name)s:%(levelname)s:%(message)s",
level=getattr(logging, log_level.upper(), logging.INFO),
) | [
"def",
"init_log",
"(",
"log_level",
")",
":",
"log_level",
"=",
"log_level",
"or",
"\"INFO\"",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"\"%(name)s:%(levelname)s:%(message)s\"",
",",
"level",
"=",
"getattr",
"(",
"logging",
",",
"log_level",
".",
"upp... | Initializes logging. | [
"Initializes",
"logging",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L39-L45 | train | Initializes logging. |
mkoura/dump2polarion | dump2polarion/utils.py | write_xml | def write_xml(xml_str, output_loc=None, filename=None):
"""Outputs the XML content (string) into a file.
If `output_loc` is supplied and it's a file (not directory), the output
will be saved there and the `filename` is ignored.
Args:
xml_str: string with XML document
output_loc: file o... | python | def write_xml(xml_str, output_loc=None, filename=None):
"""Outputs the XML content (string) into a file.
If `output_loc` is supplied and it's a file (not directory), the output
will be saved there and the `filename` is ignored.
Args:
xml_str: string with XML document
output_loc: file o... | [
"def",
"write_xml",
"(",
"xml_str",
",",
"output_loc",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"xml_str",
":",
"raise",
"Dump2PolarionException",
"(",
"\"No data to write.\"",
")",
"filename_fin",
"=",
"_get_filename",
"(",
"output_loc"... | Outputs the XML content (string) into a file.
If `output_loc` is supplied and it's a file (not directory), the output
will be saved there and the `filename` is ignored.
Args:
xml_str: string with XML document
output_loc: file or directory for saving the file
filename: file name tha... | [
"Outputs",
"the",
"XML",
"content",
"(",
"string",
")",
"into",
"a",
"file",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L62-L80 | train | Outputs the XML content into a file. |
mkoura/dump2polarion | dump2polarion/utils.py | write_xml_root | def write_xml_root(xml_root, output_loc=None, filename=None):
"""Outputs the XML content (from XML element) into a file.
If `output_loc` is supplied and it's a file (not directory), the output
will be saved there and the `filename` is ignored.
Args:
xml_root: root element ot the XML document
... | python | def write_xml_root(xml_root, output_loc=None, filename=None):
"""Outputs the XML content (from XML element) into a file.
If `output_loc` is supplied and it's a file (not directory), the output
will be saved there and the `filename` is ignored.
Args:
xml_root: root element ot the XML document
... | [
"def",
"write_xml_root",
"(",
"xml_root",
",",
"output_loc",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"xml_root",
"is",
"None",
":",
"raise",
"Dump2PolarionException",
"(",
"\"No data to write.\"",
")",
"filename_fin",
"=",
"_get_filename",
"("... | Outputs the XML content (from XML element) into a file.
If `output_loc` is supplied and it's a file (not directory), the output
will be saved there and the `filename` is ignored.
Args:
xml_root: root element ot the XML document
output_loc: file or directory for saving the file
file... | [
"Outputs",
"the",
"XML",
"content",
"(",
"from",
"XML",
"element",
")",
"into",
"a",
"file",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L83-L101 | train | Outputs the XML content from XML element to a file. |
mkoura/dump2polarion | dump2polarion/utils.py | get_xml_root | def get_xml_root(xml_file):
"""Returns XML root."""
try:
xml_root = etree.parse(os.path.expanduser(xml_file), NO_BLANKS_PARSER).getroot()
# pylint: disable=broad-except
except Exception as err:
raise Dump2PolarionException("Failed to parse XML file '{}': {}".format(xml_file, err))
re... | python | def get_xml_root(xml_file):
"""Returns XML root."""
try:
xml_root = etree.parse(os.path.expanduser(xml_file), NO_BLANKS_PARSER).getroot()
# pylint: disable=broad-except
except Exception as err:
raise Dump2PolarionException("Failed to parse XML file '{}': {}".format(xml_file, err))
re... | [
"def",
"get_xml_root",
"(",
"xml_file",
")",
":",
"try",
":",
"xml_root",
"=",
"etree",
".",
"parse",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"xml_file",
")",
",",
"NO_BLANKS_PARSER",
")",
".",
"getroot",
"(",
")",
"# pylint: disable=broad-except",
... | Returns XML root. | [
"Returns",
"XML",
"root",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L104-L111 | train | Returns XML root. |
mkoura/dump2polarion | dump2polarion/utils.py | get_xml_root_from_str | def get_xml_root_from_str(xml_str):
"""Returns XML root from string."""
try:
xml_root = etree.fromstring(xml_str.encode("utf-8"), NO_BLANKS_PARSER)
# pylint: disable=broad-except
except Exception as err:
raise Dump2PolarionException("Failed to parse XML string: {}".format(err))
retur... | python | def get_xml_root_from_str(xml_str):
"""Returns XML root from string."""
try:
xml_root = etree.fromstring(xml_str.encode("utf-8"), NO_BLANKS_PARSER)
# pylint: disable=broad-except
except Exception as err:
raise Dump2PolarionException("Failed to parse XML string: {}".format(err))
retur... | [
"def",
"get_xml_root_from_str",
"(",
"xml_str",
")",
":",
"try",
":",
"xml_root",
"=",
"etree",
".",
"fromstring",
"(",
"xml_str",
".",
"encode",
"(",
"\"utf-8\"",
")",
",",
"NO_BLANKS_PARSER",
")",
"# pylint: disable=broad-except",
"except",
"Exception",
"as",
... | Returns XML root from string. | [
"Returns",
"XML",
"root",
"from",
"string",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L114-L121 | train | Returns XML root from string. |
mkoura/dump2polarion | dump2polarion/utils.py | prettify_xml | def prettify_xml(xml_root):
"""Returns pretty-printed string representation of element tree."""
xml_string = etree.tostring(xml_root, encoding="utf-8", xml_declaration=True, pretty_print=True)
return get_unicode_str(xml_string) | python | def prettify_xml(xml_root):
"""Returns pretty-printed string representation of element tree."""
xml_string = etree.tostring(xml_root, encoding="utf-8", xml_declaration=True, pretty_print=True)
return get_unicode_str(xml_string) | [
"def",
"prettify_xml",
"(",
"xml_root",
")",
":",
"xml_string",
"=",
"etree",
".",
"tostring",
"(",
"xml_root",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"xml_declaration",
"=",
"True",
",",
"pretty_print",
"=",
"True",
")",
"return",
"get_unicode_str",
"(",
"... | Returns pretty-printed string representation of element tree. | [
"Returns",
"pretty",
"-",
"printed",
"string",
"representation",
"of",
"element",
"tree",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L129-L132 | train | Returns pretty - printed string representation of element tree. |
mkoura/dump2polarion | dump2polarion/utils.py | get_session | def get_session(credentials, config):
"""Gets requests session."""
session = requests.Session()
session.verify = False
auth_url = config.get("auth_url")
if auth_url:
cookie = session.post(
auth_url,
data={
"j_username": credentials[0],
... | python | def get_session(credentials, config):
"""Gets requests session."""
session = requests.Session()
session.verify = False
auth_url = config.get("auth_url")
if auth_url:
cookie = session.post(
auth_url,
data={
"j_username": credentials[0],
... | [
"def",
"get_session",
"(",
"credentials",
",",
"config",
")",
":",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"session",
".",
"verify",
"=",
"False",
"auth_url",
"=",
"config",
".",
"get",
"(",
"\"auth_url\"",
")",
"if",
"auth_url",
":",
"cook... | Gets requests session. | [
"Gets",
"requests",
"session",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L135-L158 | train | Gets requests session. |
mkoura/dump2polarion | dump2polarion/utils.py | find_vcs_root | def find_vcs_root(path, dirs=(".git",)):
"""Searches up from a given path to find the project root."""
prev, path = None, os.path.abspath(path)
while prev != path:
if any(os.path.exists(os.path.join(path, d)) for d in dirs):
return path
prev, path = path, os.path.abspath(os.path.... | python | def find_vcs_root(path, dirs=(".git",)):
"""Searches up from a given path to find the project root."""
prev, path = None, os.path.abspath(path)
while prev != path:
if any(os.path.exists(os.path.join(path, d)) for d in dirs):
return path
prev, path = path, os.path.abspath(os.path.... | [
"def",
"find_vcs_root",
"(",
"path",
",",
"dirs",
"=",
"(",
"\".git\"",
",",
")",
")",
":",
"prev",
",",
"path",
"=",
"None",
",",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"while",
"prev",
"!=",
"path",
":",
"if",
"any",
"(",
"os",
... | Searches up from a given path to find the project root. | [
"Searches",
"up",
"from",
"a",
"given",
"path",
"to",
"find",
"the",
"project",
"root",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/utils.py#L161-L168 | train | Searches up from a given path to find the project root. |
klen/zeta-library | zetalibrary/packer.py | Packer.pack | def pack(self):
" Pack and save file "
pack_name = self.args.prefix + op.basename(self.path)
pack_path = op.join(self.args.output or self.basedir, pack_name)
self.out("Packing: %s" % self.path)
self.out("Output: %s" % pack_path)
if self.args.format:
ext = se... | python | def pack(self):
" Pack and save file "
pack_name = self.args.prefix + op.basename(self.path)
pack_path = op.join(self.args.output or self.basedir, pack_name)
self.out("Packing: %s" % self.path)
self.out("Output: %s" % pack_path)
if self.args.format:
ext = se... | [
"def",
"pack",
"(",
"self",
")",
":",
"pack_name",
"=",
"self",
".",
"args",
".",
"prefix",
"+",
"op",
".",
"basename",
"(",
"self",
".",
"path",
")",
"pack_path",
"=",
"op",
".",
"join",
"(",
"self",
".",
"args",
".",
"output",
"or",
"self",
"."... | Pack and save file | [
"Pack",
"and",
"save",
"file"
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/packer.py#L22-L39 | train | Pack and save file |
klen/zeta-library | zetalibrary/packer.py | Packer.parse_path | def parse_path(self, path, curdir):
" Normilize path. "
if path.startswith('http://'):
return path
elif path.startswith('zeta://'):
zpath = op.join(LIBDIR, path[len('zeta://'):])
if self.args.directory and not op.exists(zpath):
return op.join(... | python | def parse_path(self, path, curdir):
" Normilize path. "
if path.startswith('http://'):
return path
elif path.startswith('zeta://'):
zpath = op.join(LIBDIR, path[len('zeta://'):])
if self.args.directory and not op.exists(zpath):
return op.join(... | [
"def",
"parse_path",
"(",
"self",
",",
"path",
",",
"curdir",
")",
":",
"if",
"path",
".",
"startswith",
"(",
"'http://'",
")",
":",
"return",
"path",
"elif",
"path",
".",
"startswith",
"(",
"'zeta://'",
")",
":",
"zpath",
"=",
"op",
".",
"join",
"("... | Normilize path. | [
"Normilize",
"path",
"."
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/packer.py#L92-L103 | train | Normilize path. |
klen/zeta-library | zetalibrary/packer.py | Packer.out | def out(msg, error=False):
" Send message to shell "
pipe = stdout
if error:
pipe = stderr
msg = color_msg(msg, "warning")
pipe.write("%s\n" % msg) | python | def out(msg, error=False):
" Send message to shell "
pipe = stdout
if error:
pipe = stderr
msg = color_msg(msg, "warning")
pipe.write("%s\n" % msg) | [
"def",
"out",
"(",
"msg",
",",
"error",
"=",
"False",
")",
":",
"pipe",
"=",
"stdout",
"if",
"error",
":",
"pipe",
"=",
"stderr",
"msg",
"=",
"color_msg",
"(",
"msg",
",",
"\"warning\"",
")",
"pipe",
".",
"write",
"(",
"\"%s\\n\"",
"%",
"msg",
")"
... | Send message to shell | [
"Send",
"message",
"to",
"shell"
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/packer.py#L106-L113 | train | Send message to shell |
klen/zeta-library | zetalibrary/scss/__init__.py | _invert | def _invert(color):
"""
Returns the inverse (negative) of a color.
The red, green, and blue values are inverted, while the opacity is left alone.
"""
col = ColorValue(color)
c = col.value
c[0] = 255.0 - c[0]
c[1] = 255.0 - c[1]
c[2] = 255.0 - c[2]
return col | python | def _invert(color):
"""
Returns the inverse (negative) of a color.
The red, green, and blue values are inverted, while the opacity is left alone.
"""
col = ColorValue(color)
c = col.value
c[0] = 255.0 - c[0]
c[1] = 255.0 - c[1]
c[2] = 255.0 - c[2]
return col | [
"def",
"_invert",
"(",
"color",
")",
":",
"col",
"=",
"ColorValue",
"(",
"color",
")",
"c",
"=",
"col",
".",
"value",
"c",
"[",
"0",
"]",
"=",
"255.0",
"-",
"c",
"[",
"0",
"]",
"c",
"[",
"1",
"]",
"=",
"255.0",
"-",
"c",
"[",
"1",
"]",
"c... | Returns the inverse (negative) of a color.
The red, green, and blue values are inverted, while the opacity is left alone. | [
"Returns",
"the",
"inverse",
"(",
"negative",
")",
"of",
"a",
"color",
".",
"The",
"red",
"green",
"and",
"blue",
"values",
"are",
"inverted",
"while",
"the",
"opacity",
"is",
"left",
"alone",
"."
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2097-L2107 | train | Invert a color. |
klen/zeta-library | zetalibrary/scss/__init__.py | _mix | def _mix(color1, color2, weight=None):
"""
Mixes together two colors. Specifically, takes the average of each of the
RGB components, optionally weighted by the given percentage.
The opacity of the colors is also considered when weighting the components.
Specifically, takes the average of each of th... | python | def _mix(color1, color2, weight=None):
"""
Mixes together two colors. Specifically, takes the average of each of the
RGB components, optionally weighted by the given percentage.
The opacity of the colors is also considered when weighting the components.
Specifically, takes the average of each of th... | [
"def",
"_mix",
"(",
"color1",
",",
"color2",
",",
"weight",
"=",
"None",
")",
":",
"# This algorithm factors in both the user-provided weight",
"# and the difference between the alpha values of the two colors",
"# to decide how to perform the weighted average of the two RGB values.",
"... | Mixes together two colors. Specifically, takes the average of each of the
RGB components, optionally weighted by the given percentage.
The opacity of the colors is also considered when weighting the components.
Specifically, takes the average of each of the RGB components,
optionally weighted by the gi... | [
"Mixes",
"together",
"two",
"colors",
".",
"Specifically",
"takes",
"the",
"average",
"of",
"each",
"of",
"the",
"RGB",
"components",
"optionally",
"weighted",
"by",
"the",
"given",
"percentage",
".",
"The",
"opacity",
"of",
"the",
"colors",
"is",
"also",
"c... | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2146-L2210 | train | This function takes two colors and returns the combined color of color1 and color2. |
klen/zeta-library | zetalibrary/scss/__init__.py | _sprite_map | def _sprite_map(g, **kwargs):
"""
Generates a sprite map from the files matching the glob pattern.
Uses the keyword-style arguments passed in to control the placement.
"""
g = StringValue(g).value
if not Image:
raise Exception("Images manipulation require PIL")
if g in sprite_maps:... | python | def _sprite_map(g, **kwargs):
"""
Generates a sprite map from the files matching the glob pattern.
Uses the keyword-style arguments passed in to control the placement.
"""
g = StringValue(g).value
if not Image:
raise Exception("Images manipulation require PIL")
if g in sprite_maps:... | [
"def",
"_sprite_map",
"(",
"g",
",",
"*",
"*",
"kwargs",
")",
":",
"g",
"=",
"StringValue",
"(",
"g",
")",
".",
"value",
"if",
"not",
"Image",
":",
"raise",
"Exception",
"(",
"\"Images manipulation require PIL\"",
")",
"if",
"g",
"in",
"sprite_maps",
":"... | Generates a sprite map from the files matching the glob pattern.
Uses the keyword-style arguments passed in to control the placement. | [
"Generates",
"a",
"sprite",
"map",
"from",
"the",
"files",
"matching",
"the",
"glob",
"pattern",
".",
"Uses",
"the",
"keyword",
"-",
"style",
"arguments",
"passed",
"in",
"to",
"control",
"the",
"placement",
"."
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2572-L2764 | train | Generates a sprite map from the files matching the glob pattern. |
klen/zeta-library | zetalibrary/scss/__init__.py | _sprite_map_name | def _sprite_map_name(map):
"""
Returns the name of a sprite map The name is derived from the folder than
contains the sprites.
"""
map = StringValue(map).value
sprite_map = sprite_maps.get(map)
if not sprite_map:
log.error("No sprite map found: %s", map)
if sprite_map:
re... | python | def _sprite_map_name(map):
"""
Returns the name of a sprite map The name is derived from the folder than
contains the sprites.
"""
map = StringValue(map).value
sprite_map = sprite_maps.get(map)
if not sprite_map:
log.error("No sprite map found: %s", map)
if sprite_map:
re... | [
"def",
"_sprite_map_name",
"(",
"map",
")",
":",
"map",
"=",
"StringValue",
"(",
"map",
")",
".",
"value",
"sprite_map",
"=",
"sprite_maps",
".",
"get",
"(",
"map",
")",
"if",
"not",
"sprite_map",
":",
"log",
".",
"error",
"(",
"\"No sprite map found: %s\"... | Returns the name of a sprite map The name is derived from the folder than
contains the sprites. | [
"Returns",
"the",
"name",
"of",
"a",
"sprite",
"map",
"The",
"name",
"is",
"derived",
"from",
"the",
"folder",
"than",
"contains",
"the",
"sprites",
"."
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2859-L2870 | train | Returns the name of a sprite map |
klen/zeta-library | zetalibrary/scss/__init__.py | _sprite_file | def _sprite_file(map, sprite):
"""
Returns the relative path (from the images directory) to the original file
used when construction the sprite. This is suitable for passing to the
image_width and image_height helpers.
"""
map = StringValue(map).value
sprite_name = StringValue(sprite).value
... | python | def _sprite_file(map, sprite):
"""
Returns the relative path (from the images directory) to the original file
used when construction the sprite. This is suitable for passing to the
image_width and image_height helpers.
"""
map = StringValue(map).value
sprite_name = StringValue(sprite).value
... | [
"def",
"_sprite_file",
"(",
"map",
",",
"sprite",
")",
":",
"map",
"=",
"StringValue",
"(",
"map",
")",
".",
"value",
"sprite_name",
"=",
"StringValue",
"(",
"sprite",
")",
".",
"value",
"sprite_map",
"=",
"sprite_maps",
".",
"get",
"(",
"map",
")",
"s... | Returns the relative path (from the images directory) to the original file
used when construction the sprite. This is suitable for passing to the
image_width and image_height helpers. | [
"Returns",
"the",
"relative",
"path",
"(",
"from",
"the",
"images",
"directory",
")",
"to",
"the",
"original",
"file",
"used",
"when",
"construction",
"the",
"sprite",
".",
"This",
"is",
"suitable",
"for",
"passing",
"to",
"the",
"image_width",
"and",
"image... | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2873-L2889 | train | Returns the relative path to the original file that is used when construction the sprite. |
klen/zeta-library | zetalibrary/scss/__init__.py | _sprite | def _sprite(map, sprite, offset_x=None, offset_y=None):
"""
Returns the image and background position for use in a single shorthand
property
"""
map = StringValue(map).value
sprite_name = StringValue(sprite).value
sprite_map = sprite_maps.get(map)
sprite = sprite_map and sprite_map.get(s... | python | def _sprite(map, sprite, offset_x=None, offset_y=None):
"""
Returns the image and background position for use in a single shorthand
property
"""
map = StringValue(map).value
sprite_name = StringValue(sprite).value
sprite_map = sprite_maps.get(map)
sprite = sprite_map and sprite_map.get(s... | [
"def",
"_sprite",
"(",
"map",
",",
"sprite",
",",
"offset_x",
"=",
"None",
",",
"offset_y",
"=",
"None",
")",
":",
"map",
"=",
"StringValue",
"(",
"map",
")",
".",
"value",
"sprite_name",
"=",
"StringValue",
"(",
"sprite",
")",
".",
"value",
"sprite_ma... | Returns the image and background position for use in a single shorthand
property | [
"Returns",
"the",
"image",
"and",
"background",
"position",
"for",
"use",
"in",
"a",
"single",
"shorthand",
"property"
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2898-L2921 | train | Return the image and background position for use in a single shorthand
property |
klen/zeta-library | zetalibrary/scss/__init__.py | _sprite_url | def _sprite_url(map):
"""
Returns a url to the sprite image.
"""
map = StringValue(map).value
sprite_map = sprite_maps.get(map)
if not sprite_map:
log.error("No sprite map found: %s", map)
if sprite_map:
url = '%s%s?_=%s' % (ASSETS_URL, sprite_map['*f*'], sprite_map['*t*'])
... | python | def _sprite_url(map):
"""
Returns a url to the sprite image.
"""
map = StringValue(map).value
sprite_map = sprite_maps.get(map)
if not sprite_map:
log.error("No sprite map found: %s", map)
if sprite_map:
url = '%s%s?_=%s' % (ASSETS_URL, sprite_map['*f*'], sprite_map['*t*'])
... | [
"def",
"_sprite_url",
"(",
"map",
")",
":",
"map",
"=",
"StringValue",
"(",
"map",
")",
".",
"value",
"sprite_map",
"=",
"sprite_maps",
".",
"get",
"(",
"map",
")",
"if",
"not",
"sprite_map",
":",
"log",
".",
"error",
"(",
"\"No sprite map found: %s\"",
... | Returns a url to the sprite image. | [
"Returns",
"a",
"url",
"to",
"the",
"sprite",
"image",
"."
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2924-L2936 | train | Returns a url to the sprite image. |
klen/zeta-library | zetalibrary/scss/__init__.py | _sprite_position | def _sprite_position(map, sprite, offset_x=None, offset_y=None):
"""
Returns the position for the original image in the sprite.
This is suitable for use as a value to background-position.
"""
map = StringValue(map).value
sprite_name = StringValue(sprite).value
sprite_map = sprite_maps.get(ma... | python | def _sprite_position(map, sprite, offset_x=None, offset_y=None):
"""
Returns the position for the original image in the sprite.
This is suitable for use as a value to background-position.
"""
map = StringValue(map).value
sprite_name = StringValue(sprite).value
sprite_map = sprite_maps.get(ma... | [
"def",
"_sprite_position",
"(",
"map",
",",
"sprite",
",",
"offset_x",
"=",
"None",
",",
"offset_y",
"=",
"None",
")",
":",
"map",
"=",
"StringValue",
"(",
"map",
")",
".",
"value",
"sprite_name",
"=",
"StringValue",
"(",
"sprite",
")",
".",
"value",
"... | Returns the position for the original image in the sprite.
This is suitable for use as a value to background-position. | [
"Returns",
"the",
"position",
"for",
"the",
"original",
"image",
"in",
"the",
"sprite",
".",
"This",
"is",
"suitable",
"for",
"use",
"as",
"a",
"value",
"to",
"background",
"-",
"position",
"."
] | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2939-L2973 | train | Returns the position of the original image in the sprite. |
klen/zeta-library | zetalibrary/scss/__init__.py | _inline_image | def _inline_image(image, mime_type=None):
"""
Embeds the contents of a file directly inside your stylesheet, eliminating
the need for another HTTP request. For small files such images or fonts,
this can be a performance benefit at the cost of a larger generated CSS
file.
"""
file = StringVal... | python | def _inline_image(image, mime_type=None):
"""
Embeds the contents of a file directly inside your stylesheet, eliminating
the need for another HTTP request. For small files such images or fonts,
this can be a performance benefit at the cost of a larger generated CSS
file.
"""
file = StringVal... | [
"def",
"_inline_image",
"(",
"image",
",",
"mime_type",
"=",
"None",
")",
":",
"file",
"=",
"StringValue",
"(",
"image",
")",
".",
"value",
"mime_type",
"=",
"StringValue",
"(",
"mime_type",
")",
".",
"value",
"or",
"mimetypes",
".",
"guess_type",
"(",
"... | Embeds the contents of a file directly inside your stylesheet, eliminating
the need for another HTTP request. For small files such images or fonts,
this can be a performance benefit at the cost of a larger generated CSS
file. | [
"Embeds",
"the",
"contents",
"of",
"a",
"file",
"directly",
"inside",
"your",
"stylesheet",
"eliminating",
"the",
"need",
"for",
"another",
"HTTP",
"request",
".",
"For",
"small",
"files",
"such",
"images",
"or",
"fonts",
"this",
"can",
"be",
"a",
"performan... | b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L2976-L3000 | train | Returns the contents of an image in a CSS stylesheet. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.