repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
lsst-sqre/lander | lander/config.py | Configuration._get_docushare_url | def _get_docushare_url(handle, validate=True):
"""Get a docushare URL given document's handle.
Parameters
----------
handle : `str`
Handle name, such as ``'LDM-151'``.
validate : `bool`, optional
Set to `True` to request that the link resolves by performi... | python | def _get_docushare_url(handle, validate=True):
"""Get a docushare URL given document's handle.
Parameters
----------
handle : `str`
Handle name, such as ``'LDM-151'``.
validate : `bool`, optional
Set to `True` to request that the link resolves by performi... | [
"def",
"_get_docushare_url",
"(",
"handle",
",",
"validate",
"=",
"True",
")",
":",
"logger",
"=",
"structlog",
".",
"get_logger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"'Using Configuration._get_docushare_url'",
")",
"# Make a short link to the DocuShare... | Get a docushare URL given document's handle.
Parameters
----------
handle : `str`
Handle name, such as ``'LDM-151'``.
validate : `bool`, optional
Set to `True` to request that the link resolves by performing
a HEAD request over the network. `False` di... | [
"Get",
"a",
"docushare",
"URL",
"given",
"document",
"s",
"handle",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/config.py#L246-L296 | train | 58,000 |
lsst-sqre/lander | lander/config.py | Configuration._init_defaults | def _init_defaults(self):
"""Create a `dict` of default configurations."""
defaults = {
'build_dir': None,
'build_datetime': datetime.datetime.now(dateutil.tz.tzutc()),
'pdf_path': None,
'extra_downloads': list(),
'environment': None,
... | python | def _init_defaults(self):
"""Create a `dict` of default configurations."""
defaults = {
'build_dir': None,
'build_datetime': datetime.datetime.now(dateutil.tz.tzutc()),
'pdf_path': None,
'extra_downloads': list(),
'environment': None,
... | [
"def",
"_init_defaults",
"(",
"self",
")",
":",
"defaults",
"=",
"{",
"'build_dir'",
":",
"None",
",",
"'build_datetime'",
":",
"datetime",
".",
"datetime",
".",
"now",
"(",
"dateutil",
".",
"tz",
".",
"tzutc",
"(",
")",
")",
",",
"'pdf_path'",
":",
"N... | Create a `dict` of default configurations. | [
"Create",
"a",
"dict",
"of",
"default",
"configurations",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/config.py#L335-L369 | train | 58,001 |
clinicedc/edc-permissions | edc_permissions/utils/generic.py | create_permissions_from_tuples | def create_permissions_from_tuples(model, codename_tpls):
"""Creates custom permissions on model "model".
"""
if codename_tpls:
model_cls = django_apps.get_model(model)
content_type = ContentType.objects.get_for_model(model_cls)
for codename_tpl in codename_tpls:
app_labe... | python | def create_permissions_from_tuples(model, codename_tpls):
"""Creates custom permissions on model "model".
"""
if codename_tpls:
model_cls = django_apps.get_model(model)
content_type = ContentType.objects.get_for_model(model_cls)
for codename_tpl in codename_tpls:
app_labe... | [
"def",
"create_permissions_from_tuples",
"(",
"model",
",",
"codename_tpls",
")",
":",
"if",
"codename_tpls",
":",
"model_cls",
"=",
"django_apps",
".",
"get_model",
"(",
"model",
")",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
... | Creates custom permissions on model "model". | [
"Creates",
"custom",
"permissions",
"on",
"model",
"model",
"."
] | d1aee39a8ddaf4b7741d9306139ddd03625d4e1a | https://github.com/clinicedc/edc-permissions/blob/d1aee39a8ddaf4b7741d9306139ddd03625d4e1a/edc_permissions/utils/generic.py#L108-L124 | train | 58,002 |
clinicedc/edc-permissions | edc_permissions/utils/generic.py | remove_historical_group_permissions | def remove_historical_group_permissions(group=None, allowed_permissions=None):
"""Removes group permissions for historical models
except those whose prefix is in `allowed_historical_permissions`.
Default removes all except `view`.
"""
allowed_permissions = allowed_permissions or ["view"]
for a... | python | def remove_historical_group_permissions(group=None, allowed_permissions=None):
"""Removes group permissions for historical models
except those whose prefix is in `allowed_historical_permissions`.
Default removes all except `view`.
"""
allowed_permissions = allowed_permissions or ["view"]
for a... | [
"def",
"remove_historical_group_permissions",
"(",
"group",
"=",
"None",
",",
"allowed_permissions",
"=",
"None",
")",
":",
"allowed_permissions",
"=",
"allowed_permissions",
"or",
"[",
"\"view\"",
"]",
"for",
"action",
"in",
"allowed_permissions",
":",
"for",
"perm... | Removes group permissions for historical models
except those whose prefix is in `allowed_historical_permissions`.
Default removes all except `view`. | [
"Removes",
"group",
"permissions",
"for",
"historical",
"models",
"except",
"those",
"whose",
"prefix",
"is",
"in",
"allowed_historical_permissions",
"."
] | d1aee39a8ddaf4b7741d9306139ddd03625d4e1a | https://github.com/clinicedc/edc-permissions/blob/d1aee39a8ddaf4b7741d9306139ddd03625d4e1a/edc_permissions/utils/generic.py#L214-L226 | train | 58,003 |
brmscheiner/ideogram | ideogram/converter.py | traversal | def traversal(root):
'''Tree traversal function that generates nodes. For each subtree, the
deepest node is evaluated first. Then, the next-deepest nodes are
evaluated until all the nodes in the subtree are generated.'''
stack = [root]
while len(stack) > 0:
node = stack.pop()
if ha... | python | def traversal(root):
'''Tree traversal function that generates nodes. For each subtree, the
deepest node is evaluated first. Then, the next-deepest nodes are
evaluated until all the nodes in the subtree are generated.'''
stack = [root]
while len(stack) > 0:
node = stack.pop()
if ha... | [
"def",
"traversal",
"(",
"root",
")",
":",
"stack",
"=",
"[",
"root",
"]",
"while",
"len",
"(",
"stack",
")",
">",
"0",
":",
"node",
"=",
"stack",
".",
"pop",
"(",
")",
"if",
"hasattr",
"(",
"node",
",",
"'children'",
")",
":",
"if",
"node",
".... | Tree traversal function that generates nodes. For each subtree, the
deepest node is evaluated first. Then, the next-deepest nodes are
evaluated until all the nodes in the subtree are generated. | [
"Tree",
"traversal",
"function",
"that",
"generates",
"nodes",
".",
"For",
"each",
"subtree",
"the",
"deepest",
"node",
"is",
"evaluated",
"first",
".",
"Then",
"the",
"next",
"-",
"deepest",
"nodes",
"are",
"evaluated",
"until",
"all",
"the",
"nodes",
"in",... | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L27-L47 | train | 58,004 |
brmscheiner/ideogram | ideogram/converter.py | firstPass | def firstPass(ASTs,verbose):
'''Return a dictionary of function definition nodes, a dictionary of
imported object names and a dictionary of imported module names. All three
dictionaries use source file paths as keys.'''
fdefs=dict()
cdefs=dict()
imp_obj_strs=dict()
imp_mods=dict()
for... | python | def firstPass(ASTs,verbose):
'''Return a dictionary of function definition nodes, a dictionary of
imported object names and a dictionary of imported module names. All three
dictionaries use source file paths as keys.'''
fdefs=dict()
cdefs=dict()
imp_obj_strs=dict()
imp_mods=dict()
for... | [
"def",
"firstPass",
"(",
"ASTs",
",",
"verbose",
")",
":",
"fdefs",
"=",
"dict",
"(",
")",
"cdefs",
"=",
"dict",
"(",
")",
"imp_obj_strs",
"=",
"dict",
"(",
")",
"imp_mods",
"=",
"dict",
"(",
")",
"for",
"(",
"root",
",",
"path",
")",
"in",
"ASTs... | Return a dictionary of function definition nodes, a dictionary of
imported object names and a dictionary of imported module names. All three
dictionaries use source file paths as keys. | [
"Return",
"a",
"dictionary",
"of",
"function",
"definition",
"nodes",
"a",
"dictionary",
"of",
"imported",
"object",
"names",
"and",
"a",
"dictionary",
"of",
"imported",
"module",
"names",
".",
"All",
"three",
"dictionaries",
"use",
"source",
"file",
"paths",
... | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L49-L81 | train | 58,005 |
brmscheiner/ideogram | ideogram/converter.py | formatBodyNode | def formatBodyNode(root,path):
'''Format the root node for use as the body node.'''
body = root
body.name = "body"
body.weight = calcFnWeight(body)
body.path = path
body.pclass = None
return body | python | def formatBodyNode(root,path):
'''Format the root node for use as the body node.'''
body = root
body.name = "body"
body.weight = calcFnWeight(body)
body.path = path
body.pclass = None
return body | [
"def",
"formatBodyNode",
"(",
"root",
",",
"path",
")",
":",
"body",
"=",
"root",
"body",
".",
"name",
"=",
"\"body\"",
"body",
".",
"weight",
"=",
"calcFnWeight",
"(",
"body",
")",
"body",
".",
"path",
"=",
"path",
"body",
".",
"pclass",
"=",
"None"... | Format the root node for use as the body node. | [
"Format",
"the",
"root",
"node",
"for",
"use",
"as",
"the",
"body",
"node",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L104-L111 | train | 58,006 |
brmscheiner/ideogram | ideogram/converter.py | formatFunctionNode | def formatFunctionNode(node,path,stack):
'''Add some helpful attributes to node.'''
#node.name is already defined by AST module
node.weight = calcFnWeight(node)
node.path = path
node.pclass = getCurrentClass(stack)
return node | python | def formatFunctionNode(node,path,stack):
'''Add some helpful attributes to node.'''
#node.name is already defined by AST module
node.weight = calcFnWeight(node)
node.path = path
node.pclass = getCurrentClass(stack)
return node | [
"def",
"formatFunctionNode",
"(",
"node",
",",
"path",
",",
"stack",
")",
":",
"#node.name is already defined by AST module",
"node",
".",
"weight",
"=",
"calcFnWeight",
"(",
"node",
")",
"node",
".",
"path",
"=",
"path",
"node",
".",
"pclass",
"=",
"getCurren... | Add some helpful attributes to node. | [
"Add",
"some",
"helpful",
"attributes",
"to",
"node",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L113-L119 | train | 58,007 |
brmscheiner/ideogram | ideogram/converter.py | getSourceFnDef | def getSourceFnDef(stack,fdefs,path):
'''VERY VERY SLOW'''
found = False
for x in stack:
if isinstance(x, ast.FunctionDef):
for y in fdefs[path]:
if ast.dump(x)==ast.dump(y): #probably causing the slowness
found = True
return y
... | python | def getSourceFnDef(stack,fdefs,path):
'''VERY VERY SLOW'''
found = False
for x in stack:
if isinstance(x, ast.FunctionDef):
for y in fdefs[path]:
if ast.dump(x)==ast.dump(y): #probably causing the slowness
found = True
return y
... | [
"def",
"getSourceFnDef",
"(",
"stack",
",",
"fdefs",
",",
"path",
")",
":",
"found",
"=",
"False",
"for",
"x",
"in",
"stack",
":",
"if",
"isinstance",
"(",
"x",
",",
"ast",
".",
"FunctionDef",
")",
":",
"for",
"y",
"in",
"fdefs",
"[",
"path",
"]",
... | VERY VERY SLOW | [
"VERY",
"VERY",
"SLOW"
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L134-L148 | train | 58,008 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/mongo/mongo_util.py | delete_database | def delete_database(mongo_uri, database_name):
"""
Delete a mongo database using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
"""
client = pymongo.MongoClient(mongo_uri)
client.drop_dat... | python | def delete_database(mongo_uri, database_name):
"""
Delete a mongo database using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
"""
client = pymongo.MongoClient(mongo_uri)
client.drop_dat... | [
"def",
"delete_database",
"(",
"mongo_uri",
",",
"database_name",
")",
":",
"client",
"=",
"pymongo",
".",
"MongoClient",
"(",
"mongo_uri",
")",
"client",
".",
"drop_database",
"(",
"database_name",
")"
] | Delete a mongo database using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string. | [
"Delete",
"a",
"mongo",
"database",
"using",
"pymongo",
".",
"Mongo",
"daemon",
"assumed",
"to",
"be",
"running",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/mongo/mongo_util.py#L18-L27 | train | 58,009 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/mongo/mongo_util.py | delete_collection | def delete_collection(mongo_uri, database_name, collection_name):
"""
Delete a mongo document collection using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
- collection_name: The mongo c... | python | def delete_collection(mongo_uri, database_name, collection_name):
"""
Delete a mongo document collection using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
- collection_name: The mongo c... | [
"def",
"delete_collection",
"(",
"mongo_uri",
",",
"database_name",
",",
"collection_name",
")",
":",
"client",
"=",
"pymongo",
".",
"MongoClient",
"(",
"mongo_uri",
")",
"db",
"=",
"client",
"[",
"database_name",
"]",
"db",
".",
"drop_collection",
"(",
"colle... | Delete a mongo document collection using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
- collection_name: The mongo collection as a python string. | [
"Delete",
"a",
"mongo",
"document",
"collection",
"using",
"pymongo",
".",
"Mongo",
"daemon",
"assumed",
"to",
"be",
"running",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/mongo/mongo_util.py#L30-L42 | train | 58,010 |
helixyte/everest | everest/resources/staging.py | create_staging_collection | def create_staging_collection(resource):
"""
Helper function to create a staging collection for the given registered
resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface.
"""
ent_cls = ... | python | def create_staging_collection(resource):
"""
Helper function to create a staging collection for the given registered
resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface.
"""
ent_cls = ... | [
"def",
"create_staging_collection",
"(",
"resource",
")",
":",
"ent_cls",
"=",
"get_entity_class",
"(",
"resource",
")",
"coll_cls",
"=",
"get_collection_class",
"(",
"resource",
")",
"agg",
"=",
"StagingAggregate",
"(",
"ent_cls",
")",
"return",
"coll_cls",
".",
... | Helper function to create a staging collection for the given registered
resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface. | [
"Helper",
"function",
"to",
"create",
"a",
"staging",
"collection",
"for",
"the",
"given",
"registered",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/staging.py#L114-L126 | train | 58,011 |
Nekroze/partpy | examples/contacts.py | ContactsParser.parse | def parse(self):
"""Run the parser over the entire sourestring and return the results."""
try:
return self.parse_top_level()
except PartpyError as ex:
self.error = True
print(ex.pretty_print()) | python | def parse(self):
"""Run the parser over the entire sourestring and return the results."""
try:
return self.parse_top_level()
except PartpyError as ex:
self.error = True
print(ex.pretty_print()) | [
"def",
"parse",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"parse_top_level",
"(",
")",
"except",
"PartpyError",
"as",
"ex",
":",
"self",
".",
"error",
"=",
"True",
"print",
"(",
"ex",
".",
"pretty_print",
"(",
")",
")"
] | Run the parser over the entire sourestring and return the results. | [
"Run",
"the",
"parser",
"over",
"the",
"entire",
"sourestring",
"and",
"return",
"the",
"results",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/examples/contacts.py#L23-L29 | train | 58,012 |
Nekroze/partpy | examples/contacts.py | ContactsParser.parse_top_level | def parse_top_level(self):
"""The top level parser will do a loop where it looks for a single
contact parse and then eats all whitespace until there is no more
input left or another contact is found to be parsed and stores them.
"""
contacts = []
while not self.eos:
... | python | def parse_top_level(self):
"""The top level parser will do a loop where it looks for a single
contact parse and then eats all whitespace until there is no more
input left or another contact is found to be parsed and stores them.
"""
contacts = []
while not self.eos:
... | [
"def",
"parse_top_level",
"(",
"self",
")",
":",
"contacts",
"=",
"[",
"]",
"while",
"not",
"self",
".",
"eos",
":",
"contact",
"=",
"self",
".",
"parse_contact",
"(",
")",
"# match a contact expression.",
"if",
"not",
"contact",
":",
"# There was no contact s... | The top level parser will do a loop where it looks for a single
contact parse and then eats all whitespace until there is no more
input left or another contact is found to be parsed and stores them. | [
"The",
"top",
"level",
"parser",
"will",
"do",
"a",
"loop",
"where",
"it",
"looks",
"for",
"a",
"single",
"contact",
"parse",
"and",
"then",
"eats",
"all",
"whitespace",
"until",
"there",
"is",
"no",
"more",
"input",
"left",
"or",
"another",
"contact",
"... | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/examples/contacts.py#L31-L48 | train | 58,013 |
Nekroze/partpy | examples/contacts.py | ContactsParser.parse_contact | def parse_contact(self):
"""Parse a top level contact expression, these consist of a name
expression a special char and an email expression.
The characters found in a name and email expression are returned.
"""
self.parse_whitespace()
name = self.parse_name() # parse a ... | python | def parse_contact(self):
"""Parse a top level contact expression, these consist of a name
expression a special char and an email expression.
The characters found in a name and email expression are returned.
"""
self.parse_whitespace()
name = self.parse_name() # parse a ... | [
"def",
"parse_contact",
"(",
"self",
")",
":",
"self",
".",
"parse_whitespace",
"(",
")",
"name",
"=",
"self",
".",
"parse_name",
"(",
")",
"# parse a name expression and get the string.",
"if",
"not",
"name",
":",
"# No name was found so shout it out.",
"raise",
"P... | Parse a top level contact expression, these consist of a name
expression a special char and an email expression.
The characters found in a name and email expression are returned. | [
"Parse",
"a",
"top",
"level",
"contact",
"expression",
"these",
"consist",
"of",
"a",
"name",
"expression",
"a",
"special",
"char",
"and",
"an",
"email",
"expression",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/examples/contacts.py#L50-L71 | train | 58,014 |
Nekroze/partpy | examples/contacts.py | ContactsParser.parse_name | def parse_name(self):
"""This function uses string patterns to match a title cased name.
This is done in a loop until there are no more names to match so as
to be able to include surnames etc. in the output."""
name = []
while True:
# Match the current char until it d... | python | def parse_name(self):
"""This function uses string patterns to match a title cased name.
This is done in a loop until there are no more names to match so as
to be able to include surnames etc. in the output."""
name = []
while True:
# Match the current char until it d... | [
"def",
"parse_name",
"(",
"self",
")",
":",
"name",
"=",
"[",
"]",
"while",
"True",
":",
"# Match the current char until it doesnt match the given pattern:",
"# first char must be an uppercase alpha and the rest must be lower",
"# cased alphas.",
"part",
"=",
"self",
".",
"ma... | This function uses string patterns to match a title cased name.
This is done in a loop until there are no more names to match so as
to be able to include surnames etc. in the output. | [
"This",
"function",
"uses",
"string",
"patterns",
"to",
"match",
"a",
"title",
"cased",
"name",
".",
"This",
"is",
"done",
"in",
"a",
"loop",
"until",
"there",
"are",
"no",
"more",
"names",
"to",
"match",
"so",
"as",
"to",
"be",
"able",
"to",
"include"... | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/examples/contacts.py#L84-L104 | train | 58,015 |
VJftw/invoke-tools | idflow/flow.py | Flow.get_development_container_name | def get_development_container_name(self):
"""
Returns the development container name
"""
if self.__prefix:
return "{0}:{1}-{2}-dev".format(
self.__repository,
self.__prefix,
self.__branch)
else:
return "{0}:{... | python | def get_development_container_name(self):
"""
Returns the development container name
"""
if self.__prefix:
return "{0}:{1}-{2}-dev".format(
self.__repository,
self.__prefix,
self.__branch)
else:
return "{0}:{... | [
"def",
"get_development_container_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"__prefix",
":",
"return",
"\"{0}:{1}-{2}-dev\"",
".",
"format",
"(",
"self",
".",
"__repository",
",",
"self",
".",
"__prefix",
",",
"self",
".",
"__branch",
")",
"else",
":"... | Returns the development container name | [
"Returns",
"the",
"development",
"container",
"name"
] | 9584a1f8a402118310b6f2a495062f388fc8dc3a | https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/flow.py#L59-L71 | train | 58,016 |
VJftw/invoke-tools | idflow/flow.py | Flow.get_build_container_tag | def get_build_container_tag(self):
"""
Return the build container tag
"""
if self.__prefix:
return "{0}-{1}-{2}".format(
self.__prefix,
self.__branch,
self.__version)
else:
return "{0}-{1}".format(
... | python | def get_build_container_tag(self):
"""
Return the build container tag
"""
if self.__prefix:
return "{0}-{1}-{2}".format(
self.__prefix,
self.__branch,
self.__version)
else:
return "{0}-{1}".format(
... | [
"def",
"get_build_container_tag",
"(",
"self",
")",
":",
"if",
"self",
".",
"__prefix",
":",
"return",
"\"{0}-{1}-{2}\"",
".",
"format",
"(",
"self",
".",
"__prefix",
",",
"self",
".",
"__branch",
",",
"self",
".",
"__version",
")",
"else",
":",
"return",
... | Return the build container tag | [
"Return",
"the",
"build",
"container",
"tag"
] | 9584a1f8a402118310b6f2a495062f388fc8dc3a | https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/flow.py#L73-L85 | train | 58,017 |
VJftw/invoke-tools | idflow/flow.py | Flow.get_branch_container_tag | def get_branch_container_tag(self):
"""
Returns the branch container tag
"""
if self.__prefix:
return "{0}-{1}".format(
self.__prefix,
self.__branch)
else:
return "{0}".format(self.__branch) | python | def get_branch_container_tag(self):
"""
Returns the branch container tag
"""
if self.__prefix:
return "{0}-{1}".format(
self.__prefix,
self.__branch)
else:
return "{0}".format(self.__branch) | [
"def",
"get_branch_container_tag",
"(",
"self",
")",
":",
"if",
"self",
".",
"__prefix",
":",
"return",
"\"{0}-{1}\"",
".",
"format",
"(",
"self",
".",
"__prefix",
",",
"self",
".",
"__branch",
")",
"else",
":",
"return",
"\"{0}\"",
".",
"format",
"(",
"... | Returns the branch container tag | [
"Returns",
"the",
"branch",
"container",
"tag"
] | 9584a1f8a402118310b6f2a495062f388fc8dc3a | https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/flow.py#L95-L104 | train | 58,018 |
callowayproject/Calloway | calloway/apps/django_ext/views.py | custom_server_error | def custom_server_error(request, template_name='500.html', admin_template_name='500A.html'):
"""
500 error handler. Displays a full trackback for superusers and the first line of the
traceback for staff members.
Templates: `500.html` or `500A.html` (admin)
Context: trace
Holds the traceback... | python | def custom_server_error(request, template_name='500.html', admin_template_name='500A.html'):
"""
500 error handler. Displays a full trackback for superusers and the first line of the
traceback for staff members.
Templates: `500.html` or `500A.html` (admin)
Context: trace
Holds the traceback... | [
"def",
"custom_server_error",
"(",
"request",
",",
"template_name",
"=",
"'500.html'",
",",
"admin_template_name",
"=",
"'500A.html'",
")",
":",
"trace",
"=",
"None",
"if",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
"and",
"(",
"request",
".",
... | 500 error handler. Displays a full trackback for superusers and the first line of the
traceback for staff members.
Templates: `500.html` or `500A.html` (admin)
Context: trace
Holds the traceback information for debugging. | [
"500",
"error",
"handler",
".",
"Displays",
"a",
"full",
"trackback",
"for",
"superusers",
"and",
"the",
"first",
"line",
"of",
"the",
"traceback",
"for",
"staff",
"members",
"."
] | d22e98d41fbd298ab6393ba7bd84a75528be9f81 | https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/views.py#L6-L31 | train | 58,019 |
skylander86/ycsettings | ycsettings/settings.py | parse_n_jobs | def parse_n_jobs(s):
"""
This function parses a "math"-like string as a function of CPU count.
It is useful for specifying the number of jobs.
For example, on an 8-core machine::
assert parse_n_jobs('0.5 * n') == 4
assert parse_n_jobs('2n') == 16
assert parse_n_jobs('n') == 8
... | python | def parse_n_jobs(s):
"""
This function parses a "math"-like string as a function of CPU count.
It is useful for specifying the number of jobs.
For example, on an 8-core machine::
assert parse_n_jobs('0.5 * n') == 4
assert parse_n_jobs('2n') == 16
assert parse_n_jobs('n') == 8
... | [
"def",
"parse_n_jobs",
"(",
"s",
")",
":",
"n_jobs",
"=",
"None",
"N",
"=",
"cpu_count",
"(",
")",
"if",
"isinstance",
"(",
"s",
",",
"int",
")",
":",
"n_jobs",
"=",
"s",
"elif",
"isinstance",
"(",
"s",
",",
"float",
")",
":",
"n_jobs",
"=",
"int... | This function parses a "math"-like string as a function of CPU count.
It is useful for specifying the number of jobs.
For example, on an 8-core machine::
assert parse_n_jobs('0.5 * n') == 4
assert parse_n_jobs('2n') == 16
assert parse_n_jobs('n') == 8
assert parse_n_jobs('4') =... | [
"This",
"function",
"parses",
"a",
"math",
"-",
"like",
"string",
"as",
"a",
"function",
"of",
"CPU",
"count",
".",
"It",
"is",
"useful",
"for",
"specifying",
"the",
"number",
"of",
"jobs",
"."
] | 3f363673a6cb1823ebb18c4d640d87aa49202344 | https://github.com/skylander86/ycsettings/blob/3f363673a6cb1823ebb18c4d640d87aa49202344/ycsettings/settings.py#L456-L495 | train | 58,020 |
skylander86/ycsettings | ycsettings/settings.py | Settings._load_settings_from_source | def _load_settings_from_source(self, source):
"""
Loads the relevant settings from the specified ``source``.
:returns: a standard :func:`dict` containing the settings from the source
:rtype: dict
"""
if not source:
pass
elif source == 'env_settings_ur... | python | def _load_settings_from_source(self, source):
"""
Loads the relevant settings from the specified ``source``.
:returns: a standard :func:`dict` containing the settings from the source
:rtype: dict
"""
if not source:
pass
elif source == 'env_settings_ur... | [
"def",
"_load_settings_from_source",
"(",
"self",
",",
"source",
")",
":",
"if",
"not",
"source",
":",
"pass",
"elif",
"source",
"==",
"'env_settings_uri'",
":",
"for",
"env_settings_uri_key",
"in",
"self",
".",
"env_settings_uri_keys",
":",
"env_settings_uri",
"=... | Loads the relevant settings from the specified ``source``.
:returns: a standard :func:`dict` containing the settings from the source
:rtype: dict | [
"Loads",
"the",
"relevant",
"settings",
"from",
"the",
"specified",
"source",
"."
] | 3f363673a6cb1823ebb18c4d640d87aa49202344 | https://github.com/skylander86/ycsettings/blob/3f363673a6cb1823ebb18c4d640d87aa49202344/ycsettings/settings.py#L93-L158 | train | 58,021 |
skylander86/ycsettings | ycsettings/settings.py | Settings.get | def get(self, key, *, default=None, cast_func=None, case_sensitive=None, raise_exception=None, warn_missing=None, use_cache=True, additional_sources=[]):
"""
Gets the setting specified by ``key``. For efficiency, we cache the retrieval of settings to avoid multiple searches through the sources list.
... | python | def get(self, key, *, default=None, cast_func=None, case_sensitive=None, raise_exception=None, warn_missing=None, use_cache=True, additional_sources=[]):
"""
Gets the setting specified by ``key``. For efficiency, we cache the retrieval of settings to avoid multiple searches through the sources list.
... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"*",
",",
"default",
"=",
"None",
",",
"cast_func",
"=",
"None",
",",
"case_sensitive",
"=",
"None",
",",
"raise_exception",
"=",
"None",
",",
"warn_missing",
"=",
"None",
",",
"use_cache",
"=",
"True",
",",
... | Gets the setting specified by ``key``. For efficiency, we cache the retrieval of settings to avoid multiple searches through the sources list.
:param str key: settings key to retrieve
:param str default: use this as default value when the setting key is not found
:param func cast_func: cast the... | [
"Gets",
"the",
"setting",
"specified",
"by",
"key",
".",
"For",
"efficiency",
"we",
"cache",
"the",
"retrieval",
"of",
"settings",
"to",
"avoid",
"multiple",
"searches",
"through",
"the",
"sources",
"list",
"."
] | 3f363673a6cb1823ebb18c4d640d87aa49202344 | https://github.com/skylander86/ycsettings/blob/3f363673a6cb1823ebb18c4d640d87aa49202344/ycsettings/settings.py#L230-L289 | train | 58,022 |
hatemile/hatemile-for-python | hatemile/util/html/bs/bshtmldomparser.py | BeautifulSoupHTMLDOMParser._in_list | def _in_list(self, original_list, item):
"""
Check that an item as contained in a list.
:param original_list: The list.
:type original_list: list(object)
:param item: The item.
:type item: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if the item... | python | def _in_list(self, original_list, item):
"""
Check that an item as contained in a list.
:param original_list: The list.
:type original_list: list(object)
:param item: The item.
:type item: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if the item... | [
"def",
"_in_list",
"(",
"self",
",",
"original_list",
",",
"item",
")",
":",
"# pylint: disable=no-self-use",
"for",
"item_list",
"in",
"original_list",
":",
"if",
"item",
"is",
"item_list",
":",
"return",
"True",
"return",
"False"
] | Check that an item as contained in a list.
:param original_list: The list.
:type original_list: list(object)
:param item: The item.
:type item: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if the item contained in the list or False if not.
:rtype: bool | [
"Check",
"that",
"an",
"item",
"as",
"contained",
"in",
"a",
"list",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/html/bs/bshtmldomparser.py#L49-L65 | train | 58,023 |
hatemile/hatemile-for-python | hatemile/util/html/bs/bshtmldomparser.py | BeautifulSoupHTMLDOMParser._sort_results | def _sort_results(self, results):
"""
Order the results.
:param results: The disordened results.
:type results: array.bs4.element.Tag
:return: The ordened results.
:rtype: array.bs4.element.Tag
"""
parents = []
groups = []
for result in r... | python | def _sort_results(self, results):
"""
Order the results.
:param results: The disordened results.
:type results: array.bs4.element.Tag
:return: The ordened results.
:rtype: array.bs4.element.Tag
"""
parents = []
groups = []
for result in r... | [
"def",
"_sort_results",
"(",
"self",
",",
"results",
")",
":",
"parents",
"=",
"[",
"]",
"groups",
"=",
"[",
"]",
"for",
"result",
"in",
"results",
":",
"if",
"not",
"self",
".",
"_in_list",
"(",
"parents",
",",
"result",
".",
"parent",
")",
":",
"... | Order the results.
:param results: The disordened results.
:type results: array.bs4.element.Tag
:return: The ordened results.
:rtype: array.bs4.element.Tag | [
"Order",
"the",
"results",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/html/bs/bshtmldomparser.py#L67-L92 | train | 58,024 |
hatemile/hatemile-for-python | hatemile/util/html/bs/bshtmldomparser.py | BeautifulSoupHTMLDOMParser._fix_data_select | def _fix_data_select(self):
"""
Replace all hyphens of data attributes for 'aaaaa', to avoid error in
search.
"""
elements = self.document.select('*')
for element in elements:
attributes = element.attrs.keys()
data_attributes = list()
... | python | def _fix_data_select(self):
"""
Replace all hyphens of data attributes for 'aaaaa', to avoid error in
search.
"""
elements = self.document.select('*')
for element in elements:
attributes = element.attrs.keys()
data_attributes = list()
... | [
"def",
"_fix_data_select",
"(",
"self",
")",
":",
"elements",
"=",
"self",
".",
"document",
".",
"select",
"(",
"'*'",
")",
"for",
"element",
"in",
"elements",
":",
"attributes",
"=",
"element",
".",
"attrs",
".",
"keys",
"(",
")",
"data_attributes",
"="... | Replace all hyphens of data attributes for 'aaaaa', to avoid error in
search. | [
"Replace",
"all",
"hyphens",
"of",
"data",
"attributes",
"for",
"aaaaa",
"to",
"avoid",
"error",
"in",
"search",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/html/bs/bshtmldomparser.py#L94-L120 | train | 58,025 |
tBaxter/activity-monitor | activity_monitor/templatetags/activity_tags.py | render_activity | def render_activity(activity, grouped_activity=None, *args, **kwargs):
"""
Given an activity, will attempt to render the matching template snippet
for that activity's content object
or will return a simple representation of the activity.
Also takes an optional 'grouped_activity' argument that would... | python | def render_activity(activity, grouped_activity=None, *args, **kwargs):
"""
Given an activity, will attempt to render the matching template snippet
for that activity's content object
or will return a simple representation of the activity.
Also takes an optional 'grouped_activity' argument that would... | [
"def",
"render_activity",
"(",
"activity",
",",
"grouped_activity",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"template_name",
"=",
"'activity_monitor/includes/models/{0.app_label}_{0.model}.html'",
".",
"format",
"(",
"activity",
".",
"conte... | Given an activity, will attempt to render the matching template snippet
for that activity's content object
or will return a simple representation of the activity.
Also takes an optional 'grouped_activity' argument that would match up with
what is produced by utils.group_activity | [
"Given",
"an",
"activity",
"will",
"attempt",
"to",
"render",
"the",
"matching",
"template",
"snippet",
"for",
"that",
"activity",
"s",
"content",
"object",
"or",
"will",
"return",
"a",
"simple",
"representation",
"of",
"the",
"activity",
"."
] | be6c6edc7c6b4141923b47376502cde0f785eb68 | https://github.com/tBaxter/activity-monitor/blob/be6c6edc7c6b4141923b47376502cde0f785eb68/activity_monitor/templatetags/activity_tags.py#L38-L58 | train | 58,026 |
tBaxter/activity-monitor | activity_monitor/templatetags/activity_tags.py | show_activity_count | def show_activity_count(date=None):
"""
Simple filter to get activity count for a given day.
Defaults to today.
"""
if not date:
today = datetime.datetime.now() - datetime.timedelta(hours = 24)
return Activity.objects.filter(timestamp__gte=today).count()
return Activity.objects.f... | python | def show_activity_count(date=None):
"""
Simple filter to get activity count for a given day.
Defaults to today.
"""
if not date:
today = datetime.datetime.now() - datetime.timedelta(hours = 24)
return Activity.objects.filter(timestamp__gte=today).count()
return Activity.objects.f... | [
"def",
"show_activity_count",
"(",
"date",
"=",
"None",
")",
":",
"if",
"not",
"date",
":",
"today",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"-",
"datetime",
".",
"timedelta",
"(",
"hours",
"=",
"24",
")",
"return",
"Activity",
".",
"... | Simple filter to get activity count for a given day.
Defaults to today. | [
"Simple",
"filter",
"to",
"get",
"activity",
"count",
"for",
"a",
"given",
"day",
".",
"Defaults",
"to",
"today",
"."
] | be6c6edc7c6b4141923b47376502cde0f785eb68 | https://github.com/tBaxter/activity-monitor/blob/be6c6edc7c6b4141923b47376502cde0f785eb68/activity_monitor/templatetags/activity_tags.py#L62-L70 | train | 58,027 |
AtomHash/evernode | evernode/classes/app.py | __root_path | def __root_path(self):
""" Just checks the root path if set """
if self.root_path is not None:
if os.path.isdir(self.root_path):
sys.path.append(self.root_path)
return
raise RuntimeError('EverNode requires a valid root path.'
... | python | def __root_path(self):
""" Just checks the root path if set """
if self.root_path is not None:
if os.path.isdir(self.root_path):
sys.path.append(self.root_path)
return
raise RuntimeError('EverNode requires a valid root path.'
... | [
"def",
"__root_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"root_path",
"is",
"not",
"None",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"root_path",
")",
":",
"sys",
".",
"path",
".",
"append",
"(",
"self",
".",
"root_path",... | Just checks the root path if set | [
"Just",
"checks",
"the",
"root",
"path",
"if",
"set"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/app.py#L37-L45 | train | 58,028 |
lsst-sqre/lander | lander/lander.py | Lander.write_metadata | def write_metadata(self, output_path):
"""Build a JSON-LD dataset for LSST Projectmeta.
Parameters
----------
output_path : `str`
File path where the ``metadata.jsonld`` should be written for the
build.
"""
if self._config.lsstdoc is None:
... | python | def write_metadata(self, output_path):
"""Build a JSON-LD dataset for LSST Projectmeta.
Parameters
----------
output_path : `str`
File path where the ``metadata.jsonld`` should be written for the
build.
"""
if self._config.lsstdoc is None:
... | [
"def",
"write_metadata",
"(",
"self",
",",
"output_path",
")",
":",
"if",
"self",
".",
"_config",
".",
"lsstdoc",
"is",
"None",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"'No known LSST LaTeX source (--tex argument). '",
"'Not writing a metadata.jsonld file.'",
... | Build a JSON-LD dataset for LSST Projectmeta.
Parameters
----------
output_path : `str`
File path where the ``metadata.jsonld`` should be written for the
build. | [
"Build",
"a",
"JSON",
"-",
"LD",
"dataset",
"for",
"LSST",
"Projectmeta",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/lander.py#L89-L117 | train | 58,029 |
lsst-sqre/lander | lander/lander.py | Lander.upload_site | def upload_site(self):
"""Upload a previously-built site to LSST the Docs."""
if not os.path.isdir(self._config['build_dir']):
message = 'Site not built at {0}'.format(self._config['build_dir'])
self._logger.error(message)
raise RuntimeError(message)
ltdclien... | python | def upload_site(self):
"""Upload a previously-built site to LSST the Docs."""
if not os.path.isdir(self._config['build_dir']):
message = 'Site not built at {0}'.format(self._config['build_dir'])
self._logger.error(message)
raise RuntimeError(message)
ltdclien... | [
"def",
"upload_site",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"_config",
"[",
"'build_dir'",
"]",
")",
":",
"message",
"=",
"'Site not built at {0}'",
".",
"format",
"(",
"self",
".",
"_config",
"[",
"'bui... | Upload a previously-built site to LSST the Docs. | [
"Upload",
"a",
"previously",
"-",
"built",
"site",
"to",
"LSST",
"the",
"Docs",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/lander.py#L119-L126 | train | 58,030 |
ponty/confduino | confduino/liblist.py | libraries | def libraries():
"""return installed library names."""
ls = libraries_dir().dirs()
ls = [str(x.name) for x in ls]
ls.sort()
return ls | python | def libraries():
"""return installed library names."""
ls = libraries_dir().dirs()
ls = [str(x.name) for x in ls]
ls.sort()
return ls | [
"def",
"libraries",
"(",
")",
":",
"ls",
"=",
"libraries_dir",
"(",
")",
".",
"dirs",
"(",
")",
"ls",
"=",
"[",
"str",
"(",
"x",
".",
"name",
")",
"for",
"x",
"in",
"ls",
"]",
"ls",
".",
"sort",
"(",
")",
"return",
"ls"
] | return installed library names. | [
"return",
"installed",
"library",
"names",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/liblist.py#L26-L31 | train | 58,031 |
ponty/confduino | confduino/liblist.py | lib_examples | def lib_examples(lib):
"""return library examples.
EXAMPLE1,EXAMPLE2,..
"""
d = lib_examples_dir(lib)
if not d.exists():
return []
ls = d.dirs()
ls = [x.name for x in ls]
ls.sort()
return ls | python | def lib_examples(lib):
"""return library examples.
EXAMPLE1,EXAMPLE2,..
"""
d = lib_examples_dir(lib)
if not d.exists():
return []
ls = d.dirs()
ls = [x.name for x in ls]
ls.sort()
return ls | [
"def",
"lib_examples",
"(",
"lib",
")",
":",
"d",
"=",
"lib_examples_dir",
"(",
"lib",
")",
"if",
"not",
"d",
".",
"exists",
"(",
")",
":",
"return",
"[",
"]",
"ls",
"=",
"d",
".",
"dirs",
"(",
")",
"ls",
"=",
"[",
"x",
".",
"name",
"for",
"x... | return library examples.
EXAMPLE1,EXAMPLE2,.. | [
"return",
"library",
"examples",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/liblist.py#L61-L73 | train | 58,032 |
vicalloy/lbutils | lbutils/utils.py | safe_eval | def safe_eval(source, *args, **kwargs):
""" eval without import """
source = source.replace('import', '') # import is not allowed
return eval(source, *args, **kwargs) | python | def safe_eval(source, *args, **kwargs):
""" eval without import """
source = source.replace('import', '') # import is not allowed
return eval(source, *args, **kwargs) | [
"def",
"safe_eval",
"(",
"source",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"source",
"=",
"source",
".",
"replace",
"(",
"'import'",
",",
"''",
")",
"# import is not allowed",
"return",
"eval",
"(",
"source",
",",
"*",
"args",
",",
"*",
... | eval without import | [
"eval",
"without",
"import"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/utils.py#L15-L18 | train | 58,033 |
asascience-open/paegan-transport | paegan/transport/shoreline.py | Shoreline.intersect | def intersect(self, **kwargs):
"""
Intersect a Line or Point Collection and the Shoreline
Returns the point of intersection along the coastline
Should also return a linestring buffer around the interseciton point
so we can calculate the direction to bounce a part... | python | def intersect(self, **kwargs):
"""
Intersect a Line or Point Collection and the Shoreline
Returns the point of intersection along the coastline
Should also return a linestring buffer around the interseciton point
so we can calculate the direction to bounce a part... | [
"def",
"intersect",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"ls",
"=",
"None",
"if",
"\"linestring\"",
"in",
"kwargs",
":",
"ls",
"=",
"kwargs",
".",
"pop",
"(",
"'linestring'",
")",
"spoint",
"=",
"Point",
"(",
"ls",
".",
"coords",
"[",
"0... | Intersect a Line or Point Collection and the Shoreline
Returns the point of intersection along the coastline
Should also return a linestring buffer around the interseciton point
so we can calculate the direction to bounce a particle. | [
"Intersect",
"a",
"Line",
"or",
"Point",
"Collection",
"and",
"the",
"Shoreline"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/shoreline.py#L104-L173 | train | 58,034 |
asascience-open/paegan-transport | paegan/transport/shoreline.py | Shoreline.__bounce | def __bounce(self, **kwargs):
"""
Bounce off of the shoreline.
NOTE: This does not work, but left here for future implementation
feature = Linestring of two points, being the line segment the particle hit.
angle = decimal degrees from 0 (x-axis), couter-clockwis... | python | def __bounce(self, **kwargs):
"""
Bounce off of the shoreline.
NOTE: This does not work, but left here for future implementation
feature = Linestring of two points, being the line segment the particle hit.
angle = decimal degrees from 0 (x-axis), couter-clockwis... | [
"def",
"__bounce",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"start_point",
"=",
"kwargs",
".",
"pop",
"(",
"'start_point'",
")",
"hit_point",
"=",
"kwargs",
".",
"pop",
"(",
"'hit_point'",
")",
"end_point",
"=",
"kwargs",
".",
"pop",
"(",
"'end_... | Bounce off of the shoreline.
NOTE: This does not work, but left here for future implementation
feature = Linestring of two points, being the line segment the particle hit.
angle = decimal degrees from 0 (x-axis), couter-clockwise (math style) | [
"Bounce",
"off",
"of",
"the",
"shoreline",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/shoreline.py#L190-L230 | train | 58,035 |
asascience-open/paegan-transport | paegan/transport/shoreline.py | Shoreline.__reverse | def __reverse(self, **kwargs):
"""
Reverse particle just off of the shore in the direction that it came in.
Adds a slight random factor to the distance and angle it is reversed in.
"""
start_point = kwargs.pop('start_point')
hit_point = kwargs.pop('hit_point')
... | python | def __reverse(self, **kwargs):
"""
Reverse particle just off of the shore in the direction that it came in.
Adds a slight random factor to the distance and angle it is reversed in.
"""
start_point = kwargs.pop('start_point')
hit_point = kwargs.pop('hit_point')
... | [
"def",
"__reverse",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"start_point",
"=",
"kwargs",
".",
"pop",
"(",
"'start_point'",
")",
"hit_point",
"=",
"kwargs",
".",
"pop",
"(",
"'hit_point'",
")",
"distance",
"=",
"kwargs",
".",
"pop",
"(",
"'dist... | Reverse particle just off of the shore in the direction that it came in.
Adds a slight random factor to the distance and angle it is reversed in. | [
"Reverse",
"particle",
"just",
"off",
"of",
"the",
"shore",
"in",
"the",
"direction",
"that",
"it",
"came",
"in",
".",
"Adds",
"a",
"slight",
"random",
"factor",
"to",
"the",
"distance",
"and",
"angle",
"it",
"is",
"reversed",
"in",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/shoreline.py#L232-L286 | train | 58,036 |
asascience-open/paegan-transport | paegan/transport/shoreline.py | ShorelineWFS.get_feature_type_info | def get_feature_type_info(self):
"""
Gets FeatureType as a python dict.
Transforms feature_name info into python dict.
"""
caps = self.get_capabilities()
if caps is None:
return None
el = caps.find('{http://www.opengis.net/wfs}FeatureTypeList')
... | python | def get_feature_type_info(self):
"""
Gets FeatureType as a python dict.
Transforms feature_name info into python dict.
"""
caps = self.get_capabilities()
if caps is None:
return None
el = caps.find('{http://www.opengis.net/wfs}FeatureTypeList')
... | [
"def",
"get_feature_type_info",
"(",
"self",
")",
":",
"caps",
"=",
"self",
".",
"get_capabilities",
"(",
")",
"if",
"caps",
"is",
"None",
":",
"return",
"None",
"el",
"=",
"caps",
".",
"find",
"(",
"'{http://www.opengis.net/wfs}FeatureTypeList'",
")",
"for",
... | Gets FeatureType as a python dict.
Transforms feature_name info into python dict. | [
"Gets",
"FeatureType",
"as",
"a",
"python",
"dict",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/shoreline.py#L416-L447 | train | 58,037 |
brap/brap | brap/node_registrations.py | extract_edges_from_callable | def extract_edges_from_callable(fn):
"""
This takes args and kwargs provided, and returns the names of the strings
assigned. If a string is not provided for a value, an exception is raised.
This is how we extract the edges provided in the brap call lambdas.
"""
def extractor(*args, **kwargs):
... | python | def extract_edges_from_callable(fn):
"""
This takes args and kwargs provided, and returns the names of the strings
assigned. If a string is not provided for a value, an exception is raised.
This is how we extract the edges provided in the brap call lambdas.
"""
def extractor(*args, **kwargs):
... | [
"def",
"extract_edges_from_callable",
"(",
"fn",
")",
":",
"def",
"extractor",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"\n Because I don't think this technique is common in python...\n\n Service constructors were defined as:\n lambda c: c... | This takes args and kwargs provided, and returns the names of the strings
assigned. If a string is not provided for a value, an exception is raised.
This is how we extract the edges provided in the brap call lambdas. | [
"This",
"takes",
"args",
"and",
"kwargs",
"provided",
"and",
"returns",
"the",
"names",
"of",
"the",
"strings",
"assigned",
".",
"If",
"a",
"string",
"is",
"not",
"provided",
"for",
"a",
"value",
"an",
"exception",
"is",
"raised",
"."
] | 227d1b6ce2799b7caf1d98d8805e821d19d0969b | https://github.com/brap/brap/blob/227d1b6ce2799b7caf1d98d8805e821d19d0969b/brap/node_registrations.py#L4-L36 | train | 58,038 |
SeattleTestbed/seash | pyreadline/rlmain.py | BaseReadline.parse_and_bind | def parse_and_bind(self, string):
u'''Parse and execute single line of a readline init file.'''
try:
log(u'parse_and_bind("%s")' % string)
if string.startswith(u'#'):
return
if string.startswith(u'set'):
m = re.compile(ur'set\s+([-a-zA-... | python | def parse_and_bind(self, string):
u'''Parse and execute single line of a readline init file.'''
try:
log(u'parse_and_bind("%s")' % string)
if string.startswith(u'#'):
return
if string.startswith(u'set'):
m = re.compile(ur'set\s+([-a-zA-... | [
"def",
"parse_and_bind",
"(",
"self",
",",
"string",
")",
":",
"try",
":",
"log",
"(",
"u'parse_and_bind(\"%s\")'",
"%",
"string",
")",
"if",
"string",
".",
"startswith",
"(",
"u'#'",
")",
":",
"return",
"if",
"string",
".",
"startswith",
"(",
"u'set'",
... | u'''Parse and execute single line of a readline init file. | [
"u",
"Parse",
"and",
"execute",
"single",
"line",
"of",
"a",
"readline",
"init",
"file",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/rlmain.py#L69-L102 | train | 58,039 |
SeattleTestbed/seash | pyreadline/rlmain.py | Readline._bell | def _bell(self):
u'''ring the bell if requested.'''
if self.bell_style == u'none':
pass
elif self.bell_style == u'visible':
raise NotImplementedError(u"Bellstyle visible is not implemented yet.")
elif self.bell_style == u'audible':
self.console.bell()
... | python | def _bell(self):
u'''ring the bell if requested.'''
if self.bell_style == u'none':
pass
elif self.bell_style == u'visible':
raise NotImplementedError(u"Bellstyle visible is not implemented yet.")
elif self.bell_style == u'audible':
self.console.bell()
... | [
"def",
"_bell",
"(",
"self",
")",
":",
"if",
"self",
".",
"bell_style",
"==",
"u'none'",
":",
"pass",
"elif",
"self",
".",
"bell_style",
"==",
"u'visible'",
":",
"raise",
"NotImplementedError",
"(",
"u\"Bellstyle visible is not implemented yet.\"",
")",
"elif",
... | u'''ring the bell if requested. | [
"u",
"ring",
"the",
"bell",
"if",
"requested",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/rlmain.py#L432-L441 | train | 58,040 |
hatemile/hatemile-for-python | hatemile/util/commonfunctions.py | CommonFunctions.set_list_attributes | def set_list_attributes(element1, element2, attributes):
"""
Copy a list of attributes of a element for other element.
:param element1: The element that have attributes copied.
:type element1: hatemile.util.html.htmldomelement.HTMLDOMElement
:param element2: The element that cop... | python | def set_list_attributes(element1, element2, attributes):
"""
Copy a list of attributes of a element for other element.
:param element1: The element that have attributes copied.
:type element1: hatemile.util.html.htmldomelement.HTMLDOMElement
:param element2: The element that cop... | [
"def",
"set_list_attributes",
"(",
"element1",
",",
"element2",
",",
"attributes",
")",
":",
"for",
"attribute",
"in",
"attributes",
":",
"if",
"element1",
".",
"has_attribute",
"(",
"attribute",
")",
":",
"element2",
".",
"set_attribute",
"(",
"attribute",
",... | Copy a list of attributes of a element for other element.
:param element1: The element that have attributes copied.
:type element1: hatemile.util.html.htmldomelement.HTMLDOMElement
:param element2: The element that copy the attributes.
:type element2: hatemile.util.html.htmldomelement.H... | [
"Copy",
"a",
"list",
"of",
"attributes",
"of",
"a",
"element",
"for",
"other",
"element",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/commonfunctions.py#L29-L46 | train | 58,041 |
hatemile/hatemile-for-python | hatemile/util/commonfunctions.py | CommonFunctions.increase_in_list | def increase_in_list(list_to_increase, string_to_increase):
"""
Increase a item in a HTML list.
:param list_to_increase: The list.
:type list_to_increase: str
:param string_to_increase: The value of item.
:type string_to_increase: str
:return: The HTML list with ... | python | def increase_in_list(list_to_increase, string_to_increase):
"""
Increase a item in a HTML list.
:param list_to_increase: The list.
:type list_to_increase: str
:param string_to_increase: The value of item.
:type string_to_increase: str
:return: The HTML list with ... | [
"def",
"increase_in_list",
"(",
"list_to_increase",
",",
"string_to_increase",
")",
":",
"if",
"(",
"bool",
"(",
"list_to_increase",
")",
")",
"and",
"(",
"bool",
"(",
"string_to_increase",
")",
")",
":",
"if",
"CommonFunctions",
".",
"in_list",
"(",
"list_to_... | Increase a item in a HTML list.
:param list_to_increase: The list.
:type list_to_increase: str
:param string_to_increase: The value of item.
:type string_to_increase: str
:return: The HTML list with the item added, if the item not was
contained in list.
... | [
"Increase",
"a",
"item",
"in",
"a",
"HTML",
"list",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/commonfunctions.py#L49-L68 | train | 58,042 |
hatemile/hatemile-for-python | hatemile/util/commonfunctions.py | CommonFunctions.in_list | def in_list(list_to_search, string_to_search):
"""
Verify if the list contains the item.
:param list_to_search: The list.
:type list_to_search: str
:param string_to_search: The value of item.
:type string_to_search: str
:return: True if the list contains the item... | python | def in_list(list_to_search, string_to_search):
"""
Verify if the list contains the item.
:param list_to_search: The list.
:type list_to_search: str
:param string_to_search: The value of item.
:type string_to_search: str
:return: True if the list contains the item... | [
"def",
"in_list",
"(",
"list_to_search",
",",
"string_to_search",
")",
":",
"if",
"(",
"bool",
"(",
"list_to_search",
")",
")",
"and",
"(",
"bool",
"(",
"string_to_search",
")",
")",
":",
"elements",
"=",
"re",
".",
"split",
"(",
"'[ \\n\\t\\r]+'",
",",
... | Verify if the list contains the item.
:param list_to_search: The list.
:type list_to_search: str
:param string_to_search: The value of item.
:type string_to_search: str
:return: True if the list contains the item or False is not contains.
:rtype: bool | [
"Verify",
"if",
"the",
"list",
"contains",
"the",
"item",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/commonfunctions.py#L71-L88 | train | 58,043 |
hatemile/hatemile-for-python | hatemile/util/commonfunctions.py | CommonFunctions.is_valid_element | def is_valid_element(element):
"""
Check that the element can be manipulated by HaTeMiLe.
:param element: The element
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if element can be manipulated or False if element cannot
be manipu... | python | def is_valid_element(element):
"""
Check that the element can be manipulated by HaTeMiLe.
:param element: The element
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if element can be manipulated or False if element cannot
be manipu... | [
"def",
"is_valid_element",
"(",
"element",
")",
":",
"if",
"element",
".",
"has_attribute",
"(",
"CommonFunctions",
".",
"DATA_IGNORE",
")",
":",
"return",
"False",
"else",
":",
"parent_element",
"=",
"element",
".",
"get_parent_element",
"(",
")",
"if",
"pare... | Check that the element can be manipulated by HaTeMiLe.
:param element: The element
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if element can be manipulated or False if element cannot
be manipulated.
:rtype: bool | [
"Check",
"that",
"the",
"element",
"can",
"be",
"manipulated",
"by",
"HaTeMiLe",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/commonfunctions.py#L91-L111 | train | 58,044 |
seancallaway/laughs | laughs/services/chucknorris.py | get_joke | def get_joke():
"""Returns a joke from the WebKnox one liner API.
Returns None if unable to retrieve a joke.
"""
page = requests.get("https://api.chucknorris.io/jokes/random")
if page.status_code == 200:
joke = json.loads(page.content.decode("UTF-8"))
return joke["value"]
... | python | def get_joke():
"""Returns a joke from the WebKnox one liner API.
Returns None if unable to retrieve a joke.
"""
page = requests.get("https://api.chucknorris.io/jokes/random")
if page.status_code == 200:
joke = json.loads(page.content.decode("UTF-8"))
return joke["value"]
... | [
"def",
"get_joke",
"(",
")",
":",
"page",
"=",
"requests",
".",
"get",
"(",
"\"https://api.chucknorris.io/jokes/random\"",
")",
"if",
"page",
".",
"status_code",
"==",
"200",
":",
"joke",
"=",
"json",
".",
"loads",
"(",
"page",
".",
"content",
".",
"decode... | Returns a joke from the WebKnox one liner API.
Returns None if unable to retrieve a joke. | [
"Returns",
"a",
"joke",
"from",
"the",
"WebKnox",
"one",
"liner",
"API",
".",
"Returns",
"None",
"if",
"unable",
"to",
"retrieve",
"a",
"joke",
"."
] | e13ca6f16b12401b0384bbf1fea86c081e52143d | https://github.com/seancallaway/laughs/blob/e13ca6f16b12401b0384bbf1fea86c081e52143d/laughs/services/chucknorris.py#L13-L26 | train | 58,045 |
brews/snakebacon | snakebacon/mcmc.py | McmcResults.burnin | def burnin(self, n):
"""Remove the earliest n ensemble members from the MCMC output"""
self.sediment_rate = self.sediment_rate[:, n:]
self.headage = self.headage[n:]
self.sediment_memory = self.sediment_memory[n:]
self.objective = self.objective[n:] | python | def burnin(self, n):
"""Remove the earliest n ensemble members from the MCMC output"""
self.sediment_rate = self.sediment_rate[:, n:]
self.headage = self.headage[n:]
self.sediment_memory = self.sediment_memory[n:]
self.objective = self.objective[n:] | [
"def",
"burnin",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"sediment_rate",
"=",
"self",
".",
"sediment_rate",
"[",
":",
",",
"n",
":",
"]",
"self",
".",
"headage",
"=",
"self",
".",
"headage",
"[",
"n",
":",
"]",
"self",
".",
"sediment_memory"... | Remove the earliest n ensemble members from the MCMC output | [
"Remove",
"the",
"earliest",
"n",
"ensemble",
"members",
"from",
"the",
"MCMC",
"output"
] | f5363d0d1225912adc30031bf2c13b54000de8f2 | https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmc.py#L54-L59 | train | 58,046 |
silver-castle/mach9 | mach9/timer.py | update_current_time | def update_current_time(loop):
"""Cache the current time, since it is needed at the end of every
keep-alive request to update the request timeout time
:param loop:
:return:
"""
global current_time
current_time = time()
loop.call_later(1, partial(update_current_time, loop)) | python | def update_current_time(loop):
"""Cache the current time, since it is needed at the end of every
keep-alive request to update the request timeout time
:param loop:
:return:
"""
global current_time
current_time = time()
loop.call_later(1, partial(update_current_time, loop)) | [
"def",
"update_current_time",
"(",
"loop",
")",
":",
"global",
"current_time",
"current_time",
"=",
"time",
"(",
")",
"loop",
".",
"call_later",
"(",
"1",
",",
"partial",
"(",
"update_current_time",
",",
"loop",
")",
")"
] | Cache the current time, since it is needed at the end of every
keep-alive request to update the request timeout time
:param loop:
:return: | [
"Cache",
"the",
"current",
"time",
"since",
"it",
"is",
"needed",
"at",
"the",
"end",
"of",
"every",
"keep",
"-",
"alive",
"request",
"to",
"update",
"the",
"request",
"timeout",
"time"
] | 7a623aab3c70d89d36ade6901b6307e115400c5e | https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/timer.py#L8-L17 | train | 58,047 |
helixyte/everest | everest/ini.py | EverestNosePlugin.options | def options(self, parser, env=None):
"""
Adds command-line options for this plugin.
"""
if env is None:
env = os.environ
env_opt_name = 'NOSE_%s' % self.__dest_opt_name.upper()
parser.add_option("--%s" % self.__opt_name,
dest=self.__d... | python | def options(self, parser, env=None):
"""
Adds command-line options for this plugin.
"""
if env is None:
env = os.environ
env_opt_name = 'NOSE_%s' % self.__dest_opt_name.upper()
parser.add_option("--%s" % self.__opt_name,
dest=self.__d... | [
"def",
"options",
"(",
"self",
",",
"parser",
",",
"env",
"=",
"None",
")",
":",
"if",
"env",
"is",
"None",
":",
"env",
"=",
"os",
".",
"environ",
"env_opt_name",
"=",
"'NOSE_%s'",
"%",
"self",
".",
"__dest_opt_name",
".",
"upper",
"(",
")",
"parser"... | Adds command-line options for this plugin. | [
"Adds",
"command",
"-",
"line",
"options",
"for",
"this",
"plugin",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/ini.py#L32-L44 | train | 58,048 |
helixyte/everest | everest/ini.py | EverestNosePlugin.configure | def configure(self, options, conf):
"""
Configures the plugin.
"""
super(EverestNosePlugin, self).configure(options, conf)
opt_val = getattr(options, self.__dest_opt_name, None)
if opt_val:
self.enabled = True
EverestIni.ini_file_path = opt_val | python | def configure(self, options, conf):
"""
Configures the plugin.
"""
super(EverestNosePlugin, self).configure(options, conf)
opt_val = getattr(options, self.__dest_opt_name, None)
if opt_val:
self.enabled = True
EverestIni.ini_file_path = opt_val | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"conf",
")",
":",
"super",
"(",
"EverestNosePlugin",
",",
"self",
")",
".",
"configure",
"(",
"options",
",",
"conf",
")",
"opt_val",
"=",
"getattr",
"(",
"options",
",",
"self",
".",
"__dest_opt_name... | Configures the plugin. | [
"Configures",
"the",
"plugin",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/ini.py#L46-L54 | train | 58,049 |
RetailMeNotSandbox/acky | acky/ec2.py | InstanceCollection.create | def create(self, ami, count, config=None):
"""Create an instance using the launcher."""
return self.Launcher(config=config).launch(ami, count) | python | def create(self, ami, count, config=None):
"""Create an instance using the launcher."""
return self.Launcher(config=config).launch(ami, count) | [
"def",
"create",
"(",
"self",
",",
"ami",
",",
"count",
",",
"config",
"=",
"None",
")",
":",
"return",
"self",
".",
"Launcher",
"(",
"config",
"=",
"config",
")",
".",
"launch",
"(",
"ami",
",",
"count",
")"
] | Create an instance using the launcher. | [
"Create",
"an",
"instance",
"using",
"the",
"launcher",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/ec2.py#L218-L220 | train | 58,050 |
RetailMeNotSandbox/acky | acky/ec2.py | InstanceCollection.Launcher | def Launcher(self, config=None):
"""Provides a configurable launcher for EC2 instances."""
class _launcher(EC2ApiClient):
"""Configurable launcher for EC2 instances. Create the Launcher
(passing an optional dict of its attributes), set its attributes
(as described in ... | python | def Launcher(self, config=None):
"""Provides a configurable launcher for EC2 instances."""
class _launcher(EC2ApiClient):
"""Configurable launcher for EC2 instances. Create the Launcher
(passing an optional dict of its attributes), set its attributes
(as described in ... | [
"def",
"Launcher",
"(",
"self",
",",
"config",
"=",
"None",
")",
":",
"class",
"_launcher",
"(",
"EC2ApiClient",
")",
":",
"\"\"\"Configurable launcher for EC2 instances. Create the Launcher\n (passing an optional dict of its attributes), set its attributes\n (a... | Provides a configurable launcher for EC2 instances. | [
"Provides",
"a",
"configurable",
"launcher",
"for",
"EC2",
"instances",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/ec2.py#L260-L288 | train | 58,051 |
RetailMeNotSandbox/acky | acky/ec2.py | InstanceCollection.events | def events(self, all_instances=None, instance_ids=None, filters=None):
"""a list of tuples containing instance Id's and event information"""
params = {}
if filters:
params["filters"] = make_filters(filters)
if instance_ids:
params['InstanceIds'] = instance_ids
... | python | def events(self, all_instances=None, instance_ids=None, filters=None):
"""a list of tuples containing instance Id's and event information"""
params = {}
if filters:
params["filters"] = make_filters(filters)
if instance_ids:
params['InstanceIds'] = instance_ids
... | [
"def",
"events",
"(",
"self",
",",
"all_instances",
"=",
"None",
",",
"instance_ids",
"=",
"None",
",",
"filters",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"filters",
":",
"params",
"[",
"\"filters\"",
"]",
"=",
"make_filters",
"(",
"filte... | a list of tuples containing instance Id's and event information | [
"a",
"list",
"of",
"tuples",
"containing",
"instance",
"Id",
"s",
"and",
"event",
"information"
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/ec2.py#L304-L318 | train | 58,052 |
RetailMeNotSandbox/acky | acky/ec2.py | VolumeCollection.get | def get(self, volume_ids=None, filters=None):
"""List EBS Volume info."""
params = {}
if filters:
params["filters"] = make_filters(filters)
if isinstance(volume_ids, str):
volume_ids = [volume_ids]
return self.call("DescribeVolumes",
... | python | def get(self, volume_ids=None, filters=None):
"""List EBS Volume info."""
params = {}
if filters:
params["filters"] = make_filters(filters)
if isinstance(volume_ids, str):
volume_ids = [volume_ids]
return self.call("DescribeVolumes",
... | [
"def",
"get",
"(",
"self",
",",
"volume_ids",
"=",
"None",
",",
"filters",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"filters",
":",
"params",
"[",
"\"filters\"",
"]",
"=",
"make_filters",
"(",
"filters",
")",
"if",
"isinstance",
"(",
"vo... | List EBS Volume info. | [
"List",
"EBS",
"Volume",
"info",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/ec2.py#L473-L483 | train | 58,053 |
RetailMeNotSandbox/acky | acky/ec2.py | VolumeCollection.attach | def attach(self, volume_id, instance_id, device_path):
"""Attach a volume to an instance, exposing it with a device name."""
return self.call("AttachVolume",
VolumeId=volume_id, InstanceId=instance_id,
Device=device_path) | python | def attach(self, volume_id, instance_id, device_path):
"""Attach a volume to an instance, exposing it with a device name."""
return self.call("AttachVolume",
VolumeId=volume_id, InstanceId=instance_id,
Device=device_path) | [
"def",
"attach",
"(",
"self",
",",
"volume_id",
",",
"instance_id",
",",
"device_path",
")",
":",
"return",
"self",
".",
"call",
"(",
"\"AttachVolume\"",
",",
"VolumeId",
"=",
"volume_id",
",",
"InstanceId",
"=",
"instance_id",
",",
"Device",
"=",
"device_pa... | Attach a volume to an instance, exposing it with a device name. | [
"Attach",
"a",
"volume",
"to",
"an",
"instance",
"exposing",
"it",
"with",
"a",
"device",
"name",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/ec2.py#L515-L519 | train | 58,054 |
RetailMeNotSandbox/acky | acky/ec2.py | VolumeCollection.detach | def detach(self, volume_id, instance_id='', device_path='', force=False):
"""Detach a volume from an instance."""
return self.call("DetachVolume",
VolumeId=volume_id, InstanceId=instance_id,
Device=device_path, force=force) | python | def detach(self, volume_id, instance_id='', device_path='', force=False):
"""Detach a volume from an instance."""
return self.call("DetachVolume",
VolumeId=volume_id, InstanceId=instance_id,
Device=device_path, force=force) | [
"def",
"detach",
"(",
"self",
",",
"volume_id",
",",
"instance_id",
"=",
"''",
",",
"device_path",
"=",
"''",
",",
"force",
"=",
"False",
")",
":",
"return",
"self",
".",
"call",
"(",
"\"DetachVolume\"",
",",
"VolumeId",
"=",
"volume_id",
",",
"InstanceI... | Detach a volume from an instance. | [
"Detach",
"a",
"volume",
"from",
"an",
"instance",
"."
] | fcd4d092c42892ede7c924cafc41e9cf4be3fb9f | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/ec2.py#L521-L525 | train | 58,055 |
solocompt/plugs-core | plugs_core/mixins.py | Slugable.save | def save(self, *args, **kwargs):
"""
Overrides the save method
"""
self.slug = self.create_slug()
super(Slugable, self).save(*args, **kwargs) | python | def save(self, *args, **kwargs):
"""
Overrides the save method
"""
self.slug = self.create_slug()
super(Slugable, self).save(*args, **kwargs) | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"slug",
"=",
"self",
".",
"create_slug",
"(",
")",
"super",
"(",
"Slugable",
",",
"self",
")",
".",
"save",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",... | Overrides the save method | [
"Overrides",
"the",
"save",
"method"
] | 19fd23101fcfdabe657485f0a22e6b63e2b44f9d | https://github.com/solocompt/plugs-core/blob/19fd23101fcfdabe657485f0a22e6b63e2b44f9d/plugs_core/mixins.py#L12-L17 | train | 58,056 |
solocompt/plugs-core | plugs_core/mixins.py | Slugable.create_slug | def create_slug(self):
"""
Creates slug, checks if slug is unique, and loop if not
"""
name = self.slug_source
counter = 0
# loops until slug is unique
while True:
if counter == 0:
slug = slugify(name)
else:
... | python | def create_slug(self):
"""
Creates slug, checks if slug is unique, and loop if not
"""
name = self.slug_source
counter = 0
# loops until slug is unique
while True:
if counter == 0:
slug = slugify(name)
else:
... | [
"def",
"create_slug",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"slug_source",
"counter",
"=",
"0",
"# loops until slug is unique",
"while",
"True",
":",
"if",
"counter",
"==",
"0",
":",
"slug",
"=",
"slugify",
"(",
"name",
")",
"else",
":",
"# us... | Creates slug, checks if slug is unique, and loop if not | [
"Creates",
"slug",
"checks",
"if",
"slug",
"is",
"unique",
"and",
"loop",
"if",
"not"
] | 19fd23101fcfdabe657485f0a22e6b63e2b44f9d | https://github.com/solocompt/plugs-core/blob/19fd23101fcfdabe657485f0a22e6b63e2b44f9d/plugs_core/mixins.py#L19-L41 | train | 58,057 |
MacHu-GWU/crawl_zillow-project | crawl_zillow/spider.py | get_html | def get_html(url,
headers=None,
timeout=None,
errors="strict",
wait_time=None,
driver=None,
zillow_only=False,
cache_only=False,
zillow_first=False,
cache_first=False,
random=False,
... | python | def get_html(url,
headers=None,
timeout=None,
errors="strict",
wait_time=None,
driver=None,
zillow_only=False,
cache_only=False,
zillow_first=False,
cache_first=False,
random=False,
... | [
"def",
"get_html",
"(",
"url",
",",
"headers",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"errors",
"=",
"\"strict\"",
",",
"wait_time",
"=",
"None",
",",
"driver",
"=",
"None",
",",
"zillow_only",
"=",
"False",
",",
"cache_only",
"=",
"False",
","... | Use Google Cached Url.
:param cache_only: if True, then real zillow site will never be used.
:param driver: selenium browser driver。 | [
"Use",
"Google",
"Cached",
"Url",
"."
] | c6d7ca8e4c80e7e7e963496433ef73df1413c16e | https://github.com/MacHu-GWU/crawl_zillow-project/blob/c6d7ca8e4c80e7e7e963496433ef73df1413c16e/crawl_zillow/spider.py#L85-L148 | train | 58,058 |
RI-imaging/qpformat | examples/convert_txt2tif.py | get_paths | def get_paths(folder, ignore_endswith=ignore_endswith):
'''Return hologram file paths
Parameters
----------
folder: str or pathlib.Path
Path to search folder
ignore_endswith: list
List of filename ending strings indicating which
files should be ignored.
'''
folder = ... | python | def get_paths(folder, ignore_endswith=ignore_endswith):
'''Return hologram file paths
Parameters
----------
folder: str or pathlib.Path
Path to search folder
ignore_endswith: list
List of filename ending strings indicating which
files should be ignored.
'''
folder = ... | [
"def",
"get_paths",
"(",
"folder",
",",
"ignore_endswith",
"=",
"ignore_endswith",
")",
":",
"folder",
"=",
"pathlib",
".",
"Path",
"(",
"folder",
")",
".",
"resolve",
"(",
")",
"files",
"=",
"folder",
".",
"rglob",
"(",
"\"*\"",
")",
"for",
"ie",
"in"... | Return hologram file paths
Parameters
----------
folder: str or pathlib.Path
Path to search folder
ignore_endswith: list
List of filename ending strings indicating which
files should be ignored. | [
"Return",
"hologram",
"file",
"paths"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/examples/convert_txt2tif.py#L27-L42 | train | 58,059 |
contains-io/rcli | rcli/call.py | call | def call(func, args):
"""Call the function with args normalized and cast to the correct types.
Args:
func: The function to call.
args: The arguments parsed by docopt.
Returns:
The return value of func.
"""
assert hasattr(func, '__call__'), 'Cannot call func: {}'.format(
... | python | def call(func, args):
"""Call the function with args normalized and cast to the correct types.
Args:
func: The function to call.
args: The arguments parsed by docopt.
Returns:
The return value of func.
"""
assert hasattr(func, '__call__'), 'Cannot call func: {}'.format(
... | [
"def",
"call",
"(",
"func",
",",
"args",
")",
":",
"assert",
"hasattr",
"(",
"func",
",",
"'__call__'",
")",
",",
"'Cannot call func: {}'",
".",
"format",
"(",
"func",
".",
"__name__",
")",
"raw_func",
"=",
"(",
"func",
"if",
"isinstance",
"(",
"func",
... | Call the function with args normalized and cast to the correct types.
Args:
func: The function to call.
args: The arguments parsed by docopt.
Returns:
The return value of func. | [
"Call",
"the",
"function",
"with",
"args",
"normalized",
"and",
"cast",
"to",
"the",
"correct",
"types",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/call.py#L45-L78 | train | 58,060 |
contains-io/rcli | rcli/call.py | get_callable | def get_callable(subcommand):
# type: (config.RcliEntryPoint) -> Union[FunctionType, MethodType]
"""Return a callable object from the subcommand.
Args:
subcommand: A object loaded from an entry point. May be a module,
class, or function.
Returns:
The callable entry point fo... | python | def get_callable(subcommand):
# type: (config.RcliEntryPoint) -> Union[FunctionType, MethodType]
"""Return a callable object from the subcommand.
Args:
subcommand: A object loaded from an entry point. May be a module,
class, or function.
Returns:
The callable entry point fo... | [
"def",
"get_callable",
"(",
"subcommand",
")",
":",
"# type: (config.RcliEntryPoint) -> Union[FunctionType, MethodType]",
"_LOGGER",
".",
"debug",
"(",
"'Creating callable from subcommand \"%s\".'",
",",
"subcommand",
".",
"__name__",
")",
"if",
"isinstance",
"(",
"subcommand... | Return a callable object from the subcommand.
Args:
subcommand: A object loaded from an entry point. May be a module,
class, or function.
Returns:
The callable entry point for the subcommand. If the subcommand is a
function, it will be returned unchanged. If the subcommand ... | [
"Return",
"a",
"callable",
"object",
"from",
"the",
"subcommand",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/call.py#L81-L109 | train | 58,061 |
contains-io/rcli | rcli/call.py | _getargspec | def _getargspec(func):
"""Return a Python 3-like argspec object.
Note:
args contains varargs and varkw if they exist. This behavior differs
from getargspec and getfullargspec.
Args:
func: The function to inspect.
Returns:
A named tuple with three parameters:
... | python | def _getargspec(func):
"""Return a Python 3-like argspec object.
Note:
args contains varargs and varkw if they exist. This behavior differs
from getargspec and getfullargspec.
Args:
func: The function to inspect.
Returns:
A named tuple with three parameters:
... | [
"def",
"_getargspec",
"(",
"func",
")",
":",
"argspec",
"=",
"_getspec",
"(",
"func",
")",
"args",
"=",
"list",
"(",
"argspec",
".",
"args",
")",
"if",
"argspec",
".",
"varargs",
":",
"args",
"+=",
"[",
"argspec",
".",
"varargs",
"]",
"if",
"argspec"... | Return a Python 3-like argspec object.
Note:
args contains varargs and varkw if they exist. This behavior differs
from getargspec and getfullargspec.
Args:
func: The function to inspect.
Returns:
A named tuple with three parameters:
args: All named arguments, i... | [
"Return",
"a",
"Python",
"3",
"-",
"like",
"argspec",
"object",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/call.py#L112-L135 | train | 58,062 |
contains-io/rcli | rcli/call.py | _normalize | def _normalize(args):
# type: (Dict[str, Any]) -> Generator[Tuple[str, str, Any], None, None]
"""Yield a 3-tuple containing the key, a normalized key, and the value.
Args:
args: The arguments parsed by docopt.
Yields:
A 3-tuple that contains the docopt parameter name, the parameter na... | python | def _normalize(args):
# type: (Dict[str, Any]) -> Generator[Tuple[str, str, Any], None, None]
"""Yield a 3-tuple containing the key, a normalized key, and the value.
Args:
args: The arguments parsed by docopt.
Yields:
A 3-tuple that contains the docopt parameter name, the parameter na... | [
"def",
"_normalize",
"(",
"args",
")",
":",
"# type: (Dict[str, Any]) -> Generator[Tuple[str, str, Any], None, None]",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"args",
")",
":",
"nk",
"=",
"re",
".",
"sub",
"(",
"r'\\W|^(?=\\d)'",
",",
"'_'",
... | Yield a 3-tuple containing the key, a normalized key, and the value.
Args:
args: The arguments parsed by docopt.
Yields:
A 3-tuple that contains the docopt parameter name, the parameter name
normalized to be a valid python identifier, and the value assigned to
the parameter. | [
"Yield",
"a",
"3",
"-",
"tuple",
"containing",
"the",
"key",
"a",
"normalized",
"key",
"and",
"the",
"value",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/call.py#L138-L156 | train | 58,063 |
erikvw/django-collect-offline-files | django_collect_offline_files/sftp_client.py | SFTPClient.copy | def copy(self, filename=None):
"""Puts on destination as a temp file, renames on
the destination.
"""
dst = os.path.join(self.dst_path, filename)
src = os.path.join(self.src_path, filename)
dst_tmp = os.path.join(self.dst_tmp, filename)
self.put(src=src, dst=dst_t... | python | def copy(self, filename=None):
"""Puts on destination as a temp file, renames on
the destination.
"""
dst = os.path.join(self.dst_path, filename)
src = os.path.join(self.src_path, filename)
dst_tmp = os.path.join(self.dst_tmp, filename)
self.put(src=src, dst=dst_t... | [
"def",
"copy",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"dst",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"dst_path",
",",
"filename",
")",
"src",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"src_path",
",",
"... | Puts on destination as a temp file, renames on
the destination. | [
"Puts",
"on",
"destination",
"as",
"a",
"temp",
"file",
"renames",
"on",
"the",
"destination",
"."
] | 78f61c823ea3926eb88206b019b5dca3c36017da | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/sftp_client.py#L38-L46 | train | 58,064 |
AtomHash/evernode | evernode/classes/email.py | Email.__create | def __create(self):
""" Construct the email """
self.__data = json.dumps({
'config_path': self.encode(self.config_path),
'subject': self.encode(self.__subject),
'text': self.encode(self.__text),
'html': self.encode(self.__html),
'files':... | python | def __create(self):
""" Construct the email """
self.__data = json.dumps({
'config_path': self.encode(self.config_path),
'subject': self.encode(self.__subject),
'text': self.encode(self.__text),
'html': self.encode(self.__html),
'files':... | [
"def",
"__create",
"(",
"self",
")",
":",
"self",
".",
"__data",
"=",
"json",
".",
"dumps",
"(",
"{",
"'config_path'",
":",
"self",
".",
"encode",
"(",
"self",
".",
"config_path",
")",
",",
"'subject'",
":",
"self",
".",
"encode",
"(",
"self",
".",
... | Construct the email | [
"Construct",
"the",
"email"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/email.py#L78-L89 | train | 58,065 |
jeradM/pyxeoma | pyxeoma/xeoma.py | Xeoma.async_get_camera_image | async def async_get_camera_image(self, image_name, username=None, password=None):
"""
Grab a single image from the Xeoma web server
Arguments:
image_name: the name of the image to fetch (i.e. image01)
username: the username to directly access this image
... | python | async def async_get_camera_image(self, image_name, username=None, password=None):
"""
Grab a single image from the Xeoma web server
Arguments:
image_name: the name of the image to fetch (i.e. image01)
username: the username to directly access this image
... | [
"async",
"def",
"async_get_camera_image",
"(",
"self",
",",
"image_name",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"try",
":",
"data",
"=",
"await",
"self",
".",
"async_fetch_image_data",
"(",
"image_name",
",",
"username",
",",
... | Grab a single image from the Xeoma web server
Arguments:
image_name: the name of the image to fetch (i.e. image01)
username: the username to directly access this image
password: the password to directly access this image | [
"Grab",
"a",
"single",
"image",
"from",
"the",
"Xeoma",
"web",
"server"
] | 5bfa19c4968283af0f450acf80b4651cd718f389 | https://github.com/jeradM/pyxeoma/blob/5bfa19c4968283af0f450acf80b4651cd718f389/pyxeoma/xeoma.py#L34-L54 | train | 58,066 |
jeradM/pyxeoma | pyxeoma/xeoma.py | Xeoma.async_fetch_image_data | async def async_fetch_image_data(self, image_name, username, password):
"""
Fetch image data from the Xeoma web server
Arguments:
image_name: the name of the image to fetch (i.e. image01)
username: the username to directly access this image
... | python | async def async_fetch_image_data(self, image_name, username, password):
"""
Fetch image data from the Xeoma web server
Arguments:
image_name: the name of the image to fetch (i.e. image01)
username: the username to directly access this image
... | [
"async",
"def",
"async_fetch_image_data",
"(",
"self",
",",
"image_name",
",",
"username",
",",
"password",
")",
":",
"params",
"=",
"{",
"}",
"cookies",
"=",
"self",
".",
"get_session_cookie",
"(",
")",
"if",
"username",
"is",
"not",
"None",
"and",
"passw... | Fetch image data from the Xeoma web server
Arguments:
image_name: the name of the image to fetch (i.e. image01)
username: the username to directly access this image
password: the password to directly access this image | [
"Fetch",
"image",
"data",
"from",
"the",
"Xeoma",
"web",
"server"
] | 5bfa19c4968283af0f450acf80b4651cd718f389 | https://github.com/jeradM/pyxeoma/blob/5bfa19c4968283af0f450acf80b4651cd718f389/pyxeoma/xeoma.py#L56-L80 | train | 58,067 |
jeradM/pyxeoma | pyxeoma/xeoma.py | Xeoma.async_get_image_names | async def async_get_image_names(self):
"""
Parse web server camera view for camera image names
"""
cookies = self.get_session_cookie()
try:
async with aiohttp.ClientSession(cookies=cookies) as session:
resp = await session.get(
... | python | async def async_get_image_names(self):
"""
Parse web server camera view for camera image names
"""
cookies = self.get_session_cookie()
try:
async with aiohttp.ClientSession(cookies=cookies) as session:
resp = await session.get(
... | [
"async",
"def",
"async_get_image_names",
"(",
"self",
")",
":",
"cookies",
"=",
"self",
".",
"get_session_cookie",
"(",
")",
"try",
":",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
"cookies",
"=",
"cookies",
")",
"as",
"session",
":",
"resp",
"=... | Parse web server camera view for camera image names | [
"Parse",
"web",
"server",
"camera",
"view",
"for",
"camera",
"image",
"names"
] | 5bfa19c4968283af0f450acf80b4651cd718f389 | https://github.com/jeradM/pyxeoma/blob/5bfa19c4968283af0f450acf80b4651cd718f389/pyxeoma/xeoma.py#L82-L114 | train | 58,068 |
jeradM/pyxeoma | pyxeoma/xeoma.py | Xeoma.get_session_cookie | def get_session_cookie(self):
"""
Create a session cookie object for use by aiohttp
"""
if self._login is not None and self._password is not None:
session_key = self.encode_user(self._login, self._password)
return {'sessionkey': session_key}
else:
... | python | def get_session_cookie(self):
"""
Create a session cookie object for use by aiohttp
"""
if self._login is not None and self._password is not None:
session_key = self.encode_user(self._login, self._password)
return {'sessionkey': session_key}
else:
... | [
"def",
"get_session_cookie",
"(",
"self",
")",
":",
"if",
"self",
".",
"_login",
"is",
"not",
"None",
"and",
"self",
".",
"_password",
"is",
"not",
"None",
":",
"session_key",
"=",
"self",
".",
"encode_user",
"(",
"self",
".",
"_login",
",",
"self",
".... | Create a session cookie object for use by aiohttp | [
"Create",
"a",
"session",
"cookie",
"object",
"for",
"use",
"by",
"aiohttp"
] | 5bfa19c4968283af0f450acf80b4651cd718f389 | https://github.com/jeradM/pyxeoma/blob/5bfa19c4968283af0f450acf80b4651cd718f389/pyxeoma/xeoma.py#L121-L130 | train | 58,069 |
mcash/merchant-api-python-sdk | mcash/mapi_client/auth.py | RsaSha256Auth._get_sha256_digest | def _get_sha256_digest(self, content):
"""Return the sha256 digest of the content in the
header format the Merchant API expects.
"""
content_sha256 = base64.b64encode(SHA256.new(content).digest())
return 'SHA256=' + content_sha256 | python | def _get_sha256_digest(self, content):
"""Return the sha256 digest of the content in the
header format the Merchant API expects.
"""
content_sha256 = base64.b64encode(SHA256.new(content).digest())
return 'SHA256=' + content_sha256 | [
"def",
"_get_sha256_digest",
"(",
"self",
",",
"content",
")",
":",
"content_sha256",
"=",
"base64",
".",
"b64encode",
"(",
"SHA256",
".",
"new",
"(",
"content",
")",
".",
"digest",
"(",
")",
")",
"return",
"'SHA256='",
"+",
"content_sha256"
] | Return the sha256 digest of the content in the
header format the Merchant API expects. | [
"Return",
"the",
"sha256",
"digest",
"of",
"the",
"content",
"in",
"the",
"header",
"format",
"the",
"Merchant",
"API",
"expects",
"."
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/auth.py#L47-L52 | train | 58,070 |
mcash/merchant-api-python-sdk | mcash/mapi_client/auth.py | RsaSha256Auth._sha256_sign | def _sha256_sign(self, method, url, headers, body):
"""Sign the request with SHA256.
"""
d = ''
sign_headers = method.upper() + '|' + url + '|'
for key, value in sorted(headers.items()):
if key.startswith('X-Mcash-'):
sign_headers += d + key.upper() + ... | python | def _sha256_sign(self, method, url, headers, body):
"""Sign the request with SHA256.
"""
d = ''
sign_headers = method.upper() + '|' + url + '|'
for key, value in sorted(headers.items()):
if key.startswith('X-Mcash-'):
sign_headers += d + key.upper() + ... | [
"def",
"_sha256_sign",
"(",
"self",
",",
"method",
",",
"url",
",",
"headers",
",",
"body",
")",
":",
"d",
"=",
"''",
"sign_headers",
"=",
"method",
".",
"upper",
"(",
")",
"+",
"'|'",
"+",
"url",
"+",
"'|'",
"for",
"key",
",",
"value",
"in",
"so... | Sign the request with SHA256. | [
"Sign",
"the",
"request",
"with",
"SHA256",
"."
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/auth.py#L54-L67 | train | 58,071 |
envi-idl/envipyarclib | envipyarclib/gptoolbox.py | GPToolbox.create_toolbox | def create_toolbox(self, filename):
"""
Creates a new Python toolbox where each task name is a GPTool in the toolbox.
:param filename: the filename of the generated toolbox
:param service_name: The name of the ESE service containing the tasks. Only tasks from
... | python | def create_toolbox(self, filename):
"""
Creates a new Python toolbox where each task name is a GPTool in the toolbox.
:param filename: the filename of the generated toolbox
:param service_name: The name of the ESE service containing the tasks. Only tasks from
... | [
"def",
"create_toolbox",
"(",
"self",
",",
"filename",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"0",
"]",
"label",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
"# Get task information fir... | Creates a new Python toolbox where each task name is a GPTool in the toolbox.
:param filename: the filename of the generated toolbox
:param service_name: The name of the ESE service containing the tasks. Only tasks from
one service may be used.
:param tasks: The li... | [
"Creates",
"a",
"new",
"Python",
"toolbox",
"where",
"each",
"task",
"name",
"is",
"a",
"GPTool",
"in",
"the",
"toolbox",
"."
] | 90135652510c3d53c5f51177252c1fea2639bf22 | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptoolbox.py#L86-L121 | train | 58,072 |
envi-idl/envipyarclib | envipyarclib/gptoolbox.py | GPToolbox.create_tool | def create_tool(self, task):
"""
Creates a new GPTool for the toolbox.
"""
gp_tool = dict(taskName=task.name,
taskDisplayName=task.display_name,
taskDescription=task.description,
canRunInBackground=True,
... | python | def create_tool(self, task):
"""
Creates a new GPTool for the toolbox.
"""
gp_tool = dict(taskName=task.name,
taskDisplayName=task.display_name,
taskDescription=task.description,
canRunInBackground=True,
... | [
"def",
"create_tool",
"(",
"self",
",",
"task",
")",
":",
"gp_tool",
"=",
"dict",
"(",
"taskName",
"=",
"task",
".",
"name",
",",
"taskDisplayName",
"=",
"task",
".",
"display_name",
",",
"taskDescription",
"=",
"task",
".",
"description",
",",
"canRunInBa... | Creates a new GPTool for the toolbox. | [
"Creates",
"a",
"new",
"GPTool",
"for",
"the",
"toolbox",
"."
] | 90135652510c3d53c5f51177252c1fea2639bf22 | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptoolbox.py#L123-L144 | train | 58,073 |
envi-idl/envipyarclib | envipyarclib/gptoolbox.py | GPToolbox.import_script | def import_script(self, script_name):
"""Finds the script file and copies it into the toolbox"""
filename = os.path.abspath(script_name)
with open(filename, 'r') as script_file:
self.toolbox_file.write(script_file.read()) | python | def import_script(self, script_name):
"""Finds the script file and copies it into the toolbox"""
filename = os.path.abspath(script_name)
with open(filename, 'r') as script_file:
self.toolbox_file.write(script_file.read()) | [
"def",
"import_script",
"(",
"self",
",",
"script_name",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"script_name",
")",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"script_file",
":",
"self",
".",
"toolbox_file",
".",
... | Finds the script file and copies it into the toolbox | [
"Finds",
"the",
"script",
"file",
"and",
"copies",
"it",
"into",
"the",
"toolbox"
] | 90135652510c3d53c5f51177252c1fea2639bf22 | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptoolbox.py#L146-L150 | train | 58,074 |
helixyte/everest | everest/resources/descriptors.py | _relation_attribute.make_relationship | def make_relationship(self, relator,
direction=
RELATIONSHIP_DIRECTIONS.BIDIRECTIONAL):
"""
Create a relationship object for this attribute from the given
relator and relationship direction.
"""
if IEntity.providedBy(relator):... | python | def make_relationship(self, relator,
direction=
RELATIONSHIP_DIRECTIONS.BIDIRECTIONAL):
"""
Create a relationship object for this attribute from the given
relator and relationship direction.
"""
if IEntity.providedBy(relator):... | [
"def",
"make_relationship",
"(",
"self",
",",
"relator",
",",
"direction",
"=",
"RELATIONSHIP_DIRECTIONS",
".",
"BIDIRECTIONAL",
")",
":",
"if",
"IEntity",
".",
"providedBy",
"(",
"relator",
")",
":",
"# pylint:disable=E1101",
"rel",
"=",
"DomainRelationship",
"("... | Create a relationship object for this attribute from the given
relator and relationship direction. | [
"Create",
"a",
"relationship",
"object",
"for",
"this",
"attribute",
"from",
"the",
"given",
"relator",
"and",
"relationship",
"direction",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/descriptors.py#L143-L160 | train | 58,075 |
silver-castle/mach9 | mach9/blueprints.py | Blueprint.register | def register(self, app, options):
"""Register the blueprint to the mach9 app."""
url_prefix = options.get('url_prefix', self.url_prefix)
# Routes
for future in self.routes:
# attach the blueprint name to the handler so that it can be
# prefixed properly in the r... | python | def register(self, app, options):
"""Register the blueprint to the mach9 app."""
url_prefix = options.get('url_prefix', self.url_prefix)
# Routes
for future in self.routes:
# attach the blueprint name to the handler so that it can be
# prefixed properly in the r... | [
"def",
"register",
"(",
"self",
",",
"app",
",",
"options",
")",
":",
"url_prefix",
"=",
"options",
".",
"get",
"(",
"'url_prefix'",
",",
"self",
".",
"url_prefix",
")",
"# Routes",
"for",
"future",
"in",
"self",
".",
"routes",
":",
"# attach the blueprint... | Register the blueprint to the mach9 app. | [
"Register",
"the",
"blueprint",
"to",
"the",
"mach9",
"app",
"."
] | 7a623aab3c70d89d36ade6901b6307e115400c5e | https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/blueprints.py#L34-L76 | train | 58,076 |
silver-castle/mach9 | mach9/blueprints.py | Blueprint.add_route | def add_route(self, handler, uri, methods=frozenset({'GET'}), host=None,
strict_slashes=False):
"""Create a blueprint route from a function.
:param handler: function for handling uri requests. Accepts function,
or class instance with a view_class method.
... | python | def add_route(self, handler, uri, methods=frozenset({'GET'}), host=None,
strict_slashes=False):
"""Create a blueprint route from a function.
:param handler: function for handling uri requests. Accepts function,
or class instance with a view_class method.
... | [
"def",
"add_route",
"(",
"self",
",",
"handler",
",",
"uri",
",",
"methods",
"=",
"frozenset",
"(",
"{",
"'GET'",
"}",
")",
",",
"host",
"=",
"None",
",",
"strict_slashes",
"=",
"False",
")",
":",
"# Handle HTTPMethodView differently",
"if",
"hasattr",
"("... | Create a blueprint route from a function.
:param handler: function for handling uri requests. Accepts function,
or class instance with a view_class method.
:param uri: endpoint at which the route will be accessible.
:param methods: list of acceptable HTTP methods.
... | [
"Create",
"a",
"blueprint",
"route",
"from",
"a",
"function",
"."
] | 7a623aab3c70d89d36ade6901b6307e115400c5e | https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/blueprints.py#L92-L117 | train | 58,077 |
ponty/confduino | confduino/examples/remove_boards.py | remove_boards_gui | def remove_boards_gui(hwpack=''):
"""remove boards by GUI."""
if not hwpack:
if len(hwpack_names()) > 1:
hwpack = psidialogs.choice(hwpack_names(),
'select hardware package to select board from!',
title='select')
... | python | def remove_boards_gui(hwpack=''):
"""remove boards by GUI."""
if not hwpack:
if len(hwpack_names()) > 1:
hwpack = psidialogs.choice(hwpack_names(),
'select hardware package to select board from!',
title='select')
... | [
"def",
"remove_boards_gui",
"(",
"hwpack",
"=",
"''",
")",
":",
"if",
"not",
"hwpack",
":",
"if",
"len",
"(",
"hwpack_names",
"(",
")",
")",
">",
"1",
":",
"hwpack",
"=",
"psidialogs",
".",
"choice",
"(",
"hwpack_names",
"(",
")",
",",
"'select hardwar... | remove boards by GUI. | [
"remove",
"boards",
"by",
"GUI",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/remove_boards.py#L10-L31 | train | 58,078 |
BlackEarth/bxml | bxml/builder.py | Builder.single | def single(C, namespace=None):
"""An element maker with a single namespace that uses that namespace as the default"""
if namespace is None:
B = C()._
else:
B = C(default=namespace, _=namespace)._
return B | python | def single(C, namespace=None):
"""An element maker with a single namespace that uses that namespace as the default"""
if namespace is None:
B = C()._
else:
B = C(default=namespace, _=namespace)._
return B | [
"def",
"single",
"(",
"C",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"B",
"=",
"C",
"(",
")",
".",
"_",
"else",
":",
"B",
"=",
"C",
"(",
"default",
"=",
"namespace",
",",
"_",
"=",
"namespace",
")",
".",
"... | An element maker with a single namespace that uses that namespace as the default | [
"An",
"element",
"maker",
"with",
"a",
"single",
"namespace",
"that",
"uses",
"that",
"namespace",
"as",
"the",
"default"
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/builder.py#L39-L45 | train | 58,079 |
asascience-open/paegan-transport | paegan/transport/bathymetry.py | Bathymetry.intersect | def intersect(self, **kwargs):
"""
Intersect Point and Bathymetry
returns bool
"""
end_point = kwargs.pop('end_point')
depth = self.get_depth(location=end_point)
# Bathymetry and a particle's depth are both negative down
if depth < 0 and depth > en... | python | def intersect(self, **kwargs):
"""
Intersect Point and Bathymetry
returns bool
"""
end_point = kwargs.pop('end_point')
depth = self.get_depth(location=end_point)
# Bathymetry and a particle's depth are both negative down
if depth < 0 and depth > en... | [
"def",
"intersect",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"end_point",
"=",
"kwargs",
".",
"pop",
"(",
"'end_point'",
")",
"depth",
"=",
"self",
".",
"get_depth",
"(",
"location",
"=",
"end_point",
")",
"# Bathymetry and a particle's depth are both n... | Intersect Point and Bathymetry
returns bool | [
"Intersect",
"Point",
"and",
"Bathymetry",
"returns",
"bool"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/bathymetry.py#L28-L40 | train | 58,080 |
asascience-open/paegan-transport | paegan/transport/bathymetry.py | Bathymetry.react | def react(self, **kwargs):
"""
The time of recation is ignored hereTime is ignored here
and should be handled by whatever called this function.
"""
react_type = kwargs.get("type", self._type)
if react_type == 'hover':
return self.__hover(**kwargs)
... | python | def react(self, **kwargs):
"""
The time of recation is ignored hereTime is ignored here
and should be handled by whatever called this function.
"""
react_type = kwargs.get("type", self._type)
if react_type == 'hover':
return self.__hover(**kwargs)
... | [
"def",
"react",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"react_type",
"=",
"kwargs",
".",
"get",
"(",
"\"type\"",
",",
"self",
".",
"_type",
")",
"if",
"react_type",
"==",
"'hover'",
":",
"return",
"self",
".",
"__hover",
"(",
"*",
"*",
"kw... | The time of recation is ignored hereTime is ignored here
and should be handled by whatever called this function. | [
"The",
"time",
"of",
"recation",
"is",
"ignored",
"hereTime",
"is",
"ignored",
"here",
"and",
"should",
"be",
"handled",
"by",
"whatever",
"called",
"this",
"function",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/bathymetry.py#L45-L59 | train | 58,081 |
asascience-open/paegan-transport | paegan/transport/bathymetry.py | Bathymetry.__hover | def __hover(self, **kwargs):
"""
This hovers the particle 1m above the bathymetry WHERE IT WOULD HAVE ENDED UP.
This is WRONG and we need to compute the location that it actually hit
the bathymetry and hover 1m above THAT.
"""
end_point = kwargs.pop('end_point... | python | def __hover(self, **kwargs):
"""
This hovers the particle 1m above the bathymetry WHERE IT WOULD HAVE ENDED UP.
This is WRONG and we need to compute the location that it actually hit
the bathymetry and hover 1m above THAT.
"""
end_point = kwargs.pop('end_point... | [
"def",
"__hover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"end_point",
"=",
"kwargs",
".",
"pop",
"(",
"'end_point'",
")",
"# The location argument here should be the point that intersected the bathymetry,",
"# not the end_point that is \"through\" the bathymetry.",
"... | This hovers the particle 1m above the bathymetry WHERE IT WOULD HAVE ENDED UP.
This is WRONG and we need to compute the location that it actually hit
the bathymetry and hover 1m above THAT. | [
"This",
"hovers",
"the",
"particle",
"1m",
"above",
"the",
"bathymetry",
"WHERE",
"IT",
"WOULD",
"HAVE",
"ENDED",
"UP",
".",
"This",
"is",
"WRONG",
"and",
"we",
"need",
"to",
"compute",
"the",
"location",
"that",
"it",
"actually",
"hit",
"the",
"bathymetry... | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/bathymetry.py#L61-L71 | train | 58,082 |
asascience-open/paegan-transport | paegan/transport/bathymetry.py | Bathymetry.__reverse | def __reverse(self, **kwargs):
"""
If we hit the bathymetry, set the location to where we came from.
"""
start_point = kwargs.pop('start_point')
return Location4D(latitude=start_point.latitude, longitude=start_point.longitude, depth=start_point.depth) | python | def __reverse(self, **kwargs):
"""
If we hit the bathymetry, set the location to where we came from.
"""
start_point = kwargs.pop('start_point')
return Location4D(latitude=start_point.latitude, longitude=start_point.longitude, depth=start_point.depth) | [
"def",
"__reverse",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"start_point",
"=",
"kwargs",
".",
"pop",
"(",
"'start_point'",
")",
"return",
"Location4D",
"(",
"latitude",
"=",
"start_point",
".",
"latitude",
",",
"longitude",
"=",
"start_point",
"."... | If we hit the bathymetry, set the location to where we came from. | [
"If",
"we",
"hit",
"the",
"bathymetry",
"set",
"the",
"location",
"to",
"where",
"we",
"came",
"from",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/bathymetry.py#L73-L78 | train | 58,083 |
contains-io/rcli | rcli/dispatcher.py | main | def main():
# type: () -> typing.Any
"""Parse the command line options and launch the requested command.
If the command is 'help' then print the help message for the subcommand; if
no subcommand is given, print the standard help message.
"""
colorama.init(wrap=six.PY3)
doc = usage.get_prima... | python | def main():
# type: () -> typing.Any
"""Parse the command line options and launch the requested command.
If the command is 'help' then print the help message for the subcommand; if
no subcommand is given, print the standard help message.
"""
colorama.init(wrap=six.PY3)
doc = usage.get_prima... | [
"def",
"main",
"(",
")",
":",
"# type: () -> typing.Any",
"colorama",
".",
"init",
"(",
"wrap",
"=",
"six",
".",
"PY3",
")",
"doc",
"=",
"usage",
".",
"get_primary_command_usage",
"(",
")",
"allow_subcommands",
"=",
"'<command>'",
"in",
"doc",
"args",
"=",
... | Parse the command line options and launch the requested command.
If the command is 'help' then print the help message for the subcommand; if
no subcommand is given, print the standard help message. | [
"Parse",
"the",
"command",
"line",
"options",
"and",
"launch",
"the",
"requested",
"command",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/dispatcher.py#L34-L58 | train | 58,084 |
contains-io/rcli | rcli/dispatcher.py | _get_subcommand | def _get_subcommand(name):
# type: (str) -> config.RcliEntryPoint
"""Return the function for the specified subcommand.
Args:
name: The name of a subcommand.
Returns:
The loadable object from the entry point represented by the subcommand.
"""
_LOGGER.debug('Accessing subcommand ... | python | def _get_subcommand(name):
# type: (str) -> config.RcliEntryPoint
"""Return the function for the specified subcommand.
Args:
name: The name of a subcommand.
Returns:
The loadable object from the entry point represented by the subcommand.
"""
_LOGGER.debug('Accessing subcommand ... | [
"def",
"_get_subcommand",
"(",
"name",
")",
":",
"# type: (str) -> config.RcliEntryPoint",
"_LOGGER",
".",
"debug",
"(",
"'Accessing subcommand \"%s\".'",
",",
"name",
")",
"if",
"name",
"not",
"in",
"settings",
".",
"subcommands",
":",
"raise",
"ValueError",
"(",
... | Return the function for the specified subcommand.
Args:
name: The name of a subcommand.
Returns:
The loadable object from the entry point represented by the subcommand. | [
"Return",
"the",
"function",
"for",
"the",
"specified",
"subcommand",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/dispatcher.py#L61-L78 | train | 58,085 |
contains-io/rcli | rcli/dispatcher.py | _run_command | def _run_command(argv):
# type: (typing.List[str]) -> typing.Any
"""Run the command with the given CLI options and exit.
Command functions are expected to have a __doc__ string that is parseable
by docopt.
Args:
argv: The list of command line arguments supplied for a command. The
... | python | def _run_command(argv):
# type: (typing.List[str]) -> typing.Any
"""Run the command with the given CLI options and exit.
Command functions are expected to have a __doc__ string that is parseable
by docopt.
Args:
argv: The list of command line arguments supplied for a command. The
... | [
"def",
"_run_command",
"(",
"argv",
")",
":",
"# type: (typing.List[str]) -> typing.Any",
"command_name",
",",
"argv",
"=",
"_get_command_and_argv",
"(",
"argv",
")",
"_LOGGER",
".",
"info",
"(",
"'Running command \"%s %s\" with args: %s'",
",",
"settings",
".",
"comman... | Run the command with the given CLI options and exit.
Command functions are expected to have a __doc__ string that is parseable
by docopt.
Args:
argv: The list of command line arguments supplied for a command. The
first argument is expected to be the name of the command to be run.
... | [
"Run",
"the",
"command",
"with",
"the",
"given",
"CLI",
"options",
"and",
"exit",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/dispatcher.py#L81-L104 | train | 58,086 |
contains-io/rcli | rcli/dispatcher.py | _get_command_and_argv | def _get_command_and_argv(argv):
# type: (typing.List[str]) -> typing.Tuple[str, typing.List[str]]
"""Extract the command name and arguments to pass to docopt.
Args:
argv: The argument list being used to run the command.
Returns:
A tuple containing the name of the command and the argum... | python | def _get_command_and_argv(argv):
# type: (typing.List[str]) -> typing.Tuple[str, typing.List[str]]
"""Extract the command name and arguments to pass to docopt.
Args:
argv: The argument list being used to run the command.
Returns:
A tuple containing the name of the command and the argum... | [
"def",
"_get_command_and_argv",
"(",
"argv",
")",
":",
"# type: (typing.List[str]) -> typing.Tuple[str, typing.List[str]]",
"command_name",
"=",
"argv",
"[",
"0",
"]",
"if",
"not",
"command_name",
":",
"argv",
"=",
"argv",
"[",
"1",
":",
"]",
"elif",
"command_name",... | Extract the command name and arguments to pass to docopt.
Args:
argv: The argument list being used to run the command.
Returns:
A tuple containing the name of the command and the arguments to pass
to docopt. | [
"Extract",
"the",
"command",
"name",
"and",
"arguments",
"to",
"pass",
"to",
"docopt",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/dispatcher.py#L107-L123 | train | 58,087 |
contains-io/rcli | rcli/dispatcher.py | _get_parsed_args | def _get_parsed_args(command_name, doc, argv):
# type: (str, str, typing.List[str]) -> typing.Dict[str, typing.Any]
"""Parse the docstring with docopt.
Args:
command_name: The name of the subcommand to parse.
doc: A docopt-parseable string.
argv: The list of arguments to pass to doc... | python | def _get_parsed_args(command_name, doc, argv):
# type: (str, str, typing.List[str]) -> typing.Dict[str, typing.Any]
"""Parse the docstring with docopt.
Args:
command_name: The name of the subcommand to parse.
doc: A docopt-parseable string.
argv: The list of arguments to pass to doc... | [
"def",
"_get_parsed_args",
"(",
"command_name",
",",
"doc",
",",
"argv",
")",
":",
"# type: (str, str, typing.List[str]) -> typing.Dict[str, typing.Any]",
"_LOGGER",
".",
"debug",
"(",
"'Parsing docstring: \"\"\"%s\"\"\" with arguments %s.'",
",",
"doc",
",",
"argv",
")",
"... | Parse the docstring with docopt.
Args:
command_name: The name of the subcommand to parse.
doc: A docopt-parseable string.
argv: The list of arguments to pass to docopt during parsing.
Returns:
The docopt results dictionary. If the subcommand has the same name as
the pri... | [
"Parse",
"the",
"docstring",
"with",
"docopt",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/dispatcher.py#L126-L144 | train | 58,088 |
Jarn/jarn.mkrelease | jarn/mkrelease/exit.py | trace | def trace(msg):
"""Print a trace message to stderr if environment variable is set.
"""
if os.environ.get('JARN_TRACE') == '1':
print('TRACE:', msg, file=sys.stderr) | python | def trace(msg):
"""Print a trace message to stderr if environment variable is set.
"""
if os.environ.get('JARN_TRACE') == '1':
print('TRACE:', msg, file=sys.stderr) | [
"def",
"trace",
"(",
"msg",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'JARN_TRACE'",
")",
"==",
"'1'",
":",
"print",
"(",
"'TRACE:'",
",",
"msg",
",",
"file",
"=",
"sys",
".",
"stderr",
")"
] | Print a trace message to stderr if environment variable is set. | [
"Print",
"a",
"trace",
"message",
"to",
"stderr",
"if",
"environment",
"variable",
"is",
"set",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/exit.py#L27-L31 | train | 58,089 |
timothydmorton/orbitutils | orbitutils/kepler.py | Efn | def Efn(Ms,eccs):
"""works for -2pi < Ms < 2pi, e <= 0.97"""
Ms = np.atleast_1d(Ms)
eccs = np.atleast_1d(eccs)
unit = np.floor(Ms / (2*np.pi))
Es = EFN((Ms % (2*np.pi)),eccs)
Es += unit*(2*np.pi)
return Es | python | def Efn(Ms,eccs):
"""works for -2pi < Ms < 2pi, e <= 0.97"""
Ms = np.atleast_1d(Ms)
eccs = np.atleast_1d(eccs)
unit = np.floor(Ms / (2*np.pi))
Es = EFN((Ms % (2*np.pi)),eccs)
Es += unit*(2*np.pi)
return Es | [
"def",
"Efn",
"(",
"Ms",
",",
"eccs",
")",
":",
"Ms",
"=",
"np",
".",
"atleast_1d",
"(",
"Ms",
")",
"eccs",
"=",
"np",
".",
"atleast_1d",
"(",
"eccs",
")",
"unit",
"=",
"np",
".",
"floor",
"(",
"Ms",
"/",
"(",
"2",
"*",
"np",
".",
"pi",
")"... | works for -2pi < Ms < 2pi, e <= 0.97 | [
"works",
"for",
"-",
"2pi",
"<",
"Ms",
"<",
"2pi",
"e",
"<",
"=",
"0",
".",
"97"
] | 949c6b901e519458d80b8d7427916c0698e4013e | https://github.com/timothydmorton/orbitutils/blob/949c6b901e519458d80b8d7427916c0698e4013e/orbitutils/kepler.py#L20-L27 | train | 58,090 |
SeattleTestbed/seash | seash_modules.py | enable_modules_from_last_session | def enable_modules_from_last_session(seashcommanddict):
"""
Enable every module that isn't marked as disabled in the modules folder.
This function is meant to be called when seash is initializing and nowhere
else. A module is marked as disabled when there is a modulename.disabled
file.
"""
successfully_... | python | def enable_modules_from_last_session(seashcommanddict):
"""
Enable every module that isn't marked as disabled in the modules folder.
This function is meant to be called when seash is initializing and nowhere
else. A module is marked as disabled when there is a modulename.disabled
file.
"""
successfully_... | [
"def",
"enable_modules_from_last_session",
"(",
"seashcommanddict",
")",
":",
"successfully_enabled_modules",
"=",
"[",
"]",
"modules_to_enable",
"=",
"get_enabled_modules",
"(",
")",
"for",
"modulename",
"in",
"modules_to_enable",
":",
"# There are no bad side effects to sea... | Enable every module that isn't marked as disabled in the modules folder.
This function is meant to be called when seash is initializing and nowhere
else. A module is marked as disabled when there is a modulename.disabled
file. | [
"Enable",
"every",
"module",
"that",
"isn",
"t",
"marked",
"as",
"disabled",
"in",
"the",
"modules",
"folder",
".",
"This",
"function",
"is",
"meant",
"to",
"be",
"called",
"when",
"seash",
"is",
"initializing",
"and",
"nowhere",
"else",
".",
"A",
"module"... | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/seash_modules.py#L450-L478 | train | 58,091 |
SeattleTestbed/seash | seash_modules.py | _ensure_module_folder_exists | def _ensure_module_folder_exists():
"""
Checks to see if the module folder exists. If it does not, create it.
If there is an existing file with the same name, we raise a RuntimeError.
"""
if not os.path.isdir(MODULES_FOLDER_PATH):
try:
os.mkdir(MODULES_FOLDER_PATH)
except OSError, e:
if "... | python | def _ensure_module_folder_exists():
"""
Checks to see if the module folder exists. If it does not, create it.
If there is an existing file with the same name, we raise a RuntimeError.
"""
if not os.path.isdir(MODULES_FOLDER_PATH):
try:
os.mkdir(MODULES_FOLDER_PATH)
except OSError, e:
if "... | [
"def",
"_ensure_module_folder_exists",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"MODULES_FOLDER_PATH",
")",
":",
"try",
":",
"os",
".",
"mkdir",
"(",
"MODULES_FOLDER_PATH",
")",
"except",
"OSError",
",",
"e",
":",
"if",
"\"file alr... | Checks to see if the module folder exists. If it does not, create it.
If there is an existing file with the same name, we raise a RuntimeError. | [
"Checks",
"to",
"see",
"if",
"the",
"module",
"folder",
"exists",
".",
"If",
"it",
"does",
"not",
"create",
"it",
".",
"If",
"there",
"is",
"an",
"existing",
"file",
"with",
"the",
"same",
"name",
"we",
"raise",
"a",
"RuntimeError",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/seash_modules.py#L598-L608 | train | 58,092 |
helixyte/everest | everest/configuration.py | Configurator.get_configuration_from_settings | def get_configuration_from_settings(self, setting_info):
"""
Returns a dictionary with configuration names as keys and setting
values extracted from this configurator's settings as values.
:param setting_info: Sequence of 2-tuples containing the configuration
name as the first... | python | def get_configuration_from_settings(self, setting_info):
"""
Returns a dictionary with configuration names as keys and setting
values extracted from this configurator's settings as values.
:param setting_info: Sequence of 2-tuples containing the configuration
name as the first... | [
"def",
"get_configuration_from_settings",
"(",
"self",
",",
"setting_info",
")",
":",
"settings",
"=",
"self",
".",
"get_settings",
"(",
")",
"return",
"dict",
"(",
"[",
"(",
"name",
",",
"settings",
".",
"get",
"(",
"key",
")",
")",
"for",
"(",
"name",
... | Returns a dictionary with configuration names as keys and setting
values extracted from this configurator's settings as values.
:param setting_info: Sequence of 2-tuples containing the configuration
name as the first and the setting name as the second element. | [
"Returns",
"a",
"dictionary",
"with",
"configuration",
"names",
"as",
"keys",
"and",
"setting",
"values",
"extracted",
"from",
"this",
"configurator",
"s",
"settings",
"as",
"values",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/configuration.py#L171-L182 | train | 58,093 |
helixyte/everest | everest/configuration.py | Configurator.add_repository | def add_repository(self, name, repository_type, repository_class,
aggregate_class, make_default, configuration):
"""
Generic method for adding a repository.
"""
repo_mgr = self.get_registered_utility(IRepositoryManager)
if name is None:
# If no ... | python | def add_repository(self, name, repository_type, repository_class,
aggregate_class, make_default, configuration):
"""
Generic method for adding a repository.
"""
repo_mgr = self.get_registered_utility(IRepositoryManager)
if name is None:
# If no ... | [
"def",
"add_repository",
"(",
"self",
",",
"name",
",",
"repository_type",
",",
"repository_class",
",",
"aggregate_class",
",",
"make_default",
",",
"configuration",
")",
":",
"repo_mgr",
"=",
"self",
".",
"get_registered_utility",
"(",
"IRepositoryManager",
")",
... | Generic method for adding a repository. | [
"Generic",
"method",
"for",
"adding",
"a",
"repository",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/configuration.py#L237-L252 | train | 58,094 |
dfm/ugly | ugly/models.py | encrypt_email | def encrypt_email(email):
"""
The default encryption function for storing emails in the database. This
uses AES and the encryption key defined in the applications configuration.
:param email:
The email address.
"""
aes = SimpleAES(flask.current_app.config["AES_KEY"])
return aes.enc... | python | def encrypt_email(email):
"""
The default encryption function for storing emails in the database. This
uses AES and the encryption key defined in the applications configuration.
:param email:
The email address.
"""
aes = SimpleAES(flask.current_app.config["AES_KEY"])
return aes.enc... | [
"def",
"encrypt_email",
"(",
"email",
")",
":",
"aes",
"=",
"SimpleAES",
"(",
"flask",
".",
"current_app",
".",
"config",
"[",
"\"AES_KEY\"",
"]",
")",
"return",
"aes",
".",
"encrypt",
"(",
"email",
")"
] | The default encryption function for storing emails in the database. This
uses AES and the encryption key defined in the applications configuration.
:param email:
The email address. | [
"The",
"default",
"encryption",
"function",
"for",
"storing",
"emails",
"in",
"the",
"database",
".",
"This",
"uses",
"AES",
"and",
"the",
"encryption",
"key",
"defined",
"in",
"the",
"applications",
"configuration",
"."
] | bc09834849184552619ee926d7563ed37630accb | https://github.com/dfm/ugly/blob/bc09834849184552619ee926d7563ed37630accb/ugly/models.py#L40-L50 | train | 58,095 |
mcash/merchant-api-python-sdk | mcash/mapi_client/mapi_client_example.py | MapiClientExample.shortlink_scanned | def shortlink_scanned(self, data):
"""Called when a shortlink_scanned event is received
"""
# Inform log that we received an event
self.logger.info("Received shortlink_scanned event")
data = json.loads(data)
customer_token = str(data['object']['id'])
response = s... | python | def shortlink_scanned(self, data):
"""Called when a shortlink_scanned event is received
"""
# Inform log that we received an event
self.logger.info("Received shortlink_scanned event")
data = json.loads(data)
customer_token = str(data['object']['id'])
response = s... | [
"def",
"shortlink_scanned",
"(",
"self",
",",
"data",
")",
":",
"# Inform log that we received an event",
"self",
".",
"logger",
".",
"info",
"(",
"\"Received shortlink_scanned event\"",
")",
"data",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"customer_token",
"... | Called when a shortlink_scanned event is received | [
"Called",
"when",
"a",
"shortlink_scanned",
"event",
"is",
"received"
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/mapi_client_example.py#L22-L42 | train | 58,096 |
mcash/merchant-api-python-sdk | mcash/mapi_client/mapi_client_example.py | MapiClientExample.pusher_connected | def pusher_connected(self, data):
"""Called when the pusherclient is connected
"""
# Inform user that pusher is done connecting
self.logger.info("Pusherclient connected")
# Bind the events we want to listen to
self.callback_client.bind("payment_authorized",
... | python | def pusher_connected(self, data):
"""Called when the pusherclient is connected
"""
# Inform user that pusher is done connecting
self.logger.info("Pusherclient connected")
# Bind the events we want to listen to
self.callback_client.bind("payment_authorized",
... | [
"def",
"pusher_connected",
"(",
"self",
",",
"data",
")",
":",
"# Inform user that pusher is done connecting",
"self",
".",
"logger",
".",
"info",
"(",
"\"Pusherclient connected\"",
")",
"# Bind the events we want to listen to",
"self",
".",
"callback_client",
".",
"bind"... | Called when the pusherclient is connected | [
"Called",
"when",
"the",
"pusherclient",
"is",
"connected"
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/mapi_client_example.py#L53-L63 | train | 58,097 |
callowayproject/Calloway | calloway/apps/django_ext/managers.py | CachingQuerySet.get | def get(self, *args, **kwargs):
"""
Checks the cache to see if there's a cached entry for this pk. If not, fetches
using super then stores the result in cache.
Most of the logic here was gathered from a careful reading of
``django.db.models.sql.query.add_filter``
"""
... | python | def get(self, *args, **kwargs):
"""
Checks the cache to see if there's a cached entry for this pk. If not, fetches
using super then stores the result in cache.
Most of the logic here was gathered from a careful reading of
``django.db.models.sql.query.add_filter``
"""
... | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"query",
".",
"where",
":",
"# If there is any other ``where`` filter on this QuerySet just call",
"# super. There will be a where clause if this QuerySet has already",
"# b... | Checks the cache to see if there's a cached entry for this pk. If not, fetches
using super then stores the result in cache.
Most of the logic here was gathered from a careful reading of
``django.db.models.sql.query.add_filter`` | [
"Checks",
"the",
"cache",
"to",
"see",
"if",
"there",
"s",
"a",
"cached",
"entry",
"for",
"this",
"pk",
".",
"If",
"not",
"fetches",
"using",
"super",
"then",
"stores",
"the",
"result",
"in",
"cache",
".",
"Most",
"of",
"the",
"logic",
"here",
"was",
... | d22e98d41fbd298ab6393ba7bd84a75528be9f81 | https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/managers.py#L62-L87 | train | 58,098 |
calmjs/nunja | src/nunja/engine.py | Engine.fetch_path | def fetch_path(self, name):
"""
Fetch contents from the path retrieved via lookup_path.
No caching will be done.
"""
with codecs.open(self.lookup_path(name), encoding='utf-8') as fd:
return fd.read() | python | def fetch_path(self, name):
"""
Fetch contents from the path retrieved via lookup_path.
No caching will be done.
"""
with codecs.open(self.lookup_path(name), encoding='utf-8') as fd:
return fd.read() | [
"def",
"fetch_path",
"(",
"self",
",",
"name",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"self",
".",
"lookup_path",
"(",
"name",
")",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"fd",
":",
"return",
"fd",
".",
"read",
"(",
")"
] | Fetch contents from the path retrieved via lookup_path.
No caching will be done. | [
"Fetch",
"contents",
"from",
"the",
"path",
"retrieved",
"via",
"lookup_path",
"."
] | 37ba114ca2239322718fd9994bb078c037682c33 | https://github.com/calmjs/nunja/blob/37ba114ca2239322718fd9994bb078c037682c33/src/nunja/engine.py#L71-L79 | train | 58,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.