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 list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
openstack/python-saharaclient | saharaclient/api/clusters.py | ClusterManagerV1.get | def get(self, cluster_id, show_progress=False):
"""Get information about a Cluster."""
url = ('/clusters/%(cluster_id)s?%(params)s' %
{"cluster_id": cluster_id,
"params": parse.urlencode({"show_progress": show_progress})})
return self._get(url, 'cluster') | python | def get(self, cluster_id, show_progress=False):
"""Get information about a Cluster."""
url = ('/clusters/%(cluster_id)s?%(params)s' %
{"cluster_id": cluster_id,
"params": parse.urlencode({"show_progress": show_progress})})
return self._get(url, 'cluster') | [
"def",
"get",
"(",
"self",
",",
"cluster_id",
",",
"show_progress",
"=",
"False",
")",
":",
"url",
"=",
"(",
"'/clusters/%(cluster_id)s?%(params)s'",
"%",
"{",
"\"cluster_id\"",
":",
"cluster_id",
",",
"\"params\"",
":",
"parse",
".",
"urlencode",
"(",
"{",
... | Get information about a Cluster. | [
"Get",
"information",
"about",
"a",
"Cluster",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L125-L131 | train |
openstack/python-saharaclient | saharaclient/api/clusters.py | ClusterManagerV1.update | def update(self, cluster_id, name=NotUpdated, description=NotUpdated,
is_public=NotUpdated, is_protected=NotUpdated,
shares=NotUpdated):
"""Update a Cluster."""
data = {}
self._copy_if_updated(data, name=name, description=description,
... | python | def update(self, cluster_id, name=NotUpdated, description=NotUpdated,
is_public=NotUpdated, is_protected=NotUpdated,
shares=NotUpdated):
"""Update a Cluster."""
data = {}
self._copy_if_updated(data, name=name, description=description,
... | [
"def",
"update",
"(",
"self",
",",
"cluster_id",
",",
"name",
"=",
"NotUpdated",
",",
"description",
"=",
"NotUpdated",
",",
"is_public",
"=",
"NotUpdated",
",",
"is_protected",
"=",
"NotUpdated",
",",
"shares",
"=",
"NotUpdated",
")",
":",
"data",
"=",
"{... | Update a Cluster. | [
"Update",
"a",
"Cluster",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L137-L147 | train |
openstack/python-saharaclient | saharaclient/api/clusters.py | ClusterManagerV1.verification_update | def verification_update(self, cluster_id, status):
"""Start a verification for a Cluster."""
data = {'verification': {'status': status}}
return self._patch("/clusters/%s" % cluster_id, data) | python | def verification_update(self, cluster_id, status):
"""Start a verification for a Cluster."""
data = {'verification': {'status': status}}
return self._patch("/clusters/%s" % cluster_id, data) | [
"def",
"verification_update",
"(",
"self",
",",
"cluster_id",
",",
"status",
")",
":",
"data",
"=",
"{",
"'verification'",
":",
"{",
"'status'",
":",
"status",
"}",
"}",
"return",
"self",
".",
"_patch",
"(",
"\"/clusters/%s\"",
"%",
"cluster_id",
",",
"dat... | Start a verification for a Cluster. | [
"Start",
"a",
"verification",
"for",
"a",
"Cluster",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L149-L152 | train |
openstack/python-saharaclient | saharaclient/api/clusters.py | ClusterManagerV2.create | def create(self, name, plugin_name, plugin_version,
cluster_template_id=None, default_image_id=None,
is_transient=None, description=None, cluster_configs=None,
node_groups=None, user_keypair_id=None,
anti_affinity=None, net_id=None, count=None,
... | python | def create(self, name, plugin_name, plugin_version,
cluster_template_id=None, default_image_id=None,
is_transient=None, description=None, cluster_configs=None,
node_groups=None, user_keypair_id=None,
anti_affinity=None, net_id=None, count=None,
... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"plugin_name",
",",
"plugin_version",
",",
"cluster_template_id",
"=",
"None",
",",
"default_image_id",
"=",
"None",
",",
"is_transient",
"=",
"None",
",",
"description",
"=",
"None",
",",
"cluster_configs",
"=",... | Launch a Cluster. | [
"Launch",
"a",
"Cluster",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/clusters.py#L157-L176 | train |
openstack/python-saharaclient | doc/ext/cli.py | _get_command | def _get_command(classes):
"""Associates each command class with command depending on setup.cfg
"""
commands = {}
setup_file = os.path.join(
os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')),
'setup.cfg')
for line in open(setup_file, 'r'):
for cl in classes:
... | python | def _get_command(classes):
"""Associates each command class with command depending on setup.cfg
"""
commands = {}
setup_file = os.path.join(
os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')),
'setup.cfg')
for line in open(setup_file, 'r'):
for cl in classes:
... | [
"def",
"_get_command",
"(",
"classes",
")",
":",
"commands",
"=",
"{",
"}",
"setup_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(... | Associates each command class with command depending on setup.cfg | [
"Associates",
"each",
"command",
"class",
"with",
"command",
"depending",
"on",
"setup",
".",
"cfg"
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/doc/ext/cli.py#L25-L37 | train |
openstack/python-saharaclient | saharaclient/api/base.py | get_json | def get_json(response):
"""Provide backward compatibility with old versions of requests library."""
json_field_or_function = getattr(response, 'json', None)
if callable(json_field_or_function):
return response.json()
else:
return jsonutils.loads(response.content) | python | def get_json(response):
"""Provide backward compatibility with old versions of requests library."""
json_field_or_function = getattr(response, 'json', None)
if callable(json_field_or_function):
return response.json()
else:
return jsonutils.loads(response.content) | [
"def",
"get_json",
"(",
"response",
")",
":",
"json_field_or_function",
"=",
"getattr",
"(",
"response",
",",
"'json'",
",",
"None",
")",
"if",
"callable",
"(",
"json_field_or_function",
")",
":",
"return",
"response",
".",
"json",
"(",
")",
"else",
":",
"... | Provide backward compatibility with old versions of requests library. | [
"Provide",
"backward",
"compatibility",
"with",
"old",
"versions",
"of",
"requests",
"library",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/base.py#L239-L246 | train |
openstack/python-saharaclient | saharaclient/api/job_binary_internals.py | JobBinaryInternalsManager.create | def create(self, name, data):
"""Create a Job Binary Internal.
:param str data: raw data of script text
"""
return self._update('/job-binary-internals/%s' %
urlparse.quote(name.encode('utf-8')), data,
'job_binary_internal', dump_js... | python | def create(self, name, data):
"""Create a Job Binary Internal.
:param str data: raw data of script text
"""
return self._update('/job-binary-internals/%s' %
urlparse.quote(name.encode('utf-8')), data,
'job_binary_internal', dump_js... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"data",
")",
":",
"return",
"self",
".",
"_update",
"(",
"'/job-binary-internals/%s'",
"%",
"urlparse",
".",
"quote",
"(",
"name",
".",
"encode",
"(",
"'utf-8'",
")",
")",
",",
"data",
",",
"'job_binary_int... | Create a Job Binary Internal.
:param str data: raw data of script text | [
"Create",
"a",
"Job",
"Binary",
"Internal",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_binary_internals.py#L29-L36 | train |
openstack/python-saharaclient | saharaclient/api/job_binary_internals.py | JobBinaryInternalsManager.update | def update(self, job_binary_id, name=NotUpdated, is_public=NotUpdated,
is_protected=NotUpdated):
"""Update a Job Binary Internal."""
data = {}
self._copy_if_updated(data, name=name, is_public=is_public,
is_protected=is_protected)
return self... | python | def update(self, job_binary_id, name=NotUpdated, is_public=NotUpdated,
is_protected=NotUpdated):
"""Update a Job Binary Internal."""
data = {}
self._copy_if_updated(data, name=name, is_public=is_public,
is_protected=is_protected)
return self... | [
"def",
"update",
"(",
"self",
",",
"job_binary_id",
",",
"name",
"=",
"NotUpdated",
",",
"is_public",
"=",
"NotUpdated",
",",
"is_protected",
"=",
"NotUpdated",
")",
":",
"data",
"=",
"{",
"}",
"self",
".",
"_copy_if_updated",
"(",
"data",
",",
"name",
"... | Update a Job Binary Internal. | [
"Update",
"a",
"Job",
"Binary",
"Internal",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_binary_internals.py#L55-L63 | train |
Enteee/pdml2flow | pdml2flow/utils.py | autoconvert | def autoconvert(string):
"""Try to convert variables into datatypes."""
for fn in (boolify, int, float):
try:
return fn(string)
except ValueError:
pass
return string | python | def autoconvert(string):
"""Try to convert variables into datatypes."""
for fn in (boolify, int, float):
try:
return fn(string)
except ValueError:
pass
return string | [
"def",
"autoconvert",
"(",
"string",
")",
":",
"for",
"fn",
"in",
"(",
"boolify",
",",
"int",
",",
"float",
")",
":",
"try",
":",
"return",
"fn",
"(",
"string",
")",
"except",
"ValueError",
":",
"pass",
"return",
"string"
] | Try to convert variables into datatypes. | [
"Try",
"to",
"convert",
"variables",
"into",
"datatypes",
"."
] | bc9efe379b0b2406bfbbbd8e0f678b1f63805c66 | https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/utils.py#L11-L18 | train |
Enteee/pdml2flow | pdml2flow/utils.py | call_plugin | def call_plugin(plugin, f, *args, **kwargs):
"""Calls function f from plugin, returns None if plugin does not implement f."""
try:
getattr(plugin, f)
except AttributeError:
return None
if kwargs:
getattr(plugin, f)(
*args,
**kwargs
)
else:
... | python | def call_plugin(plugin, f, *args, **kwargs):
"""Calls function f from plugin, returns None if plugin does not implement f."""
try:
getattr(plugin, f)
except AttributeError:
return None
if kwargs:
getattr(plugin, f)(
*args,
**kwargs
)
else:
... | [
"def",
"call_plugin",
"(",
"plugin",
",",
"f",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"getattr",
"(",
"plugin",
",",
"f",
")",
"except",
"AttributeError",
":",
"return",
"None",
"if",
"kwargs",
":",
"getattr",
"(",
"plugin",
","... | Calls function f from plugin, returns None if plugin does not implement f. | [
"Calls",
"function",
"f",
"from",
"plugin",
"returns",
"None",
"if",
"plugin",
"does",
"not",
"implement",
"f",
"."
] | bc9efe379b0b2406bfbbbd8e0f678b1f63805c66 | https://github.com/Enteee/pdml2flow/blob/bc9efe379b0b2406bfbbbd8e0f678b1f63805c66/pdml2flow/utils.py#L20-L34 | train |
openstack/python-saharaclient | saharaclient/api/job_executions.py | JobExecutionsManager.create | def create(self, job_id, cluster_id, input_id=None,
output_id=None, configs=None, interface=None, is_public=None,
is_protected=None):
"""Launch a Job."""
url = "/jobs/%s/execute" % job_id
data = {
"cluster_id": cluster_id,
}
self._copy_... | python | def create(self, job_id, cluster_id, input_id=None,
output_id=None, configs=None, interface=None, is_public=None,
is_protected=None):
"""Launch a Job."""
url = "/jobs/%s/execute" % job_id
data = {
"cluster_id": cluster_id,
}
self._copy_... | [
"def",
"create",
"(",
"self",
",",
"job_id",
",",
"cluster_id",
",",
"input_id",
"=",
"None",
",",
"output_id",
"=",
"None",
",",
"configs",
"=",
"None",
",",
"interface",
"=",
"None",
",",
"is_public",
"=",
"None",
",",
"is_protected",
"=",
"None",
")... | Launch a Job. | [
"Launch",
"a",
"Job",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_executions.py#L43-L57 | train |
openstack/python-saharaclient | saharaclient/api/job_executions.py | JobExecutionsManager.update | def update(self, obj_id, is_public=NotUpdated, is_protected=NotUpdated):
"""Update a Job Execution."""
data = {}
self._copy_if_updated(data, is_public=is_public,
is_protected=is_protected)
return self._patch('/job-executions/%s' % obj_id, data) | python | def update(self, obj_id, is_public=NotUpdated, is_protected=NotUpdated):
"""Update a Job Execution."""
data = {}
self._copy_if_updated(data, is_public=is_public,
is_protected=is_protected)
return self._patch('/job-executions/%s' % obj_id, data) | [
"def",
"update",
"(",
"self",
",",
"obj_id",
",",
"is_public",
"=",
"NotUpdated",
",",
"is_protected",
"=",
"NotUpdated",
")",
":",
"data",
"=",
"{",
"}",
"self",
".",
"_copy_if_updated",
"(",
"data",
",",
"is_public",
"=",
"is_public",
",",
"is_protected"... | Update a Job Execution. | [
"Update",
"a",
"Job",
"Execution",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/job_executions.py#L59-L65 | train |
datacamp/antlr-tsql | antlr_tsql/ast.py | AstVisitor.visitTerminal | def visitTerminal(self, ctx):
"""Converts case insensitive keywords and identifiers to lowercase
Identifiers in quotes are not lowercased even though there is case sensitivity in quotes for identifiers,
to prevent lowercasing quoted values.
"""
text = str(super().visitTerm... | python | def visitTerminal(self, ctx):
"""Converts case insensitive keywords and identifiers to lowercase
Identifiers in quotes are not lowercased even though there is case sensitivity in quotes for identifiers,
to prevent lowercasing quoted values.
"""
text = str(super().visitTerm... | [
"def",
"visitTerminal",
"(",
"self",
",",
"ctx",
")",
":",
"text",
"=",
"str",
"(",
"super",
"(",
")",
".",
"visitTerminal",
"(",
"ctx",
")",
")",
"quotes",
"=",
"[",
"\"'\"",
",",
"'\"'",
"]",
"if",
"not",
"(",
"text",
"[",
"0",
"]",
"in",
"qu... | Converts case insensitive keywords and identifiers to lowercase
Identifiers in quotes are not lowercased even though there is case sensitivity in quotes for identifiers,
to prevent lowercasing quoted values. | [
"Converts",
"case",
"insensitive",
"keywords",
"and",
"identifiers",
"to",
"lowercase",
"Identifiers",
"in",
"quotes",
"are",
"not",
"lowercased",
"even",
"though",
"there",
"is",
"case",
"sensitivity",
"in",
"quotes",
"for",
"identifiers",
"to",
"prevent",
"lower... | b048bfb084bad6b8e5f111a9127e38c2b07fd714 | https://github.com/datacamp/antlr-tsql/blob/b048bfb084bad6b8e5f111a9127e38c2b07fd714/antlr_tsql/ast.py#L499-L508 | train |
openstack/python-saharaclient | saharaclient/api/plugins.py | _PluginManager.list | def list(self, search_opts=None):
"""Get a list of Plugins."""
query = base.get_query_string(search_opts)
return self._list('/plugins%s' % query, 'plugins') | python | def list(self, search_opts=None):
"""Get a list of Plugins."""
query = base.get_query_string(search_opts)
return self._list('/plugins%s' % query, 'plugins') | [
"def",
"list",
"(",
"self",
",",
"search_opts",
"=",
"None",
")",
":",
"query",
"=",
"base",
".",
"get_query_string",
"(",
"search_opts",
")",
"return",
"self",
".",
"_list",
"(",
"'/plugins%s'",
"%",
"query",
",",
"'plugins'",
")"
] | Get a list of Plugins. | [
"Get",
"a",
"list",
"of",
"Plugins",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/plugins.py#L34-L37 | train |
openstack/python-saharaclient | saharaclient/api/plugins.py | PluginManagerV1.convert_to_cluster_template | def convert_to_cluster_template(self, plugin_name, hadoop_version,
template_name, filecontent):
"""Convert to cluster template
Create Cluster Template directly, avoiding Cluster Template
mechanism.
"""
resp = self.api.post('/plugins/%s/%s/conv... | python | def convert_to_cluster_template(self, plugin_name, hadoop_version,
template_name, filecontent):
"""Convert to cluster template
Create Cluster Template directly, avoiding Cluster Template
mechanism.
"""
resp = self.api.post('/plugins/%s/%s/conv... | [
"def",
"convert_to_cluster_template",
"(",
"self",
",",
"plugin_name",
",",
"hadoop_version",
",",
"template_name",
",",
"filecontent",
")",
":",
"resp",
"=",
"self",
".",
"api",
".",
"post",
"(",
"'/plugins/%s/%s/convert-config/%s'",
"%",
"(",
"plugin_name",
",",... | Convert to cluster template
Create Cluster Template directly, avoiding Cluster Template
mechanism. | [
"Convert",
"to",
"cluster",
"template"
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/plugins.py#L60-L77 | train |
openstack/python-saharaclient | saharaclient/api/jobs.py | JobsManagerV1.create | def create(self, name, type, mains=None, libs=None, description=None,
interface=None, is_public=None, is_protected=None):
"""Create a Job."""
data = {
'name': name,
'type': type
}
self._copy_if_defined(data, description=description, mains=mains,
... | python | def create(self, name, type, mains=None, libs=None, description=None,
interface=None, is_public=None, is_protected=None):
"""Create a Job."""
data = {
'name': name,
'type': type
}
self._copy_if_defined(data, description=description, mains=mains,
... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"type",
",",
"mains",
"=",
"None",
",",
"libs",
"=",
"None",
",",
"description",
"=",
"None",
",",
"interface",
"=",
"None",
",",
"is_public",
"=",
"None",
",",
"is_protected",
"=",
"None",
")",
":",
... | Create a Job. | [
"Create",
"a",
"Job",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/jobs.py#L27-L39 | train |
openstack/python-saharaclient | saharaclient/api/jobs.py | JobsManagerV1.list | def list(self, search_opts=None, limit=None,
marker=None, sort_by=None, reverse=None):
"""Get a list of Jobs."""
query = base.get_query_string(search_opts, limit=limit, marker=marker,
sort_by=sort_by, reverse=reverse)
url = "/jobs%s" % query
... | python | def list(self, search_opts=None, limit=None,
marker=None, sort_by=None, reverse=None):
"""Get a list of Jobs."""
query = base.get_query_string(search_opts, limit=limit, marker=marker,
sort_by=sort_by, reverse=reverse)
url = "/jobs%s" % query
... | [
"def",
"list",
"(",
"self",
",",
"search_opts",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"sort_by",
"=",
"None",
",",
"reverse",
"=",
"None",
")",
":",
"query",
"=",
"base",
".",
"get_query_string",
"(",
"search_opts",
... | Get a list of Jobs. | [
"Get",
"a",
"list",
"of",
"Jobs",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/jobs.py#L41-L47 | train |
openstack/python-saharaclient | saharaclient/api/jobs.py | JobsManagerV1.update | def update(self, job_id, name=NotUpdated, description=NotUpdated,
is_public=NotUpdated, is_protected=NotUpdated):
"""Update a Job."""
data = {}
self._copy_if_updated(data, name=name, description=description,
is_public=is_public, is_protected=is_prote... | python | def update(self, job_id, name=NotUpdated, description=NotUpdated,
is_public=NotUpdated, is_protected=NotUpdated):
"""Update a Job."""
data = {}
self._copy_if_updated(data, name=name, description=description,
is_public=is_public, is_protected=is_prote... | [
"def",
"update",
"(",
"self",
",",
"job_id",
",",
"name",
"=",
"NotUpdated",
",",
"description",
"=",
"NotUpdated",
",",
"is_public",
"=",
"NotUpdated",
",",
"is_protected",
"=",
"NotUpdated",
")",
":",
"data",
"=",
"{",
"}",
"self",
".",
"_copy_if_updated... | Update a Job. | [
"Update",
"a",
"Job",
"."
] | c53831d686d9e94187ce5dfdbfa43883b792280e | https://github.com/openstack/python-saharaclient/blob/c53831d686d9e94187ce5dfdbfa43883b792280e/saharaclient/api/jobs.py#L61-L69 | train |
OpenCageData/python-opencage-geocoder | opencage/geocoder.py | _query_for_reverse_geocoding | def _query_for_reverse_geocoding(lat, lng):
"""
Given a lat & lng, what's the string search query.
If the API changes, change this function. Only for internal use.
"""
# have to do some stupid f/Decimal/str stuff to (a) ensure we get as much
# decimal places as the user already specified and (b... | python | def _query_for_reverse_geocoding(lat, lng):
"""
Given a lat & lng, what's the string search query.
If the API changes, change this function. Only for internal use.
"""
# have to do some stupid f/Decimal/str stuff to (a) ensure we get as much
# decimal places as the user already specified and (b... | [
"def",
"_query_for_reverse_geocoding",
"(",
"lat",
",",
"lng",
")",
":",
"return",
"\"{0:f},{1:f}\"",
".",
"format",
"(",
"Decimal",
"(",
"str",
"(",
"lat",
")",
")",
",",
"Decimal",
"(",
"str",
"(",
"lng",
")",
")",
")"
] | Given a lat & lng, what's the string search query.
If the API changes, change this function. Only for internal use. | [
"Given",
"a",
"lat",
"&",
"lng",
"what",
"s",
"the",
"string",
"search",
"query",
"."
] | 21f102a33a036ed29e08e8375eceaa1bb4ec5009 | https://github.com/OpenCageData/python-opencage-geocoder/blob/21f102a33a036ed29e08e8375eceaa1bb4ec5009/opencage/geocoder.py#L155-L164 | train |
OpenCageData/python-opencage-geocoder | opencage/geocoder.py | OpenCageGeocode.geocode | def geocode(self, query, **kwargs):
"""
Given a string to search for, return the results from OpenCage's Geocoder.
:param string query: String to search for
:returns: Dict results
:raises InvalidInputError: if the query string is not a unicode string
:raises RateLimitEx... | python | def geocode(self, query, **kwargs):
"""
Given a string to search for, return the results from OpenCage's Geocoder.
:param string query: String to search for
:returns: Dict results
:raises InvalidInputError: if the query string is not a unicode string
:raises RateLimitEx... | [
"def",
"geocode",
"(",
"self",
",",
"query",
",",
"**",
"kwargs",
")",
":",
"if",
"six",
".",
"PY2",
":",
"try",
":",
"query",
"=",
"unicode",
"(",
"query",
")",
"except",
"UnicodeDecodeError",
":",
"raise",
"InvalidInputError",
"(",
"bad_value",
"=",
... | Given a string to search for, return the results from OpenCage's Geocoder.
:param string query: String to search for
:returns: Dict results
:raises InvalidInputError: if the query string is not a unicode string
:raises RateLimitExceededError: if you have exceeded the number of queries ... | [
"Given",
"a",
"string",
"to",
"search",
"for",
"return",
"the",
"results",
"from",
"OpenCage",
"s",
"Geocoder",
"."
] | 21f102a33a036ed29e08e8375eceaa1bb4ec5009 | https://github.com/OpenCageData/python-opencage-geocoder/blob/21f102a33a036ed29e08e8375eceaa1bb4ec5009/opencage/geocoder.py#L90-L139 | train |
OpenCageData/python-opencage-geocoder | opencage/geocoder.py | OpenCageGeocode.reverse_geocode | def reverse_geocode(self, lat, lng, **kwargs):
"""
Given a latitude & longitude, return an address for that point from OpenCage's Geocoder.
:param lat: Latitude
:param lng: Longitude
:return: Results from OpenCageData
:rtype: dict
:raises RateLimitExceededError: ... | python | def reverse_geocode(self, lat, lng, **kwargs):
"""
Given a latitude & longitude, return an address for that point from OpenCage's Geocoder.
:param lat: Latitude
:param lng: Longitude
:return: Results from OpenCageData
:rtype: dict
:raises RateLimitExceededError: ... | [
"def",
"reverse_geocode",
"(",
"self",
",",
"lat",
",",
"lng",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"geocode",
"(",
"_query_for_reverse_geocoding",
"(",
"lat",
",",
"lng",
")",
",",
"**",
"kwargs",
")"
] | Given a latitude & longitude, return an address for that point from OpenCage's Geocoder.
:param lat: Latitude
:param lng: Longitude
:return: Results from OpenCageData
:rtype: dict
:raises RateLimitExceededError: if you have exceeded the number of queries you can make. Exception ... | [
"Given",
"a",
"latitude",
"&",
"longitude",
"return",
"an",
"address",
"for",
"that",
"point",
"from",
"OpenCage",
"s",
"Geocoder",
"."
] | 21f102a33a036ed29e08e8375eceaa1bb4ec5009 | https://github.com/OpenCageData/python-opencage-geocoder/blob/21f102a33a036ed29e08e8375eceaa1bb4ec5009/opencage/geocoder.py#L141-L152 | train |
zillow/ctds | src/ctds/pool/__init__.py | ConnectionPool.acquire | def acquire(self):
'''
Get a new connection from the pool.
This will return an existing connection, if one is available in the
pool, or create a new connection.
.. warning:: If the pool was created with `maxsize` and `block=True`,
this method may block until a connec... | python | def acquire(self):
'''
Get a new connection from the pool.
This will return an existing connection, if one is available in the
pool, or create a new connection.
.. warning:: If the pool was created with `maxsize` and `block=True`,
this method may block until a connec... | [
"def",
"acquire",
"(",
"self",
")",
":",
"self",
".",
"_condition",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"self",
".",
"_maxsize",
"is",
"not",
"None",
"and",
"self",
".",
"_block",
":",
"while",
"not",
"self",
".",
"_pool",
"and",
"self",
".... | Get a new connection from the pool.
This will return an existing connection, if one is available in the
pool, or create a new connection.
.. warning:: If the pool was created with `maxsize` and `block=True`,
this method may block until a connection is available in the pool. | [
"Get",
"a",
"new",
"connection",
"from",
"the",
"pool",
".",
"This",
"will",
"return",
"an",
"existing",
"connection",
"if",
"one",
"is",
"available",
"in",
"the",
"pool",
"or",
"create",
"a",
"new",
"connection",
"."
] | 03c9d182f63900fe6c792dda2d320392d6e3e759 | https://github.com/zillow/ctds/blob/03c9d182f63900fe6c792dda2d320392d6e3e759/src/ctds/pool/__init__.py#L118-L149 | train |
zillow/ctds | src/ctds/pool/__init__.py | ConnectionPool.release | def release(self, connection):
'''
Return a connection back to the pool.
Prior to release, :py:meth:`ctds.Connection.rollback()` is called to
rollback any pending transaction.
.. note:: This must be called once for every successful call to
:py:meth:`.acquire()`.
... | python | def release(self, connection):
'''
Return a connection back to the pool.
Prior to release, :py:meth:`ctds.Connection.rollback()` is called to
rollback any pending transaction.
.. note:: This must be called once for every successful call to
:py:meth:`.acquire()`.
... | [
"def",
"release",
"(",
"self",
",",
"connection",
")",
":",
"try",
":",
"connection",
".",
"rollback",
"(",
")",
"except",
"self",
".",
"_dbapi2",
".",
"Error",
":",
"self",
".",
"_close",
"(",
"connection",
")",
"return",
"self",
".",
"_condition",
".... | Return a connection back to the pool.
Prior to release, :py:meth:`ctds.Connection.rollback()` is called to
rollback any pending transaction.
.. note:: This must be called once for every successful call to
:py:meth:`.acquire()`.
:param connection: The connection object retu... | [
"Return",
"a",
"connection",
"back",
"to",
"the",
"pool",
"."
] | 03c9d182f63900fe6c792dda2d320392d6e3e759 | https://github.com/zillow/ctds/blob/03c9d182f63900fe6c792dda2d320392d6e3e759/src/ctds/pool/__init__.py#L151-L179 | train |
zillow/ctds | src/ctds/pool/__init__.py | ConnectionPool.finalize | def finalize(self):
'''
Release all connections contained in the pool.
.. note:: This should be called to cleanly shutdown the pool, i.e.
on process exit.
'''
self._condition.acquire()
try:
if self._nconnections != len(self._pool):
... | python | def finalize(self):
'''
Release all connections contained in the pool.
.. note:: This should be called to cleanly shutdown the pool, i.e.
on process exit.
'''
self._condition.acquire()
try:
if self._nconnections != len(self._pool):
... | [
"def",
"finalize",
"(",
"self",
")",
":",
"self",
".",
"_condition",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"self",
".",
"_nconnections",
"!=",
"len",
"(",
"self",
".",
"_pool",
")",
":",
"warnings",
".",
"warn",
"(",
"'finalize() called with unrele... | Release all connections contained in the pool.
.. note:: This should be called to cleanly shutdown the pool, i.e.
on process exit. | [
"Release",
"all",
"connections",
"contained",
"in",
"the",
"pool",
"."
] | 03c9d182f63900fe6c792dda2d320392d6e3e759 | https://github.com/zillow/ctds/blob/03c9d182f63900fe6c792dda2d320392d6e3e759/src/ctds/pool/__init__.py#L181-L197 | train |
sphinx-contrib/openapi | sphinxcontrib/openapi/openapi30.py | _dict_merge | def _dict_merge(dct, merge_dct):
"""Recursive dict merge.
Inspired by :meth:``dict.update()``, instead of updating only top-level
keys, dict_merge recurses down into dicts nested to an arbitrary depth,
updating keys. The ``merge_dct`` is merged into ``dct``.
From https://gist.github.com/angstwad/b... | python | def _dict_merge(dct, merge_dct):
"""Recursive dict merge.
Inspired by :meth:``dict.update()``, instead of updating only top-level
keys, dict_merge recurses down into dicts nested to an arbitrary depth,
updating keys. The ``merge_dct`` is merged into ``dct``.
From https://gist.github.com/angstwad/b... | [
"def",
"_dict_merge",
"(",
"dct",
",",
"merge_dct",
")",
":",
"for",
"k",
",",
"v",
"in",
"merge_dct",
".",
"items",
"(",
")",
":",
"if",
"(",
"k",
"in",
"dct",
"and",
"isinstance",
"(",
"dct",
"[",
"k",
"]",
",",
"dict",
")",
"and",
"isinstance"... | Recursive dict merge.
Inspired by :meth:``dict.update()``, instead of updating only top-level
keys, dict_merge recurses down into dicts nested to an arbitrary depth,
updating keys. The ``merge_dct`` is merged into ``dct``.
From https://gist.github.com/angstwad/bf22d1822c38a92ec0a9
Arguments:
... | [
"Recursive",
"dict",
"merge",
"."
] | 71ff7af270896db49ff9f9136468b78cc929db19 | https://github.com/sphinx-contrib/openapi/blob/71ff7af270896db49ff9f9136468b78cc929db19/sphinxcontrib/openapi/openapi30.py#L58-L76 | train |
sphinx-contrib/openapi | sphinxcontrib/openapi/openapi30.py | _parse_schema | def _parse_schema(schema, method):
"""
Convert a Schema Object to a Python object.
Args:
schema: An ``OrderedDict`` representing the schema object.
"""
if method and schema.get('readOnly', False):
return _READONLY_PROPERTY
# allOf: Must be valid against all of the subschemas
... | python | def _parse_schema(schema, method):
"""
Convert a Schema Object to a Python object.
Args:
schema: An ``OrderedDict`` representing the schema object.
"""
if method and schema.get('readOnly', False):
return _READONLY_PROPERTY
# allOf: Must be valid against all of the subschemas
... | [
"def",
"_parse_schema",
"(",
"schema",
",",
"method",
")",
":",
"if",
"method",
"and",
"schema",
".",
"get",
"(",
"'readOnly'",
",",
"False",
")",
":",
"return",
"_READONLY_PROPERTY",
"if",
"'allOf'",
"in",
"schema",
":",
"schema_",
"=",
"copy",
".",
"de... | Convert a Schema Object to a Python object.
Args:
schema: An ``OrderedDict`` representing the schema object. | [
"Convert",
"a",
"Schema",
"Object",
"to",
"a",
"Python",
"object",
"."
] | 71ff7af270896db49ff9f9136468b78cc929db19 | https://github.com/sphinx-contrib/openapi/blob/71ff7af270896db49ff9f9136468b78cc929db19/sphinxcontrib/openapi/openapi30.py#L79-L136 | train |
sphinx-contrib/openapi | sphinxcontrib/openapi/openapi30.py | _example | def _example(media_type_objects, method=None, endpoint=None, status=None,
nb_indent=0):
"""
Format examples in `Media Type Object` openapi v3 to HTTP request or
HTTP response example.
If method and endpoint is provided, this fonction prints a request example
else status should be provid... | python | def _example(media_type_objects, method=None, endpoint=None, status=None,
nb_indent=0):
"""
Format examples in `Media Type Object` openapi v3 to HTTP request or
HTTP response example.
If method and endpoint is provided, this fonction prints a request example
else status should be provid... | [
"def",
"_example",
"(",
"media_type_objects",
",",
"method",
"=",
"None",
",",
"endpoint",
"=",
"None",
",",
"status",
"=",
"None",
",",
"nb_indent",
"=",
"0",
")",
":",
"indent",
"=",
"' '",
"extra_indent",
"=",
"indent",
"*",
"nb_indent",
"if",
"meth... | Format examples in `Media Type Object` openapi v3 to HTTP request or
HTTP response example.
If method and endpoint is provided, this fonction prints a request example
else status should be provided to print a response example.
Arguments:
media_type_objects (Dict[str, Dict]): Dict containing
... | [
"Format",
"examples",
"in",
"Media",
"Type",
"Object",
"openapi",
"v3",
"to",
"HTTP",
"request",
"or",
"HTTP",
"response",
"example",
".",
"If",
"method",
"and",
"endpoint",
"is",
"provided",
"this",
"fonction",
"prints",
"a",
"request",
"example",
"else",
"... | 71ff7af270896db49ff9f9136468b78cc929db19 | https://github.com/sphinx-contrib/openapi/blob/71ff7af270896db49ff9f9136468b78cc929db19/sphinxcontrib/openapi/openapi30.py#L139-L225 | train |
rossmann-engineering/EasyModbusTCP.PY | easymodbus/modbusClient.py | ModbusClient.connect | def connect(self):
"""
Connects to a Modbus-TCP Server or a Modbus-RTU Slave with the given Parameters
"""
if (self.__ser is not None):
serial = importlib.import_module("serial")
if self.__stopbits == 0:
self.__ser.stopbits = serial.STOPBITS_ON... | python | def connect(self):
"""
Connects to a Modbus-TCP Server or a Modbus-RTU Slave with the given Parameters
"""
if (self.__ser is not None):
serial = importlib.import_module("serial")
if self.__stopbits == 0:
self.__ser.stopbits = serial.STOPBITS_ON... | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"__ser",
"is",
"not",
"None",
")",
":",
"serial",
"=",
"importlib",
".",
"import_module",
"(",
"\"serial\"",
")",
"if",
"self",
".",
"__stopbits",
"==",
"0",
":",
"self",
".",
"__ser",
... | Connects to a Modbus-TCP Server or a Modbus-RTU Slave with the given Parameters | [
"Connects",
"to",
"a",
"Modbus",
"-",
"TCP",
"Server",
"or",
"a",
"Modbus",
"-",
"RTU",
"Slave",
"with",
"the",
"given",
"Parameters"
] | 3ea417470288619ba63ec0474ed1da6bcf105b70 | https://github.com/rossmann-engineering/EasyModbusTCP.PY/blob/3ea417470288619ba63ec0474ed1da6bcf105b70/easymodbus/modbusClient.py#L52-L80 | train |
rossmann-engineering/EasyModbusTCP.PY | easymodbus/modbusClient.py | ModbusClient.close | def close(self):
"""
Closes Serial port, or TCP-Socket connection
"""
if (self.__ser is not None):
self.__ser.close()
if (self.__tcpClientSocket is not None):
self.__stoplistening = True
self.__tcpClientSocket.shutdown(socket.SHUT_RDWR)
... | python | def close(self):
"""
Closes Serial port, or TCP-Socket connection
"""
if (self.__ser is not None):
self.__ser.close()
if (self.__tcpClientSocket is not None):
self.__stoplistening = True
self.__tcpClientSocket.shutdown(socket.SHUT_RDWR)
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"__ser",
"is",
"not",
"None",
")",
":",
"self",
".",
"__ser",
".",
"close",
"(",
")",
"if",
"(",
"self",
".",
"__tcpClientSocket",
"is",
"not",
"None",
")",
":",
"self",
".",
"__stopl... | Closes Serial port, or TCP-Socket connection | [
"Closes",
"Serial",
"port",
"or",
"TCP",
"-",
"Socket",
"connection"
] | 3ea417470288619ba63ec0474ed1da6bcf105b70 | https://github.com/rossmann-engineering/EasyModbusTCP.PY/blob/3ea417470288619ba63ec0474ed1da6bcf105b70/easymodbus/modbusClient.py#L97-L107 | train |
crunchyroll/ef-open | efopen/ef_plugin.py | run_plugins | def run_plugins(context_obj, boto3_clients):
"""
Executes all loaded plugins designated for the service calling the function.
Args:
context_obj (obj:EFContext): The EFContext object created by the service.
boto3_clients (dict): Dictionary of boto3 clients created by ef_utils.create_aws_clients()
"""
... | python | def run_plugins(context_obj, boto3_clients):
"""
Executes all loaded plugins designated for the service calling the function.
Args:
context_obj (obj:EFContext): The EFContext object created by the service.
boto3_clients (dict): Dictionary of boto3 clients created by ef_utils.create_aws_clients()
"""
... | [
"def",
"run_plugins",
"(",
"context_obj",
",",
"boto3_clients",
")",
":",
"def",
"print_if_verbose",
"(",
"message",
")",
":",
"if",
"context_obj",
".",
"verbose",
":",
"print",
"(",
"message",
")",
"service_name",
"=",
"os",
".",
"path",
".",
"basename",
... | Executes all loaded plugins designated for the service calling the function.
Args:
context_obj (obj:EFContext): The EFContext object created by the service.
boto3_clients (dict): Dictionary of boto3 clients created by ef_utils.create_aws_clients() | [
"Executes",
"all",
"loaded",
"plugins",
"designated",
"for",
"the",
"service",
"calling",
"the",
"function",
"."
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_plugin.py#L61-L98 | train |
crunchyroll/ef-open | efopen/ef_cf_diff.py | diff_string_templates | def diff_string_templates(string_a, string_b):
"""
Determine the diff of two strings. Return an empty string if the strings
are identical, and the diff output string if they are not.
"""
s1 = string_a.strip().splitlines()
s2 = string_b.strip().splitlines()
diffs = unified_diff(s2, s1, fromf... | python | def diff_string_templates(string_a, string_b):
"""
Determine the diff of two strings. Return an empty string if the strings
are identical, and the diff output string if they are not.
"""
s1 = string_a.strip().splitlines()
s2 = string_b.strip().splitlines()
diffs = unified_diff(s2, s1, fromf... | [
"def",
"diff_string_templates",
"(",
"string_a",
",",
"string_b",
")",
":",
"s1",
"=",
"string_a",
".",
"strip",
"(",
")",
".",
"splitlines",
"(",
")",
"s2",
"=",
"string_b",
".",
"strip",
"(",
")",
".",
"splitlines",
"(",
")",
"diffs",
"=",
"unified_d... | Determine the diff of two strings. Return an empty string if the strings
are identical, and the diff output string if they are not. | [
"Determine",
"the",
"diff",
"of",
"two",
"strings",
".",
"Return",
"an",
"empty",
"string",
"if",
"the",
"strings",
"are",
"identical",
"and",
"the",
"diff",
"output",
"string",
"if",
"they",
"are",
"not",
"."
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L50-L58 | train |
crunchyroll/ef-open | efopen/ef_cf_diff.py | render_local_template | def render_local_template(service_name, environment, repo_root, template_file):
"""
Render a given service's template for a given environment and return it
"""
cmd = 'cd {} && ef-cf {} {} --devel --verbose'.format(repo_root, template_file, environment)
p = subprocess.Popen(cmd, shell=True, stdout=su... | python | def render_local_template(service_name, environment, repo_root, template_file):
"""
Render a given service's template for a given environment and return it
"""
cmd = 'cd {} && ef-cf {} {} --devel --verbose'.format(repo_root, template_file, environment)
p = subprocess.Popen(cmd, shell=True, stdout=su... | [
"def",
"render_local_template",
"(",
"service_name",
",",
"environment",
",",
"repo_root",
",",
"template_file",
")",
":",
"cmd",
"=",
"'cd {} && ef-cf {} {} --devel --verbose'",
".",
"format",
"(",
"repo_root",
",",
"template_file",
",",
"environment",
")",
"p",
"=... | Render a given service's template for a given environment and return it | [
"Render",
"a",
"given",
"service",
"s",
"template",
"for",
"a",
"given",
"environment",
"and",
"return",
"it"
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L61-L78 | train |
crunchyroll/ef-open | efopen/ef_cf_diff.py | fetch_current_cloudformation_template | def fetch_current_cloudformation_template(service_name, environment, cf_client):
"""
Fetch the currently-deployed template for the given service in the given
environment and return it.
"""
stack_name = get_stack_name(environment, service_name)
logger.debug('Fetching template for `%s`', stack_nam... | python | def fetch_current_cloudformation_template(service_name, environment, cf_client):
"""
Fetch the currently-deployed template for the given service in the given
environment and return it.
"""
stack_name = get_stack_name(environment, service_name)
logger.debug('Fetching template for `%s`', stack_nam... | [
"def",
"fetch_current_cloudformation_template",
"(",
"service_name",
",",
"environment",
",",
"cf_client",
")",
":",
"stack_name",
"=",
"get_stack_name",
"(",
"environment",
",",
"service_name",
")",
"logger",
".",
"debug",
"(",
"'Fetching template for `%s`'",
",",
"s... | Fetch the currently-deployed template for the given service in the given
environment and return it. | [
"Fetch",
"the",
"currently",
"-",
"deployed",
"template",
"for",
"the",
"given",
"service",
"in",
"the",
"given",
"environment",
"and",
"return",
"it",
"."
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L81-L89 | train |
crunchyroll/ef-open | efopen/ef_cf_diff.py | diff_sevice_by_text | def diff_sevice_by_text(service_name, service, environment, cf_client, repo_root):
"""
Render the local template and compare it to the template that was last
applied in the target environment.
"""
global ret_code
logger.info('Investigating textual diff for `%s`:`%s` in environment `%s`',
... | python | def diff_sevice_by_text(service_name, service, environment, cf_client, repo_root):
"""
Render the local template and compare it to the template that was last
applied in the target environment.
"""
global ret_code
logger.info('Investigating textual diff for `%s`:`%s` in environment `%s`',
... | [
"def",
"diff_sevice_by_text",
"(",
"service_name",
",",
"service",
",",
"environment",
",",
"cf_client",
",",
"repo_root",
")",
":",
"global",
"ret_code",
"logger",
".",
"info",
"(",
"'Investigating textual diff for `%s`:`%s` in environment `%s`'",
",",
"service",
"[",
... | Render the local template and compare it to the template that was last
applied in the target environment. | [
"Render",
"the",
"local",
"template",
"and",
"compare",
"it",
"to",
"the",
"template",
"that",
"was",
"last",
"applied",
"in",
"the",
"target",
"environment",
"."
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L92-L123 | train |
crunchyroll/ef-open | efopen/ef_cf_diff.py | diff_sevice_by_changeset | def diff_sevice_by_changeset(service_name, service, environment, cf_client, repo_root):
"""
If an ef-cf call fails, the error will be logged, the retcode set to 2, but
the function will run to completion and return the list of non-error
results.
"""
global ret_code
logger.info('Investigatin... | python | def diff_sevice_by_changeset(service_name, service, environment, cf_client, repo_root):
"""
If an ef-cf call fails, the error will be logged, the retcode set to 2, but
the function will run to completion and return the list of non-error
results.
"""
global ret_code
logger.info('Investigatin... | [
"def",
"diff_sevice_by_changeset",
"(",
"service_name",
",",
"service",
",",
"environment",
",",
"cf_client",
",",
"repo_root",
")",
":",
"global",
"ret_code",
"logger",
".",
"info",
"(",
"'Investigating changeset for `%s`:`%s` in environment `%s`'",
",",
"service",
"["... | If an ef-cf call fails, the error will be logged, the retcode set to 2, but
the function will run to completion and return the list of non-error
results. | [
"If",
"an",
"ef",
"-",
"cf",
"call",
"fails",
"the",
"error",
"will",
"be",
"logged",
"the",
"retcode",
"set",
"to",
"2",
"but",
"the",
"function",
"will",
"run",
"to",
"completion",
"and",
"return",
"the",
"list",
"of",
"non",
"-",
"error",
"results",... | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L198-L238 | train |
crunchyroll/ef-open | efopen/ef_cf_diff.py | get_cloudformation_client | def get_cloudformation_client(service_name, environment_name):
"""
Given a service name and an environment name, return a boto CloudFormation
client object.
"""
region = service_registry.service_region(service_name)
if whereami() == 'ec2':
profile = None
else:
profile = get_... | python | def get_cloudformation_client(service_name, environment_name):
"""
Given a service name and an environment name, return a boto CloudFormation
client object.
"""
region = service_registry.service_region(service_name)
if whereami() == 'ec2':
profile = None
else:
profile = get_... | [
"def",
"get_cloudformation_client",
"(",
"service_name",
",",
"environment_name",
")",
":",
"region",
"=",
"service_registry",
".",
"service_region",
"(",
"service_name",
")",
"if",
"whereami",
"(",
")",
"==",
"'ec2'",
":",
"profile",
"=",
"None",
"else",
":",
... | Given a service name and an environment name, return a boto CloudFormation
client object. | [
"Given",
"a",
"service",
"name",
"and",
"an",
"environment",
"name",
"return",
"a",
"boto",
"CloudFormation",
"client",
"object",
"."
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L241-L254 | train |
crunchyroll/ef-open | efopen/ef_cf_diff.py | evaluate_service_changes | def evaluate_service_changes(services, envs, repo_root, func):
"""
Given a dict of services, and a list of environments, apply the diff
function to evaluate the differences between the target environments
and the rendered templates.
Sub-services (names with '.' in them) are skipped.
"""
for... | python | def evaluate_service_changes(services, envs, repo_root, func):
"""
Given a dict of services, and a list of environments, apply the diff
function to evaluate the differences between the target environments
and the rendered templates.
Sub-services (names with '.' in them) are skipped.
"""
for... | [
"def",
"evaluate_service_changes",
"(",
"services",
",",
"envs",
",",
"repo_root",
",",
"func",
")",
":",
"for",
"service_name",
",",
"service",
"in",
"services",
".",
"iteritems",
"(",
")",
":",
"for",
"env_category",
"in",
"service",
"[",
"'environments'",
... | Given a dict of services, and a list of environments, apply the diff
function to evaluate the differences between the target environments
and the rendered templates.
Sub-services (names with '.' in them) are skipped. | [
"Given",
"a",
"dict",
"of",
"services",
"and",
"a",
"list",
"of",
"environments",
"apply",
"the",
"diff",
"function",
"to",
"evaluate",
"the",
"differences",
"between",
"the",
"target",
"environments",
"and",
"the",
"rendered",
"templates",
"."
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L277-L297 | train |
crunchyroll/ef-open | efopen/ef_cf_diff.py | get_matching_service_template_file | def get_matching_service_template_file(service_name, template_files):
"""
Return the template file that goes with the given service name, or return
None if there's no match. Subservices return the parent service's file.
"""
# If this is a subservice, use the parent service's template
service_na... | python | def get_matching_service_template_file(service_name, template_files):
"""
Return the template file that goes with the given service name, or return
None if there's no match. Subservices return the parent service's file.
"""
# If this is a subservice, use the parent service's template
service_na... | [
"def",
"get_matching_service_template_file",
"(",
"service_name",
",",
"template_files",
")",
":",
"service_name",
"=",
"service_name",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"if",
"service_name",
"in",
"template_files",
":",
"return",
"template_files",
"["... | Return the template file that goes with the given service name, or return
None if there's no match. Subservices return the parent service's file. | [
"Return",
"the",
"template",
"file",
"that",
"goes",
"with",
"the",
"given",
"service",
"name",
"or",
"return",
"None",
"if",
"there",
"s",
"no",
"match",
".",
"Subservices",
"return",
"the",
"parent",
"service",
"s",
"file",
"."
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_cf_diff.py#L316-L325 | train |
penguinmenac3/starttf | starttf/layers/tile_2d.py | inverse_tile_2d | def inverse_tile_2d(input, k_x, k_y, name):
"""
An inverse tiling layer.
An inverse to the tiling layer can be of great use, since you can keep the resolution of your output low,
but harness the benefits of the resolution of a higher level feature layer.
If you insist on a source yo... | python | def inverse_tile_2d(input, k_x, k_y, name):
"""
An inverse tiling layer.
An inverse to the tiling layer can be of great use, since you can keep the resolution of your output low,
but harness the benefits of the resolution of a higher level feature layer.
If you insist on a source yo... | [
"def",
"inverse_tile_2d",
"(",
"input",
",",
"k_x",
",",
"k_y",
",",
"name",
")",
":",
"batch_size",
",",
"h",
",",
"w",
",",
"c",
"=",
"input",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
"if",
"batch_size",
"is",
"None",
":",
"batch_siz... | An inverse tiling layer.
An inverse to the tiling layer can be of great use, since you can keep the resolution of your output low,
but harness the benefits of the resolution of a higher level feature layer.
If you insist on a source you can call it very lightly inspired by yolo9000 "passthrough... | [
"An",
"inverse",
"tiling",
"layer",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/layers/tile_2d.py#L69-L99 | train |
penguinmenac3/starttf | starttf/layers/tile_2d.py | feature_passthrough | def feature_passthrough(early_feat, late_feat, filters, name, kernel_size=(1, 1)):
"""
A feature passthrough layer inspired by yolo9000 and the inverse tiling layer.
It can be proven, that this layer does the same as conv(concat(inverse_tile(early_feat), late_feat)).
This layer has no activation functi... | python | def feature_passthrough(early_feat, late_feat, filters, name, kernel_size=(1, 1)):
"""
A feature passthrough layer inspired by yolo9000 and the inverse tiling layer.
It can be proven, that this layer does the same as conv(concat(inverse_tile(early_feat), late_feat)).
This layer has no activation functi... | [
"def",
"feature_passthrough",
"(",
"early_feat",
",",
"late_feat",
",",
"filters",
",",
"name",
",",
"kernel_size",
"=",
"(",
"1",
",",
"1",
")",
")",
":",
"_",
",",
"h_early",
",",
"w_early",
",",
"c_early",
"=",
"early_feat",
".",
"get_shape",
"(",
"... | A feature passthrough layer inspired by yolo9000 and the inverse tiling layer.
It can be proven, that this layer does the same as conv(concat(inverse_tile(early_feat), late_feat)).
This layer has no activation function.
:param early_feat: The early feature layer of shape [batch_size, h * s_x, w * s_y, _].... | [
"A",
"feature",
"passthrough",
"layer",
"inspired",
"by",
"yolo9000",
"and",
"the",
"inverse",
"tiling",
"layer",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/layers/tile_2d.py#L102-L128 | train |
penguinmenac3/starttf | starttf/layers/tile_2d.py | upsampling_feature_passthrough | def upsampling_feature_passthrough(early_feat, late_feat, filters, name, kernel_size=(1, 1)):
"""
An upsampling feature passthrough layer inspired by yolo9000 and the tiling layer.
It can be proven, that this layer does the same as conv(concat(early_feat, tile_2d(late_feat))).
This layer has no activat... | python | def upsampling_feature_passthrough(early_feat, late_feat, filters, name, kernel_size=(1, 1)):
"""
An upsampling feature passthrough layer inspired by yolo9000 and the tiling layer.
It can be proven, that this layer does the same as conv(concat(early_feat, tile_2d(late_feat))).
This layer has no activat... | [
"def",
"upsampling_feature_passthrough",
"(",
"early_feat",
",",
"late_feat",
",",
"filters",
",",
"name",
",",
"kernel_size",
"=",
"(",
"1",
",",
"1",
")",
")",
":",
"_",
",",
"h_early",
",",
"w_early",
",",
"c_early",
"=",
"early_feat",
".",
"get_shape",... | An upsampling feature passthrough layer inspired by yolo9000 and the tiling layer.
It can be proven, that this layer does the same as conv(concat(early_feat, tile_2d(late_feat))).
This layer has no activation function.
:param early_feat: The early feature layer of shape [batch_size, h * s_x, w * s_y, _].
... | [
"An",
"upsampling",
"feature",
"passthrough",
"layer",
"inspired",
"by",
"yolo9000",
"and",
"the",
"tiling",
"layer",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/layers/tile_2d.py#L131-L157 | train |
crunchyroll/ef-open | efopen/ef_site_config.py | EFSiteConfig.load | def load(self):
"""Loads the config"""
try:
with open(self._ef_site_config, 'r') as yml_file:
return yaml.safe_load(yml_file)
except (IOError, yaml.parser.ParserError) as error:
print("Error: {}".format(error), file=sys.stderr)
sys.exit(1) | python | def load(self):
"""Loads the config"""
try:
with open(self._ef_site_config, 'r') as yml_file:
return yaml.safe_load(yml_file)
except (IOError, yaml.parser.ParserError) as error:
print("Error: {}".format(error), file=sys.stderr)
sys.exit(1) | [
"def",
"load",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"_ef_site_config",
",",
"'r'",
")",
"as",
"yml_file",
":",
"return",
"yaml",
".",
"safe_load",
"(",
"yml_file",
")",
"except",
"(",
"IOError",
",",
"yaml",
".",
"pars... | Loads the config | [
"Loads",
"the",
"config"
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_site_config.py#L32-L39 | train |
penguinmenac3/starttf | starttf/losses/loss_processors.py | interpolate_loss | def interpolate_loss(labels, loss1, loss2, interpolation_values):
"""
Interpolate two losses linearly.
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:param loss1: A float tensor of shape [batch_size, ...] representing the loss1 for int... | python | def interpolate_loss(labels, loss1, loss2, interpolation_values):
"""
Interpolate two losses linearly.
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:param loss1: A float tensor of shape [batch_size, ...] representing the loss1 for int... | [
"def",
"interpolate_loss",
"(",
"labels",
",",
"loss1",
",",
"loss2",
",",
"interpolation_values",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"interpolate_focus_loss\"",
")",
":",
"t",
"=",
"tf",
".",
"reduce_sum",
"(",
"labels",
"*",
"interpolation... | Interpolate two losses linearly.
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:param loss1: A float tensor of shape [batch_size, ...] representing the loss1 for interpolation.
:param loss2: A float tensor of shape [batch_size, ...] repres... | [
"Interpolate",
"two",
"losses",
"linearly",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/loss_processors.py#L27-L40 | train |
penguinmenac3/starttf | starttf/losses/loss_processors.py | mask_loss | def mask_loss(input_tensor, binary_tensor):
"""
Mask a loss by using a tensor filled with 0 or 1.
:param input_tensor: A float tensor of shape [batch_size, ...] representing the loss/cross_entropy
:param binary_tensor: A float tensor of shape [batch_size, ...] representing the mask.
:return: A floa... | python | def mask_loss(input_tensor, binary_tensor):
"""
Mask a loss by using a tensor filled with 0 or 1.
:param input_tensor: A float tensor of shape [batch_size, ...] representing the loss/cross_entropy
:param binary_tensor: A float tensor of shape [batch_size, ...] representing the mask.
:return: A floa... | [
"def",
"mask_loss",
"(",
"input_tensor",
",",
"binary_tensor",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"mask_loss\"",
")",
":",
"mask",
"=",
"tf",
".",
"cast",
"(",
"tf",
".",
"cast",
"(",
"binary_tensor",
",",
"tf",
".",
"bool",
")",
","... | Mask a loss by using a tensor filled with 0 or 1.
:param input_tensor: A float tensor of shape [batch_size, ...] representing the loss/cross_entropy
:param binary_tensor: A float tensor of shape [batch_size, ...] representing the mask.
:return: A float tensor of shape [batch_size, ...] representing the mas... | [
"Mask",
"a",
"loss",
"by",
"using",
"a",
"tensor",
"filled",
"with",
"0",
"or",
"1",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/loss_processors.py#L85-L96 | train |
penguinmenac3/starttf | starttf/losses/loss_processors.py | mean_on_masked | def mean_on_masked(loss, mask, epsilon=1e-8, axis=None):
"""
Average a loss correctly when it was masked.
:param loss: A float tensor of shape [batch_size, ...] representing the (already masked) loss to be averaged.
:param mask: A float tensor of shape [batch_size, ...] representing the mask.
:para... | python | def mean_on_masked(loss, mask, epsilon=1e-8, axis=None):
"""
Average a loss correctly when it was masked.
:param loss: A float tensor of shape [batch_size, ...] representing the (already masked) loss to be averaged.
:param mask: A float tensor of shape [batch_size, ...] representing the mask.
:para... | [
"def",
"mean_on_masked",
"(",
"loss",
",",
"mask",
",",
"epsilon",
"=",
"1e-8",
",",
"axis",
"=",
"None",
")",
":",
"mask",
"=",
"tf",
".",
"cast",
"(",
"tf",
".",
"cast",
"(",
"mask",
",",
"tf",
".",
"bool",
")",
",",
"tf",
".",
"float32",
")"... | Average a loss correctly when it was masked.
:param loss: A float tensor of shape [batch_size, ...] representing the (already masked) loss to be averaged.
:param mask: A float tensor of shape [batch_size, ...] representing the mask.
:param epsilon: Offset of log for numerical stability.
:param axis: Th... | [
"Average",
"a",
"loss",
"correctly",
"when",
"it",
"was",
"masked",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/loss_processors.py#L99-L112 | train |
penguinmenac3/starttf | starttf/losses/loss_processors.py | mask_and_mean_loss | def mask_and_mean_loss(input_tensor, binary_tensor, axis=None):
"""
Mask a loss by using a tensor filled with 0 or 1 and average correctly.
:param input_tensor: A float tensor of shape [batch_size, ...] representing the loss/cross_entropy
:param binary_tensor: A float tensor of shape [batch_size, ...] ... | python | def mask_and_mean_loss(input_tensor, binary_tensor, axis=None):
"""
Mask a loss by using a tensor filled with 0 or 1 and average correctly.
:param input_tensor: A float tensor of shape [batch_size, ...] representing the loss/cross_entropy
:param binary_tensor: A float tensor of shape [batch_size, ...] ... | [
"def",
"mask_and_mean_loss",
"(",
"input_tensor",
",",
"binary_tensor",
",",
"axis",
"=",
"None",
")",
":",
"return",
"mean_on_masked",
"(",
"mask_loss",
"(",
"input_tensor",
",",
"binary_tensor",
")",
",",
"binary_tensor",
",",
"axis",
"=",
"axis",
")"
] | Mask a loss by using a tensor filled with 0 or 1 and average correctly.
:param input_tensor: A float tensor of shape [batch_size, ...] representing the loss/cross_entropy
:param binary_tensor: A float tensor of shape [batch_size, ...] representing the mask.
:return: A float tensor of shape [batch_size, ...... | [
"Mask",
"a",
"loss",
"by",
"using",
"a",
"tensor",
"filled",
"with",
"0",
"or",
"1",
"and",
"average",
"correctly",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/loss_processors.py#L115-L125 | train |
penguinmenac3/starttf | starttf/losses/loss_processors.py | variance_corrected_loss | def variance_corrected_loss(loss, sigma_2=None):
"""
Create a variance corrected loss.
When summing variance corrected losses you get the same as multiloss.
This is especially usefull for keras where when having multiple losses they are summed by keras.
This multi-loss implementation is inspired by... | python | def variance_corrected_loss(loss, sigma_2=None):
"""
Create a variance corrected loss.
When summing variance corrected losses you get the same as multiloss.
This is especially usefull for keras where when having multiple losses they are summed by keras.
This multi-loss implementation is inspired by... | [
"def",
"variance_corrected_loss",
"(",
"loss",
",",
"sigma_2",
"=",
"None",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"variance_corrected_loss\"",
")",
":",
"sigma_cost",
"=",
"0",
"if",
"sigma_2",
"is",
"None",
":",
"sigma",
"=",
"tf",
".",
"g... | Create a variance corrected loss.
When summing variance corrected losses you get the same as multiloss.
This is especially usefull for keras where when having multiple losses they are summed by keras.
This multi-loss implementation is inspired by the Paper "Multi-Task Learning Using Uncertainty to Weight L... | [
"Create",
"a",
"variance",
"corrected",
"loss",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/loss_processors.py#L128-L148 | train |
penguinmenac3/starttf | starttf/losses/loss_processors.py | focus_loss | def focus_loss(labels, probs, loss, gamma):
"""
Calculate the alpha balanced focal loss.
See the focal loss paper: "Focal Loss for Dense Object Detection" [by Facebook AI Research]
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:pa... | python | def focus_loss(labels, probs, loss, gamma):
"""
Calculate the alpha balanced focal loss.
See the focal loss paper: "Focal Loss for Dense Object Detection" [by Facebook AI Research]
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:pa... | [
"def",
"focus_loss",
"(",
"labels",
",",
"probs",
",",
"loss",
",",
"gamma",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"focus_loss\"",
")",
":",
"p_t",
"=",
"tf",
".",
"reduce_sum",
"(",
"probs",
"*",
"labels",
",",
"axis",
"=",
"-",
"1",... | Calculate the alpha balanced focal loss.
See the focal loss paper: "Focal Loss for Dense Object Detection" [by Facebook AI Research]
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:param probs: A float tensor of shape [batch_size, ..., num... | [
"Calculate",
"the",
"alpha",
"balanced",
"focal",
"loss",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/loss_processors.py#L172-L190 | train |
penguinmenac3/starttf | starttf/layers/caffe_tensorflow.py | Network.get_unique_name | def get_unique_name(self, prefix):
'''Returns an index-suffixed unique name for the given prefix.
This is used for auto-generating layer names based on the type-prefix.
'''
ident = sum(t.startswith(prefix) for t, _ in self.layers.items()) + 1
return '%s_%d' % (prefix, ident) | python | def get_unique_name(self, prefix):
'''Returns an index-suffixed unique name for the given prefix.
This is used for auto-generating layer names based on the type-prefix.
'''
ident = sum(t.startswith(prefix) for t, _ in self.layers.items()) + 1
return '%s_%d' % (prefix, ident) | [
"def",
"get_unique_name",
"(",
"self",
",",
"prefix",
")",
":",
"ident",
"=",
"sum",
"(",
"t",
".",
"startswith",
"(",
"prefix",
")",
"for",
"t",
",",
"_",
"in",
"self",
".",
"layers",
".",
"items",
"(",
")",
")",
"+",
"1",
"return",
"'%s_%d'",
"... | Returns an index-suffixed unique name for the given prefix.
This is used for auto-generating layer names based on the type-prefix. | [
"Returns",
"an",
"index",
"-",
"suffixed",
"unique",
"name",
"for",
"the",
"given",
"prefix",
".",
"This",
"is",
"used",
"for",
"auto",
"-",
"generating",
"layer",
"names",
"based",
"on",
"the",
"type",
"-",
"prefix",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/layers/caffe_tensorflow.py#L142-L147 | train |
penguinmenac3/starttf | starttf/layers/caffe_tensorflow.py | Network.make_var | def make_var(self, op_name, name, shape):
'''Creates a new TensorFlow variable.'''
if op_name in self.weights and name in self.weights[op_name]:
if self.verbose:
print("Using: {} {}".format(op_name, name))
initializer = tf.constant(self.weights[op_name][name], sha... | python | def make_var(self, op_name, name, shape):
'''Creates a new TensorFlow variable.'''
if op_name in self.weights and name in self.weights[op_name]:
if self.verbose:
print("Using: {} {}".format(op_name, name))
initializer = tf.constant(self.weights[op_name][name], sha... | [
"def",
"make_var",
"(",
"self",
",",
"op_name",
",",
"name",
",",
"shape",
")",
":",
"if",
"op_name",
"in",
"self",
".",
"weights",
"and",
"name",
"in",
"self",
".",
"weights",
"[",
"op_name",
"]",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"... | Creates a new TensorFlow variable. | [
"Creates",
"a",
"new",
"TensorFlow",
"variable",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/layers/caffe_tensorflow.py#L149-L156 | train |
penguinmenac3/starttf | starttf/data/autorecords.py | write_data | def write_data(hyper_params,
mode,
sequence,
num_threads):
"""
Write a tf record containing a feature dict and a label dict.
:param hyper_params: The hyper parameters required for writing {"problem": {"augmentation": {"steps": Int}}}
:param mode: The mode sp... | python | def write_data(hyper_params,
mode,
sequence,
num_threads):
"""
Write a tf record containing a feature dict and a label dict.
:param hyper_params: The hyper parameters required for writing {"problem": {"augmentation": {"steps": Int}}}
:param mode: The mode sp... | [
"def",
"write_data",
"(",
"hyper_params",
",",
"mode",
",",
"sequence",
",",
"num_threads",
")",
":",
"if",
"not",
"isinstance",
"(",
"sequence",
",",
"Sequence",
")",
"and",
"not",
"(",
"callable",
"(",
"getattr",
"(",
"sequence",
",",
"\"__getitem__\"",
... | Write a tf record containing a feature dict and a label dict.
:param hyper_params: The hyper parameters required for writing {"problem": {"augmentation": {"steps": Int}}}
:param mode: The mode specifies the purpose of the data. Typically it is either "train" or "validation".
:param sequence: A tf.keras.uti... | [
"Write",
"a",
"tf",
"record",
"containing",
"a",
"feature",
"dict",
"and",
"a",
"label",
"dict",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/data/autorecords.py#L264-L300 | train |
crunchyroll/ef-open | efopen/ef_context.py | EFContext.account_id | def account_id(self, value):
"""
Sets the current account id
Args:
value: current account id (string)
Returns:
None
"""
if type(value) is not str:
raise TypeError("commit value must be string")
self._account_id = value | python | def account_id(self, value):
"""
Sets the current account id
Args:
value: current account id (string)
Returns:
None
"""
if type(value) is not str:
raise TypeError("commit value must be string")
self._account_id = value | [
"def",
"account_id",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"is",
"not",
"str",
":",
"raise",
"TypeError",
"(",
"\"commit value must be string\"",
")",
"self",
".",
"_account_id",
"=",
"value"
] | Sets the current account id
Args:
value: current account id (string)
Returns:
None | [
"Sets",
"the",
"current",
"account",
"id"
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_context.py#L127-L139 | train |
penguinmenac3/starttf | starttf/rl/agents/agent.py | Agent.learn | def learn(self, steps=1, **kwargs):
"""
Train the model using the environment and the agent.
Note that the model might be shared between multiple agents (which most probably are of the same type)
at the same time.
:param steps: The number of steps to train for.
"""
... | python | def learn(self, steps=1, **kwargs):
"""
Train the model using the environment and the agent.
Note that the model might be shared between multiple agents (which most probably are of the same type)
at the same time.
:param steps: The number of steps to train for.
"""
... | [
"def",
"learn",
"(",
"self",
",",
"steps",
"=",
"1",
",",
"**",
"kwargs",
")",
":",
"for",
"i",
"in",
"range",
"(",
"steps",
")",
":",
"self",
".",
"step",
"(",
"**",
"kwargs",
")"
] | Train the model using the environment and the agent.
Note that the model might be shared between multiple agents (which most probably are of the same type)
at the same time.
:param steps: The number of steps to train for. | [
"Train",
"the",
"model",
"using",
"the",
"environment",
"and",
"the",
"agent",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/rl/agents/agent.py#L63-L73 | train |
crunchyroll/ef-open | efopen/ef_utils.py | fail | def fail(message, exception_data=None):
"""
Print a failure message and exit nonzero
"""
print(message, file=sys.stderr)
if exception_data:
print(repr(exception_data))
sys.exit(1) | python | def fail(message, exception_data=None):
"""
Print a failure message and exit nonzero
"""
print(message, file=sys.stderr)
if exception_data:
print(repr(exception_data))
sys.exit(1) | [
"def",
"fail",
"(",
"message",
",",
"exception_data",
"=",
"None",
")",
":",
"print",
"(",
"message",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"if",
"exception_data",
":",
"print",
"(",
"repr",
"(",
"exception_data",
")",
")",
"sys",
".",
"exit",
... | Print a failure message and exit nonzero | [
"Print",
"a",
"failure",
"message",
"and",
"exit",
"nonzero"
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_utils.py#L47-L54 | train |
crunchyroll/ef-open | efopen/ef_utils.py | is_in_virtualbox | def is_in_virtualbox():
"""
Is the current environment a virtualbox instance?
Returns a boolean
Raises IOError if the necessary tooling isn't available
"""
if not isfile(__VIRT_WHAT) or not access(__VIRT_WHAT, X_OK):
raise IOError("virt-what not available")
try:
return subprocess.check_output(["su... | python | def is_in_virtualbox():
"""
Is the current environment a virtualbox instance?
Returns a boolean
Raises IOError if the necessary tooling isn't available
"""
if not isfile(__VIRT_WHAT) or not access(__VIRT_WHAT, X_OK):
raise IOError("virt-what not available")
try:
return subprocess.check_output(["su... | [
"def",
"is_in_virtualbox",
"(",
")",
":",
"if",
"not",
"isfile",
"(",
"__VIRT_WHAT",
")",
"or",
"not",
"access",
"(",
"__VIRT_WHAT",
",",
"X_OK",
")",
":",
"raise",
"IOError",
"(",
"\"virt-what not available\"",
")",
"try",
":",
"return",
"subprocess",
".",
... | Is the current environment a virtualbox instance?
Returns a boolean
Raises IOError if the necessary tooling isn't available | [
"Is",
"the",
"current",
"environment",
"a",
"virtualbox",
"instance?",
"Returns",
"a",
"boolean",
"Raises",
"IOError",
"if",
"the",
"necessary",
"tooling",
"isn",
"t",
"available"
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_utils.py#L75-L86 | train |
penguinmenac3/starttf | starttf/losses/basic_losses.py | sum_abs_distance | def sum_abs_distance(labels, preds):
"""
Compute the sum of abs distances.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...]... | python | def sum_abs_distance(labels, preds):
"""
Compute the sum of abs distances.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...]... | [
"def",
"sum_abs_distance",
"(",
"labels",
",",
"preds",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"sum_abs_distance\"",
")",
":",
"return",
"tf",
".",
"reduce_sum",
"(",
"tf",
".",
"abs",
"(",
"preds",
"-",
"labels",
")",
",",
"axis",
"=",
... | Compute the sum of abs distances.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...] representing the summed absolute distance. | [
"Compute",
"the",
"sum",
"of",
"abs",
"distances",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/basic_losses.py#L26-L35 | train |
penguinmenac3/starttf | starttf/losses/basic_losses.py | l1_distance | def l1_distance(labels, preds):
"""
Compute the l1_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...] representing ... | python | def l1_distance(labels, preds):
"""
Compute the l1_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...] representing ... | [
"def",
"l1_distance",
"(",
"labels",
",",
"preds",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"l1_distance\"",
")",
":",
"return",
"tf",
".",
"norm",
"(",
"preds",
"-",
"labels",
",",
"ord",
"=",
"1",
")"
] | Compute the l1_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...] representing the l1 distance. | [
"Compute",
"the",
"l1_distance",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/basic_losses.py#L38-L47 | train |
penguinmenac3/starttf | starttf/losses/basic_losses.py | smooth_l1_distance | def smooth_l1_distance(labels, preds, delta=1.0):
"""
Compute the smooth l1_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:param delta: `float`, the point where ... | python | def smooth_l1_distance(labels, preds, delta=1.0):
"""
Compute the smooth l1_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:param delta: `float`, the point where ... | [
"def",
"smooth_l1_distance",
"(",
"labels",
",",
"preds",
",",
"delta",
"=",
"1.0",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"smooth_l1\"",
")",
":",
"return",
"tf",
".",
"reduce_sum",
"(",
"tf",
".",
"losses",
".",
"huber_loss",
"(",
"label... | Compute the smooth l1_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:param delta: `float`, the point where the huber loss function changes from a quadratic to linear.
... | [
"Compute",
"the",
"smooth",
"l1_distance",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/basic_losses.py#L50-L66 | train |
penguinmenac3/starttf | starttf/losses/basic_losses.py | l2_distance | def l2_distance(labels, preds):
"""
Compute the l2_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...] representing ... | python | def l2_distance(labels, preds):
"""
Compute the l2_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...] representing ... | [
"def",
"l2_distance",
"(",
"labels",
",",
"preds",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"l2_distance\"",
")",
":",
"return",
"tf",
".",
"norm",
"(",
"preds",
"-",
"labels",
",",
"ord",
"=",
"2",
")"
] | Compute the l2_distance.
:param labels: A float tensor of shape [batch_size, ..., X] representing the labels.
:param preds: A float tensor of shape [batch_size, ..., X] representing the predictions.
:return: A float tensor of shape [batch_size, ...] representing the l2 distance. | [
"Compute",
"the",
"l2_distance",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/basic_losses.py#L69-L78 | train |
penguinmenac3/starttf | starttf/losses/basic_losses.py | cross_entropy | def cross_entropy(labels, logits):
"""
Calculate the cross_entropy.
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:param logits: A float tensor of shape [batch_size, ..., num_classes] representing the logits.
:return: A tensor repr... | python | def cross_entropy(labels, logits):
"""
Calculate the cross_entropy.
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:param logits: A float tensor of shape [batch_size, ..., num_classes] representing the logits.
:return: A tensor repr... | [
"def",
"cross_entropy",
"(",
"labels",
",",
"logits",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"cross_entropy\"",
")",
":",
"return",
"tf",
".",
"nn",
".",
"softmax_cross_entropy_with_logits",
"(",
"labels",
"=",
"labels",
",",
"logits",
"=",
"l... | Calculate the cross_entropy.
:param labels: A float tensor of shape [batch_size, ..., num_classes] representing the label class probabilities.
:param logits: A float tensor of shape [batch_size, ..., num_classes] representing the logits.
:return: A tensor representing the cross entropy. | [
"Calculate",
"the",
"cross_entropy",
"."
] | f4086489d169757c0504e822165db2fea534b944 | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/losses/basic_losses.py#L81-L90 | train |
crunchyroll/ef-open | plugins_available/newrelic/interface.py | NewRelic.alert_policy_exists | def alert_policy_exists(self, policy_name):
"""Check to see if an alert policy exists in NewRelic. Return True if so, False if not"""
if next((policy for policy in self.all_alerts if policy['name'] == policy_name), False):
return True | python | def alert_policy_exists(self, policy_name):
"""Check to see if an alert policy exists in NewRelic. Return True if so, False if not"""
if next((policy for policy in self.all_alerts if policy['name'] == policy_name), False):
return True | [
"def",
"alert_policy_exists",
"(",
"self",
",",
"policy_name",
")",
":",
"if",
"next",
"(",
"(",
"policy",
"for",
"policy",
"in",
"self",
".",
"all_alerts",
"if",
"policy",
"[",
"'name'",
"]",
"==",
"policy_name",
")",
",",
"False",
")",
":",
"return",
... | Check to see if an alert policy exists in NewRelic. Return True if so, False if not | [
"Check",
"to",
"see",
"if",
"an",
"alert",
"policy",
"exists",
"in",
"NewRelic",
".",
"Return",
"True",
"if",
"so",
"False",
"if",
"not"
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/plugins_available/newrelic/interface.py#L111-L114 | train |
crunchyroll/ef-open | plugins_available/newrelic/interface.py | NewRelic.create_alert_policy | def create_alert_policy(self, policy_name):
"""Creates an alert policy in NewRelic"""
policy_data = { 'policy': { 'incident_preference': 'PER_POLICY', 'name': policy_name } }
create_policy = requests.post(
'https://api.newrelic.com/v2/alerts_policies.json',
headers=self.auth_header,
data=j... | python | def create_alert_policy(self, policy_name):
"""Creates an alert policy in NewRelic"""
policy_data = { 'policy': { 'incident_preference': 'PER_POLICY', 'name': policy_name } }
create_policy = requests.post(
'https://api.newrelic.com/v2/alerts_policies.json',
headers=self.auth_header,
data=j... | [
"def",
"create_alert_policy",
"(",
"self",
",",
"policy_name",
")",
":",
"policy_data",
"=",
"{",
"'policy'",
":",
"{",
"'incident_preference'",
":",
"'PER_POLICY'",
",",
"'name'",
":",
"policy_name",
"}",
"}",
"create_policy",
"=",
"requests",
".",
"post",
"(... | Creates an alert policy in NewRelic | [
"Creates",
"an",
"alert",
"policy",
"in",
"NewRelic"
] | 59fff3761af07a59f8f1c1682f2be004bdac15f7 | https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/plugins_available/newrelic/interface.py#L116-L126 | train |
gabstopper/smc-python | smc/actions/_search.py | element_href | def element_href(name):
""" Get specified element href by element name
:param name: name of element
:return: string href location of object, else None
"""
if name:
element = fetch_meta_by_name(name)
if element.href:
return element.href | python | def element_href(name):
""" Get specified element href by element name
:param name: name of element
:return: string href location of object, else None
"""
if name:
element = fetch_meta_by_name(name)
if element.href:
return element.href | [
"def",
"element_href",
"(",
"name",
")",
":",
"if",
"name",
":",
"element",
"=",
"fetch_meta_by_name",
"(",
"name",
")",
"if",
"element",
".",
"href",
":",
"return",
"element",
".",
"href"
] | Get specified element href by element name
:param name: name of element
:return: string href location of object, else None | [
"Get",
"specified",
"element",
"href",
"by",
"element",
"name"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L44-L53 | train |
gabstopper/smc-python | smc/actions/_search.py | element_as_json | def element_as_json(name):
""" Get specified element json data by name
:param name: name of element
:return: json data representing element, else None
"""
if name:
element = fetch_json_by_name(name)
if element.json:
return element.json | python | def element_as_json(name):
""" Get specified element json data by name
:param name: name of element
:return: json data representing element, else None
"""
if name:
element = fetch_json_by_name(name)
if element.json:
return element.json | [
"def",
"element_as_json",
"(",
"name",
")",
":",
"if",
"name",
":",
"element",
"=",
"fetch_json_by_name",
"(",
"name",
")",
"if",
"element",
".",
"json",
":",
"return",
"element",
".",
"json"
] | Get specified element json data by name
:param name: name of element
:return: json data representing element, else None | [
"Get",
"specified",
"element",
"json",
"data",
"by",
"name"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L56-L65 | train |
gabstopper/smc-python | smc/actions/_search.py | element_as_json_with_filter | def element_as_json_with_filter(name, _filter):
"""
Get specified element json data by name with filter.
Filter can be any valid element type.
:param name: name of element
:param _filter: element filter, host, network, tcp_service,
network_elements, services, services_and_applic... | python | def element_as_json_with_filter(name, _filter):
"""
Get specified element json data by name with filter.
Filter can be any valid element type.
:param name: name of element
:param _filter: element filter, host, network, tcp_service,
network_elements, services, services_and_applic... | [
"def",
"element_as_json_with_filter",
"(",
"name",
",",
"_filter",
")",
":",
"if",
"name",
":",
"element_href",
"=",
"element_href_use_filter",
"(",
"name",
",",
"_filter",
")",
"if",
"element_href",
":",
"return",
"element_by_href_as_json",
"(",
"element_href",
"... | Get specified element json data by name with filter.
Filter can be any valid element type.
:param name: name of element
:param _filter: element filter, host, network, tcp_service,
network_elements, services, services_and_applications, etc
:return: json data representing element, els... | [
"Get",
"specified",
"element",
"json",
"data",
"by",
"name",
"with",
"filter",
".",
"Filter",
"can",
"be",
"any",
"valid",
"element",
"type",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L68-L81 | train |
gabstopper/smc-python | smc/actions/_search.py | element_href_use_wildcard | def element_href_use_wildcard(name):
""" Get element href using a wildcard rather than matching only on the name
field. This will likely return multiple results.
:param name: name of element
:return: list of matched elements
"""
if name:
element = fetch_meta_by_name(name, exact_match=Fa... | python | def element_href_use_wildcard(name):
""" Get element href using a wildcard rather than matching only on the name
field. This will likely return multiple results.
:param name: name of element
:return: list of matched elements
"""
if name:
element = fetch_meta_by_name(name, exact_match=Fa... | [
"def",
"element_href_use_wildcard",
"(",
"name",
")",
":",
"if",
"name",
":",
"element",
"=",
"fetch_meta_by_name",
"(",
"name",
",",
"exact_match",
"=",
"False",
")",
"return",
"element",
".",
"json"
] | Get element href using a wildcard rather than matching only on the name
field. This will likely return multiple results.
:param name: name of element
:return: list of matched elements | [
"Get",
"element",
"href",
"using",
"a",
"wildcard",
"rather",
"than",
"matching",
"only",
"on",
"the",
"name",
"field",
".",
"This",
"will",
"likely",
"return",
"multiple",
"results",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L127-L136 | train |
gabstopper/smc-python | smc/actions/_search.py | element_href_use_filter | def element_href_use_filter(name, _filter):
""" Get element href using filter
Filter should be a valid entry point value, ie host, router, network,
single_fw, etc
:param name: name of element
:param _filter: filter type, unknown filter will result in no matches
:return: element href (if found)... | python | def element_href_use_filter(name, _filter):
""" Get element href using filter
Filter should be a valid entry point value, ie host, router, network,
single_fw, etc
:param name: name of element
:param _filter: filter type, unknown filter will result in no matches
:return: element href (if found)... | [
"def",
"element_href_use_filter",
"(",
"name",
",",
"_filter",
")",
":",
"if",
"name",
"and",
"_filter",
":",
"element",
"=",
"fetch_meta_by_name",
"(",
"name",
",",
"filter_context",
"=",
"_filter",
")",
"if",
"element",
".",
"json",
":",
"return",
"element... | Get element href using filter
Filter should be a valid entry point value, ie host, router, network,
single_fw, etc
:param name: name of element
:param _filter: filter type, unknown filter will result in no matches
:return: element href (if found), else None | [
"Get",
"element",
"href",
"using",
"filter"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L139-L152 | train |
gabstopper/smc-python | smc/actions/_search.py | element_by_href_as_json | def element_by_href_as_json(href, params=None):
""" Get specified element by href
:param href: link to object
:param params: optional search query parameters
:return: json data representing element, else None
"""
if href:
element = fetch_json_by_href(href, params=params)
if elem... | python | def element_by_href_as_json(href, params=None):
""" Get specified element by href
:param href: link to object
:param params: optional search query parameters
:return: json data representing element, else None
"""
if href:
element = fetch_json_by_href(href, params=params)
if elem... | [
"def",
"element_by_href_as_json",
"(",
"href",
",",
"params",
"=",
"None",
")",
":",
"if",
"href",
":",
"element",
"=",
"fetch_json_by_href",
"(",
"href",
",",
"params",
"=",
"params",
")",
"if",
"element",
":",
"return",
"element",
".",
"json"
] | Get specified element by href
:param href: link to object
:param params: optional search query parameters
:return: json data representing element, else None | [
"Get",
"specified",
"element",
"by",
"href"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L155-L165 | train |
gabstopper/smc-python | smc/actions/_search.py | element_name_by_href | def element_name_by_href(href):
"""
The element href is known, possibly from a reference in an
elements json. You want to retrieve the name of this element.
:param str href: href of element
:return: str name of element, or None
"""
if href:
element = fetch_json_by_href(href)
... | python | def element_name_by_href(href):
"""
The element href is known, possibly from a reference in an
elements json. You want to retrieve the name of this element.
:param str href: href of element
:return: str name of element, or None
"""
if href:
element = fetch_json_by_href(href)
... | [
"def",
"element_name_by_href",
"(",
"href",
")",
":",
"if",
"href",
":",
"element",
"=",
"fetch_json_by_href",
"(",
"href",
")",
"if",
"element",
".",
"json",
":",
"return",
"element",
".",
"json",
".",
"get",
"(",
"'name'",
")"
] | The element href is known, possibly from a reference in an
elements json. You want to retrieve the name of this element.
:param str href: href of element
:return: str name of element, or None | [
"The",
"element",
"href",
"is",
"known",
"possibly",
"from",
"a",
"reference",
"in",
"an",
"elements",
"json",
".",
"You",
"want",
"to",
"retrieve",
"the",
"name",
"of",
"this",
"element",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L168-L179 | train |
gabstopper/smc-python | smc/actions/_search.py | element_name_and_type_by_href | def element_name_and_type_by_href(href):
"""
Retrieve the element name and type of element based on the href.
You may have a href that is within another element reference and
want more information on that reference.
:param str href: href of element
:return: tuple (name, type)
"""
if hre... | python | def element_name_and_type_by_href(href):
"""
Retrieve the element name and type of element based on the href.
You may have a href that is within another element reference and
want more information on that reference.
:param str href: href of element
:return: tuple (name, type)
"""
if hre... | [
"def",
"element_name_and_type_by_href",
"(",
"href",
")",
":",
"if",
"href",
":",
"element",
"=",
"fetch_json_by_href",
"(",
"href",
")",
"if",
"element",
".",
"json",
":",
"for",
"entries",
"in",
"element",
".",
"json",
".",
"get",
"(",
"'link'",
")",
"... | Retrieve the element name and type of element based on the href.
You may have a href that is within another element reference and
want more information on that reference.
:param str href: href of element
:return: tuple (name, type) | [
"Retrieve",
"the",
"element",
"name",
"and",
"type",
"of",
"element",
"based",
"on",
"the",
"href",
".",
"You",
"may",
"have",
"a",
"href",
"that",
"is",
"within",
"another",
"element",
"reference",
"and",
"want",
"more",
"information",
"on",
"that",
"refe... | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L182-L199 | train |
gabstopper/smc-python | smc/actions/_search.py | element_attribute_by_href | def element_attribute_by_href(href, attr_name):
"""
The element href is known and you want to retrieve a specific
attribute from that element.
For example, if you want a specific attribute by it's name::
search.element_attribute_by_href(href_to_resource, 'name')
:param str href: href of e... | python | def element_attribute_by_href(href, attr_name):
"""
The element href is known and you want to retrieve a specific
attribute from that element.
For example, if you want a specific attribute by it's name::
search.element_attribute_by_href(href_to_resource, 'name')
:param str href: href of e... | [
"def",
"element_attribute_by_href",
"(",
"href",
",",
"attr_name",
")",
":",
"if",
"href",
":",
"element",
"=",
"fetch_json_by_href",
"(",
"href",
")",
"if",
"element",
".",
"json",
":",
"return",
"element",
".",
"json",
".",
"get",
"(",
"attr_name",
")"
] | The element href is known and you want to retrieve a specific
attribute from that element.
For example, if you want a specific attribute by it's name::
search.element_attribute_by_href(href_to_resource, 'name')
:param str href: href of element
:param str attr_name: name of attribute
:retu... | [
"The",
"element",
"href",
"is",
"known",
"and",
"you",
"want",
"to",
"retrieve",
"a",
"specific",
"attribute",
"from",
"that",
"element",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L202-L218 | train |
gabstopper/smc-python | smc/actions/_search.py | element_by_href_as_smcresult | def element_by_href_as_smcresult(href, params=None):
""" Get specified element returned as an SMCResult object
:param href: href direct link to object
:return: :py:class:`smc.api.web.SMCResult` with etag, href and
element field holding json, else None
"""
if href:
element = fet... | python | def element_by_href_as_smcresult(href, params=None):
""" Get specified element returned as an SMCResult object
:param href: href direct link to object
:return: :py:class:`smc.api.web.SMCResult` with etag, href and
element field holding json, else None
"""
if href:
element = fet... | [
"def",
"element_by_href_as_smcresult",
"(",
"href",
",",
"params",
"=",
"None",
")",
":",
"if",
"href",
":",
"element",
"=",
"fetch_json_by_href",
"(",
"href",
",",
"params",
"=",
"params",
")",
"if",
"element",
":",
"return",
"element"
] | Get specified element returned as an SMCResult object
:param href: href direct link to object
:return: :py:class:`smc.api.web.SMCResult` with etag, href and
element field holding json, else None | [
"Get",
"specified",
"element",
"returned",
"as",
"an",
"SMCResult",
"object"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L221-L231 | train |
gabstopper/smc-python | smc/actions/_search.py | element_as_smcresult_use_filter | def element_as_smcresult_use_filter(name, _filter):
""" Return SMCResult object and use search filter to
find object
:param name: name of element to find
:param _filter: filter to use, i.e. tcp_service, host, etc
:return: :py:class:`smc.api.web.SMCResult`
"""
if name:
element = fetc... | python | def element_as_smcresult_use_filter(name, _filter):
""" Return SMCResult object and use search filter to
find object
:param name: name of element to find
:param _filter: filter to use, i.e. tcp_service, host, etc
:return: :py:class:`smc.api.web.SMCResult`
"""
if name:
element = fetc... | [
"def",
"element_as_smcresult_use_filter",
"(",
"name",
",",
"_filter",
")",
":",
"if",
"name",
":",
"element",
"=",
"fetch_meta_by_name",
"(",
"name",
",",
"filter_context",
"=",
"_filter",
")",
"if",
"element",
".",
"msg",
":",
"return",
"element",
"if",
"e... | Return SMCResult object and use search filter to
find object
:param name: name of element to find
:param _filter: filter to use, i.e. tcp_service, host, etc
:return: :py:class:`smc.api.web.SMCResult` | [
"Return",
"SMCResult",
"object",
"and",
"use",
"search",
"filter",
"to",
"find",
"object"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L246-L259 | train |
gabstopper/smc-python | smc/actions/_search.py | element_href_by_batch | def element_href_by_batch(list_to_find, filter=None): # @ReservedAssignment
""" Find batch of entries by name. Reduces number of find calls from
calling class.
:param list list_to_find: list of names to find
:param filter: optional filter, i.e. 'tcp_service', 'host', etc
:return: list: {name: href... | python | def element_href_by_batch(list_to_find, filter=None): # @ReservedAssignment
""" Find batch of entries by name. Reduces number of find calls from
calling class.
:param list list_to_find: list of names to find
:param filter: optional filter, i.e. 'tcp_service', 'host', etc
:return: list: {name: href... | [
"def",
"element_href_by_batch",
"(",
"list_to_find",
",",
"filter",
"=",
"None",
")",
":",
"try",
":",
"if",
"filter",
":",
"return",
"[",
"{",
"k",
":",
"element_href_use_filter",
"(",
"k",
",",
"filter",
")",
"for",
"k",
"in",
"list_to_find",
"}",
"]",... | Find batch of entries by name. Reduces number of find calls from
calling class.
:param list list_to_find: list of names to find
:param filter: optional filter, i.e. 'tcp_service', 'host', etc
:return: list: {name: href, name: href}, href may be None if not found | [
"Find",
"batch",
"of",
"entries",
"by",
"name",
".",
"Reduces",
"number",
"of",
"find",
"calls",
"from",
"calling",
"class",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L262-L276 | train |
gabstopper/smc-python | smc/actions/_search.py | fetch_json_by_name | def fetch_json_by_name(name):
"""
Fetch json based on the element name
First gets the href based on a search by name, then makes a
second query to obtain the element json
:method: GET
:param str name: element name
:return: :py:class:`smc.api.web.SMCResult`
"""
result = fetch_meta_by... | python | def fetch_json_by_name(name):
"""
Fetch json based on the element name
First gets the href based on a search by name, then makes a
second query to obtain the element json
:method: GET
:param str name: element name
:return: :py:class:`smc.api.web.SMCResult`
"""
result = fetch_meta_by... | [
"def",
"fetch_json_by_name",
"(",
"name",
")",
":",
"result",
"=",
"fetch_meta_by_name",
"(",
"name",
")",
"if",
"result",
".",
"href",
":",
"result",
"=",
"fetch_json_by_href",
"(",
"result",
".",
"href",
")",
"return",
"result"
] | Fetch json based on the element name
First gets the href based on a search by name, then makes a
second query to obtain the element json
:method: GET
:param str name: element name
:return: :py:class:`smc.api.web.SMCResult` | [
"Fetch",
"json",
"based",
"on",
"the",
"element",
"name",
"First",
"gets",
"the",
"href",
"based",
"on",
"a",
"search",
"by",
"name",
"then",
"makes",
"a",
"second",
"query",
"to",
"obtain",
"the",
"element",
"json"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/actions/_search.py#L342-L355 | train |
gabstopper/smc-python | smc/vpn/elements.py | GatewaySettings.create | def create(cls, name, negotiation_expiration=200000,
negotiation_retry_timer=500,
negotiation_retry_max_number=32,
negotiation_retry_timer_max=7000,
certificate_cache_crl_validity=90000,
mobike_after_sa_update=False,
mobike_before... | python | def create(cls, name, negotiation_expiration=200000,
negotiation_retry_timer=500,
negotiation_retry_max_number=32,
negotiation_retry_timer_max=7000,
certificate_cache_crl_validity=90000,
mobike_after_sa_update=False,
mobike_before... | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"negotiation_expiration",
"=",
"200000",
",",
"negotiation_retry_timer",
"=",
"500",
",",
"negotiation_retry_max_number",
"=",
"32",
",",
"negotiation_retry_timer_max",
"=",
"7000",
",",
"certificate_cache_crl_validity",
... | Create a new gateway setting profile.
:param str name: name of profile
:param int negotiation_expiration: expire after (ms)
:param int negotiation_retry_timer: retry time length (ms)
:param int negotiation_retry_max_num: max number of retries allowed
:param int negotiation_retry... | [
"Create",
"a",
"new",
"gateway",
"setting",
"profile",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L65-L102 | train |
gabstopper/smc-python | smc/vpn/elements.py | ExternalGateway.create | def create(cls, name, trust_all_cas=True):
"""
Create new External Gateway
:param str name: name of test_external gateway
:param bool trust_all_cas: whether to trust all internal CA's
(default: True)
:return: instance with meta
:rtype: ExternalGateway
... | python | def create(cls, name, trust_all_cas=True):
"""
Create new External Gateway
:param str name: name of test_external gateway
:param bool trust_all_cas: whether to trust all internal CA's
(default: True)
:return: instance with meta
:rtype: ExternalGateway
... | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"trust_all_cas",
"=",
"True",
")",
":",
"json",
"=",
"{",
"'name'",
":",
"name",
",",
"'trust_all_cas'",
":",
"trust_all_cas",
"}",
"return",
"ElementCreator",
"(",
"cls",
",",
"json",
")"
] | Create new External Gateway
:param str name: name of test_external gateway
:param bool trust_all_cas: whether to trust all internal CA's
(default: True)
:return: instance with meta
:rtype: ExternalGateway | [
"Create",
"new",
"External",
"Gateway"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L136-L149 | train |
gabstopper/smc-python | smc/vpn/elements.py | ExternalEndpoint.create | def create(self, name, address=None, enabled=True, balancing_mode='active',
ipsec_vpn=True, nat_t=False, force_nat_t=False, dynamic=False,
ike_phase1_id_type=None, ike_phase1_id_value=None):
"""
Create an test_external endpoint. Define common settings for that
speci... | python | def create(self, name, address=None, enabled=True, balancing_mode='active',
ipsec_vpn=True, nat_t=False, force_nat_t=False, dynamic=False,
ike_phase1_id_type=None, ike_phase1_id_value=None):
"""
Create an test_external endpoint. Define common settings for that
speci... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"address",
"=",
"None",
",",
"enabled",
"=",
"True",
",",
"balancing_mode",
"=",
"'active'",
",",
"ipsec_vpn",
"=",
"True",
",",
"nat_t",
"=",
"False",
",",
"force_nat_t",
"=",
"False",
",",
"dynamic",
"=... | Create an test_external endpoint. Define common settings for that
specify the address, enabled, nat_t, name, etc. You can also omit
the IP address if the endpoint is dynamic. In that case, you must
also specify the ike_phase1 settings.
:param str name: name of test_external endpoint
... | [
"Create",
"an",
"test_external",
"endpoint",
".",
"Define",
"common",
"settings",
"for",
"that",
"specify",
"the",
"address",
"enabled",
"nat_t",
"name",
"etc",
".",
"You",
"can",
"also",
"omit",
"the",
"IP",
"address",
"if",
"the",
"endpoint",
"is",
"dynami... | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L273-L316 | train |
gabstopper/smc-python | smc/vpn/elements.py | ExternalEndpoint.enable_disable | def enable_disable(self):
"""
Enable or disable this endpoint. If enabled, it will be disabled
and vice versa.
:return: None
"""
if self.enabled:
self.data['enabled'] = False
else:
self.data['enabled'] = True
self.update() | python | def enable_disable(self):
"""
Enable or disable this endpoint. If enabled, it will be disabled
and vice versa.
:return: None
"""
if self.enabled:
self.data['enabled'] = False
else:
self.data['enabled'] = True
self.update() | [
"def",
"enable_disable",
"(",
"self",
")",
":",
"if",
"self",
".",
"enabled",
":",
"self",
".",
"data",
"[",
"'enabled'",
"]",
"=",
"False",
"else",
":",
"self",
".",
"data",
"[",
"'enabled'",
"]",
"=",
"True",
"self",
".",
"update",
"(",
")"
] | Enable or disable this endpoint. If enabled, it will be disabled
and vice versa.
:return: None | [
"Enable",
"or",
"disable",
"this",
"endpoint",
".",
"If",
"enabled",
"it",
"will",
"be",
"disabled",
"and",
"vice",
"versa",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L383-L394 | train |
gabstopper/smc-python | smc/vpn/elements.py | ExternalEndpoint.enable_disable_force_nat_t | def enable_disable_force_nat_t(self):
"""
Enable or disable NAT-T on this endpoint. If enabled, it will be
disabled and vice versa.
:return: None
"""
if self.force_nat_t:
self.data['force_nat_t'] = False
else:
self.data['force_nat_t'] = Tr... | python | def enable_disable_force_nat_t(self):
"""
Enable or disable NAT-T on this endpoint. If enabled, it will be
disabled and vice versa.
:return: None
"""
if self.force_nat_t:
self.data['force_nat_t'] = False
else:
self.data['force_nat_t'] = Tr... | [
"def",
"enable_disable_force_nat_t",
"(",
"self",
")",
":",
"if",
"self",
".",
"force_nat_t",
":",
"self",
".",
"data",
"[",
"'force_nat_t'",
"]",
"=",
"False",
"else",
":",
"self",
".",
"data",
"[",
"'force_nat_t'",
"]",
"=",
"True",
"self",
".",
"updat... | Enable or disable NAT-T on this endpoint. If enabled, it will be
disabled and vice versa.
:return: None | [
"Enable",
"or",
"disable",
"NAT",
"-",
"T",
"on",
"this",
"endpoint",
".",
"If",
"enabled",
"it",
"will",
"be",
"disabled",
"and",
"vice",
"versa",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L396-L407 | train |
gabstopper/smc-python | smc/vpn/elements.py | VPNSite.create | def create(self, name, site_element):
"""
Create a VPN site for an internal or external gateway
:param str name: name of site
:param list site_element: list of protected networks/hosts
:type site_element: list[str,Element]
:raises CreateElementFailed: create element fail... | python | def create(self, name, site_element):
"""
Create a VPN site for an internal or external gateway
:param str name: name of site
:param list site_element: list of protected networks/hosts
:type site_element: list[str,Element]
:raises CreateElementFailed: create element fail... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"site_element",
")",
":",
"site_element",
"=",
"element_resolver",
"(",
"site_element",
")",
"json",
"=",
"{",
"'name'",
":",
"name",
",",
"'site_element'",
":",
"site_element",
"}",
"return",
"ElementCreator",
... | Create a VPN site for an internal or external gateway
:param str name: name of site
:param list site_element: list of protected networks/hosts
:type site_element: list[str,Element]
:raises CreateElementFailed: create element failed with reason
:return: href of new element
... | [
"Create",
"a",
"VPN",
"site",
"for",
"an",
"internal",
"or",
"external",
"gateway"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L436-L455 | train |
gabstopper/smc-python | smc/vpn/elements.py | VPNSite.add_site_element | def add_site_element(self, element):
"""
Add a site element or list of elements to this VPN.
:param list element: list of Elements or href's of vpn site
elements
:type element: list(str,Network)
:raises UpdateElementFailed: fails due to reason
:return: None
... | python | def add_site_element(self, element):
"""
Add a site element or list of elements to this VPN.
:param list element: list of Elements or href's of vpn site
elements
:type element: list(str,Network)
:raises UpdateElementFailed: fails due to reason
:return: None
... | [
"def",
"add_site_element",
"(",
"self",
",",
"element",
")",
":",
"element",
"=",
"element_resolver",
"(",
"element",
")",
"self",
".",
"data",
"[",
"'site_element'",
"]",
".",
"extend",
"(",
"element",
")",
"self",
".",
"update",
"(",
")"
] | Add a site element or list of elements to this VPN.
:param list element: list of Elements or href's of vpn site
elements
:type element: list(str,Network)
:raises UpdateElementFailed: fails due to reason
:return: None | [
"Add",
"a",
"site",
"element",
"or",
"list",
"of",
"elements",
"to",
"this",
"VPN",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L514-L526 | train |
gabstopper/smc-python | smc/elements/helpers.py | location_helper | def location_helper(name, search_only=False):
"""
Location finder by name. If location doesn't exist, create it
and return the href
:param str,Element name: location to resolve. If the location is
by name, it will be retrieved or created, if href, returned
and if Location, href returned... | python | def location_helper(name, search_only=False):
"""
Location finder by name. If location doesn't exist, create it
and return the href
:param str,Element name: location to resolve. If the location is
by name, it will be retrieved or created, if href, returned
and if Location, href returned... | [
"def",
"location_helper",
"(",
"name",
",",
"search_only",
"=",
"False",
")",
":",
"try",
":",
"return",
"name",
".",
"href",
"except",
"AttributeError",
":",
"if",
"name",
"and",
"name",
".",
"startswith",
"(",
"'http'",
")",
":",
"return",
"name",
"exc... | Location finder by name. If location doesn't exist, create it
and return the href
:param str,Element name: location to resolve. If the location is
by name, it will be retrieved or created, if href, returned
and if Location, href returned. If None, settings an elements
location to None w... | [
"Location",
"finder",
"by",
"name",
".",
"If",
"location",
"doesn",
"t",
"exist",
"create",
"it",
"and",
"return",
"the",
"href"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/helpers.py#L12-L42 | train |
gabstopper/smc-python | smc/elements/helpers.py | zone_helper | def zone_helper(zone):
"""
Zone finder by name. If zone doesn't exist, create it and
return the href
:param str zone: name of zone (if href, will be returned as is)
:return str href: href of zone
"""
if zone is None:
return None
elif isinstance(zone, Zone):
return zone.h... | python | def zone_helper(zone):
"""
Zone finder by name. If zone doesn't exist, create it and
return the href
:param str zone: name of zone (if href, will be returned as is)
:return str href: href of zone
"""
if zone is None:
return None
elif isinstance(zone, Zone):
return zone.h... | [
"def",
"zone_helper",
"(",
"zone",
")",
":",
"if",
"zone",
"is",
"None",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"zone",
",",
"Zone",
")",
":",
"return",
"zone",
".",
"href",
"elif",
"zone",
".",
"startswith",
"(",
"'http'",
")",
":",
"retu... | Zone finder by name. If zone doesn't exist, create it and
return the href
:param str zone: name of zone (if href, will be returned as is)
:return str href: href of zone | [
"Zone",
"finder",
"by",
"name",
".",
"If",
"zone",
"doesn",
"t",
"exist",
"create",
"it",
"and",
"return",
"the",
"href"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/helpers.py#L45-L59 | train |
gabstopper/smc-python | smc/elements/helpers.py | logical_intf_helper | def logical_intf_helper(interface):
"""
Logical Interface finder by name. Create if it doesn't exist.
This is useful when adding logical interfaces to for inline
or capture interfaces.
:param interface: logical interface name
:return str href: href of logical interface
"""
if interface ... | python | def logical_intf_helper(interface):
"""
Logical Interface finder by name. Create if it doesn't exist.
This is useful when adding logical interfaces to for inline
or capture interfaces.
:param interface: logical interface name
:return str href: href of logical interface
"""
if interface ... | [
"def",
"logical_intf_helper",
"(",
"interface",
")",
":",
"if",
"interface",
"is",
"None",
":",
"return",
"LogicalInterface",
".",
"get_or_create",
"(",
"name",
"=",
"'default_eth'",
")",
".",
"href",
"elif",
"isinstance",
"(",
"interface",
",",
"LogicalInterfac... | Logical Interface finder by name. Create if it doesn't exist.
This is useful when adding logical interfaces to for inline
or capture interfaces.
:param interface: logical interface name
:return str href: href of logical interface | [
"Logical",
"Interface",
"finder",
"by",
"name",
".",
"Create",
"if",
"it",
"doesn",
"t",
"exist",
".",
"This",
"is",
"useful",
"when",
"adding",
"logical",
"interfaces",
"to",
"for",
"inline",
"or",
"capture",
"interfaces",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/helpers.py#L62-L77 | train |
gabstopper/smc-python | smc/elements/user.py | UserMixin.change_password | def change_password(self, password):
"""
Change user password. Change is committed immediately.
:param str password: new password
:return: None
"""
self.make_request(
ModificationFailed,
method='update',
resource='change_password',
... | python | def change_password(self, password):
"""
Change user password. Change is committed immediately.
:param str password: new password
:return: None
"""
self.make_request(
ModificationFailed,
method='update',
resource='change_password',
... | [
"def",
"change_password",
"(",
"self",
",",
"password",
")",
":",
"self",
".",
"make_request",
"(",
"ModificationFailed",
",",
"method",
"=",
"'update'",
",",
"resource",
"=",
"'change_password'",
",",
"params",
"=",
"{",
"'password'",
":",
"password",
"}",
... | Change user password. Change is committed immediately.
:param str password: new password
:return: None | [
"Change",
"user",
"password",
".",
"Change",
"is",
"committed",
"immediately",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/user.py#L71-L82 | train |
gabstopper/smc-python | smc/elements/user.py | AdminUser.change_engine_password | def change_engine_password(self, password):
""" Change Engine password for engines on allowed
list.
:param str password: password for engine level
:raises ModificationFailed: failed setting password on engine
:return: None
"""
self.make_request(
Modif... | python | def change_engine_password(self, password):
""" Change Engine password for engines on allowed
list.
:param str password: password for engine level
:raises ModificationFailed: failed setting password on engine
:return: None
"""
self.make_request(
Modif... | [
"def",
"change_engine_password",
"(",
"self",
",",
"password",
")",
":",
"self",
".",
"make_request",
"(",
"ModificationFailed",
",",
"method",
"=",
"'update'",
",",
"resource",
"=",
"'change_engine_password'",
",",
"params",
"=",
"{",
"'password'",
":",
"passwo... | Change Engine password for engines on allowed
list.
:param str password: password for engine level
:raises ModificationFailed: failed setting password on engine
:return: None | [
"Change",
"Engine",
"password",
"for",
"engines",
"on",
"allowed",
"list",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/user.py#L212-L224 | train |
gabstopper/smc-python | smc/core/engine.py | Engine.location | def location(self):
"""
The location for this engine. May be None if no specific
location has been assigned.
:param value: location to assign engine. Can be name, str href,
or Location element. If name, it will be automatically created
if a Location with the same... | python | def location(self):
"""
The location for this engine. May be None if no specific
location has been assigned.
:param value: location to assign engine. Can be name, str href,
or Location element. If name, it will be automatically created
if a Location with the same... | [
"def",
"location",
"(",
"self",
")",
":",
"location",
"=",
"Element",
".",
"from_href",
"(",
"self",
".",
"location_ref",
")",
"if",
"location",
"and",
"location",
".",
"name",
"==",
"'Default'",
":",
"return",
"None",
"return",
"location"
] | The location for this engine. May be None if no specific
location has been assigned.
:param value: location to assign engine. Can be name, str href,
or Location element. If name, it will be automatically created
if a Location with the same name doesn't exist.
:raises Upd... | [
"The",
"location",
"for",
"this",
"engine",
".",
"May",
"be",
"None",
"if",
"no",
"specific",
"location",
"has",
"been",
"assigned",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/engine.py#L208-L222 | train |
gabstopper/smc-python | smc/core/engine.py | Engine.pending_changes | def pending_changes(self):
"""
Pending changes provides insight into changes on an engine that are
pending approval or disapproval. Feature requires SMC >= v6.2.
:raises UnsupportedEngineFeature: SMC version >= 6.2 is required to
support pending changes
:rtype: Pendi... | python | def pending_changes(self):
"""
Pending changes provides insight into changes on an engine that are
pending approval or disapproval. Feature requires SMC >= v6.2.
:raises UnsupportedEngineFeature: SMC version >= 6.2 is required to
support pending changes
:rtype: Pendi... | [
"def",
"pending_changes",
"(",
"self",
")",
":",
"if",
"'pending_changes'",
"in",
"self",
".",
"data",
".",
"links",
":",
"return",
"PendingChanges",
"(",
"self",
")",
"raise",
"UnsupportedEngineFeature",
"(",
"'Pending changes is an unsupported feature on this engine: ... | Pending changes provides insight into changes on an engine that are
pending approval or disapproval. Feature requires SMC >= v6.2.
:raises UnsupportedEngineFeature: SMC version >= 6.2 is required to
support pending changes
:rtype: PendingChanges | [
"Pending",
"changes",
"provides",
"insight",
"into",
"changes",
"on",
"an",
"engine",
"that",
"are",
"pending",
"approval",
"or",
"disapproval",
".",
"Feature",
"requires",
"SMC",
">",
"=",
"v6",
".",
"2",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/engine.py#L496-L509 | train |
gabstopper/smc-python | smc/core/engine.py | Engine.virtual_resource | def virtual_resource(self):
"""
Available on a Master Engine only.
To get all virtual resources call::
engine.virtual_resource.all()
:raises UnsupportedEngineFeature: master engine only
:rtype: CreateCollection(VirtualResource)
"""
resource = create... | python | def virtual_resource(self):
"""
Available on a Master Engine only.
To get all virtual resources call::
engine.virtual_resource.all()
:raises UnsupportedEngineFeature: master engine only
:rtype: CreateCollection(VirtualResource)
"""
resource = create... | [
"def",
"virtual_resource",
"(",
"self",
")",
":",
"resource",
"=",
"create_collection",
"(",
"self",
".",
"get_relation",
"(",
"'virtual_resources'",
",",
"UnsupportedEngineFeature",
")",
",",
"VirtualResource",
")",
"resource",
".",
"_load_from_engine",
"(",
"self"... | Available on a Master Engine only.
To get all virtual resources call::
engine.virtual_resource.all()
:raises UnsupportedEngineFeature: master engine only
:rtype: CreateCollection(VirtualResource) | [
"Available",
"on",
"a",
"Master",
"Engine",
"only",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/engine.py#L784-L801 | train |
gabstopper/smc-python | smc/core/engine.py | Engine.generate_snapshot | def generate_snapshot(self, filename='snapshot.zip'):
"""
Generate and retrieve a policy snapshot from the engine
This is blocking as file is downloaded
:param str filename: name of file to save file to, including directory
path
:raises EngineCommandFailed: snapshot ... | python | def generate_snapshot(self, filename='snapshot.zip'):
"""
Generate and retrieve a policy snapshot from the engine
This is blocking as file is downloaded
:param str filename: name of file to save file to, including directory
path
:raises EngineCommandFailed: snapshot ... | [
"def",
"generate_snapshot",
"(",
"self",
",",
"filename",
"=",
"'snapshot.zip'",
")",
":",
"try",
":",
"self",
".",
"make_request",
"(",
"EngineCommandFailed",
",",
"resource",
"=",
"'generate_snapshot'",
",",
"filename",
"=",
"filename",
")",
"except",
"IOError... | Generate and retrieve a policy snapshot from the engine
This is blocking as file is downloaded
:param str filename: name of file to save file to, including directory
path
:raises EngineCommandFailed: snapshot failed, possibly invalid filename
specified
:return: N... | [
"Generate",
"and",
"retrieve",
"a",
"policy",
"snapshot",
"from",
"the",
"engine",
"This",
"is",
"blocking",
"as",
"file",
"is",
"downloaded"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/engine.py#L1050-L1069 | train |
gabstopper/smc-python | smc/core/engine.py | VPN.generate_certificate | def generate_certificate(self, common_name, public_key_algorithm='rsa',
signature_algorithm='rsa_sha_512', key_length=2048,
signing_ca=None):
"""
Generate an internal gateway certificate used for VPN on this engine.
Certificate request should be an instance of VPNCertific... | python | def generate_certificate(self, common_name, public_key_algorithm='rsa',
signature_algorithm='rsa_sha_512', key_length=2048,
signing_ca=None):
"""
Generate an internal gateway certificate used for VPN on this engine.
Certificate request should be an instance of VPNCertific... | [
"def",
"generate_certificate",
"(",
"self",
",",
"common_name",
",",
"public_key_algorithm",
"=",
"'rsa'",
",",
"signature_algorithm",
"=",
"'rsa_sha_512'",
",",
"key_length",
"=",
"2048",
",",
"signing_ca",
"=",
"None",
")",
":",
"return",
"GatewayCertificate",
"... | Generate an internal gateway certificate used for VPN on this engine.
Certificate request should be an instance of VPNCertificate.
:param: str common_name: common name for certificate
:param str public_key_algorithm: public key type to use. Valid values
rsa, dsa, ecdsa.
:par... | [
"Generate",
"an",
"internal",
"gateway",
"certificate",
"used",
"for",
"VPN",
"on",
"this",
"engine",
".",
"Certificate",
"request",
"should",
"be",
"an",
"instance",
"of",
"VPNCertificate",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/engine.py#L1334-L1357 | train |
gabstopper/smc-python | smc/core/general.py | DNSRelay.enable | def enable(self, interface_id, dns_relay_profile=None):
"""
Enable the DNS Relay service on this engine.
:param int interface_id: interface id to enable relay
:param str,DNSRelayProfile dns_relay_profile: DNSRelayProfile element
or str href
:raises EngineCommandFaile... | python | def enable(self, interface_id, dns_relay_profile=None):
"""
Enable the DNS Relay service on this engine.
:param int interface_id: interface id to enable relay
:param str,DNSRelayProfile dns_relay_profile: DNSRelayProfile element
or str href
:raises EngineCommandFaile... | [
"def",
"enable",
"(",
"self",
",",
"interface_id",
",",
"dns_relay_profile",
"=",
"None",
")",
":",
"if",
"not",
"dns_relay_profile",
":",
"href",
"=",
"DNSRelayProfile",
"(",
"'Cache Only'",
")",
".",
"href",
"else",
":",
"href",
"=",
"element_resolver",
"(... | Enable the DNS Relay service on this engine.
:param int interface_id: interface id to enable relay
:param str,DNSRelayProfile dns_relay_profile: DNSRelayProfile element
or str href
:raises EngineCommandFailed: interface not found
:raises ElementNotFound: profile not found
... | [
"Enable",
"the",
"DNS",
"Relay",
"service",
"on",
"this",
"engine",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/general.py#L162-L181 | train |
gabstopper/smc-python | smc/policy/ips.py | IPSPolicy.create | def create(cls, name, template='High-Security IPS Template'):
"""
Create an IPS Policy
:param str name: Name of policy
:param str template: name of template
:raises CreatePolicyFailed: policy failed to create
:return: IPSPolicy
"""
try:
if cls... | python | def create(cls, name, template='High-Security IPS Template'):
"""
Create an IPS Policy
:param str name: Name of policy
:param str template: name of template
:raises CreatePolicyFailed: policy failed to create
:return: IPSPolicy
"""
try:
if cls... | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"template",
"=",
"'High-Security IPS Template'",
")",
":",
"try",
":",
"if",
"cls",
".",
"typeof",
"==",
"'ips_template_policy'",
"and",
"template",
"is",
"None",
":",
"fw_template",
"=",
"None",
"else",
":",
... | Create an IPS Policy
:param str name: Name of policy
:param str template: name of template
:raises CreatePolicyFailed: policy failed to create
:return: IPSPolicy | [
"Create",
"an",
"IPS",
"Policy"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/policy/ips.py#L98-L121 | train |
gabstopper/smc-python | smc/examples/ip_lists.py | upload_as_zip | def upload_as_zip(name, filename):
"""
Upload an IPList as a zip file. Useful when IPList is very large.
This is the default upload format for IPLists.
:param str name: name of IPList
:param str filename: name of zip file to upload, full path
:return: None
"""
location = list(IPList.obj... | python | def upload_as_zip(name, filename):
"""
Upload an IPList as a zip file. Useful when IPList is very large.
This is the default upload format for IPLists.
:param str name: name of IPList
:param str filename: name of zip file to upload, full path
:return: None
"""
location = list(IPList.obj... | [
"def",
"upload_as_zip",
"(",
"name",
",",
"filename",
")",
":",
"location",
"=",
"list",
"(",
"IPList",
".",
"objects",
".",
"filter",
"(",
"name",
")",
")",
"if",
"location",
":",
"iplist",
"=",
"location",
"[",
"0",
"]",
"return",
"iplist",
".",
"u... | Upload an IPList as a zip file. Useful when IPList is very large.
This is the default upload format for IPLists.
:param str name: name of IPList
:param str filename: name of zip file to upload, full path
:return: None | [
"Upload",
"an",
"IPList",
"as",
"a",
"zip",
"file",
".",
"Useful",
"when",
"IPList",
"is",
"very",
"large",
".",
"This",
"is",
"the",
"default",
"upload",
"format",
"for",
"IPLists",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/examples/ip_lists.py#L42-L54 | train |
gabstopper/smc-python | smc/examples/ip_lists.py | upload_as_text | def upload_as_text(name, filename):
"""
Upload the IPList as text from a file.
:param str name: name of IPList
:param str filename: name of text file to upload
:return: None
"""
location = list(IPList.objects.filter(name))
if location:
iplist = location[0]
return iplist... | python | def upload_as_text(name, filename):
"""
Upload the IPList as text from a file.
:param str name: name of IPList
:param str filename: name of text file to upload
:return: None
"""
location = list(IPList.objects.filter(name))
if location:
iplist = location[0]
return iplist... | [
"def",
"upload_as_text",
"(",
"name",
",",
"filename",
")",
":",
"location",
"=",
"list",
"(",
"IPList",
".",
"objects",
".",
"filter",
"(",
"name",
")",
")",
"if",
"location",
":",
"iplist",
"=",
"location",
"[",
"0",
"]",
"return",
"iplist",
".",
"... | Upload the IPList as text from a file.
:param str name: name of IPList
:param str filename: name of text file to upload
:return: None | [
"Upload",
"the",
"IPList",
"as",
"text",
"from",
"a",
"file",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/examples/ip_lists.py#L57-L68 | train |
gabstopper/smc-python | smc/examples/ip_lists.py | upload_as_json | def upload_as_json(name, mylist):
"""
Upload the IPList as json payload.
:param str name: name of IPList
:param list: list of IPList entries
:return: None
"""
location = list(IPList.objects.filter(name))
if location:
iplist = location[0]
return iplist.upload(json=mylist... | python | def upload_as_json(name, mylist):
"""
Upload the IPList as json payload.
:param str name: name of IPList
:param list: list of IPList entries
:return: None
"""
location = list(IPList.objects.filter(name))
if location:
iplist = location[0]
return iplist.upload(json=mylist... | [
"def",
"upload_as_json",
"(",
"name",
",",
"mylist",
")",
":",
"location",
"=",
"list",
"(",
"IPList",
".",
"objects",
".",
"filter",
"(",
"name",
")",
")",
"if",
"location",
":",
"iplist",
"=",
"location",
"[",
"0",
"]",
"return",
"iplist",
".",
"up... | Upload the IPList as json payload.
:param str name: name of IPList
:param list: list of IPList entries
:return: None | [
"Upload",
"the",
"IPList",
"as",
"json",
"payload",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/examples/ip_lists.py#L71-L82 | train |
gabstopper/smc-python | smc/examples/ip_lists.py | download_as_zip | def download_as_zip(name, filename):
"""
Download IPList with zip compression. Recommended for IPLists
of larger sizes. This is the default format for downloading
IPLists.
:param str name: name of IPList
:param str filename: name of filename for IPList
"""
location = list(IPList.objects... | python | def download_as_zip(name, filename):
"""
Download IPList with zip compression. Recommended for IPLists
of larger sizes. This is the default format for downloading
IPLists.
:param str name: name of IPList
:param str filename: name of filename for IPList
"""
location = list(IPList.objects... | [
"def",
"download_as_zip",
"(",
"name",
",",
"filename",
")",
":",
"location",
"=",
"list",
"(",
"IPList",
".",
"objects",
".",
"filter",
"(",
"name",
")",
")",
"if",
"location",
":",
"iplist",
"=",
"location",
"[",
"0",
"]",
"return",
"iplist",
".",
... | Download IPList with zip compression. Recommended for IPLists
of larger sizes. This is the default format for downloading
IPLists.
:param str name: name of IPList
:param str filename: name of filename for IPList | [
"Download",
"IPList",
"with",
"zip",
"compression",
".",
"Recommended",
"for",
"IPLists",
"of",
"larger",
"sizes",
".",
"This",
"is",
"the",
"default",
"format",
"for",
"downloading",
"IPLists",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/examples/ip_lists.py#L85-L97 | train |
gabstopper/smc-python | smc/examples/ip_lists.py | download_as_text | def download_as_text(name, filename):
"""
Download IPList as text to specified filename.
:param str name: name of IPList
:param str filename: name of file for IPList download
"""
location = list(IPList.objects.filter(name))
if location:
iplist = location[0]
return iplist.dow... | python | def download_as_text(name, filename):
"""
Download IPList as text to specified filename.
:param str name: name of IPList
:param str filename: name of file for IPList download
"""
location = list(IPList.objects.filter(name))
if location:
iplist = location[0]
return iplist.dow... | [
"def",
"download_as_text",
"(",
"name",
",",
"filename",
")",
":",
"location",
"=",
"list",
"(",
"IPList",
".",
"objects",
".",
"filter",
"(",
"name",
")",
")",
"if",
"location",
":",
"iplist",
"=",
"location",
"[",
"0",
"]",
"return",
"iplist",
".",
... | Download IPList as text to specified filename.
:param str name: name of IPList
:param str filename: name of file for IPList download | [
"Download",
"IPList",
"as",
"text",
"to",
"specified",
"filename",
"."
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/examples/ip_lists.py#L100-L110 | train |
gabstopper/smc-python | smc/examples/ip_lists.py | download_as_json | def download_as_json(name):
"""
Download IPList as json. This would allow for easily
manipulation of the IPList, but generally recommended only for
smaller lists
:param str name: name of IPList
:return: None
"""
location = list(IPList.objects.filter(name))
if location:
ipli... | python | def download_as_json(name):
"""
Download IPList as json. This would allow for easily
manipulation of the IPList, but generally recommended only for
smaller lists
:param str name: name of IPList
:return: None
"""
location = list(IPList.objects.filter(name))
if location:
ipli... | [
"def",
"download_as_json",
"(",
"name",
")",
":",
"location",
"=",
"list",
"(",
"IPList",
".",
"objects",
".",
"filter",
"(",
"name",
")",
")",
"if",
"location",
":",
"iplist",
"=",
"location",
"[",
"0",
"]",
"return",
"iplist",
".",
"download",
"(",
... | Download IPList as json. This would allow for easily
manipulation of the IPList, but generally recommended only for
smaller lists
:param str name: name of IPList
:return: None | [
"Download",
"IPList",
"as",
"json",
".",
"This",
"would",
"allow",
"for",
"easily",
"manipulation",
"of",
"the",
"IPList",
"but",
"generally",
"recommended",
"only",
"for",
"smaller",
"lists"
] | e027b8a5dcfaf884eada32d113d41c1e56b32457 | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/examples/ip_lists.py#L113-L125 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.