repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
mandiant/ioc_writer | ioc_writer/ioc_api.py | write_ioc | def write_ioc(root, output_dir=None, force=False):
"""
Serialize an IOC, as defined by a set of etree Elements, to a .IOC file.
:param root: etree Element to write out. Should have the tag 'OpenIOC'
:param output_dir: Directory to write the ioc out to. default is current working directory.
:param... | python | def write_ioc(root, output_dir=None, force=False):
"""
Serialize an IOC, as defined by a set of etree Elements, to a .IOC file.
:param root: etree Element to write out. Should have the tag 'OpenIOC'
:param output_dir: Directory to write the ioc out to. default is current working directory.
:param... | [
"def",
"write_ioc",
"(",
"root",
",",
"output_dir",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"root_tag",
"=",
"'OpenIOC'",
"if",
"not",
"force",
"and",
"root",
".",
"tag",
"!=",
"root_tag",
":",
"raise",
"ValueError",
"(",
"'Root tag is not \"{}\... | Serialize an IOC, as defined by a set of etree Elements, to a .IOC file.
:param root: etree Element to write out. Should have the tag 'OpenIOC'
:param output_dir: Directory to write the ioc out to. default is current working directory.
:param force: If set, skip the root node tag check.
:return: True... | [
"Serialize",
"an",
"IOC",
"as",
"defined",
"by",
"a",
"set",
"of",
"etree",
"Elements",
"to",
"a",
".",
"IOC",
"file",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L885-L919 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | write_ioc_string | def write_ioc_string(root, force=False):
"""
Serialize an IOC, as defined by a set of etree Elements, to a String.
:param root: etree Element to serialize. Should have the tag 'OpenIOC'
:param force: Skip the root node tag check.
:return:
"""
root_tag = 'OpenIOC'
if not force and root.t... | python | def write_ioc_string(root, force=False):
"""
Serialize an IOC, as defined by a set of etree Elements, to a String.
:param root: etree Element to serialize. Should have the tag 'OpenIOC'
:param force: Skip the root node tag check.
:return:
"""
root_tag = 'OpenIOC'
if not force and root.t... | [
"def",
"write_ioc_string",
"(",
"root",
",",
"force",
"=",
"False",
")",
":",
"root_tag",
"=",
"'OpenIOC'",
"if",
"not",
"force",
"and",
"root",
".",
"tag",
"!=",
"root_tag",
":",
"raise",
"ValueError",
"(",
"'Root tag is not \"{}\".'",
".",
"format",
"(",
... | Serialize an IOC, as defined by a set of etree Elements, to a String.
:param root: etree Element to serialize. Should have the tag 'OpenIOC'
:param force: Skip the root node tag check.
:return: | [
"Serialize",
"an",
"IOC",
"as",
"defined",
"by",
"a",
"set",
"of",
"etree",
"Elements",
"to",
"a",
"String",
".",
":",
"param",
"root",
":",
"etree",
"Element",
"to",
"serialize",
".",
"Should",
"have",
"the",
"tag",
"OpenIOC",
":",
"param",
"force",
"... | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L922-L940 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.open_ioc | def open_ioc(fn):
"""
Opens an IOC file, or XML string. Returns the root element, top level
indicator element, and parameters element. If the IOC or string fails
to parse, an IOCParseError is raised.
This is a helper function used by __init__.
:param fn: This is a pat... | python | def open_ioc(fn):
"""
Opens an IOC file, or XML string. Returns the root element, top level
indicator element, and parameters element. If the IOC or string fails
to parse, an IOCParseError is raised.
This is a helper function used by __init__.
:param fn: This is a pat... | [
"def",
"open_ioc",
"(",
"fn",
")",
":",
"parsed_xml",
"=",
"xmlutils",
".",
"read_xml_no_ns",
"(",
"fn",
")",
"if",
"not",
"parsed_xml",
":",
"raise",
"IOCParseError",
"(",
"'Error occured parsing XML'",
")",
"root",
"=",
"parsed_xml",
".",
"getroot",
"(",
"... | Opens an IOC file, or XML string. Returns the root element, top level
indicator element, and parameters element. If the IOC or string fails
to parse, an IOCParseError is raised.
This is a helper function used by __init__.
:param fn: This is a path to a file to open, or a string conta... | [
"Opens",
"an",
"IOC",
"file",
"or",
"XML",
"string",
".",
"Returns",
"the",
"root",
"element",
"top",
"level",
"indicator",
"element",
"and",
"parameters",
"element",
".",
"If",
"the",
"IOC",
"or",
"string",
"fails",
"to",
"parse",
"an",
"IOCParseError",
"... | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L108-L135 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.make_ioc | def make_ioc(name=None,
description='Automatically generated IOC',
author='IOC_api',
links=None,
keywords=None,
iocid=None):
"""
This generates all parts of an IOC, but without any definition.
This is a helper ... | python | def make_ioc(name=None,
description='Automatically generated IOC',
author='IOC_api',
links=None,
keywords=None,
iocid=None):
"""
This generates all parts of an IOC, but without any definition.
This is a helper ... | [
"def",
"make_ioc",
"(",
"name",
"=",
"None",
",",
"description",
"=",
"'Automatically generated IOC'",
",",
"author",
"=",
"'IOC_api'",
",",
"links",
"=",
"None",
",",
"keywords",
"=",
"None",
",",
"iocid",
"=",
"None",
")",
":",
"root",
"=",
"ioc_et",
"... | This generates all parts of an IOC, but without any definition.
This is a helper function used by __init__.
:param name: string, Name of the ioc
:param description: string, description of the ioc
:param author: string, author name/email address
:param links: ist of tuples. Eac... | [
"This",
"generates",
"all",
"parts",
"of",
"an",
"IOC",
"but",
"without",
"any",
"definition",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L138-L170 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.set_lastmodified_date | def set_lastmodified_date(self, date=None):
"""
Set the last modified date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the last modified date to. This should be in the xsdDate form.
This defaults to the curre... | python | def set_lastmodified_date(self, date=None):
"""
Set the last modified date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the last modified date to. This should be in the xsdDate form.
This defaults to the curre... | [
"def",
"set_lastmodified_date",
"(",
"self",
",",
"date",
"=",
"None",
")",
":",
"if",
"date",
":",
"match",
"=",
"re",
".",
"match",
"(",
"DATE_REGEX",
",",
"date",
")",
"if",
"not",
"match",
":",
"raise",
"IOCParseError",
"(",
"'last-modified date is not... | Set the last modified date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the last modified date to. This should be in the xsdDate form.
This defaults to the current date if it is not provided.
xsdDate Form: YYYY-MM-DD... | [
"Set",
"the",
"last",
"modified",
"date",
"of",
"a",
"IOC",
"to",
"the",
"current",
"date",
".",
"User",
"may",
"specify",
"the",
"date",
"they",
"want",
"to",
"set",
"as",
"well",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L172-L188 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.set_published_date | def set_published_date(self, date=None):
"""
Set the published date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the published date to. This should be in the xsdDate form.
This defaults to the current date if ... | python | def set_published_date(self, date=None):
"""
Set the published date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the published date to. This should be in the xsdDate form.
This defaults to the current date if ... | [
"def",
"set_published_date",
"(",
"self",
",",
"date",
"=",
"None",
")",
":",
"if",
"date",
":",
"match",
"=",
"re",
".",
"match",
"(",
"DATE_REGEX",
",",
"date",
")",
"if",
"not",
"match",
":",
"raise",
"IOCParseError",
"(",
"'Published date is not valid.... | Set the published date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the published date to. This should be in the xsdDate form.
This defaults to the current date if it is not provided.
xsdDate Form: YYYY-MM-DDTHH:MM:S... | [
"Set",
"the",
"published",
"date",
"of",
"a",
"IOC",
"to",
"the",
"current",
"date",
".",
"User",
"may",
"specify",
"the",
"date",
"they",
"want",
"to",
"set",
"as",
"well",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L190-L206 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.set_created_date | def set_created_date(self, date=None):
"""
Set the created date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the created date to. This should be in the xsdDate form.
This defaults to the current date if it is ... | python | def set_created_date(self, date=None):
"""
Set the created date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the created date to. This should be in the xsdDate form.
This defaults to the current date if it is ... | [
"def",
"set_created_date",
"(",
"self",
",",
"date",
"=",
"None",
")",
":",
"if",
"date",
":",
"match",
"=",
"re",
".",
"match",
"(",
"DATE_REGEX",
",",
"date",
")",
"if",
"not",
"match",
":",
"raise",
"IOCParseError",
"(",
"'Created date is not valid. Mu... | Set the created date of a IOC to the current date.
User may specify the date they want to set as well.
:param date: Date value to set the created date to. This should be in the xsdDate form.
This defaults to the current date if it is not provided.
xsdDate form: YYYY-MM-DDTHH:MM:SS
... | [
"Set",
"the",
"created",
"date",
"of",
"a",
"IOC",
"to",
"the",
"current",
"date",
".",
"User",
"may",
"specify",
"the",
"date",
"they",
"want",
"to",
"set",
"as",
"well",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L208-L225 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.add_parameter | def add_parameter(self, indicator_id, content, name='comment', ptype='string'):
"""
Add a a parameter to the IOC.
:param indicator_id: The unique Indicator/IndicatorItem id the parameter is associated with.
:param content: The value of the parameter.
:param name: The name of the... | python | def add_parameter(self, indicator_id, content, name='comment', ptype='string'):
"""
Add a a parameter to the IOC.
:param indicator_id: The unique Indicator/IndicatorItem id the parameter is associated with.
:param content: The value of the parameter.
:param name: The name of the... | [
"def",
"add_parameter",
"(",
"self",
",",
"indicator_id",
",",
"content",
",",
"name",
"=",
"'comment'",
",",
"ptype",
"=",
"'string'",
")",
":",
"parameters_node",
"=",
"self",
".",
"parameters",
"criteria_node",
"=",
"self",
".",
"top_level_indicator",
".",
... | Add a a parameter to the IOC.
:param indicator_id: The unique Indicator/IndicatorItem id the parameter is associated with.
:param content: The value of the parameter.
:param name: The name of the parameter.
:param ptype: The type of the parameter content.
:return: True
:... | [
"Add",
"a",
"a",
"parameter",
"to",
"the",
"IOC",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L227-L251 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.add_link | def add_link(self, rel, value, href=None):
"""
Add a Link metadata element to the IOC.
:param rel: Type of the link.
:param value: Value of the link text.
:param href: A href value assigned to the link.
:return: True
"""
links_node = self.metadata.find('l... | python | def add_link(self, rel, value, href=None):
"""
Add a Link metadata element to the IOC.
:param rel: Type of the link.
:param value: Value of the link text.
:param href: A href value assigned to the link.
:return: True
"""
links_node = self.metadata.find('l... | [
"def",
"add_link",
"(",
"self",
",",
"rel",
",",
"value",
",",
"href",
"=",
"None",
")",
":",
"links_node",
"=",
"self",
".",
"metadata",
".",
"find",
"(",
"'links'",
")",
"if",
"links_node",
"is",
"None",
":",
"links_node",
"=",
"ioc_et",
".",
"make... | Add a Link metadata element to the IOC.
:param rel: Type of the link.
:param value: Value of the link text.
:param href: A href value assigned to the link.
:return: True | [
"Add",
"a",
"Link",
"metadata",
"element",
"to",
"the",
"IOC",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L253-L268 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.update_name | def update_name(self, name):
"""
Update the name (short description) of an IOC
This creates the short description node if it is not present.
:param name: Value to set the short description too
:return:
"""
short_desc_node = self.metadata.find('short_description'... | python | def update_name(self, name):
"""
Update the name (short description) of an IOC
This creates the short description node if it is not present.
:param name: Value to set the short description too
:return:
"""
short_desc_node = self.metadata.find('short_description'... | [
"def",
"update_name",
"(",
"self",
",",
"name",
")",
":",
"short_desc_node",
"=",
"self",
".",
"metadata",
".",
"find",
"(",
"'short_description'",
")",
"if",
"short_desc_node",
"is",
"None",
":",
"log",
".",
"debug",
"(",
"'Could not find short description node... | Update the name (short description) of an IOC
This creates the short description node if it is not present.
:param name: Value to set the short description too
:return: | [
"Update",
"the",
"name",
"(",
"short",
"description",
")",
"of",
"an",
"IOC"
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L270-L287 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.update_description | def update_description(self, description):
"""
Update the description) of an IOC
This creates the description node if it is not present.
:param description: Value to set the description too
:return: True
"""
desc_node = self.metadata.find('description')
i... | python | def update_description(self, description):
"""
Update the description) of an IOC
This creates the description node if it is not present.
:param description: Value to set the description too
:return: True
"""
desc_node = self.metadata.find('description')
i... | [
"def",
"update_description",
"(",
"self",
",",
"description",
")",
":",
"desc_node",
"=",
"self",
".",
"metadata",
".",
"find",
"(",
"'description'",
")",
"if",
"desc_node",
"is",
"None",
":",
"log",
".",
"debug",
"(",
"'Could not find short description node for... | Update the description) of an IOC
This creates the description node if it is not present.
:param description: Value to set the description too
:return: True | [
"Update",
"the",
"description",
")",
"of",
"an",
"IOC"
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L289-L311 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.update_link_rel_based | def update_link_rel_based(self, old_rel, new_rel=None, new_text=None, single_link=False):
"""
Update link nodes, based on the existing link/@rel values.
This requires specifying a link/@rel value to update, and either a new
link/@rel value, or a new link/text() value for all links which... | python | def update_link_rel_based(self, old_rel, new_rel=None, new_text=None, single_link=False):
"""
Update link nodes, based on the existing link/@rel values.
This requires specifying a link/@rel value to update, and either a new
link/@rel value, or a new link/text() value for all links which... | [
"def",
"update_link_rel_based",
"(",
"self",
",",
"old_rel",
",",
"new_rel",
"=",
"None",
",",
"new_text",
"=",
"None",
",",
"single_link",
"=",
"False",
")",
":",
"links",
"=",
"self",
".",
"metadata",
".",
"xpath",
"(",
"'./links/link[@rel=\"{}\"]'",
".",
... | Update link nodes, based on the existing link/@rel values.
This requires specifying a link/@rel value to update, and either a new
link/@rel value, or a new link/text() value for all links which match
the link/@rel value. Optionally, only the first link which matches the
link/@rel value... | [
"Update",
"link",
"nodes",
"based",
"on",
"the",
"existing",
"link",
"/",
"@rel",
"values",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L313-L350 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.update_link_rewrite | def update_link_rewrite(self, old_rel, old_text, new_text, single_link=False):
"""
Rewrite the text() value of a link based on the link/@rel and link/text() value.
This is similar to update_link_rel_based but users link/@rel AND link/text() values
to determine which links have their lin... | python | def update_link_rewrite(self, old_rel, old_text, new_text, single_link=False):
"""
Rewrite the text() value of a link based on the link/@rel and link/text() value.
This is similar to update_link_rel_based but users link/@rel AND link/text() values
to determine which links have their lin... | [
"def",
"update_link_rewrite",
"(",
"self",
",",
"old_rel",
",",
"old_text",
",",
"new_text",
",",
"single_link",
"=",
"False",
")",
":",
"links",
"=",
"self",
".",
"metadata",
".",
"xpath",
"(",
"'./links/link[@rel=\"{}\" and text()=\"{}\"]'",
".",
"format",
"("... | Rewrite the text() value of a link based on the link/@rel and link/text() value.
This is similar to update_link_rel_based but users link/@rel AND link/text() values
to determine which links have their link/@text() values updated.
:param old_rel: The link/@rel value used to select link nodes to... | [
"Rewrite",
"the",
"text",
"()",
"value",
"of",
"a",
"link",
"based",
"on",
"the",
"link",
"/",
"@rel",
"and",
"link",
"/",
"text",
"()",
"value",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L352-L373 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.update_parameter | def update_parameter(self, parameter_id, content=None, name=None, param_type=None):
"""
Updates the parameter attached to an Indicator or IndicatorItem node.
All inputs must be strings or unicode objects.
:param parameter_id: The unique id of the parameter to modify
:param cont... | python | def update_parameter(self, parameter_id, content=None, name=None, param_type=None):
"""
Updates the parameter attached to an Indicator or IndicatorItem node.
All inputs must be strings or unicode objects.
:param parameter_id: The unique id of the parameter to modify
:param cont... | [
"def",
"update_parameter",
"(",
"self",
",",
"parameter_id",
",",
"content",
"=",
"None",
",",
"name",
"=",
"None",
",",
"param_type",
"=",
"None",
")",
":",
"if",
"not",
"(",
"content",
"or",
"name",
"or",
"param_type",
")",
":",
"log",
".",
"warning"... | Updates the parameter attached to an Indicator or IndicatorItem node.
All inputs must be strings or unicode objects.
:param parameter_id: The unique id of the parameter to modify
:param content: The value of the parameter.
:param name: The name of the parameter.
:param param_ty... | [
"Updates",
"the",
"parameter",
"attached",
"to",
"an",
"Indicator",
"or",
"IndicatorItem",
"node",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L375-L413 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.remove_link | def remove_link(self, rel, value=None, href=None):
"""
Removes link nodes based on the function arguments.
This can remove link nodes based on the following combinations of arguments:
link/@rel
link/@rel & link/text()
link/@rel & link/@href
link/@... | python | def remove_link(self, rel, value=None, href=None):
"""
Removes link nodes based on the function arguments.
This can remove link nodes based on the following combinations of arguments:
link/@rel
link/@rel & link/text()
link/@rel & link/@href
link/@... | [
"def",
"remove_link",
"(",
"self",
",",
"rel",
",",
"value",
"=",
"None",
",",
"href",
"=",
"None",
")",
":",
"links_node",
"=",
"self",
".",
"metadata",
".",
"find",
"(",
"'links'",
")",
"if",
"links_node",
"is",
"None",
":",
"log",
".",
"warning",
... | Removes link nodes based on the function arguments.
This can remove link nodes based on the following combinations of arguments:
link/@rel
link/@rel & link/text()
link/@rel & link/@href
link/@rel & link/text() & link/@href
:param rel: link/@rel value to ... | [
"Removes",
"link",
"nodes",
"based",
"on",
"the",
"function",
"arguments",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L415-L452 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.remove_indicator | def remove_indicator(self, nid, prune=False):
"""
Removes a Indicator or IndicatorItem node from the IOC. By default,
if nodes are removed, any children nodes are inherited by the removed
node. It has the ability to delete all children Indicator and
IndicatorItem nodes undernea... | python | def remove_indicator(self, nid, prune=False):
"""
Removes a Indicator or IndicatorItem node from the IOC. By default,
if nodes are removed, any children nodes are inherited by the removed
node. It has the ability to delete all children Indicator and
IndicatorItem nodes undernea... | [
"def",
"remove_indicator",
"(",
"self",
",",
"nid",
",",
"prune",
"=",
"False",
")",
":",
"try",
":",
"node_to_remove",
"=",
"self",
".",
"top_level_indicator",
".",
"xpath",
"(",
"'//IndicatorItem[@id=\"{}\"]|//Indicator[@id=\"{}\"]'",
".",
"format",
"(",
"str",
... | Removes a Indicator or IndicatorItem node from the IOC. By default,
if nodes are removed, any children nodes are inherited by the removed
node. It has the ability to delete all children Indicator and
IndicatorItem nodes underneath an Indicator node if the 'prune'
argument is set.
... | [
"Removes",
"a",
"Indicator",
"or",
"IndicatorItem",
"node",
"from",
"the",
"IOC",
".",
"By",
"default",
"if",
"nodes",
"are",
"removed",
"any",
"children",
"nodes",
"are",
"inherited",
"by",
"the",
"removed",
"node",
".",
"It",
"has",
"the",
"ability",
"to... | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L454-L500 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.remove_parameter | def remove_parameter(self, param_id=None, name=None, ref_id=None, ):
"""
Removes parameters based on function arguments.
This can remove parameters based on the following param values:
param/@id
param/@name
param/@ref_id
Each input is mutually exclus... | python | def remove_parameter(self, param_id=None, name=None, ref_id=None, ):
"""
Removes parameters based on function arguments.
This can remove parameters based on the following param values:
param/@id
param/@name
param/@ref_id
Each input is mutually exclus... | [
"def",
"remove_parameter",
"(",
"self",
",",
"param_id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"ref_id",
"=",
"None",
",",
")",
":",
"l",
"=",
"[",
"]",
"if",
"param_id",
":",
"l",
".",
"append",
"(",
"'param_id'",
")",
"if",
"name",
":",
"... | Removes parameters based on function arguments.
This can remove parameters based on the following param values:
param/@id
param/@name
param/@ref_id
Each input is mutually exclusive. Calling this function with multiple values set will cause an IOCParseError
... | [
"Removes",
"parameters",
"based",
"on",
"function",
"arguments",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L502-L549 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.remove_name | def remove_name(self):
"""
Removes the name (short_description node) from the metadata node, if present.
:return: True if the node is removed. False is the node is node is not present.
"""
short_description_node = self.metadata.find('short_description')
if short_descrip... | python | def remove_name(self):
"""
Removes the name (short_description node) from the metadata node, if present.
:return: True if the node is removed. False is the node is node is not present.
"""
short_description_node = self.metadata.find('short_description')
if short_descrip... | [
"def",
"remove_name",
"(",
"self",
")",
":",
"short_description_node",
"=",
"self",
".",
"metadata",
".",
"find",
"(",
"'short_description'",
")",
"if",
"short_description_node",
"is",
"not",
"None",
":",
"self",
".",
"metadata",
".",
"remove",
"(",
"short_des... | Removes the name (short_description node) from the metadata node, if present.
:return: True if the node is removed. False is the node is node is not present. | [
"Removes",
"the",
"name",
"(",
"short_description",
"node",
")",
"from",
"the",
"metadata",
"node",
"if",
"present",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L551-L561 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.remove_description | def remove_description(self):
"""
Removes the description node from the metadata node, if present.
:return: Returns True if the description node is removed. Returns False if the node is not present.
"""
description_node = self.metadata.find('description')
if description_... | python | def remove_description(self):
"""
Removes the description node from the metadata node, if present.
:return: Returns True if the description node is removed. Returns False if the node is not present.
"""
description_node = self.metadata.find('description')
if description_... | [
"def",
"remove_description",
"(",
"self",
")",
":",
"description_node",
"=",
"self",
".",
"metadata",
".",
"find",
"(",
"'description'",
")",
"if",
"description_node",
"is",
"not",
"None",
":",
"self",
".",
"metadata",
".",
"remove",
"(",
"description_node",
... | Removes the description node from the metadata node, if present.
:return: Returns True if the description node is removed. Returns False if the node is not present. | [
"Removes",
"the",
"description",
"node",
"from",
"the",
"metadata",
"node",
"if",
"present",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L563-L573 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.write_ioc_to_file | def write_ioc_to_file(self, output_dir=None, force=False):
"""
Serialize the IOC to a .ioc file.
:param output_dir: Directory to write the ioc out to. default is the current working directory.
:param force: If specified, will not validate the root node of the IOC is 'OpenIOC'.
... | python | def write_ioc_to_file(self, output_dir=None, force=False):
"""
Serialize the IOC to a .ioc file.
:param output_dir: Directory to write the ioc out to. default is the current working directory.
:param force: If specified, will not validate the root node of the IOC is 'OpenIOC'.
... | [
"def",
"write_ioc_to_file",
"(",
"self",
",",
"output_dir",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"return",
"write_ioc",
"(",
"self",
".",
"root",
",",
"output_dir",
",",
"force",
"=",
"force",
")"
] | Serialize the IOC to a .ioc file.
:param output_dir: Directory to write the ioc out to. default is the current working directory.
:param force: If specified, will not validate the root node of the IOC is 'OpenIOC'.
:return: | [
"Serialize",
"the",
"IOC",
"to",
"a",
".",
"ioc",
"file",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L575-L583 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.display_ioc | def display_ioc(self, width=120, sep=' ', params=False):
"""
Get a string representation of an IOC.
:param width: Width to print the description too.
:param sep: Separator used for displaying the contents of the criteria nodes.
:param params: Boolean, set to True in order to di... | python | def display_ioc(self, width=120, sep=' ', params=False):
"""
Get a string representation of an IOC.
:param width: Width to print the description too.
:param sep: Separator used for displaying the contents of the criteria nodes.
:param params: Boolean, set to True in order to di... | [
"def",
"display_ioc",
"(",
"self",
",",
"width",
"=",
"120",
",",
"sep",
"=",
"' '",
",",
"params",
"=",
"False",
")",
":",
"s",
"=",
"'Name: {}\\n'",
".",
"format",
"(",
"self",
".",
"metadata",
".",
"findtext",
"(",
"'short_description'",
",",
"defa... | Get a string representation of an IOC.
:param width: Width to print the description too.
:param sep: Separator used for displaying the contents of the criteria nodes.
:param params: Boolean, set to True in order to display node parameters.
:return: | [
"Get",
"a",
"string",
"representation",
"of",
"an",
"IOC",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L594-L617 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.link_text | def link_text(self):
"""
Get a text represention of the links node.
:return:
"""
s = ''
links_node = self.metadata.find('links')
if links_node is None:
return s
links = links_node.getchildren()
if links is None:
return s
... | python | def link_text(self):
"""
Get a text represention of the links node.
:return:
"""
s = ''
links_node = self.metadata.find('links')
if links_node is None:
return s
links = links_node.getchildren()
if links is None:
return s
... | [
"def",
"link_text",
"(",
"self",
")",
":",
"s",
"=",
"''",
"links_node",
"=",
"self",
".",
"metadata",
".",
"find",
"(",
"'links'",
")",
"if",
"links_node",
"is",
"None",
":",
"return",
"s",
"links",
"=",
"links_node",
".",
"getchildren",
"(",
")",
"... | Get a text represention of the links node.
:return: | [
"Get",
"a",
"text",
"represention",
"of",
"the",
"links",
"node",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L619-L641 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.criteria_text | def criteria_text(self, sep=' ', params=False):
"""
Get a text representation of the criteria node.
:param sep: Separator used to indent the contents of the node.
:param params: Boolean, set to True in order to display node parameters.
:return:
"""
s = ''
... | python | def criteria_text(self, sep=' ', params=False):
"""
Get a text representation of the criteria node.
:param sep: Separator used to indent the contents of the node.
:param params: Boolean, set to True in order to display node parameters.
:return:
"""
s = ''
... | [
"def",
"criteria_text",
"(",
"self",
",",
"sep",
"=",
"' '",
",",
"params",
"=",
"False",
")",
":",
"s",
"=",
"''",
"criteria_node",
"=",
"self",
".",
"root",
".",
"find",
"(",
"'criteria'",
")",
"if",
"criteria_node",
"is",
"None",
":",
"return",
"... | Get a text representation of the criteria node.
:param sep: Separator used to indent the contents of the node.
:param params: Boolean, set to True in order to display node parameters.
:return: | [
"Get",
"a",
"text",
"representation",
"of",
"the",
"criteria",
"node",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L643-L661 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.get_node_text | def get_node_text(self, node, depth, sep, params=False,):
"""
Get the text for a given Indicator or IndicatorItem node.
This does walk an IndicatorItem node to get its children text as well.
:param node: Node to get the text for.
:param depth: Track the number of recursions that... | python | def get_node_text(self, node, depth, sep, params=False,):
"""
Get the text for a given Indicator or IndicatorItem node.
This does walk an IndicatorItem node to get its children text as well.
:param node: Node to get the text for.
:param depth: Track the number of recursions that... | [
"def",
"get_node_text",
"(",
"self",
",",
"node",
",",
"depth",
",",
"sep",
",",
"params",
"=",
"False",
",",
")",
":",
"indent",
"=",
"sep",
"*",
"depth",
"s",
"=",
"''",
"tag",
"=",
"node",
".",
"tag",
"if",
"tag",
"==",
"'Indicator'",
":",
"no... | Get the text for a given Indicator or IndicatorItem node.
This does walk an IndicatorItem node to get its children text as well.
:param node: Node to get the text for.
:param depth: Track the number of recursions that have occured, modifies the indentation.
:param sep: Seperator used fo... | [
"Get",
"the",
"text",
"for",
"a",
"given",
"Indicator",
"or",
"IndicatorItem",
"node",
".",
"This",
"does",
"walk",
"an",
"IndicatorItem",
"node",
"to",
"get",
"its",
"children",
"text",
"as",
"well",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L663-L691 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.get_i_text | def get_i_text(node):
"""
Get the text for an Indicator node.
:param node: Indicator node.
:return:
"""
if node.tag != 'Indicator':
raise IOCParseError('Invalid tag: {}'.format(node.tag))
s = node.get('operator').upper()
return s | python | def get_i_text(node):
"""
Get the text for an Indicator node.
:param node: Indicator node.
:return:
"""
if node.tag != 'Indicator':
raise IOCParseError('Invalid tag: {}'.format(node.tag))
s = node.get('operator').upper()
return s | [
"def",
"get_i_text",
"(",
"node",
")",
":",
"if",
"node",
".",
"tag",
"!=",
"'Indicator'",
":",
"raise",
"IOCParseError",
"(",
"'Invalid tag: {}'",
".",
"format",
"(",
"node",
".",
"tag",
")",
")",
"s",
"=",
"node",
".",
"get",
"(",
"'operator'",
")",
... | Get the text for an Indicator node.
:param node: Indicator node.
:return: | [
"Get",
"the",
"text",
"for",
"an",
"Indicator",
"node",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L694-L704 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.get_ii_text | def get_ii_text(node):
"""
Get the text for IndicatorItem node.
:param node: IndicatorItem node.
:return:
"""
if node.tag != 'IndicatorItem':
raise IOCParseError('Invalid tag: {}'.format(node.tag))
condition = node.attrib.get('condition')
pres... | python | def get_ii_text(node):
"""
Get the text for IndicatorItem node.
:param node: IndicatorItem node.
:return:
"""
if node.tag != 'IndicatorItem':
raise IOCParseError('Invalid tag: {}'.format(node.tag))
condition = node.attrib.get('condition')
pres... | [
"def",
"get_ii_text",
"(",
"node",
")",
":",
"if",
"node",
".",
"tag",
"!=",
"'IndicatorItem'",
":",
"raise",
"IOCParseError",
"(",
"'Invalid tag: {}'",
".",
"format",
"(",
"node",
".",
"tag",
")",
")",
"condition",
"=",
"node",
".",
"attrib",
".",
"get"... | Get the text for IndicatorItem node.
:param node: IndicatorItem node.
:return: | [
"Get",
"the",
"text",
"for",
"IndicatorItem",
"node",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L707-L734 |
mandiant/ioc_writer | ioc_writer/ioc_api.py | IOC.get_param_text | def get_param_text(self, nid):
"""
Get a list of parameters as text values for a given node id.
:param nid: id to look for.
:return:
"""
r = []
params = self.parameters.xpath('.//param[@ref-id="{}"]'.format(nid))
if not params:
return r
... | python | def get_param_text(self, nid):
"""
Get a list of parameters as text values for a given node id.
:param nid: id to look for.
:return:
"""
r = []
params = self.parameters.xpath('.//param[@ref-id="{}"]'.format(nid))
if not params:
return r
... | [
"def",
"get_param_text",
"(",
"self",
",",
"nid",
")",
":",
"r",
"=",
"[",
"]",
"params",
"=",
"self",
".",
"parameters",
".",
"xpath",
"(",
"'.//param[@ref-id=\"{}\"]'",
".",
"format",
"(",
"nid",
")",
")",
"if",
"not",
"params",
":",
"return",
"r",
... | Get a list of parameters as text values for a given node id.
:param nid: id to look for.
:return: | [
"Get",
"a",
"list",
"of",
"parameters",
"as",
"text",
"values",
"for",
"a",
"given",
"node",
"id",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L736-L753 |
mandiant/ioc_writer | ioc_writer/utils/xmlutils.py | read_xml | def read_xml(filename):
"""
Use et to read in a xml file, or string, into a Element object.
:param filename: File to parse.
:return: lxml._elementTree object or None
"""
parser = et.XMLParser(remove_blank_text=True)
isfile=False
try:
isfile = os.path.exists(filename)
except ... | python | def read_xml(filename):
"""
Use et to read in a xml file, or string, into a Element object.
:param filename: File to parse.
:return: lxml._elementTree object or None
"""
parser = et.XMLParser(remove_blank_text=True)
isfile=False
try:
isfile = os.path.exists(filename)
except ... | [
"def",
"read_xml",
"(",
"filename",
")",
":",
"parser",
"=",
"et",
".",
"XMLParser",
"(",
"remove_blank_text",
"=",
"True",
")",
"isfile",
"=",
"False",
"try",
":",
"isfile",
"=",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
"except",
"Value... | Use et to read in a xml file, or string, into a Element object.
:param filename: File to parse.
:return: lxml._elementTree object or None | [
"Use",
"et",
"to",
"read",
"in",
"a",
"xml",
"file",
"or",
"string",
"into",
"a",
"Element",
"object",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/utils/xmlutils.py#L30-L57 |
mandiant/ioc_writer | ioc_writer/utils/xmlutils.py | remove_namespace | def remove_namespace(doc, namespace):
"""
Takes in a ElementTree object and namespace value. The length of that
namespace value is removed from all Element nodes within the document.
This effectively removes the namespace from that document.
:param doc: lxml.etree
:param namespace: Namespace t... | python | def remove_namespace(doc, namespace):
"""
Takes in a ElementTree object and namespace value. The length of that
namespace value is removed from all Element nodes within the document.
This effectively removes the namespace from that document.
:param doc: lxml.etree
:param namespace: Namespace t... | [
"def",
"remove_namespace",
"(",
"doc",
",",
"namespace",
")",
":",
"# http://homework.nwsnet.de/products/45be_remove-namespace-in-an-xml-document-using-elementtree",
"#",
"# Permission is hereby granted, free of charge, to any person obtaining",
"# a copy of this software and associated docume... | Takes in a ElementTree object and namespace value. The length of that
namespace value is removed from all Element nodes within the document.
This effectively removes the namespace from that document.
:param doc: lxml.etree
:param namespace: Namespace that needs to be removed.
:return: Returns the ... | [
"Takes",
"in",
"a",
"ElementTree",
"object",
"and",
"namespace",
"value",
".",
"The",
"length",
"of",
"that",
"namespace",
"value",
"is",
"removed",
"from",
"all",
"Element",
"nodes",
"within",
"the",
"document",
".",
"This",
"effectively",
"removes",
"the",
... | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/utils/xmlutils.py#L60-L96 |
mandiant/ioc_writer | ioc_writer/utils/xmlutils.py | delete_namespace | def delete_namespace(parsed_xml):
"""
Identifies the namespace associated with the root node of a XML document
and removes that names from the document.
:param parsed_xml: lxml.Etree object.
:return: Returns the sources document with the namespace removed.
"""
if parsed_xml.getroot().tag.st... | python | def delete_namespace(parsed_xml):
"""
Identifies the namespace associated with the root node of a XML document
and removes that names from the document.
:param parsed_xml: lxml.Etree object.
:return: Returns the sources document with the namespace removed.
"""
if parsed_xml.getroot().tag.st... | [
"def",
"delete_namespace",
"(",
"parsed_xml",
")",
":",
"if",
"parsed_xml",
".",
"getroot",
"(",
")",
".",
"tag",
".",
"startswith",
"(",
"'{'",
")",
":",
"root",
"=",
"parsed_xml",
".",
"getroot",
"(",
")",
".",
"tag",
"end_ns",
"=",
"root",
".",
"f... | Identifies the namespace associated with the root node of a XML document
and removes that names from the document.
:param parsed_xml: lxml.Etree object.
:return: Returns the sources document with the namespace removed. | [
"Identifies",
"the",
"namespace",
"associated",
"with",
"the",
"root",
"node",
"of",
"a",
"XML",
"document",
"and",
"removes",
"that",
"names",
"from",
"the",
"document",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/utils/xmlutils.py#L99-L111 |
mandiant/ioc_writer | ioc_writer/managers/upgrade_10.py | UpgradeManager.insert | def insert(self, filename):
"""
Parses files to load them into memory and insert them into the class.
:param filename: File or directory pointing to .ioc files.
:return: A list of .ioc files which could not be parsed.
"""
errors = []
if os.path.isfile(filename):
... | python | def insert(self, filename):
"""
Parses files to load them into memory and insert them into the class.
:param filename: File or directory pointing to .ioc files.
:return: A list of .ioc files which could not be parsed.
"""
errors = []
if os.path.isfile(filename):
... | [
"def",
"insert",
"(",
"self",
",",
"filename",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"log",
".",
"info",
"(",
"'loading IOC from: {}'",
".",
"format",
"(",
"filename",
")",
")",
"if",
... | Parses files to load them into memory and insert them into the class.
:param filename: File or directory pointing to .ioc files.
:return: A list of .ioc files which could not be parsed. | [
"Parses",
"files",
"to",
"load",
"them",
"into",
"memory",
"and",
"insert",
"them",
"into",
"the",
"class",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/upgrade_10.py#L52-L77 |
mandiant/ioc_writer | ioc_writer/managers/upgrade_10.py | UpgradeManager.parse | def parse(self, fn):
"""
Parses a file into a lxml.etree structure with namespaces remove. This tree is added to self.iocs.
:param fn: File to parse.
:return:
"""
ioc_xml = xmlutils.read_xml_no_ns(fn)
if not ioc_xml:
return False
root = ioc_x... | python | def parse(self, fn):
"""
Parses a file into a lxml.etree structure with namespaces remove. This tree is added to self.iocs.
:param fn: File to parse.
:return:
"""
ioc_xml = xmlutils.read_xml_no_ns(fn)
if not ioc_xml:
return False
root = ioc_x... | [
"def",
"parse",
"(",
"self",
",",
"fn",
")",
":",
"ioc_xml",
"=",
"xmlutils",
".",
"read_xml_no_ns",
"(",
"fn",
")",
"if",
"not",
"ioc_xml",
":",
"return",
"False",
"root",
"=",
"ioc_xml",
".",
"getroot",
"(",
")",
"iocid",
"=",
"root",
".",
"get",
... | Parses a file into a lxml.etree structure with namespaces remove. This tree is added to self.iocs.
:param fn: File to parse.
:return: | [
"Parses",
"a",
"file",
"into",
"a",
"lxml",
".",
"etree",
"structure",
"with",
"namespaces",
"remove",
".",
"This",
"tree",
"is",
"added",
"to",
"self",
".",
"iocs",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/upgrade_10.py#L79-L94 |
mandiant/ioc_writer | ioc_writer/managers/upgrade_10.py | UpgradeManager.convert_to_11 | def convert_to_11(self):
"""
converts the iocs in self.iocs from openioc 1.0 to openioc 1.1 format.
the converted iocs are stored in the dictionary self.iocs_11
"""
if len(self) < 1:
log.error('No iocs available to modify.')
return False
log.info('... | python | def convert_to_11(self):
"""
converts the iocs in self.iocs from openioc 1.0 to openioc 1.1 format.
the converted iocs are stored in the dictionary self.iocs_11
"""
if len(self) < 1:
log.error('No iocs available to modify.')
return False
log.info('... | [
"def",
"convert_to_11",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
")",
"<",
"1",
":",
"log",
".",
"error",
"(",
"'No iocs available to modify.'",
")",
"return",
"False",
"log",
".",
"info",
"(",
"'Converting IOCs from 1.0 to 1.1'",
")",
"errors",
"=",... | converts the iocs in self.iocs from openioc 1.0 to openioc 1.1 format.
the converted iocs are stored in the dictionary self.iocs_11 | [
"converts",
"the",
"iocs",
"in",
"self",
".",
"iocs",
"from",
"openioc",
"1",
".",
"0",
"to",
"openioc",
"1",
".",
"1",
"format",
".",
"the",
"converted",
"iocs",
"are",
"stored",
"in",
"the",
"dictionary",
"self",
".",
"iocs_11"
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/upgrade_10.py#L96-L153 |
mandiant/ioc_writer | ioc_writer/managers/upgrade_10.py | UpgradeManager.convert_branch | def convert_branch(self, old_node, new_node, comment_dict=None):
"""
recursively walk a indicator logic tree, starting from a Indicator node.
converts OpenIOC 1.0 Indicator/IndicatorItems to Openioc 1.1 and preserves order.
:param old_node: Indicator node, which we walk down to convert
... | python | def convert_branch(self, old_node, new_node, comment_dict=None):
"""
recursively walk a indicator logic tree, starting from a Indicator node.
converts OpenIOC 1.0 Indicator/IndicatorItems to Openioc 1.1 and preserves order.
:param old_node: Indicator node, which we walk down to convert
... | [
"def",
"convert_branch",
"(",
"self",
",",
"old_node",
",",
"new_node",
",",
"comment_dict",
"=",
"None",
")",
":",
"expected_tag",
"=",
"'Indicator'",
"if",
"old_node",
".",
"tag",
"!=",
"expected_tag",
":",
"raise",
"UpgradeError",
"(",
"'old_node expected tag... | recursively walk a indicator logic tree, starting from a Indicator node.
converts OpenIOC 1.0 Indicator/IndicatorItems to Openioc 1.1 and preserves order.
:param old_node: Indicator node, which we walk down to convert
:param new_node: Indicator node, which we add new IndicatorItem and Indicator... | [
"recursively",
"walk",
"a",
"indicator",
"logic",
"tree",
"starting",
"from",
"a",
"Indicator",
"node",
".",
"converts",
"OpenIOC",
"1",
".",
"0",
"Indicator",
"/",
"IndicatorItems",
"to",
"Openioc",
"1",
".",
"1",
"and",
"preserves",
"order",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/upgrade_10.py#L155-L207 |
mandiant/ioc_writer | ioc_writer/managers/__init__.py | IOCManager.insert | def insert(self, filename):
"""
Parses files to load them into memory and insert them into the class.
:param filename: File or directory pointing to .ioc files.
:return: A list of .ioc files which could not be parsed.
"""
errors = []
if os.path.isfile(filename):
... | python | def insert(self, filename):
"""
Parses files to load them into memory and insert them into the class.
:param filename: File or directory pointing to .ioc files.
:return: A list of .ioc files which could not be parsed.
"""
errors = []
if os.path.isfile(filename):
... | [
"def",
"insert",
"(",
"self",
",",
"filename",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"log",
".",
"info",
"(",
"'loading IOC from: {}'",
".",
"format",
"(",
"filename",
")",
")",
"try",
... | Parses files to load them into memory and insert them into the class.
:param filename: File or directory pointing to .ioc files.
:return: A list of .ioc files which could not be parsed. | [
"Parses",
"files",
"to",
"load",
"them",
"into",
"memory",
"and",
"insert",
"them",
"into",
"the",
"class",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/__init__.py#L51-L80 |
mandiant/ioc_writer | ioc_writer/managers/__init__.py | IOCManager.parse | def parse(self, ioc_obj):
"""
parses an ioc to populate self.iocs and self.ioc_name
:param ioc_obj:
:return:
"""
if ioc_obj is None:
return
iocid = ioc_obj.iocid
try:
sd = ioc_obj.metadata.xpath('.//short_description/text()')[0]
... | python | def parse(self, ioc_obj):
"""
parses an ioc to populate self.iocs and self.ioc_name
:param ioc_obj:
:return:
"""
if ioc_obj is None:
return
iocid = ioc_obj.iocid
try:
sd = ioc_obj.metadata.xpath('.//short_description/text()')[0]
... | [
"def",
"parse",
"(",
"self",
",",
"ioc_obj",
")",
":",
"if",
"ioc_obj",
"is",
"None",
":",
"return",
"iocid",
"=",
"ioc_obj",
".",
"iocid",
"try",
":",
"sd",
"=",
"ioc_obj",
".",
"metadata",
".",
"xpath",
"(",
"'.//short_description/text()'",
")",
"[",
... | parses an ioc to populate self.iocs and self.ioc_name
:param ioc_obj:
:return: | [
"parses",
"an",
"ioc",
"to",
"populate",
"self",
".",
"iocs",
"and",
"self",
".",
"ioc_name"
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/__init__.py#L82-L105 |
mandiant/ioc_writer | ioc_writer/managers/__init__.py | IOCManager.register_parser_callback | def register_parser_callback(self, func):
"""
Register a callback function that is called after self.iocs and self.ioc_name is populated.
This is intended for use by subclasses that may have additional parsing requirements.
:param func: A callable function. This should accept a singl... | python | def register_parser_callback(self, func):
"""
Register a callback function that is called after self.iocs and self.ioc_name is populated.
This is intended for use by subclasses that may have additional parsing requirements.
:param func: A callable function. This should accept a singl... | [
"def",
"register_parser_callback",
"(",
"self",
",",
"func",
")",
":",
"if",
"hasattr",
"(",
"func",
",",
"'__call__'",
")",
":",
"self",
".",
"parser_callback",
"=",
"func",
"log",
".",
"debug",
"(",
"'Set callback to {}'",
".",
"format",
"(",
"func",
")"... | Register a callback function that is called after self.iocs and self.ioc_name is populated.
This is intended for use by subclasses that may have additional parsing requirements.
:param func: A callable function. This should accept a single input, which will be an IOC class.
:return: | [
"Register",
"a",
"callback",
"function",
"that",
"is",
"called",
"after",
"self",
".",
"iocs",
"and",
"self",
".",
"ioc_name",
"is",
"populated",
"."
] | train | https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/__init__.py#L107-L120 |
koordinates/python-client | koordinates/permissions.py | PermissionManager.create | def create(self, permission):
"""
Create single permission for the given object.
:param Permission permission: A single Permission object to be set.
"""
parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})
... | python | def create(self, permission):
"""
Create single permission for the given object.
:param Permission permission: A single Permission object to be set.
"""
parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})
... | [
"def",
"create",
"(",
"self",
",",
"permission",
")",
":",
"parent_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"self",
".",
"parent_object",
".",
"_manager",
".",
"_URL_KEY",
",",
"'GET'",
",",
"'single'",
",",
"{",
"'id'",
":",
"self",
".",... | Create single permission for the given object.
:param Permission permission: A single Permission object to be set. | [
"Create",
"single",
"permission",
"for",
"the",
"given",
"object",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/permissions.py#L35-L44 |
koordinates/python-client | koordinates/permissions.py | PermissionManager.set | def set(self, permissions):
"""
Set the object permissions. If the parent object already has permissions, they will be overwritten.
:param [] permissions: A group of Permission objects to be set.
"""
parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', '... | python | def set(self, permissions):
"""
Set the object permissions. If the parent object already has permissions, they will be overwritten.
:param [] permissions: A group of Permission objects to be set.
"""
parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', '... | [
"def",
"set",
"(",
"self",
",",
"permissions",
")",
":",
"parent_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"self",
".",
"parent_object",
".",
"_manager",
".",
"_URL_KEY",
",",
"'GET'",
",",
"'single'",
",",
"{",
"'id'",
":",
"self",
".",
... | Set the object permissions. If the parent object already has permissions, they will be overwritten.
:param [] permissions: A group of Permission objects to be set. | [
"Set",
"the",
"object",
"permissions",
".",
"If",
"the",
"parent",
"object",
"already",
"has",
"permissions",
"they",
"will",
"be",
"overwritten",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/permissions.py#L46-L57 |
koordinates/python-client | koordinates/permissions.py | PermissionManager.list | def list(self):
"""
List permissions for the given object.
"""
parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})
target_url = parent_url + self.client.get_url_path(self._URL_KEY, 'GET', 'multi')
return b... | python | def list(self):
"""
List permissions for the given object.
"""
parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})
target_url = parent_url + self.client.get_url_path(self._URL_KEY, 'GET', 'multi')
return b... | [
"def",
"list",
"(",
"self",
")",
":",
"parent_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"self",
".",
"parent_object",
".",
"_manager",
".",
"_URL_KEY",
",",
"'GET'",
",",
"'single'",
",",
"{",
"'id'",
":",
"self",
".",
"parent_object",
"."... | List permissions for the given object. | [
"List",
"permissions",
"for",
"the",
"given",
"object",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/permissions.py#L59-L65 |
koordinates/python-client | koordinates/permissions.py | PermissionManager.get | def get(self, permission_id, expand=[]):
"""
List a specific permisison for the given object.
:param str permission_id: the id of the Permission to be listed.
"""
parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id... | python | def get(self, permission_id, expand=[]):
"""
List a specific permisison for the given object.
:param str permission_id: the id of the Permission to be listed.
"""
parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id... | [
"def",
"get",
"(",
"self",
",",
"permission_id",
",",
"expand",
"=",
"[",
"]",
")",
":",
"parent_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"self",
".",
"parent_object",
".",
"_manager",
".",
"_URL_KEY",
",",
"'GET'",
",",
"'single'",
",",
... | List a specific permisison for the given object.
:param str permission_id: the id of the Permission to be listed. | [
"List",
"a",
"specific",
"permisison",
"for",
"the",
"given",
"object",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/permissions.py#L67-L76 |
michaelaye/pyciss | pyciss/io.py | get_config | def get_config():
"""Read the configfile and return config dict.
Returns
-------
dict
Dictionary with the content of the configpath file.
"""
configpath = get_configpath()
if not configpath.exists():
raise IOError("Config file {} not found.".format(str(configpath)))
else... | python | def get_config():
"""Read the configfile and return config dict.
Returns
-------
dict
Dictionary with the content of the configpath file.
"""
configpath = get_configpath()
if not configpath.exists():
raise IOError("Config file {} not found.".format(str(configpath)))
else... | [
"def",
"get_config",
"(",
")",
":",
"configpath",
"=",
"get_configpath",
"(",
")",
"if",
"not",
"configpath",
".",
"exists",
"(",
")",
":",
"raise",
"IOError",
"(",
"\"Config file {} not found.\"",
".",
"format",
"(",
"str",
"(",
"configpath",
")",
")",
")... | Read the configfile and return config dict.
Returns
-------
dict
Dictionary with the content of the configpath file. | [
"Read",
"the",
"configfile",
"and",
"return",
"config",
"dict",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L23-L37 |
michaelaye/pyciss | pyciss/io.py | set_database_path | def set_database_path(dbfolder):
"""Use to write the database path into the config.
Parameters
----------
dbfolder : str or pathlib.Path
Path to where pyciss will store the ISS images it downloads and receives.
"""
configpath = get_configpath()
try:
d = get_config()
exce... | python | def set_database_path(dbfolder):
"""Use to write the database path into the config.
Parameters
----------
dbfolder : str or pathlib.Path
Path to where pyciss will store the ISS images it downloads and receives.
"""
configpath = get_configpath()
try:
d = get_config()
exce... | [
"def",
"set_database_path",
"(",
"dbfolder",
")",
":",
"configpath",
"=",
"get_configpath",
"(",
")",
"try",
":",
"d",
"=",
"get_config",
"(",
")",
"except",
"IOError",
":",
"d",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"d",
"[",
"'pyciss_db'",
... | Use to write the database path into the config.
Parameters
----------
dbfolder : str or pathlib.Path
Path to where pyciss will store the ISS images it downloads and receives. | [
"Use",
"to",
"write",
"the",
"database",
"path",
"into",
"the",
"config",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L53-L70 |
michaelaye/pyciss | pyciss/io.py | get_db_root | def get_db_root():
"Read dbroot folder from config and mkdir if required."
d = get_config()
dbroot = Path(d['pyciss_db']['path'])
dbroot.mkdir(exist_ok=True)
return dbroot | python | def get_db_root():
"Read dbroot folder from config and mkdir if required."
d = get_config()
dbroot = Path(d['pyciss_db']['path'])
dbroot.mkdir(exist_ok=True)
return dbroot | [
"def",
"get_db_root",
"(",
")",
":",
"d",
"=",
"get_config",
"(",
")",
"dbroot",
"=",
"Path",
"(",
"d",
"[",
"'pyciss_db'",
"]",
"[",
"'path'",
"]",
")",
"dbroot",
".",
"mkdir",
"(",
"exist_ok",
"=",
"True",
")",
"return",
"dbroot"
] | Read dbroot folder from config and mkdir if required. | [
"Read",
"dbroot",
"folder",
"from",
"config",
"and",
"mkdir",
"if",
"required",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L81-L86 |
michaelaye/pyciss | pyciss/io.py | print_db_stats | def print_db_stats():
"""Print database stats.
Returns
-------
pd.DataFrame
Table with the found data items per type.
"""
dbroot = get_db_root()
n_ids = len(list(dbroot.glob("[N,W]*")))
print("Number of WACs and NACs in database: {}".format(n_ids))
print("These kind of data ... | python | def print_db_stats():
"""Print database stats.
Returns
-------
pd.DataFrame
Table with the found data items per type.
"""
dbroot = get_db_root()
n_ids = len(list(dbroot.glob("[N,W]*")))
print("Number of WACs and NACs in database: {}".format(n_ids))
print("These kind of data ... | [
"def",
"print_db_stats",
"(",
")",
":",
"dbroot",
"=",
"get_db_root",
"(",
")",
"n_ids",
"=",
"len",
"(",
"list",
"(",
"dbroot",
".",
"glob",
"(",
"\"[N,W]*\"",
")",
")",
")",
"print",
"(",
"\"Number of WACs and NACs in database: {}\"",
".",
"format",
"(",
... | Print database stats.
Returns
-------
pd.DataFrame
Table with the found data items per type. | [
"Print",
"database",
"stats",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L89-L104 |
michaelaye/pyciss | pyciss/io.py | is_lossy | def is_lossy(label):
"""Check Label file for the compression type. """
val = getkey(from_=label, keyword='INST_CMPRS_TYPE').decode().strip()
if val == 'LOSSY':
return True
else:
return False | python | def is_lossy(label):
"""Check Label file for the compression type. """
val = getkey(from_=label, keyword='INST_CMPRS_TYPE').decode().strip()
if val == 'LOSSY':
return True
else:
return False | [
"def",
"is_lossy",
"(",
"label",
")",
":",
"val",
"=",
"getkey",
"(",
"from_",
"=",
"label",
",",
"keyword",
"=",
"'INST_CMPRS_TYPE'",
")",
".",
"decode",
"(",
")",
".",
"strip",
"(",
")",
"if",
"val",
"==",
"'LOSSY'",
":",
"return",
"True",
"else",
... | Check Label file for the compression type. | [
"Check",
"Label",
"file",
"for",
"the",
"compression",
"type",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L237-L243 |
michaelaye/pyciss | pyciss/downloader.py | download_and_calibrate_parallel | def download_and_calibrate_parallel(list_of_ids, n=None):
"""Download and calibrate in parallel.
Parameters
----------
list_of_ids : list, optional
container with img_ids to process
n : int
Number of cores for the parallel processing. Default: n_cores_system//2
"""
setup_clu... | python | def download_and_calibrate_parallel(list_of_ids, n=None):
"""Download and calibrate in parallel.
Parameters
----------
list_of_ids : list, optional
container with img_ids to process
n : int
Number of cores for the parallel processing. Default: n_cores_system//2
"""
setup_clu... | [
"def",
"download_and_calibrate_parallel",
"(",
"list_of_ids",
",",
"n",
"=",
"None",
")",
":",
"setup_cluster",
"(",
"n_cores",
"=",
"n",
")",
"c",
"=",
"Client",
"(",
")",
"lbview",
"=",
"c",
".",
"load_balanced_view",
"(",
")",
"lbview",
".",
"map_async"... | Download and calibrate in parallel.
Parameters
----------
list_of_ids : list, optional
container with img_ids to process
n : int
Number of cores for the parallel processing. Default: n_cores_system//2 | [
"Download",
"and",
"calibrate",
"in",
"parallel",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/downloader.py#L37-L51 |
michaelaye/pyciss | pyciss/downloader.py | download_and_calibrate | def download_and_calibrate(img_id=None, overwrite=False, recalibrate=False, **kwargs):
"""Download and calibrate one or more image ids, in parallel.
Parameters
----------
img_id : str or io.PathManager, optional
If more than one item is in img_id, a parallel process is started
overwrite: bo... | python | def download_and_calibrate(img_id=None, overwrite=False, recalibrate=False, **kwargs):
"""Download and calibrate one or more image ids, in parallel.
Parameters
----------
img_id : str or io.PathManager, optional
If more than one item is in img_id, a parallel process is started
overwrite: bo... | [
"def",
"download_and_calibrate",
"(",
"img_id",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"recalibrate",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"img_id",
",",
"io",
".",
"PathManager",
")",
":",
"pm",
"=",
"im... | Download and calibrate one or more image ids, in parallel.
Parameters
----------
img_id : str or io.PathManager, optional
If more than one item is in img_id, a parallel process is started
overwrite: bool, optional
If the pm.cubepath exists, this switch controls if it is being overwritte... | [
"Download",
"and",
"calibrate",
"one",
"or",
"more",
"image",
"ids",
"in",
"parallel",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/downloader.py#L54-L83 |
michaelaye/pyciss | pyciss/pipeline.py | Calibrator.spiceinit | def spiceinit(self):
"""Perform either normal spiceinit or one for ringdata.
Note how Python name-spacing can distinguish between the method
and the function with the same name. `spiceinit` from the outer
namespace is the one imported from pysis.
"""
shape = "ringplane" ... | python | def spiceinit(self):
"""Perform either normal spiceinit or one for ringdata.
Note how Python name-spacing can distinguish between the method
and the function with the same name. `spiceinit` from the outer
namespace is the one imported from pysis.
"""
shape = "ringplane" ... | [
"def",
"spiceinit",
"(",
"self",
")",
":",
"shape",
"=",
"\"ringplane\"",
"if",
"self",
".",
"is_ring_data",
"else",
"None",
"spiceinit",
"(",
"from_",
"=",
"self",
".",
"pm",
".",
"raw_cub",
",",
"cksmithed",
"=",
"\"yes\"",
",",
"spksmithed",
"=",
"\"y... | Perform either normal spiceinit or one for ringdata.
Note how Python name-spacing can distinguish between the method
and the function with the same name. `spiceinit` from the outer
namespace is the one imported from pysis. | [
"Perform",
"either",
"normal",
"spiceinit",
"or",
"one",
"for",
"ringdata",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/pipeline.py#L142-L151 |
michaelaye/pyciss | pyciss/pipeline.py | Calibrator.check_label | def check_label(self):
""" Check label for target and fix if necessary.
Forcing the target name to Saturn here, because some observations of
the rings have moons as a target, but then the standard map projection
onto the Saturn ring plane fails.
See also
--------
... | python | def check_label(self):
""" Check label for target and fix if necessary.
Forcing the target name to Saturn here, because some observations of
the rings have moons as a target, but then the standard map projection
onto the Saturn ring plane fails.
See also
--------
... | [
"def",
"check_label",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_ring_data",
":",
"return",
"targetname",
"=",
"getkey",
"(",
"from_",
"=",
"self",
".",
"pm",
".",
"raw_cub",
",",
"grp",
"=",
"\"instrument\"",
",",
"keyword",
"=",
"\"targetname... | Check label for target and fix if necessary.
Forcing the target name to Saturn here, because some observations of
the rings have moons as a target, but then the standard map projection
onto the Saturn ring plane fails.
See also
--------
https://isis.astrogeology.usgs.go... | [
"Check",
"label",
"for",
"target",
"and",
"fix",
"if",
"necessary",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/pipeline.py#L153-L177 |
JenkinsDev/pelican-readtime | readtime.py | ReadTimeParser._set_supported_content_type | def _set_supported_content_type(self, content_types_supported):
""" Checks and sets the supported content types configuration value.
"""
if not isinstance(content_types_supported, list):
raise TypeError(("Settings 'READTIME_CONTENT_SUPPORT' must be"
"a li... | python | def _set_supported_content_type(self, content_types_supported):
""" Checks and sets the supported content types configuration value.
"""
if not isinstance(content_types_supported, list):
raise TypeError(("Settings 'READTIME_CONTENT_SUPPORT' must be"
"a li... | [
"def",
"_set_supported_content_type",
"(",
"self",
",",
"content_types_supported",
")",
":",
"if",
"not",
"isinstance",
"(",
"content_types_supported",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"(",
"\"Settings 'READTIME_CONTENT_SUPPORT' must be\"",
"\"a list of c... | Checks and sets the supported content types configuration value. | [
"Checks",
"and",
"sets",
"the",
"supported",
"content",
"types",
"configuration",
"value",
"."
] | train | https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L20-L27 |
JenkinsDev/pelican-readtime | readtime.py | ReadTimeParser._set_lang_settings | def _set_lang_settings(self, lang_settings):
""" Checks and sets the per language WPM, singular and plural values.
"""
is_int = isinstance(lang_settings, int)
is_dict = isinstance(lang_settings, dict)
if not is_int and not is_dict:
raise TypeError(("Settings 'READTIME... | python | def _set_lang_settings(self, lang_settings):
""" Checks and sets the per language WPM, singular and plural values.
"""
is_int = isinstance(lang_settings, int)
is_dict = isinstance(lang_settings, dict)
if not is_int and not is_dict:
raise TypeError(("Settings 'READTIME... | [
"def",
"_set_lang_settings",
"(",
"self",
",",
"lang_settings",
")",
":",
"is_int",
"=",
"isinstance",
"(",
"lang_settings",
",",
"int",
")",
"is_dict",
"=",
"isinstance",
"(",
"lang_settings",
",",
"dict",
")",
"if",
"not",
"is_int",
"and",
"not",
"is_dict"... | Checks and sets the per language WPM, singular and plural values. | [
"Checks",
"and",
"sets",
"the",
"per",
"language",
"WPM",
"singular",
"and",
"plural",
"values",
"."
] | train | https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L29-L69 |
JenkinsDev/pelican-readtime | readtime.py | ReadTimeParser.initialize_settings | def initialize_settings(self, sender):
""" Initializes ReadTimeParser with configuration values set by the
site author.
"""
try:
self.initialized = True
settings_content_types = sender.settings.get(
'READTIME_CONTENT_SUPPORT', self.content_type_su... | python | def initialize_settings(self, sender):
""" Initializes ReadTimeParser with configuration values set by the
site author.
"""
try:
self.initialized = True
settings_content_types = sender.settings.get(
'READTIME_CONTENT_SUPPORT', self.content_type_su... | [
"def",
"initialize_settings",
"(",
"self",
",",
"sender",
")",
":",
"try",
":",
"self",
".",
"initialized",
"=",
"True",
"settings_content_types",
"=",
"sender",
".",
"settings",
".",
"get",
"(",
"'READTIME_CONTENT_SUPPORT'",
",",
"self",
".",
"content_type_supp... | Initializes ReadTimeParser with configuration values set by the
site author. | [
"Initializes",
"ReadTimeParser",
"with",
"configuration",
"values",
"set",
"by",
"the",
"site",
"author",
"."
] | train | https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L71-L86 |
JenkinsDev/pelican-readtime | readtime.py | ReadTimeParser.read_time | def read_time(self, content):
""" Core function used to generate the read_time for content.
Parameters:
:param content: Instance of pelican.content.Content
Returns:
None
"""
if get_class_name(content) in self.content_type_supported:
# Exit if... | python | def read_time(self, content):
""" Core function used to generate the read_time for content.
Parameters:
:param content: Instance of pelican.content.Content
Returns:
None
"""
if get_class_name(content) in self.content_type_supported:
# Exit if... | [
"def",
"read_time",
"(",
"self",
",",
"content",
")",
":",
"if",
"get_class_name",
"(",
"content",
")",
"in",
"self",
".",
"content_type_supported",
":",
"# Exit if readtime is already set",
"if",
"hasattr",
"(",
"content",
",",
"'readtime'",
")",
":",
"return",... | Core function used to generate the read_time for content.
Parameters:
:param content: Instance of pelican.content.Content
Returns:
None | [
"Core",
"function",
"used",
"to",
"generate",
"the",
"read_time",
"for",
"content",
"."
] | train | https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L88-L129 |
JenkinsDev/pelican-readtime | readtime.py | ReadTimeParser.pluralize | def pluralize(self, measure, singular, plural):
""" Returns a string that contains the measure (amount) and its plural
or singular form depending on the amount.
Parameters:
:param measure: Amount, value, always a numerical value
:param singular: The singular form of the ... | python | def pluralize(self, measure, singular, plural):
""" Returns a string that contains the measure (amount) and its plural
or singular form depending on the amount.
Parameters:
:param measure: Amount, value, always a numerical value
:param singular: The singular form of the ... | [
"def",
"pluralize",
"(",
"self",
",",
"measure",
",",
"singular",
",",
"plural",
")",
":",
"if",
"measure",
"==",
"1",
":",
"return",
"\"{} {}\"",
".",
"format",
"(",
"measure",
",",
"singular",
")",
"else",
":",
"return",
"\"{} {}\"",
".",
"format",
"... | Returns a string that contains the measure (amount) and its plural
or singular form depending on the amount.
Parameters:
:param measure: Amount, value, always a numerical value
:param singular: The singular form of the chosen word
:param plural: The plural form of th... | [
"Returns",
"a",
"string",
"that",
"contains",
"the",
"measure",
"(",
"amount",
")",
"and",
"its",
"plural",
"or",
"singular",
"form",
"depending",
"on",
"the",
"amount",
"."
] | train | https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L131-L146 |
koordinates/python-client | koordinates/sources.py | SourceManager.list_datasources | def list_datasources(self, source_id):
"""
Filterable list of Datasources for a Source.
"""
target_url = self.client.get_url('DATASOURCE', 'GET', 'multi', {'source_id': source_id})
return base.Query(self.client.get_manager(Datasource), target_url) | python | def list_datasources(self, source_id):
"""
Filterable list of Datasources for a Source.
"""
target_url = self.client.get_url('DATASOURCE', 'GET', 'multi', {'source_id': source_id})
return base.Query(self.client.get_manager(Datasource), target_url) | [
"def",
"list_datasources",
"(",
"self",
",",
"source_id",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'DATASOURCE'",
",",
"'GET'",
",",
"'multi'",
",",
"{",
"'source_id'",
":",
"source_id",
"}",
")",
"return",
"base",
".",
"... | Filterable list of Datasources for a Source. | [
"Filterable",
"list",
"of",
"Datasources",
"for",
"a",
"Source",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L65-L70 |
koordinates/python-client | koordinates/sources.py | SourceManager.get_datasource | def get_datasource(self, source_id, datasource_id):
"""
Get a Datasource object
:rtype: Datasource
"""
target_url = self.client.get_url('DATASOURCE', 'GET', 'single', {'source_id': source_id, 'datasource_id': datasource_id})
return self.client.get_manager(Datasource)._ge... | python | def get_datasource(self, source_id, datasource_id):
"""
Get a Datasource object
:rtype: Datasource
"""
target_url = self.client.get_url('DATASOURCE', 'GET', 'single', {'source_id': source_id, 'datasource_id': datasource_id})
return self.client.get_manager(Datasource)._ge... | [
"def",
"get_datasource",
"(",
"self",
",",
"source_id",
",",
"datasource_id",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'DATASOURCE'",
",",
"'GET'",
",",
"'single'",
",",
"{",
"'source_id'",
":",
"source_id",
",",
"'datasource... | Get a Datasource object
:rtype: Datasource | [
"Get",
"a",
"Datasource",
"object"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L72-L79 |
koordinates/python-client | koordinates/sources.py | SourceManager.list_scans | def list_scans(self, source_id=None):
"""
Filterable list of Scans for a Source.
Ordered newest to oldest by default
"""
if source_id:
target_url = self.client.get_url('SCAN', 'GET', 'multi', {'source_id': source_id})
else:
target_url = self.client... | python | def list_scans(self, source_id=None):
"""
Filterable list of Scans for a Source.
Ordered newest to oldest by default
"""
if source_id:
target_url = self.client.get_url('SCAN', 'GET', 'multi', {'source_id': source_id})
else:
target_url = self.client... | [
"def",
"list_scans",
"(",
"self",
",",
"source_id",
"=",
"None",
")",
":",
"if",
"source_id",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'SCAN'",
",",
"'GET'",
",",
"'multi'",
",",
"{",
"'source_id'",
":",
"source_id",
"}",
")... | Filterable list of Scans for a Source.
Ordered newest to oldest by default | [
"Filterable",
"list",
"of",
"Scans",
"for",
"a",
"Source",
".",
"Ordered",
"newest",
"to",
"oldest",
"by",
"default"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L81-L90 |
koordinates/python-client | koordinates/sources.py | SourceManager.get_scan | def get_scan(self, source_id, scan_id):
"""
Get a Scan object
:rtype: Scan
"""
target_url = self.client.get_url('SCAN', 'GET', 'single', {'source_id': source_id, 'scan_id': scan_id})
return self.client.get_manager(Scan)._get(target_url) | python | def get_scan(self, source_id, scan_id):
"""
Get a Scan object
:rtype: Scan
"""
target_url = self.client.get_url('SCAN', 'GET', 'single', {'source_id': source_id, 'scan_id': scan_id})
return self.client.get_manager(Scan)._get(target_url) | [
"def",
"get_scan",
"(",
"self",
",",
"source_id",
",",
"scan_id",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'SCAN'",
",",
"'GET'",
",",
"'single'",
",",
"{",
"'source_id'",
":",
"source_id",
",",
"'scan_id'",
":",
"scan_id... | Get a Scan object
:rtype: Scan | [
"Get",
"a",
"Scan",
"object"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L92-L99 |
koordinates/python-client | koordinates/sources.py | SourceManager.get_scan_log_lines | def get_scan_log_lines(self, source_id, scan_id):
"""
Get the log text for a Scan
:rtype: Iterator over log lines.
"""
return self.client.get_manager(Scan).get_log_lines(source_id=source_id, scan_id=scan_id) | python | def get_scan_log_lines(self, source_id, scan_id):
"""
Get the log text for a Scan
:rtype: Iterator over log lines.
"""
return self.client.get_manager(Scan).get_log_lines(source_id=source_id, scan_id=scan_id) | [
"def",
"get_scan_log_lines",
"(",
"self",
",",
"source_id",
",",
"scan_id",
")",
":",
"return",
"self",
".",
"client",
".",
"get_manager",
"(",
"Scan",
")",
".",
"get_log_lines",
"(",
"source_id",
"=",
"source_id",
",",
"scan_id",
"=",
"scan_id",
")"
] | Get the log text for a Scan
:rtype: Iterator over log lines. | [
"Get",
"the",
"log",
"text",
"for",
"a",
"Scan"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L101-L107 |
koordinates/python-client | koordinates/sources.py | SourceManager.start_scan | def start_scan(self, source_id):
"""
Start a new scan of a Source.
:rtype: Scan
"""
target_url = self.client.get_url('SCAN', 'POST', 'create', {'source_id': source_id})
r = self.client.request('POST', target_url, json={})
return self.client.get_manager(Scan).crea... | python | def start_scan(self, source_id):
"""
Start a new scan of a Source.
:rtype: Scan
"""
target_url = self.client.get_url('SCAN', 'POST', 'create', {'source_id': source_id})
r = self.client.request('POST', target_url, json={})
return self.client.get_manager(Scan).crea... | [
"def",
"start_scan",
"(",
"self",
",",
"source_id",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'SCAN'",
",",
"'POST'",
",",
"'create'",
",",
"{",
"'source_id'",
":",
"source_id",
"}",
")",
"r",
"=",
"self",
".",
"client",... | Start a new scan of a Source.
:rtype: Scan | [
"Start",
"a",
"new",
"scan",
"of",
"a",
"Source",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L109-L117 |
koordinates/python-client | koordinates/sources.py | Source.save | def save(self, with_data=False):
"""
Edits this Source
"""
r = self._client.request('PUT', self.url, json=self._serialize(with_data=with_data))
return self._deserialize(r.json(), self._manager) | python | def save(self, with_data=False):
"""
Edits this Source
"""
r = self._client.request('PUT', self.url, json=self._serialize(with_data=with_data))
return self._deserialize(r.json(), self._manager) | [
"def",
"save",
"(",
"self",
",",
"with_data",
"=",
"False",
")",
":",
"r",
"=",
"self",
".",
"_client",
".",
"request",
"(",
"'PUT'",
",",
"self",
".",
"url",
",",
"json",
"=",
"self",
".",
"_serialize",
"(",
"with_data",
"=",
"with_data",
")",
")"... | Edits this Source | [
"Edits",
"this",
"Source"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L158-L163 |
koordinates/python-client | koordinates/sources.py | Source.delete | def delete(self):
""" Delete this source """
r = self._client.request('DELETE', self.url)
logger.info("delete(): %s", r.status_code) | python | def delete(self):
""" Delete this source """
r = self._client.request('DELETE', self.url)
logger.info("delete(): %s", r.status_code) | [
"def",
"delete",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_client",
".",
"request",
"(",
"'DELETE'",
",",
"self",
".",
"url",
")",
"logger",
".",
"info",
"(",
"\"delete(): %s\"",
",",
"r",
".",
"status_code",
")"
] | Delete this source | [
"Delete",
"this",
"source"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L166-L169 |
koordinates/python-client | koordinates/sources.py | UploadSource.add_file | def add_file(self, fp, upload_path=None, content_type=None):
"""
Add a single file or archive to upload.
To add metadata records with a file, add a .xml file with the same upload path basename
eg. ``points-with-metadata.geojson`` & ``points-with-metadata.xml``
Datasource XML mus... | python | def add_file(self, fp, upload_path=None, content_type=None):
"""
Add a single file or archive to upload.
To add metadata records with a file, add a .xml file with the same upload path basename
eg. ``points-with-metadata.geojson`` & ``points-with-metadata.xml``
Datasource XML mus... | [
"def",
"add_file",
"(",
"self",
",",
"fp",
",",
"upload_path",
"=",
"None",
",",
"content_type",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"fp",
",",
"six",
".",
"string_types",
")",
":",
"# path",
"if",
"not",
"os",
".",
"path",
".",
"isfile",... | Add a single file or archive to upload.
To add metadata records with a file, add a .xml file with the same upload path basename
eg. ``points-with-metadata.geojson`` & ``points-with-metadata.xml``
Datasource XML must be in one of these three formats:
- ISO 19115/19139
- FGDC... | [
"Add",
"a",
"single",
"file",
"or",
"archive",
"to",
"upload",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L258-L294 |
koordinates/python-client | koordinates/sources.py | ScanManager.get_log_lines | def get_log_lines(self, source_id, scan_id):
"""
Get the log text for a scan object
:rtype: Iterator over log lines.
"""
target_url = self.client.get_url('SCAN', 'GET', 'log', {'source_id': source_id, 'scan_id': scan_id})
r = self.client.request('GET', target_url, headers... | python | def get_log_lines(self, source_id, scan_id):
"""
Get the log text for a scan object
:rtype: Iterator over log lines.
"""
target_url = self.client.get_url('SCAN', 'GET', 'log', {'source_id': source_id, 'scan_id': scan_id})
r = self.client.request('GET', target_url, headers... | [
"def",
"get_log_lines",
"(",
"self",
",",
"source_id",
",",
"scan_id",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'SCAN'",
",",
"'GET'",
",",
"'log'",
",",
"{",
"'source_id'",
":",
"source_id",
",",
"'scan_id'",
":",
"scan_... | Get the log text for a scan object
:rtype: Iterator over log lines. | [
"Get",
"the",
"log",
"text",
"for",
"a",
"scan",
"object",
":",
"rtype",
":",
"Iterator",
"over",
"log",
"lines",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L300-L307 |
koordinates/python-client | koordinates/sources.py | Scan.get_log_lines | def get_log_lines(self):
"""
Get the log text for a scan object
:rtype: Iterator over log lines.
"""
rel = self._client.reverse_url('SCAN', self.url)
return self._manager.get_log_lines(**rel) | python | def get_log_lines(self):
"""
Get the log text for a scan object
:rtype: Iterator over log lines.
"""
rel = self._client.reverse_url('SCAN', self.url)
return self._manager.get_log_lines(**rel) | [
"def",
"get_log_lines",
"(",
"self",
")",
":",
"rel",
"=",
"self",
".",
"_client",
".",
"reverse_url",
"(",
"'SCAN'",
",",
"self",
".",
"url",
")",
"return",
"self",
".",
"_manager",
".",
"get_log_lines",
"(",
"*",
"*",
"rel",
")"
] | Get the log text for a scan object
:rtype: Iterator over log lines. | [
"Get",
"the",
"log",
"text",
"for",
"a",
"scan",
"object"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L336-L343 |
koordinates/python-client | koordinates/licenses.py | LicenseManager.get_creative_commons | def get_creative_commons(self, slug, jurisdiction=None):
"""Returns the Creative Commons license for the given attributes.
:param str slug: the type of Creative Commons license. It must start with
``cc-by`` and can optionally contain ``nc`` (non-commercial),
``sa`` (share-alike)... | python | def get_creative_commons(self, slug, jurisdiction=None):
"""Returns the Creative Commons license for the given attributes.
:param str slug: the type of Creative Commons license. It must start with
``cc-by`` and can optionally contain ``nc`` (non-commercial),
``sa`` (share-alike)... | [
"def",
"get_creative_commons",
"(",
"self",
",",
"slug",
",",
"jurisdiction",
"=",
"None",
")",
":",
"if",
"not",
"slug",
".",
"startswith",
"(",
"'cc-by'",
")",
":",
"raise",
"exceptions",
".",
"ClientValidationError",
"(",
"\"slug needs to start with 'cc-by'\"",... | Returns the Creative Commons license for the given attributes.
:param str slug: the type of Creative Commons license. It must start with
``cc-by`` and can optionally contain ``nc`` (non-commercial),
``sa`` (share-alike), ``nd`` (no derivatives) terms, seperated by
hyphens. N... | [
"Returns",
"the",
"Creative",
"Commons",
"license",
"for",
"the",
"given",
"attributes",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/licenses.py#L26-L44 |
michaelaye/pyciss | pyciss/ringcube.py | mad | def mad(arr, relative=True):
""" Median Absolute Deviation: a "Robust" version of standard deviation.
Indices variabililty of the sample.
https://en.wikipedia.org/wiki/Median_absolute_deviation
"""
with warnings.catch_warnings():
warnings.simplefilter("ignore")
med = np.nanme... | python | def mad(arr, relative=True):
""" Median Absolute Deviation: a "Robust" version of standard deviation.
Indices variabililty of the sample.
https://en.wikipedia.org/wiki/Median_absolute_deviation
"""
with warnings.catch_warnings():
warnings.simplefilter("ignore")
med = np.nanme... | [
"def",
"mad",
"(",
"arr",
",",
"relative",
"=",
"True",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")",
"med",
"=",
"np",
".",
"nanmedian",
"(",
"arr",
",",
"axis",
"=",
"1"... | Median Absolute Deviation: a "Robust" version of standard deviation.
Indices variabililty of the sample.
https://en.wikipedia.org/wiki/Median_absolute_deviation | [
"Median",
"Absolute",
"Deviation",
":",
"a",
"Robust",
"version",
"of",
"standard",
"deviation",
".",
"Indices",
"variabililty",
"of",
"the",
"sample",
".",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Median_absolute_deviation"
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/ringcube.py#L59-L71 |
michaelaye/pyciss | pyciss/ringcube.py | calc_offset | def calc_offset(cube):
"""Calculate an offset.
Calculate offset from the side of data so that at least 200 image pixels are in the MAD stats.
Parameters
==========
cube : pyciss.ringcube.RingCube
Cubefile with ring image
"""
i = 0
while pd.Series(cube.img[:, i]).count() < 200:
... | python | def calc_offset(cube):
"""Calculate an offset.
Calculate offset from the side of data so that at least 200 image pixels are in the MAD stats.
Parameters
==========
cube : pyciss.ringcube.RingCube
Cubefile with ring image
"""
i = 0
while pd.Series(cube.img[:, i]).count() < 200:
... | [
"def",
"calc_offset",
"(",
"cube",
")",
":",
"i",
"=",
"0",
"while",
"pd",
".",
"Series",
"(",
"cube",
".",
"img",
"[",
":",
",",
"i",
"]",
")",
".",
"count",
"(",
")",
"<",
"200",
":",
"i",
"+=",
"1",
"return",
"max",
"(",
"i",
",",
"20",
... | Calculate an offset.
Calculate offset from the side of data so that at least 200 image pixels are in the MAD stats.
Parameters
==========
cube : pyciss.ringcube.RingCube
Cubefile with ring image | [
"Calculate",
"an",
"offset",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/ringcube.py#L74-L87 |
michaelaye/pyciss | pyciss/ringcube.py | RingCube.imshow | def imshow(
self,
data=None,
save=False,
ax=None,
interpolation="none",
extra_title=None,
show_resonances="some",
set_extent=True,
equalized=False,
rmin=None,
rmax=None,
savepath=".",
**kwargs,
):
"""Powe... | python | def imshow(
self,
data=None,
save=False,
ax=None,
interpolation="none",
extra_title=None,
show_resonances="some",
set_extent=True,
equalized=False,
rmin=None,
rmax=None,
savepath=".",
**kwargs,
):
"""Powe... | [
"def",
"imshow",
"(",
"self",
",",
"data",
"=",
"None",
",",
"save",
"=",
"False",
",",
"ax",
"=",
"None",
",",
"interpolation",
"=",
"\"none\"",
",",
"extra_title",
"=",
"None",
",",
"show_resonances",
"=",
"\"some\"",
",",
"set_extent",
"=",
"True",
... | Powerful default display.
show_resonances can be True, a list, 'all', or 'some' | [
"Powerful",
"default",
"display",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/ringcube.py#L259-L335 |
koordinates/python-client | koordinates/base.py | Query._update_range | def _update_range(self, response):
""" Update the query count property from the `X-Resource-Range` response header """
header_value = response.headers.get('x-resource-range', '')
m = re.match(r'\d+-\d+/(\d+)$', header_value)
if m:
self._count = int(m.group(1))
else:
... | python | def _update_range(self, response):
""" Update the query count property from the `X-Resource-Range` response header """
header_value = response.headers.get('x-resource-range', '')
m = re.match(r'\d+-\d+/(\d+)$', header_value)
if m:
self._count = int(m.group(1))
else:
... | [
"def",
"_update_range",
"(",
"self",
",",
"response",
")",
":",
"header_value",
"=",
"response",
".",
"headers",
".",
"get",
"(",
"'x-resource-range'",
",",
"''",
")",
"m",
"=",
"re",
".",
"match",
"(",
"r'\\d+-\\d+/(\\d+)$'",
",",
"header_value",
")",
"if... | Update the query count property from the `X-Resource-Range` response header | [
"Update",
"the",
"query",
"count",
"property",
"from",
"the",
"X",
"-",
"Resource",
"-",
"Range",
"response",
"header"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L146-L153 |
koordinates/python-client | koordinates/base.py | Query._to_url | def _to_url(self):
""" Serialises this query into a request-able URL including parameters """
url = self._target_url
params = collections.defaultdict(list, copy.deepcopy(self._filters))
if self._order_by is not None:
params['sort'] = self._order_by
for k, vl in self.... | python | def _to_url(self):
""" Serialises this query into a request-able URL including parameters """
url = self._target_url
params = collections.defaultdict(list, copy.deepcopy(self._filters))
if self._order_by is not None:
params['sort'] = self._order_by
for k, vl in self.... | [
"def",
"_to_url",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_target_url",
"params",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
",",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_filters",
")",
")",
"if",
"self",
".",
"_order_by",
"is",
... | Serialises this query into a request-able URL including parameters | [
"Serialises",
"this",
"query",
"into",
"a",
"request",
"-",
"able",
"URL",
"including",
"parameters"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L155-L168 |
koordinates/python-client | koordinates/base.py | Query.extra | def extra(self, **params):
"""
Set extra query parameters (eg. filter expressions/attributes that don't validate).
Appends to any previous extras set.
:rtype: Query
"""
q = self._clone()
for key, value in params.items():
q._extra[key].append(value)
... | python | def extra(self, **params):
"""
Set extra query parameters (eg. filter expressions/attributes that don't validate).
Appends to any previous extras set.
:rtype: Query
"""
q = self._clone()
for key, value in params.items():
q._extra[key].append(value)
... | [
"def",
"extra",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"q",
"=",
"self",
".",
"_clone",
"(",
")",
"for",
"key",
",",
"value",
"in",
"params",
".",
"items",
"(",
")",
":",
"q",
".",
"_extra",
"[",
"key",
"]",
".",
"append",
"(",
"valu... | Set extra query parameters (eg. filter expressions/attributes that don't validate).
Appends to any previous extras set.
:rtype: Query | [
"Set",
"extra",
"query",
"parameters",
"(",
"eg",
".",
"filter",
"expressions",
"/",
"attributes",
"that",
"don",
"t",
"validate",
")",
".",
"Appends",
"to",
"any",
"previous",
"extras",
"set",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L267-L277 |
koordinates/python-client | koordinates/base.py | Query.filter | def filter(self, **filters):
"""
Add a filter to this query.
Appends to any previous filters set.
:rtype: Query
"""
q = self._clone()
for key, value in filters.items():
filter_key = re.split('__', key)
filter_attr = filter_key[0]
... | python | def filter(self, **filters):
"""
Add a filter to this query.
Appends to any previous filters set.
:rtype: Query
"""
q = self._clone()
for key, value in filters.items():
filter_key = re.split('__', key)
filter_attr = filter_key[0]
... | [
"def",
"filter",
"(",
"self",
",",
"*",
"*",
"filters",
")",
":",
"q",
"=",
"self",
".",
"_clone",
"(",
")",
"for",
"key",
",",
"value",
"in",
"filters",
".",
"items",
"(",
")",
":",
"filter_key",
"=",
"re",
".",
"split",
"(",
"'__'",
",",
"key... | Add a filter to this query.
Appends to any previous filters set.
:rtype: Query | [
"Add",
"a",
"filter",
"to",
"this",
"query",
".",
"Appends",
"to",
"any",
"previous",
"filters",
"set",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L279-L296 |
koordinates/python-client | koordinates/base.py | Query.order_by | def order_by(self, sort_key=None):
"""
Set the sort for this query. Not all attributes are sorting candidates.
To sort in descending order, call ``Query.order_by('-attribute')``.
Calling ``Query.order_by()`` replaces any previous ordering.
:rtype: Query
"""
if s... | python | def order_by(self, sort_key=None):
"""
Set the sort for this query. Not all attributes are sorting candidates.
To sort in descending order, call ``Query.order_by('-attribute')``.
Calling ``Query.order_by()`` replaces any previous ordering.
:rtype: Query
"""
if s... | [
"def",
"order_by",
"(",
"self",
",",
"sort_key",
"=",
"None",
")",
":",
"if",
"sort_key",
"is",
"not",
"None",
":",
"sort_attr",
"=",
"re",
".",
"match",
"(",
"r'(-)?(.*)$'",
",",
"sort_key",
")",
".",
"group",
"(",
"2",
")",
"if",
"sort_attr",
"not"... | Set the sort for this query. Not all attributes are sorting candidates.
To sort in descending order, call ``Query.order_by('-attribute')``.
Calling ``Query.order_by()`` replaces any previous ordering.
:rtype: Query | [
"Set",
"the",
"sort",
"for",
"this",
"query",
".",
"Not",
"all",
"attributes",
"are",
"sorting",
"candidates",
".",
"To",
"sort",
"in",
"descending",
"order",
"call",
"Query",
".",
"order_by",
"(",
"-",
"attribute",
")",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L298-L314 |
koordinates/python-client | koordinates/base.py | SerializableBase._deserialize | def _deserialize(self, data):
"""
Deserialise from JSON response data.
String items named ``*_at`` are turned into dates.
Filters out:
* attribute names in ``Meta.deserialize_skip``
:param data dict: JSON-style object with instance data.
:return: this instance
... | python | def _deserialize(self, data):
"""
Deserialise from JSON response data.
String items named ``*_at`` are turned into dates.
Filters out:
* attribute names in ``Meta.deserialize_skip``
:param data dict: JSON-style object with instance data.
:return: this instance
... | [
"def",
"_deserialize",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"Need to deserialize from a dict\"",
")",
"try",
":",
"skip",
"=",
"set",
"(",
"getattr",
"(",
"self",
... | Deserialise from JSON response data.
String items named ``*_at`` are turned into dates.
Filters out:
* attribute names in ``Meta.deserialize_skip``
:param data dict: JSON-style object with instance data.
:return: this instance | [
"Deserialise",
"from",
"JSON",
"response",
"data",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L428-L452 |
koordinates/python-client | koordinates/base.py | SerializableBase._serialize | def _serialize(self, skip_empty=True):
"""
Serialise this instance into JSON-style request data.
Filters out:
* attribute names starting with ``_``
* attribute values that are ``None`` (unless ``skip_empty`` is ``False``)
* attribute values that are empty lists/tuples/di... | python | def _serialize(self, skip_empty=True):
"""
Serialise this instance into JSON-style request data.
Filters out:
* attribute names starting with ``_``
* attribute values that are ``None`` (unless ``skip_empty`` is ``False``)
* attribute values that are empty lists/tuples/di... | [
"def",
"_serialize",
"(",
"self",
",",
"skip_empty",
"=",
"True",
")",
":",
"skip",
"=",
"set",
"(",
"getattr",
"(",
"self",
".",
"_meta",
",",
"'serialize_skip'",
",",
"[",
"]",
")",
")",
"r",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
... | Serialise this instance into JSON-style request data.
Filters out:
* attribute names starting with ``_``
* attribute values that are ``None`` (unless ``skip_empty`` is ``False``)
* attribute values that are empty lists/tuples/dicts (unless ``skip_empty`` is ``False``)
* attribut... | [
"Serialise",
"this",
"instance",
"into",
"JSON",
"-",
"style",
"request",
"data",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L459-L490 |
koordinates/python-client | koordinates/base.py | SerializableBase._serialize_value | def _serialize_value(self, value):
"""
Called by :py:meth:`._serialize` to serialise an individual value.
"""
if isinstance(value, (list, tuple, set)):
return [self._serialize_value(v) for v in value]
elif isinstance(value, dict):
return dict([(k, self._se... | python | def _serialize_value(self, value):
"""
Called by :py:meth:`._serialize` to serialise an individual value.
"""
if isinstance(value, (list, tuple, set)):
return [self._serialize_value(v) for v in value]
elif isinstance(value, dict):
return dict([(k, self._se... | [
"def",
"_serialize_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
",",
"set",
")",
")",
":",
"return",
"[",
"self",
".",
"_serialize_value",
"(",
"v",
")",
"for",
"v",
"in",
"value",
"... | Called by :py:meth:`._serialize` to serialise an individual value. | [
"Called",
"by",
":",
"py",
":",
"meth",
":",
".",
"_serialize",
"to",
"serialise",
"an",
"individual",
"value",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L492-L505 |
koordinates/python-client | koordinates/base.py | Model.refresh | def refresh(self):
"""
Refresh this model from the server.
Updates attributes with the server-defined values. This is useful where the Model
instance came from a partial response (eg. a list query) and additional details
are required.
Existing attribute values will be o... | python | def refresh(self):
"""
Refresh this model from the server.
Updates attributes with the server-defined values. This is useful where the Model
instance came from a partial response (eg. a list query) and additional details
are required.
Existing attribute values will be o... | [
"def",
"refresh",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_client",
".",
"request",
"(",
"'GET'",
",",
"self",
".",
"url",
")",
"return",
"self",
".",
"_deserialize",
"(",
"r",
".",
"json",
"(",
")",
",",
"self",
".",
"_manager",
")"
] | Refresh this model from the server.
Updates attributes with the server-defined values. This is useful where the Model
instance came from a partial response (eg. a list query) and additional details
are required.
Existing attribute values will be overwritten. | [
"Refresh",
"this",
"model",
"from",
"the",
"server",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L610-L621 |
koordinates/python-client | koordinates/exports.py | CropLayerManager.get_feature | def get_feature(self, croplayer_id, cropfeature_id):
"""
Gets a crop feature
:param int croplayer_id: ID of a cropping layer
:param int cropfeature_id: ID of a cropping feature
:rtype: CropFeature
"""
target_url = self.client.get_url('CROPFEATURE', 'GET', 'single... | python | def get_feature(self, croplayer_id, cropfeature_id):
"""
Gets a crop feature
:param int croplayer_id: ID of a cropping layer
:param int cropfeature_id: ID of a cropping feature
:rtype: CropFeature
"""
target_url = self.client.get_url('CROPFEATURE', 'GET', 'single... | [
"def",
"get_feature",
"(",
"self",
",",
"croplayer_id",
",",
"cropfeature_id",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'CROPFEATURE'",
",",
"'GET'",
",",
"'single'",
",",
"{",
"'croplayer_id'",
":",
"croplayer_id",
",",
"'cr... | Gets a crop feature
:param int croplayer_id: ID of a cropping layer
:param int cropfeature_id: ID of a cropping feature
:rtype: CropFeature | [
"Gets",
"a",
"crop",
"feature"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L37-L46 |
koordinates/python-client | koordinates/exports.py | ExportManager.create | def create(self, export):
"""
Create and start processing a new Export.
:param Export export: The Export to create.
:rtype: Export
"""
target_url = self.client.get_url(self._URL_KEY, 'POST', 'create')
r = self.client.request('POST', target_url, json=export._seria... | python | def create(self, export):
"""
Create and start processing a new Export.
:param Export export: The Export to create.
:rtype: Export
"""
target_url = self.client.get_url(self._URL_KEY, 'POST', 'create')
r = self.client.request('POST', target_url, json=export._seria... | [
"def",
"create",
"(",
"self",
",",
"export",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"self",
".",
"_URL_KEY",
",",
"'POST'",
",",
"'create'",
")",
"r",
"=",
"self",
".",
"client",
".",
"request",
"(",
"'POST'",
",",
... | Create and start processing a new Export.
:param Export export: The Export to create.
:rtype: Export | [
"Create",
"and",
"start",
"processing",
"a",
"new",
"Export",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L112-L121 |
koordinates/python-client | koordinates/exports.py | ExportManager.validate | def validate(self, export):
"""
Validates an Export.
:param Export export:
:rtype: ExportValidationResponse
"""
target_url = self.client.get_url(self._URL_KEY, 'POST', 'validate')
response_object = ExportValidationResponse()
r = self.client.request('POST... | python | def validate(self, export):
"""
Validates an Export.
:param Export export:
:rtype: ExportValidationResponse
"""
target_url = self.client.get_url(self._URL_KEY, 'POST', 'validate')
response_object = ExportValidationResponse()
r = self.client.request('POST... | [
"def",
"validate",
"(",
"self",
",",
"export",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"self",
".",
"_URL_KEY",
",",
"'POST'",
",",
"'validate'",
")",
"response_object",
"=",
"ExportValidationResponse",
"(",
")",
"r",
"=",
... | Validates an Export.
:param Export export:
:rtype: ExportValidationResponse | [
"Validates",
"an",
"Export",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L123-L134 |
koordinates/python-client | koordinates/exports.py | ExportManager._options | def _options(self):
"""
Returns a raw options object
:rtype: dict
"""
if self._options_cache is None:
target_url = self.client.get_url(self._URL_KEY, 'OPTIONS', 'options')
r = self.client.request('OPTIONS', target_url)
self._options_cache = r.... | python | def _options(self):
"""
Returns a raw options object
:rtype: dict
"""
if self._options_cache is None:
target_url = self.client.get_url(self._URL_KEY, 'OPTIONS', 'options')
r = self.client.request('OPTIONS', target_url)
self._options_cache = r.... | [
"def",
"_options",
"(",
"self",
")",
":",
"if",
"self",
".",
"_options_cache",
"is",
"None",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"self",
".",
"_URL_KEY",
",",
"'OPTIONS'",
",",
"'options'",
")",
"r",
"=",
"self",
".",
... | Returns a raw options object
:rtype: dict | [
"Returns",
"a",
"raw",
"options",
"object"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L141-L151 |
koordinates/python-client | koordinates/exports.py | ExportManager.get_formats | def get_formats(self):
"""
Returns a dictionary of format options keyed by data kind.
.. code-block:: python
{
"vector": {
"application/x-ogc-gpkg": "GeoPackage",
"application/x-zipped-shp": "Shapefile",
#.... | python | def get_formats(self):
"""
Returns a dictionary of format options keyed by data kind.
.. code-block:: python
{
"vector": {
"application/x-ogc-gpkg": "GeoPackage",
"application/x-zipped-shp": "Shapefile",
#.... | [
"def",
"get_formats",
"(",
"self",
")",
":",
"format_opts",
"=",
"self",
".",
"_options",
"(",
")",
"[",
"'actions'",
"]",
"[",
"'POST'",
"]",
"[",
"'formats'",
"]",
"[",
"'children'",
"]",
"r",
"=",
"{",
"}",
"for",
"kind",
",",
"kind_opts",
"in",
... | Returns a dictionary of format options keyed by data kind.
.. code-block:: python
{
"vector": {
"application/x-ogc-gpkg": "GeoPackage",
"application/x-zipped-shp": "Shapefile",
#...
},
"tabl... | [
"Returns",
"a",
"dictionary",
"of",
"format",
"options",
"keyed",
"by",
"data",
"kind",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L153-L192 |
koordinates/python-client | koordinates/exports.py | Export.add_item | def add_item(self, item, **options):
"""
Add a layer or table item to the export.
:param Layer|Table item: The Layer or Table to add
:rtype: self
"""
export_item = {
"item": item.url,
}
export_item.update(options)
self.items.append(exp... | python | def add_item(self, item, **options):
"""
Add a layer or table item to the export.
:param Layer|Table item: The Layer or Table to add
:rtype: self
"""
export_item = {
"item": item.url,
}
export_item.update(options)
self.items.append(exp... | [
"def",
"add_item",
"(",
"self",
",",
"item",
",",
"*",
"*",
"options",
")",
":",
"export_item",
"=",
"{",
"\"item\"",
":",
"item",
".",
"url",
",",
"}",
"export_item",
".",
"update",
"(",
"options",
")",
"self",
".",
"items",
".",
"append",
"(",
"e... | Add a layer or table item to the export.
:param Layer|Table item: The Layer or Table to add
:rtype: self | [
"Add",
"a",
"layer",
"or",
"table",
"item",
"to",
"the",
"export",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L239-L251 |
koordinates/python-client | koordinates/exports.py | Export.download | def download(self, path, progress_callback=None, chunk_size=1024**2):
"""
Download the export archive.
.. warning::
If you pass this function an open file-like object as the ``path``
parameter, the function will not close that file for you.
If a ``path`` parame... | python | def download(self, path, progress_callback=None, chunk_size=1024**2):
"""
Download the export archive.
.. warning::
If you pass this function an open file-like object as the ``path``
parameter, the function will not close that file for you.
If a ``path`` parame... | [
"def",
"download",
"(",
"self",
",",
"path",
",",
"progress_callback",
"=",
"None",
",",
"chunk_size",
"=",
"1024",
"**",
"2",
")",
":",
"if",
"not",
"self",
".",
"download_url",
"or",
"self",
".",
"state",
"!=",
"'complete'",
":",
"raise",
"DownloadErro... | Download the export archive.
.. warning::
If you pass this function an open file-like object as the ``path``
parameter, the function will not close that file for you.
If a ``path`` parameter is a directory, this function will use the
Export name to determine the name o... | [
"Download",
"the",
"export",
"archive",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L273-L351 |
koordinates/python-client | koordinates/exceptions.py | ServerError.from_requests_error | def from_requests_error(cls, err):
"""
Raises a subclass of ServerError based on the HTTP response code.
"""
import requests
if isinstance(err, requests.HTTPError):
status_code = err.response.status_code
return HTTP_ERRORS.get(status_code, cls)(error=err, ... | python | def from_requests_error(cls, err):
"""
Raises a subclass of ServerError based on the HTTP response code.
"""
import requests
if isinstance(err, requests.HTTPError):
status_code = err.response.status_code
return HTTP_ERRORS.get(status_code, cls)(error=err, ... | [
"def",
"from_requests_error",
"(",
"cls",
",",
"err",
")",
":",
"import",
"requests",
"if",
"isinstance",
"(",
"err",
",",
"requests",
".",
"HTTPError",
")",
":",
"status_code",
"=",
"err",
".",
"response",
".",
"status_code",
"return",
"HTTP_ERRORS",
".",
... | Raises a subclass of ServerError based on the HTTP response code. | [
"Raises",
"a",
"subclass",
"of",
"ServerError",
"based",
"on",
"the",
"HTTP",
"response",
"code",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exceptions.py#L28-L37 |
koordinates/python-client | koordinates/tokens.py | console_create | def console_create():
"""
Command line tool (``koordinates-create-token``) used to create an API token.
"""
import argparse
import getpass
import re
import sys
import requests
from six.moves import input
from koordinates.client import Client
parser = argparse.ArgumentParser(... | python | def console_create():
"""
Command line tool (``koordinates-create-token``) used to create an API token.
"""
import argparse
import getpass
import re
import sys
import requests
from six.moves import input
from koordinates.client import Client
parser = argparse.ArgumentParser(... | [
"def",
"console_create",
"(",
")",
":",
"import",
"argparse",
"import",
"getpass",
"import",
"re",
"import",
"sys",
"import",
"requests",
"from",
"six",
".",
"moves",
"import",
"input",
"from",
"koordinates",
".",
"client",
"import",
"Client",
"parser",
"=",
... | Command line tool (``koordinates-create-token``) used to create an API token. | [
"Command",
"line",
"tool",
"(",
"koordinates",
"-",
"create",
"-",
"token",
")",
"used",
"to",
"create",
"an",
"API",
"token",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/tokens.py#L96-L163 |
koordinates/python-client | koordinates/tokens.py | TokenManager.delete | def delete(self, id ):
""" Delete a token """
target_url = self.client.get_url('TOKEN', 'DELETE', 'single', {'id':id})
r = self.client.request('DELETE', target_url, headers={'Content-type': 'application/json'})
r.raise_for_status() | python | def delete(self, id ):
""" Delete a token """
target_url = self.client.get_url('TOKEN', 'DELETE', 'single', {'id':id})
r = self.client.request('DELETE', target_url, headers={'Content-type': 'application/json'})
r.raise_for_status() | [
"def",
"delete",
"(",
"self",
",",
"id",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'TOKEN'",
",",
"'DELETE'",
",",
"'single'",
",",
"{",
"'id'",
":",
"id",
"}",
")",
"r",
"=",
"self",
".",
"client",
".",
"request",
... | Delete a token | [
"Delete",
"a",
"token"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/tokens.py#L33-L38 |
koordinates/python-client | koordinates/tokens.py | TokenManager.create | def create(self, token, email, password):
"""
Create a new token
:param Token token: Token instance to create.
:param str email: Email address of the Koordinates user account.
:param str password: Koordinates user account password.
"""
target_url = self.client.ge... | python | def create(self, token, email, password):
"""
Create a new token
:param Token token: Token instance to create.
:param str email: Email address of the Koordinates user account.
:param str password: Koordinates user account password.
"""
target_url = self.client.ge... | [
"def",
"create",
"(",
"self",
",",
"token",
",",
"email",
",",
"password",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'TOKEN'",
",",
"'POST'",
",",
"'create'",
")",
"post_data",
"=",
"{",
"'grant_type'",
":",
"'password'",
... | Create a new token
:param Token token: Token instance to create.
:param str email: Email address of the Koordinates user account.
:param str password: Koordinates user account password. | [
"Create",
"a",
"new",
"token"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/tokens.py#L41-L64 |
michaelaye/pyciss | pyciss/index.py | read_cumulative_iss_index | def read_cumulative_iss_index():
"Read in the whole cumulative index and return dataframe."
indexdir = get_index_dir()
path = indexdir / "COISS_2999_index.hdf"
try:
df = pd.read_hdf(path, "df")
except FileNotFoundError:
path = indexdir / "cumindex.hdf"
df = pd.read_hdf(path,... | python | def read_cumulative_iss_index():
"Read in the whole cumulative index and return dataframe."
indexdir = get_index_dir()
path = indexdir / "COISS_2999_index.hdf"
try:
df = pd.read_hdf(path, "df")
except FileNotFoundError:
path = indexdir / "cumindex.hdf"
df = pd.read_hdf(path,... | [
"def",
"read_cumulative_iss_index",
"(",
")",
":",
"indexdir",
"=",
"get_index_dir",
"(",
")",
"path",
"=",
"indexdir",
"/",
"\"COISS_2999_index.hdf\"",
"try",
":",
"df",
"=",
"pd",
".",
"read_hdf",
"(",
"path",
",",
"\"df\"",
")",
"except",
"FileNotFoundError... | Read in the whole cumulative index and return dataframe. | [
"Read",
"in",
"the",
"whole",
"cumulative",
"index",
"and",
"return",
"dataframe",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/index.py#L33-L45 |
michaelaye/pyciss | pyciss/index.py | read_ring_images_index | def read_ring_images_index():
"""Filter cumulative index for ring images.
This is done by matching the column TARGET_DESC to contain the string 'ring'
Returns
-------
pandas.DataFrame
data table containing only meta-data for ring images
"""
meta = read_cumulative_iss_index()
ri... | python | def read_ring_images_index():
"""Filter cumulative index for ring images.
This is done by matching the column TARGET_DESC to contain the string 'ring'
Returns
-------
pandas.DataFrame
data table containing only meta-data for ring images
"""
meta = read_cumulative_iss_index()
ri... | [
"def",
"read_ring_images_index",
"(",
")",
":",
"meta",
"=",
"read_cumulative_iss_index",
"(",
")",
"ringfilter",
"=",
"meta",
".",
"TARGET_DESC",
".",
"str",
".",
"contains",
"(",
"\"ring\"",
",",
"case",
"=",
"False",
")",
"return",
"meta",
"[",
"ringfilte... | Filter cumulative index for ring images.
This is done by matching the column TARGET_DESC to contain the string 'ring'
Returns
-------
pandas.DataFrame
data table containing only meta-data for ring images | [
"Filter",
"cumulative",
"index",
"for",
"ring",
"images",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/index.py#L62-L74 |
michaelaye/pyciss | pyciss/index.py | filter_for_ringspan | def filter_for_ringspan(clearnacs, spanlimit):
"filter for covered ringspan, giver in km."
delta = clearnacs.MAXIMUM_RING_RADIUS - clearnacs.MINIMUM_RING_RADIUS
f = delta < spanlimit
ringspan = clearnacs[f].copy()
return ringspan | python | def filter_for_ringspan(clearnacs, spanlimit):
"filter for covered ringspan, giver in km."
delta = clearnacs.MAXIMUM_RING_RADIUS - clearnacs.MINIMUM_RING_RADIUS
f = delta < spanlimit
ringspan = clearnacs[f].copy()
return ringspan | [
"def",
"filter_for_ringspan",
"(",
"clearnacs",
",",
"spanlimit",
")",
":",
"delta",
"=",
"clearnacs",
".",
"MAXIMUM_RING_RADIUS",
"-",
"clearnacs",
".",
"MINIMUM_RING_RADIUS",
"f",
"=",
"delta",
"<",
"spanlimit",
"ringspan",
"=",
"clearnacs",
"[",
"f",
"]",
"... | filter for covered ringspan, giver in km. | [
"filter",
"for",
"covered",
"ringspan",
"giver",
"in",
"km",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/index.py#L95-L100 |
koordinates/python-client | koordinates/publishing.py | PublishManager.create | def create(self, publish):
"""
Creates a new publish group.
"""
target_url = self.client.get_url('PUBLISH', 'POST', 'create')
r = self.client.request('POST', target_url, json=publish._serialize())
return self.create_from_result(r.json()) | python | def create(self, publish):
"""
Creates a new publish group.
"""
target_url = self.client.get_url('PUBLISH', 'POST', 'create')
r = self.client.request('POST', target_url, json=publish._serialize())
return self.create_from_result(r.json()) | [
"def",
"create",
"(",
"self",
",",
"publish",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'PUBLISH'",
",",
"'POST'",
",",
"'create'",
")",
"r",
"=",
"self",
".",
"client",
".",
"request",
"(",
"'POST'",
",",
"target_url",
... | Creates a new publish group. | [
"Creates",
"a",
"new",
"publish",
"group",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L29-L35 |
koordinates/python-client | koordinates/publishing.py | Publish.cancel | def cancel(self):
""" Cancel a pending publish task """
target_url = self._client.get_url('PUBLISH', 'DELETE', 'single', {'id': self.id})
r = self._client.request('DELETE', target_url)
logger.info("cancel(): %s", r.status_code) | python | def cancel(self):
""" Cancel a pending publish task """
target_url = self._client.get_url('PUBLISH', 'DELETE', 'single', {'id': self.id})
r = self._client.request('DELETE', target_url)
logger.info("cancel(): %s", r.status_code) | [
"def",
"cancel",
"(",
"self",
")",
":",
"target_url",
"=",
"self",
".",
"_client",
".",
"get_url",
"(",
"'PUBLISH'",
",",
"'DELETE'",
",",
"'single'",
",",
"{",
"'id'",
":",
"self",
".",
"id",
"}",
")",
"r",
"=",
"self",
".",
"_client",
".",
"reque... | Cancel a pending publish task | [
"Cancel",
"a",
"pending",
"publish",
"task"
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L56-L60 |
koordinates/python-client | koordinates/publishing.py | Publish.get_items | def get_items(self):
"""
Return the item models associated with this Publish group.
"""
from .layers import Layer
# no expansion support, just URLs
results = []
for url in self.items:
if '/layers/' in url:
r = self._client.request('GET... | python | def get_items(self):
"""
Return the item models associated with this Publish group.
"""
from .layers import Layer
# no expansion support, just URLs
results = []
for url in self.items:
if '/layers/' in url:
r = self._client.request('GET... | [
"def",
"get_items",
"(",
"self",
")",
":",
"from",
".",
"layers",
"import",
"Layer",
"# no expansion support, just URLs",
"results",
"=",
"[",
"]",
"for",
"url",
"in",
"self",
".",
"items",
":",
"if",
"'/layers/'",
"in",
"url",
":",
"r",
"=",
"self",
"."... | Return the item models associated with this Publish group. | [
"Return",
"the",
"item",
"models",
"associated",
"with",
"this",
"Publish",
"group",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L62-L76 |
koordinates/python-client | koordinates/publishing.py | Publish.add_layer_item | def add_layer_item(self, layer):
"""
Adds a Layer to the publish group.
"""
if not layer.is_draft_version:
raise ValueError("Layer isn't a draft version")
self.items.append(layer.latest_version) | python | def add_layer_item(self, layer):
"""
Adds a Layer to the publish group.
"""
if not layer.is_draft_version:
raise ValueError("Layer isn't a draft version")
self.items.append(layer.latest_version) | [
"def",
"add_layer_item",
"(",
"self",
",",
"layer",
")",
":",
"if",
"not",
"layer",
".",
"is_draft_version",
":",
"raise",
"ValueError",
"(",
"\"Layer isn't a draft version\"",
")",
"self",
".",
"items",
".",
"append",
"(",
"layer",
".",
"latest_version",
")"
... | Adds a Layer to the publish group. | [
"Adds",
"a",
"Layer",
"to",
"the",
"publish",
"group",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L78-L85 |
koordinates/python-client | koordinates/publishing.py | Publish.add_table_item | def add_table_item(self, table):
"""
Adds a Table to the publish group.
"""
if not table.is_draft_version:
raise ValueError("Table isn't a draft version")
self.items.append(table.latest_version) | python | def add_table_item(self, table):
"""
Adds a Table to the publish group.
"""
if not table.is_draft_version:
raise ValueError("Table isn't a draft version")
self.items.append(table.latest_version) | [
"def",
"add_table_item",
"(",
"self",
",",
"table",
")",
":",
"if",
"not",
"table",
".",
"is_draft_version",
":",
"raise",
"ValueError",
"(",
"\"Table isn't a draft version\"",
")",
"self",
".",
"items",
".",
"append",
"(",
"table",
".",
"latest_version",
")"
... | Adds a Table to the publish group. | [
"Adds",
"a",
"Table",
"to",
"the",
"publish",
"group",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L87-L94 |
michaelaye/pyciss | pyciss/plotting.py | add_ticks_to_x | def add_ticks_to_x(ax, newticks, newnames):
"""Add new ticks to an axis.
I use this for the right-hand plotting of resonance names in my plots.
"""
ticks = list(ax.get_xticks())
ticks.extend(newticks)
ax.set_xticks(ticks)
names = list(ax.get_xticklabels())
names.extend(newnames)
ax... | python | def add_ticks_to_x(ax, newticks, newnames):
"""Add new ticks to an axis.
I use this for the right-hand plotting of resonance names in my plots.
"""
ticks = list(ax.get_xticks())
ticks.extend(newticks)
ax.set_xticks(ticks)
names = list(ax.get_xticklabels())
names.extend(newnames)
ax... | [
"def",
"add_ticks_to_x",
"(",
"ax",
",",
"newticks",
",",
"newnames",
")",
":",
"ticks",
"=",
"list",
"(",
"ax",
".",
"get_xticks",
"(",
")",
")",
"ticks",
".",
"extend",
"(",
"newticks",
")",
"ax",
".",
"set_xticks",
"(",
"ticks",
")",
"names",
"=",... | Add new ticks to an axis.
I use this for the right-hand plotting of resonance names in my plots. | [
"Add",
"new",
"ticks",
"to",
"an",
"axis",
"."
] | train | https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/plotting.py#L90-L101 |
koordinates/python-client | koordinates/sets.py | SetManager.create | def create(self, set):
"""
Creates a new Set.
"""
target_url = self.client.get_url('SET', 'POST', 'create')
r = self.client.request('POST', target_url, json=set._serialize())
return set._deserialize(r.json(), self) | python | def create(self, set):
"""
Creates a new Set.
"""
target_url = self.client.get_url('SET', 'POST', 'create')
r = self.client.request('POST', target_url, json=set._serialize())
return set._deserialize(r.json(), self) | [
"def",
"create",
"(",
"self",
",",
"set",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'SET'",
",",
"'POST'",
",",
"'create'",
")",
"r",
"=",
"self",
".",
"client",
".",
"request",
"(",
"'POST'",
",",
"target_url",
",",
... | Creates a new Set. | [
"Creates",
"a",
"new",
"Set",
"."
] | train | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sets.py#L37-L43 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.