repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L643-L661
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L663-L691
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L694-L704
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L707-L734
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_api.py#L736-L753
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/utils/xmlutils.py#L30-L57
train
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", ...
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/utils/xmlutils.py#L60-L96
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/utils/xmlutils.py#L99-L111
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/upgrade_10.py#L52-L77
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/upgrade_10.py#L79-L94
train
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" ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/upgrade_10.py#L96-L153
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/upgrade_10.py#L155-L207
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/__init__.py#L51-L80
train
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" ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/__init__.py#L82-L105
train
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", "." ]
712247f3a10bdc2584fa18ac909fc763f71df21a
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/managers/__init__.py#L107-L120
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/permissions.py#L35-L44
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/permissions.py#L46-L57
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/permissions.py#L59-L65
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/permissions.py#L67-L76
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L23-L37
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L53-L70
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L81-L86
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L89-L104
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/io.py#L237-L243
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/downloader.py#L37-L51
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/downloader.py#L54-L83
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/pipeline.py#L142-L151
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/pipeline.py#L153-L177
train
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", "." ]
9440eb062950cb34111170e057f1e73c82bdce9a
https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L20-L27
train
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", "." ]
9440eb062950cb34111170e057f1e73c82bdce9a
https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L29-L69
train
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", "." ]
9440eb062950cb34111170e057f1e73c82bdce9a
https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L71-L86
train
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", "." ]
9440eb062950cb34111170e057f1e73c82bdce9a
https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L88-L129
train
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", "." ]
9440eb062950cb34111170e057f1e73c82bdce9a
https://github.com/JenkinsDev/pelican-readtime/blob/9440eb062950cb34111170e057f1e73c82bdce9a/readtime.py#L131-L146
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L65-L70
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L72-L79
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L81-L90
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L92-L99
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L101-L107
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L109-L117
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L158-L163
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L166-L169
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L258-L294
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L300-L307
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sources.py#L336-L343
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/licenses.py#L26-L44
train
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" ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/ringcube.py#L59-L71
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/ringcube.py#L74-L87
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/ringcube.py#L259-L335
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L146-L153
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L155-L168
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L267-L277
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L279-L296
train
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", ")", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L298-L314
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L428-L452
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L459-L490
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L492-L505
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/base.py#L610-L621
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L37-L46
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L112-L121
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L123-L134
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L141-L151
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L153-L192
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L239-L251
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exports.py#L273-L351
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/exceptions.py#L28-L37
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/tokens.py#L96-L163
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/tokens.py#L33-L38
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/tokens.py#L41-L64
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/index.py#L33-L45
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/index.py#L62-L74
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/index.py#L95-L100
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L29-L35
train
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" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L56-L60
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L62-L76
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L78-L85
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L87-L94
train
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", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/plotting.py#L90-L101
train
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", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sets.py#L37-L43
train
koordinates/python-client
koordinates/sets.py
SetManager.set_metadata
def set_metadata(self, set_id, fp): """ Set the XML metadata on a set. :param file fp: file-like object to read the XML metadata from. """ base_url = self.client.get_url('SET', 'GET', 'single', {'id': set_id}) self._metadata.set(base_url, fp)
python
def set_metadata(self, set_id, fp): """ Set the XML metadata on a set. :param file fp: file-like object to read the XML metadata from. """ base_url = self.client.get_url('SET', 'GET', 'single', {'id': set_id}) self._metadata.set(base_url, fp)
[ "def", "set_metadata", "(", "self", ",", "set_id", ",", "fp", ")", ":", "base_url", "=", "self", ".", "client", ".", "get_url", "(", "'SET'", ",", "'GET'", ",", "'single'", ",", "{", "'id'", ":", "set_id", "}", ")", "self", ".", "_metadata", ".", "...
Set the XML metadata on a set. :param file fp: file-like object to read the XML metadata from.
[ "Set", "the", "XML", "metadata", "on", "a", "set", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sets.py#L45-L52
train
koordinates/python-client
koordinates/sets.py
Set.set_metadata
def set_metadata(self, fp): """ Set the XML metadata on a set. :param file fp: file-like object to read the XML metadata from. """ base_url = self._client.get_url('SET', 'GET', 'single', {'id': self.id}) self._manager._metadata.set(base_url, fp) # reload myself ...
python
def set_metadata(self, fp): """ Set the XML metadata on a set. :param file fp: file-like object to read the XML metadata from. """ base_url = self._client.get_url('SET', 'GET', 'single', {'id': self.id}) self._manager._metadata.set(base_url, fp) # reload myself ...
[ "def", "set_metadata", "(", "self", ",", "fp", ")", ":", "base_url", "=", "self", ".", "_client", ".", "get_url", "(", "'SET'", ",", "'GET'", ",", "'single'", ",", "{", "'id'", ":", "self", ".", "id", "}", ")", "self", ".", "_manager", ".", "_metad...
Set the XML metadata on a set. :param file fp: file-like object to read the XML metadata from.
[ "Set", "the", "XML", "metadata", "on", "a", "set", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/sets.py#L80-L91
train
koordinates/python-client
koordinates/metadata.py
MetadataManager.set
def set(self, parent_url, fp): """ If the parent object already has XML metadata, it will be overwritten. Accepts XML metadata in any of the three supported formats. The format will be detected from the XML content. The Metadata object becomes invalid after setting :pa...
python
def set(self, parent_url, fp): """ If the parent object already has XML metadata, it will be overwritten. Accepts XML metadata in any of the three supported formats. The format will be detected from the XML content. The Metadata object becomes invalid after setting :pa...
[ "def", "set", "(", "self", ",", "parent_url", ",", "fp", ")", ":", "url", "=", "parent_url", "+", "self", ".", "client", ".", "get_url_path", "(", "'METADATA'", ",", "'POST'", ",", "'set'", ",", "{", "}", ")", "r", "=", "self", ".", "client", ".", ...
If the parent object already has XML metadata, it will be overwritten. Accepts XML metadata in any of the three supported formats. The format will be detected from the XML content. The Metadata object becomes invalid after setting :param file fp: A reference to an open file-like objec...
[ "If", "the", "parent", "object", "already", "has", "XML", "metadata", "it", "will", "be", "overwritten", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/metadata.py#L21-L35
train
koordinates/python-client
koordinates/metadata.py
Metadata.get_xml
def get_xml(self, fp, format=FORMAT_NATIVE): """ Returns the XML metadata for this source, converted to the requested format. Converted metadata may not contain all the same information as the native format. :param file fp: A path, or an open file-like object which the content should be...
python
def get_xml(self, fp, format=FORMAT_NATIVE): """ Returns the XML metadata for this source, converted to the requested format. Converted metadata may not contain all the same information as the native format. :param file fp: A path, or an open file-like object which the content should be...
[ "def", "get_xml", "(", "self", ",", "fp", ",", "format", "=", "FORMAT_NATIVE", ")", ":", "r", "=", "self", ".", "_client", ".", "request", "(", "'GET'", ",", "getattr", "(", "self", ",", "format", ")", ",", "stream", "=", "True", ")", "filename", "...
Returns the XML metadata for this source, converted to the requested format. Converted metadata may not contain all the same information as the native format. :param file fp: A path, or an open file-like object which the content should be written to. :param str format: desired format for the ou...
[ "Returns", "the", "XML", "metadata", "for", "this", "source", "converted", "to", "the", "requested", "format", ".", "Converted", "metadata", "may", "not", "contain", "all", "the", "same", "information", "as", "the", "native", "format", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/metadata.py#L47-L61
train
koordinates/python-client
koordinates/metadata.py
Metadata.get_formats
def get_formats(self): """ Return the available format names for this metadata """ formats = [] for key in (self.FORMAT_DC, self.FORMAT_FGDC, self.FORMAT_ISO): if hasattr(self, key): formats.append(key) return formats
python
def get_formats(self): """ Return the available format names for this metadata """ formats = [] for key in (self.FORMAT_DC, self.FORMAT_FGDC, self.FORMAT_ISO): if hasattr(self, key): formats.append(key) return formats
[ "def", "get_formats", "(", "self", ")", ":", "formats", "=", "[", "]", "for", "key", "in", "(", "self", ".", "FORMAT_DC", ",", "self", ".", "FORMAT_FGDC", ",", "self", ".", "FORMAT_ISO", ")", ":", "if", "hasattr", "(", "self", ",", "key", ")", ":",...
Return the available format names for this metadata
[ "Return", "the", "available", "format", "names", "for", "this", "metadata" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/metadata.py#L63-L69
train
koordinates/python-client
koordinates/utils.py
is_bound
def is_bound(method): """ Decorator that asserts the model instance is bound. Requires: 1. an ``id`` attribute 2. a ``url`` attribute 2. a manager set """ @functools.wraps(method) def wrapper(self, *args, **kwargs): if not self._is_bound: raise ValueError("%r mus...
python
def is_bound(method): """ Decorator that asserts the model instance is bound. Requires: 1. an ``id`` attribute 2. a ``url`` attribute 2. a manager set """ @functools.wraps(method) def wrapper(self, *args, **kwargs): if not self._is_bound: raise ValueError("%r mus...
[ "def", "is_bound", "(", "method", ")", ":", "@", "functools", ".", "wraps", "(", "method", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_is_bound", ":", "raise", "ValueError", "...
Decorator that asserts the model instance is bound. Requires: 1. an ``id`` attribute 2. a ``url`` attribute 2. a manager set
[ "Decorator", "that", "asserts", "the", "model", "instance", "is", "bound", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/utils.py#L16-L30
train
michaelaye/pyciss
pyciss/opusapi.py
OPUS.query_image_id
def query_image_id(self, image_id): """Query OPUS via the image_id. This is a query using the 'primaryfilespec' field of the OPUS database. It returns a list of URLS into the `obsids` attribute. This example queries for an image of Titan: >>> opus = opusapi.OPUS() >>> ...
python
def query_image_id(self, image_id): """Query OPUS via the image_id. This is a query using the 'primaryfilespec' field of the OPUS database. It returns a list of URLS into the `obsids` attribute. This example queries for an image of Titan: >>> opus = opusapi.OPUS() >>> ...
[ "def", "query_image_id", "(", "self", ",", "image_id", ")", ":", "myquery", "=", "{", "\"primaryfilespec\"", ":", "image_id", "}", "self", ".", "create_files_request", "(", "myquery", ",", "fmt", "=", "\"json\"", ")", "self", ".", "unpack_json_response", "(", ...
Query OPUS via the image_id. This is a query using the 'primaryfilespec' field of the OPUS database. It returns a list of URLS into the `obsids` attribute. This example queries for an image of Titan: >>> opus = opusapi.OPUS() >>> opus.query_image_id('N1695760475_1') A...
[ "Query", "OPUS", "via", "the", "image_id", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/opusapi.py#L161-L179
train
michaelaye/pyciss
pyciss/opusapi.py
OPUS.create_request_with_query
def create_request_with_query(self, kind, query, size="thumb", fmt="json"): """api/data.[fmt], api/images/[size].[fmt] api/files.[fmt] kind = ['data', 'images', 'files'] """ if kind == "data" or kind == "files": url = "{}/{}.{}".format(base_url, kind, fmt) elif kin...
python
def create_request_with_query(self, kind, query, size="thumb", fmt="json"): """api/data.[fmt], api/images/[size].[fmt] api/files.[fmt] kind = ['data', 'images', 'files'] """ if kind == "data" or kind == "files": url = "{}/{}.{}".format(base_url, kind, fmt) elif kin...
[ "def", "create_request_with_query", "(", "self", ",", "kind", ",", "query", ",", "size", "=", "\"thumb\"", ",", "fmt", "=", "\"json\"", ")", ":", "if", "kind", "==", "\"data\"", "or", "kind", "==", "\"files\"", ":", "url", "=", "\"{}/{}.{}\"", ".", "form...
api/data.[fmt], api/images/[size].[fmt] api/files.[fmt] kind = ['data', 'images', 'files']
[ "api", "/", "data", ".", "[", "fmt", "]", "api", "/", "images", "/", "[", "size", "]", ".", "[", "fmt", "]", "api", "/", "files", ".", "[", "fmt", "]" ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/opusapi.py#L184-L196
train
michaelaye/pyciss
pyciss/opusapi.py
OPUS.get_between_times
def get_between_times(self, t1, t2, target=None): """ Query for OPUS data between times t1 and t2. Parameters ---------- t1, t2 : datetime.datetime, strings Start and end time for the query. If type is datetime, will be converted to isoformat string. If t...
python
def get_between_times(self, t1, t2, target=None): """ Query for OPUS data between times t1 and t2. Parameters ---------- t1, t2 : datetime.datetime, strings Start and end time for the query. If type is datetime, will be converted to isoformat string. If t...
[ "def", "get_between_times", "(", "self", ",", "t1", ",", "t2", ",", "target", "=", "None", ")", ":", "try", ":", "# checking if times have isoformat() method (datetimes have)", "t1", "=", "t1", ".", "isoformat", "(", ")", "t2", "=", "t2", ".", "isoformat", "...
Query for OPUS data between times t1 and t2. Parameters ---------- t1, t2 : datetime.datetime, strings Start and end time for the query. If type is datetime, will be converted to isoformat string. If type is string already, it needs to be in an accepted inter...
[ "Query", "for", "OPUS", "data", "between", "times", "t1", "and", "t2", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/opusapi.py#L251-L281
train
michaelaye/pyciss
pyciss/opusapi.py
OPUS.show_images
def show_images(self, size="small"): """Shows preview images using the Jupyter notebook HTML display. Parameters ========== size : {'small', 'med', 'thumb', 'full'} Determines the size of the preview image to be shown. """ d = dict(small=256, med=512, thumb=1...
python
def show_images(self, size="small"): """Shows preview images using the Jupyter notebook HTML display. Parameters ========== size : {'small', 'med', 'thumb', 'full'} Determines the size of the preview image to be shown. """ d = dict(small=256, med=512, thumb=1...
[ "def", "show_images", "(", "self", ",", "size", "=", "\"small\"", ")", ":", "d", "=", "dict", "(", "small", "=", "256", ",", "med", "=", "512", ",", "thumb", "=", "100", ",", "full", "=", "1024", ")", "try", ":", "width", "=", "d", "[", "size",...
Shows preview images using the Jupyter notebook HTML display. Parameters ========== size : {'small', 'med', 'thumb', 'full'} Determines the size of the preview image to be shown.
[ "Shows", "preview", "images", "using", "the", "Jupyter", "notebook", "HTML", "display", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/opusapi.py#L288-L311
train
michaelaye/pyciss
pyciss/opusapi.py
OPUS.download_results
def download_results(self, savedir=None, raw=True, calib=False, index=None): """Download the previously found and stored Opus obsids. Parameters ========== savedir: str or pathlib.Path, optional If the database root folder as defined by the config.ini should not be used, ...
python
def download_results(self, savedir=None, raw=True, calib=False, index=None): """Download the previously found and stored Opus obsids. Parameters ========== savedir: str or pathlib.Path, optional If the database root folder as defined by the config.ini should not be used, ...
[ "def", "download_results", "(", "self", ",", "savedir", "=", "None", ",", "raw", "=", "True", ",", "calib", "=", "False", ",", "index", "=", "None", ")", ":", "obsids", "=", "self", ".", "obsids", "if", "index", "is", "None", "else", "[", "self", "...
Download the previously found and stored Opus obsids. Parameters ========== savedir: str or pathlib.Path, optional If the database root folder as defined by the config.ini should not be used, provide a different savedir here. It will be handed to PathManager.
[ "Download", "the", "previously", "found", "and", "stored", "Opus", "obsids", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/opusapi.py#L313-L339
train
michaelaye/pyciss
pyciss/opusapi.py
OPUS.download_previews
def download_previews(self, savedir=None): """Download preview files for the previously found and stored Opus obsids. Parameters ========== savedir: str or pathlib.Path, optional If the database root folder as defined by the config.ini should not be used, provide...
python
def download_previews(self, savedir=None): """Download preview files for the previously found and stored Opus obsids. Parameters ========== savedir: str or pathlib.Path, optional If the database root folder as defined by the config.ini should not be used, provide...
[ "def", "download_previews", "(", "self", ",", "savedir", "=", "None", ")", ":", "for", "obsid", "in", "self", ".", "obsids", ":", "pm", "=", "io", ".", "PathManager", "(", "obsid", ".", "img_id", ",", "savedir", "=", "savedir", ")", "pm", ".", "basep...
Download preview files for the previously found and stored Opus obsids. Parameters ========== savedir: str or pathlib.Path, optional If the database root folder as defined by the config.ini should not be used, provide a different savedir here. It will be handed to PathMa...
[ "Download", "preview", "files", "for", "the", "previously", "found", "and", "stored", "Opus", "obsids", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/opusapi.py#L341-L355
train
michaelaye/pyciss
pyciss/_utils.py
which_epi_janus_resonance
def which_epi_janus_resonance(name, time): """Find which swap situtation we are in by time. Starting from 2006-01-21 where a Janus-Epimetheus swap occured, and defining the next 4 years until the next swap as `scenario1, and the 4 years after that `scenario2`. Calculate in units of 4 years, in whic...
python
def which_epi_janus_resonance(name, time): """Find which swap situtation we are in by time. Starting from 2006-01-21 where a Janus-Epimetheus swap occured, and defining the next 4 years until the next swap as `scenario1, and the 4 years after that `scenario2`. Calculate in units of 4 years, in whic...
[ "def", "which_epi_janus_resonance", "(", "name", ",", "time", ")", ":", "t1", "=", "Time", "(", "'2002-01-21'", ")", ".", "to_datetime", "(", ")", "delta", "=", "Time", "(", "time", ")", ".", "to_datetime", "(", ")", "-", "t1", "yearfraction", "=", "de...
Find which swap situtation we are in by time. Starting from 2006-01-21 where a Janus-Epimetheus swap occured, and defining the next 4 years until the next swap as `scenario1, and the 4 years after that `scenario2`. Calculate in units of 4 years, in which scenario the given time falls. Parameters ...
[ "Find", "which", "swap", "situtation", "we", "are", "in", "by", "time", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/_utils.py#L4-L29
train
koordinates/python-client
koordinates/layers.py
LayerManager.list_drafts
def list_drafts(self): """ A filterable list views of layers, returning the draft version of each layer. If the most recent version of a layer or table has been published already, it won’t be returned here. """ target_url = self.client.get_url('LAYER', 'GET', 'multidraft'...
python
def list_drafts(self): """ A filterable list views of layers, returning the draft version of each layer. If the most recent version of a layer or table has been published already, it won’t be returned here. """ target_url = self.client.get_url('LAYER', 'GET', 'multidraft'...
[ "def", "list_drafts", "(", "self", ")", ":", "target_url", "=", "self", ".", "client", ".", "get_url", "(", "'LAYER'", ",", "'GET'", ",", "'multidraft'", ")", "return", "base", ".", "Query", "(", "self", ",", "target_url", ")" ]
A filterable list views of layers, returning the draft version of each layer. If the most recent version of a layer or table has been published already, it won’t be returned here.
[ "A", "filterable", "list", "views", "of", "layers", "returning", "the", "draft", "version", "of", "each", "layer", ".", "If", "the", "most", "recent", "version", "of", "a", "layer", "or", "table", "has", "been", "published", "already", "it", "won’t", "be",...
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L42-L49
train
koordinates/python-client
koordinates/layers.py
LayerManager.list_versions
def list_versions(self, layer_id): """ Filterable list of versions of a layer, always ordered newest to oldest. If the version’s source supports revisions, you can get a specific revision using ``.filter(data__source__revision=value)``. Specific values depend on the source type. ...
python
def list_versions(self, layer_id): """ Filterable list of versions of a layer, always ordered newest to oldest. If the version’s source supports revisions, you can get a specific revision using ``.filter(data__source__revision=value)``. Specific values depend on the source type. ...
[ "def", "list_versions", "(", "self", ",", "layer_id", ")", ":", "target_url", "=", "self", ".", "client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'multi'", ",", "{", "'layer_id'", ":", "layer_id", "}", ")", "return", "base", ".", "Query", ...
Filterable list of versions of a layer, always ordered newest to oldest. If the version’s source supports revisions, you can get a specific revision using ``.filter(data__source__revision=value)``. Specific values depend on the source type. Use ``data__source_revision__lt`` or ``data__source_re...
[ "Filterable", "list", "of", "versions", "of", "a", "layer", "always", "ordered", "newest", "to", "oldest", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L61-L71
train
koordinates/python-client
koordinates/layers.py
LayerManager.get_version
def get_version(self, layer_id, version_id, expand=[]): """ Get a specific version of a layer. """ target_url = self.client.get_url('VERSION', 'GET', 'single', {'layer_id': layer_id, 'version_id': version_id}) return self._get(target_url, expand=expand)
python
def get_version(self, layer_id, version_id, expand=[]): """ Get a specific version of a layer. """ target_url = self.client.get_url('VERSION', 'GET', 'single', {'layer_id': layer_id, 'version_id': version_id}) return self._get(target_url, expand=expand)
[ "def", "get_version", "(", "self", ",", "layer_id", ",", "version_id", ",", "expand", "=", "[", "]", ")", ":", "target_url", "=", "self", ".", "client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'single'", ",", "{", "'layer_id'", ":", "laye...
Get a specific version of a layer.
[ "Get", "a", "specific", "version", "of", "a", "layer", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L73-L78
train
koordinates/python-client
koordinates/layers.py
LayerManager.get_draft
def get_draft(self, layer_id, expand=[]): """ Get the current draft version of a layer. :raises NotFound: if there is no draft version. """ target_url = self.client.get_url('VERSION', 'GET', 'draft', {'layer_id': layer_id}) return self._get(target_url, expand=expand)
python
def get_draft(self, layer_id, expand=[]): """ Get the current draft version of a layer. :raises NotFound: if there is no draft version. """ target_url = self.client.get_url('VERSION', 'GET', 'draft', {'layer_id': layer_id}) return self._get(target_url, expand=expand)
[ "def", "get_draft", "(", "self", ",", "layer_id", ",", "expand", "=", "[", "]", ")", ":", "target_url", "=", "self", ".", "client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'draft'", ",", "{", "'layer_id'", ":", "layer_id", "}", ")", "re...
Get the current draft version of a layer. :raises NotFound: if there is no draft version.
[ "Get", "the", "current", "draft", "version", "of", "a", "layer", ".", ":", "raises", "NotFound", ":", "if", "there", "is", "no", "draft", "version", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L80-L86
train
koordinates/python-client
koordinates/layers.py
LayerManager.get_published
def get_published(self, layer_id, expand=[]): """ Get the latest published version of this layer. :raises NotFound: if there is no published version. """ target_url = self.client.get_url('VERSION', 'GET', 'published', {'layer_id': layer_id}) return self._get(target_url, e...
python
def get_published(self, layer_id, expand=[]): """ Get the latest published version of this layer. :raises NotFound: if there is no published version. """ target_url = self.client.get_url('VERSION', 'GET', 'published', {'layer_id': layer_id}) return self._get(target_url, e...
[ "def", "get_published", "(", "self", ",", "layer_id", ",", "expand", "=", "[", "]", ")", ":", "target_url", "=", "self", ".", "client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'published'", ",", "{", "'layer_id'", ":", "layer_id", "}", ")...
Get the latest published version of this layer. :raises NotFound: if there is no published version.
[ "Get", "the", "latest", "published", "version", "of", "this", "layer", ".", ":", "raises", "NotFound", ":", "if", "there", "is", "no", "published", "version", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L88-L94
train
koordinates/python-client
koordinates/layers.py
LayerManager.create_draft
def create_draft(self, layer_id): """ Creates a new draft version. If anything in the data object has changed then an import will begin immediately. Otherwise to force a re-import from the previous sources call :py:meth:`koordinates.layers.LayerManager.start_import`. :rtype: La...
python
def create_draft(self, layer_id): """ Creates a new draft version. If anything in the data object has changed then an import will begin immediately. Otherwise to force a re-import from the previous sources call :py:meth:`koordinates.layers.LayerManager.start_import`. :rtype: La...
[ "def", "create_draft", "(", "self", ",", "layer_id", ")", ":", "target_url", "=", "self", ".", "client", ".", "get_url", "(", "'VERSION'", ",", "'POST'", ",", "'create'", ",", "{", "'layer_id'", ":", "layer_id", "}", ")", "r", "=", "self", ".", "client...
Creates a new draft version. If anything in the data object has changed then an import will begin immediately. Otherwise to force a re-import from the previous sources call :py:meth:`koordinates.layers.LayerManager.start_import`. :rtype: Layer :return: the new version :raises C...
[ "Creates", "a", "new", "draft", "version", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L96-L109
train
koordinates/python-client
koordinates/layers.py
LayerManager.start_import
def start_import(self, layer_id, version_id): """ Starts importing the specified draft version (cancelling any running import), even if the data object hasn’t changed from the previous version. """ target_url = self.client.get_url('VERSION', 'POST', 'import', {'layer_id': layer_i...
python
def start_import(self, layer_id, version_id): """ Starts importing the specified draft version (cancelling any running import), even if the data object hasn’t changed from the previous version. """ target_url = self.client.get_url('VERSION', 'POST', 'import', {'layer_id': layer_i...
[ "def", "start_import", "(", "self", ",", "layer_id", ",", "version_id", ")", ":", "target_url", "=", "self", ".", "client", ".", "get_url", "(", "'VERSION'", ",", "'POST'", ",", "'import'", ",", "{", "'layer_id'", ":", "layer_id", ",", "'version_id'", ":",...
Starts importing the specified draft version (cancelling any running import), even if the data object hasn’t changed from the previous version.
[ "Starts", "importing", "the", "specified", "draft", "version", "(", "cancelling", "any", "running", "import", ")", "even", "if", "the", "data", "object", "hasn’t", "changed", "from", "the", "previous", "version", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L111-L118
train
koordinates/python-client
koordinates/layers.py
LayerManager.start_update
def start_update(self, layer_id): """ A shortcut to create a new version and start importing it. Effectively the same as :py:meth:`koordinates.layers.LayerManager.create_draft` followed by :py:meth:`koordinates.layers.LayerManager.start_import`. """ target_url = self.client.get_u...
python
def start_update(self, layer_id): """ A shortcut to create a new version and start importing it. Effectively the same as :py:meth:`koordinates.layers.LayerManager.create_draft` followed by :py:meth:`koordinates.layers.LayerManager.start_import`. """ target_url = self.client.get_u...
[ "def", "start_update", "(", "self", ",", "layer_id", ")", ":", "target_url", "=", "self", ".", "client", ".", "get_url", "(", "'LAYER'", ",", "'POST'", ",", "'update'", ",", "{", "'layer_id'", ":", "layer_id", "}", ")", "r", "=", "self", ".", "client",...
A shortcut to create a new version and start importing it. Effectively the same as :py:meth:`koordinates.layers.LayerManager.create_draft` followed by :py:meth:`koordinates.layers.LayerManager.start_import`.
[ "A", "shortcut", "to", "create", "a", "new", "version", "and", "start", "importing", "it", ".", "Effectively", "the", "same", "as", ":", "py", ":", "meth", ":", "koordinates", ".", "layers", ".", "LayerManager", ".", "create_draft", "followed", "by", ":", ...
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L120-L127
train
koordinates/python-client
koordinates/layers.py
LayerManager.set_metadata
def set_metadata(self, layer_id, version_id, fp): """ Set the XML metadata on a layer draft version. :param file fp: file-like object to read the XML metadata from. :raises NotAllowed: if the version is already published. """ base_url = self.client.get_url('VERSION', 'GE...
python
def set_metadata(self, layer_id, version_id, fp): """ Set the XML metadata on a layer draft version. :param file fp: file-like object to read the XML metadata from. :raises NotAllowed: if the version is already published. """ base_url = self.client.get_url('VERSION', 'GE...
[ "def", "set_metadata", "(", "self", ",", "layer_id", ",", "version_id", ",", "fp", ")", ":", "base_url", "=", "self", ".", "client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'single'", ",", "{", "'layer_id'", ":", "layer_id", ",", "'version_...
Set the XML metadata on a layer draft version. :param file fp: file-like object to read the XML metadata from. :raises NotAllowed: if the version is already published.
[ "Set", "the", "XML", "metadata", "on", "a", "layer", "draft", "version", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L129-L137
train