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
twisted/txacme
src/txacme/challenges/_libcloud.py
_get_existing
def _get_existing(driver, zone_name, server_name, validation): """ Get existing validation records. """ if zone_name is None: zones = sorted( (z for z in driver.list_zones() if server_name.rstrip(u'.') .endswith(u'.' + z.domain.rstrip(u'.')))...
python
def _get_existing(driver, zone_name, server_name, validation): """ Get existing validation records. """ if zone_name is None: zones = sorted( (z for z in driver.list_zones() if server_name.rstrip(u'.') .endswith(u'.' + z.domain.rstrip(u'.')))...
[ "def", "_get_existing", "(", "driver", ",", "zone_name", ",", "server_name", ",", "validation", ")", ":", "if", "zone_name", "is", "None", ":", "zones", "=", "sorted", "(", "(", "z", "for", "z", "in", "driver", ".", "list_zones", "(", ")", "if", "serve...
Get existing validation records.
[ "Get", "existing", "validation", "records", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/challenges/_libcloud.py#L61-L90
train
twisted/txacme
src/txacme/challenges/_libcloud.py
_validation
def _validation(response): """ Get the validation value for a challenge response. """ h = hashlib.sha256(response.key_authorization.encode("utf-8")) return b64encode(h.digest()).decode()
python
def _validation(response): """ Get the validation value for a challenge response. """ h = hashlib.sha256(response.key_authorization.encode("utf-8")) return b64encode(h.digest()).decode()
[ "def", "_validation", "(", "response", ")", ":", "h", "=", "hashlib", ".", "sha256", "(", "response", ".", "key_authorization", ".", "encode", "(", "\"utf-8\"", ")", ")", "return", "b64encode", "(", "h", ".", "digest", "(", ")", ")", ".", "decode", "("...
Get the validation value for a challenge response.
[ "Get", "the", "validation", "value", "for", "a", "challenge", "response", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/challenges/_libcloud.py#L93-L98
train
twisted/txacme
src/txacme/endpoint.py
load_or_create_client_key
def load_or_create_client_key(pem_path): """ Load the client key from a directory, creating it if it does not exist. .. note:: The client key that will be created will be a 2048-bit RSA key. :type pem_path: ``twisted.python.filepath.FilePath`` :param pem_path: The certificate directory to ...
python
def load_or_create_client_key(pem_path): """ Load the client key from a directory, creating it if it does not exist. .. note:: The client key that will be created will be a 2048-bit RSA key. :type pem_path: ``twisted.python.filepath.FilePath`` :param pem_path: The certificate directory to ...
[ "def", "load_or_create_client_key", "(", "pem_path", ")", ":", "acme_key_file", "=", "pem_path", ".", "asTextMode", "(", ")", ".", "child", "(", "u'client.key'", ")", "if", "acme_key_file", ".", "exists", "(", ")", ":", "key", "=", "serialization", ".", "loa...
Load the client key from a directory, creating it if it does not exist. .. note:: The client key that will be created will be a 2048-bit RSA key. :type pem_path: ``twisted.python.filepath.FilePath`` :param pem_path: The certificate directory to use, as with the endpoint.
[ "Load", "the", "client", "key", "from", "a", "directory", "creating", "it", "if", "it", "does", "not", "exist", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/endpoint.py#L131-L154
train
twisted/txacme
src/txacme/endpoint.py
_parse
def _parse(reactor, directory, pemdir, *args, **kwargs): """ Parse a txacme endpoint description. :param reactor: The Twisted reactor. :param directory: ``twisted.python.url.URL`` for the ACME directory to use for issuing certs. :param str pemdir: The path to the certificate directory to us...
python
def _parse(reactor, directory, pemdir, *args, **kwargs): """ Parse a txacme endpoint description. :param reactor: The Twisted reactor. :param directory: ``twisted.python.url.URL`` for the ACME directory to use for issuing certs. :param str pemdir: The path to the certificate directory to us...
[ "def", "_parse", "(", "reactor", ",", "directory", ",", "pemdir", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "colon_join", "(", "items", ")", ":", "return", "':'", ".", "join", "(", "[", "item", ".", "replace", "(", "':'", ",", "...
Parse a txacme endpoint description. :param reactor: The Twisted reactor. :param directory: ``twisted.python.url.URL`` for the ACME directory to use for issuing certs. :param str pemdir: The path to the certificate directory to use.
[ "Parse", "a", "txacme", "endpoint", "description", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/endpoint.py#L157-L177
train
alexwlchan/lazyreader
lazyreader.py
lazyread
def lazyread(f, delimiter): """ Generator which continually reads ``f`` to the next instance of ``delimiter``. This allows you to do batch processing on the contents of ``f`` without loading the entire file into memory. :param f: Any file-like object which has a ``.read()`` method. :param ...
python
def lazyread(f, delimiter): """ Generator which continually reads ``f`` to the next instance of ``delimiter``. This allows you to do batch processing on the contents of ``f`` without loading the entire file into memory. :param f: Any file-like object which has a ``.read()`` method. :param ...
[ "def", "lazyread", "(", "f", ",", "delimiter", ")", ":", "# Get an empty string to start with. We need to make sure that if the", "# file is opened in binary mode, we're using byte strings, and similar", "# for Unicode. Otherwise trying to update the running string will", "# hit a TypeError....
Generator which continually reads ``f`` to the next instance of ``delimiter``. This allows you to do batch processing on the contents of ``f`` without loading the entire file into memory. :param f: Any file-like object which has a ``.read()`` method. :param delimiter: Delimiter on which to split u...
[ "Generator", "which", "continually", "reads", "f", "to", "the", "next", "instance", "of", "delimiter", "." ]
918c408efba015efc1d67b05d1e4b373ac9d1192
https://github.com/alexwlchan/lazyreader/blob/918c408efba015efc1d67b05d1e4b373ac9d1192/lazyreader.py#L3-L44
train
twisted/txacme
src/txacme/util.py
generate_private_key
def generate_private_key(key_type): """ Generate a random private key using sensible parameters. :param str key_type: The type of key to generate. One of: ``rsa``. """ if key_type == u'rsa': return rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_b...
python
def generate_private_key(key_type): """ Generate a random private key using sensible parameters. :param str key_type: The type of key to generate. One of: ``rsa``. """ if key_type == u'rsa': return rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_b...
[ "def", "generate_private_key", "(", "key_type", ")", ":", "if", "key_type", "==", "u'rsa'", ":", "return", "rsa", ".", "generate_private_key", "(", "public_exponent", "=", "65537", ",", "key_size", "=", "2048", ",", "backend", "=", "default_backend", "(", ")",...
Generate a random private key using sensible parameters. :param str key_type: The type of key to generate. One of: ``rsa``.
[ "Generate", "a", "random", "private", "key", "using", "sensible", "parameters", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L20-L29
train
twisted/txacme
src/txacme/util.py
generate_tls_sni_01_cert
def generate_tls_sni_01_cert(server_name, key_type=u'rsa', _generate_private_key=None): """ Generate a certificate/key pair for responding to a tls-sni-01 challenge. :param str server_name: The SAN the certificate should have. :param str key_type: The type of key to generat...
python
def generate_tls_sni_01_cert(server_name, key_type=u'rsa', _generate_private_key=None): """ Generate a certificate/key pair for responding to a tls-sni-01 challenge. :param str server_name: The SAN the certificate should have. :param str key_type: The type of key to generat...
[ "def", "generate_tls_sni_01_cert", "(", "server_name", ",", "key_type", "=", "u'rsa'", ",", "_generate_private_key", "=", "None", ")", ":", "key", "=", "(", "_generate_private_key", "or", "generate_private_key", ")", "(", "key_type", ")", "name", "=", "x509", "....
Generate a certificate/key pair for responding to a tls-sni-01 challenge. :param str server_name: The SAN the certificate should have. :param str key_type: The type of key to generate; usually not necessary. :rtype: ``Tuple[`~cryptography.x509.Certificate`, PrivateKey]`` :return: A tuple of the certif...
[ "Generate", "a", "certificate", "/", "key", "pair", "for", "responding", "to", "a", "tls", "-", "sni", "-", "01", "challenge", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L32-L62
train
twisted/txacme
src/txacme/util.py
tap
def tap(f): """ "Tap" a Deferred callback chain with a function whose return value is ignored. """ @wraps(f) def _cb(res, *a, **kw): d = maybeDeferred(f, res, *a, **kw) d.addCallback(lambda ignored: res) return d return _cb
python
def tap(f): """ "Tap" a Deferred callback chain with a function whose return value is ignored. """ @wraps(f) def _cb(res, *a, **kw): d = maybeDeferred(f, res, *a, **kw) d.addCallback(lambda ignored: res) return d return _cb
[ "def", "tap", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "_cb", "(", "res", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "d", "=", "maybeDeferred", "(", "f", ",", "res", ",", "*", "a", ",", "*", "*", "kw", ")", "d", ".", ...
"Tap" a Deferred callback chain with a function whose return value is ignored.
[ "Tap", "a", "Deferred", "callback", "chain", "with", "a", "function", "whose", "return", "value", "is", "ignored", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L65-L75
train
twisted/txacme
src/txacme/util.py
decode_csr
def decode_csr(b64der): """ Decode JOSE Base-64 DER-encoded CSR. :param str b64der: The encoded CSR. :rtype: `cryptography.x509.CertificateSigningRequest` :return: The decoded CSR. """ try: return x509.load_der_x509_csr( decode_b64jose(b64der), default_backend()) ex...
python
def decode_csr(b64der): """ Decode JOSE Base-64 DER-encoded CSR. :param str b64der: The encoded CSR. :rtype: `cryptography.x509.CertificateSigningRequest` :return: The decoded CSR. """ try: return x509.load_der_x509_csr( decode_b64jose(b64der), default_backend()) ex...
[ "def", "decode_csr", "(", "b64der", ")", ":", "try", ":", "return", "x509", ".", "load_der_x509_csr", "(", "decode_b64jose", "(", "b64der", ")", ",", "default_backend", "(", ")", ")", "except", "ValueError", "as", "error", ":", "raise", "DeserializationError",...
Decode JOSE Base-64 DER-encoded CSR. :param str b64der: The encoded CSR. :rtype: `cryptography.x509.CertificateSigningRequest` :return: The decoded CSR.
[ "Decode", "JOSE", "Base", "-", "64", "DER", "-", "encoded", "CSR", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L89-L102
train
twisted/txacme
src/txacme/util.py
csr_for_names
def csr_for_names(names, key): """ Generate a certificate signing request for the given names and private key. .. seealso:: `acme.client.Client.request_issuance` .. seealso:: `generate_private_key` :param ``List[str]``: One or more names (subjectAltName) for which to request a certifica...
python
def csr_for_names(names, key): """ Generate a certificate signing request for the given names and private key. .. seealso:: `acme.client.Client.request_issuance` .. seealso:: `generate_private_key` :param ``List[str]``: One or more names (subjectAltName) for which to request a certifica...
[ "def", "csr_for_names", "(", "names", ",", "key", ")", ":", "if", "len", "(", "names", ")", "==", "0", ":", "raise", "ValueError", "(", "'Must have at least one name'", ")", "if", "len", "(", "names", "[", "0", "]", ")", ">", "64", ":", "common_name", ...
Generate a certificate signing request for the given names and private key. .. seealso:: `acme.client.Client.request_issuance` .. seealso:: `generate_private_key` :param ``List[str]``: One or more names (subjectAltName) for which to request a certificate. :param key: A Cryptography private ...
[ "Generate", "a", "certificate", "signing", "request", "for", "the", "given", "names", "and", "private", "key", "." ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L105-L133
train
samuelcolvin/python-devtools
devtools/debug.py
Debug._wrap_parse
def _wrap_parse(code, filename): """ async wrapper is required to avoid await calls raising a SyntaxError """ code = 'async def wrapper():\n' + indent(code, ' ') return ast.parse(code, filename=filename).body[0].body[0].value
python
def _wrap_parse(code, filename): """ async wrapper is required to avoid await calls raising a SyntaxError """ code = 'async def wrapper():\n' + indent(code, ' ') return ast.parse(code, filename=filename).body[0].body[0].value
[ "def", "_wrap_parse", "(", "code", ",", "filename", ")", ":", "code", "=", "'async def wrapper():\\n'", "+", "indent", "(", "code", ",", "' '", ")", "return", "ast", ".", "parse", "(", "code", ",", "filename", "=", "filename", ")", ".", "body", "[", "0...
async wrapper is required to avoid await calls raising a SyntaxError
[ "async", "wrapper", "is", "required", "to", "avoid", "await", "calls", "raising", "a", "SyntaxError" ]
fb0021b3e6815348a28c1d2bf11b50b8f0bd511a
https://github.com/samuelcolvin/python-devtools/blob/fb0021b3e6815348a28c1d2bf11b50b8f0bd511a/devtools/debug.py#L274-L279
train
twisted/txacme
docs/conf.py
linkcode_resolve
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object """ if domain != 'py': return None modname = info['module'] fullname = info['fullname'] submod = sys.modules.get(modname) if submod is None: return None obj = submod for part ...
python
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object """ if domain != 'py': return None modname = info['module'] fullname = info['fullname'] submod = sys.modules.get(modname) if submod is None: return None obj = submod for part ...
[ "def", "linkcode_resolve", "(", "domain", ",", "info", ")", ":", "if", "domain", "!=", "'py'", ":", "return", "None", "modname", "=", "info", "[", "'module'", "]", "fullname", "=", "info", "[", "'fullname'", "]", "submod", "=", "sys", ".", "modules", "...
Determine the URL corresponding to Python object
[ "Determine", "the", "URL", "corresponding", "to", "Python", "object" ]
9478381cc63c6d53d14bf8db8407c923f472989a
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/docs/conf.py#L326-L359
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/solr.py
SolrHypermap.layers_to_solr
def layers_to_solr(self, layers): """ Sync n layers in Solr. """ layers_dict_list = [] layers_success_ids = [] layers_errors_ids = [] for layer in layers: layer_dict, message = layer2dict(layer) if not layer_dict: layers_e...
python
def layers_to_solr(self, layers): """ Sync n layers in Solr. """ layers_dict_list = [] layers_success_ids = [] layers_errors_ids = [] for layer in layers: layer_dict, message = layer2dict(layer) if not layer_dict: layers_e...
[ "def", "layers_to_solr", "(", "self", ",", "layers", ")", ":", "layers_dict_list", "=", "[", "]", "layers_success_ids", "=", "[", "]", "layers_errors_ids", "=", "[", "]", "for", "layer", "in", "layers", ":", "layer_dict", ",", "message", "=", "layer2dict", ...
Sync n layers in Solr.
[ "Sync", "n", "layers", "in", "Solr", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/solr.py#L19-L50
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/solr.py
SolrHypermap.layer_to_solr
def layer_to_solr(self, layer): """ Sync a layer in Solr. """ success = True message = 'Synced layer id %s to Solr' % layer.id layer_dict, message = layer2dict(layer) if not layer_dict: success = False else: layer_json = json.dumps...
python
def layer_to_solr(self, layer): """ Sync a layer in Solr. """ success = True message = 'Synced layer id %s to Solr' % layer.id layer_dict, message = layer2dict(layer) if not layer_dict: success = False else: layer_json = json.dumps...
[ "def", "layer_to_solr", "(", "self", ",", "layer", ")", ":", "success", "=", "True", "message", "=", "'Synced layer id %s to Solr'", "%", "layer", ".", "id", "layer_dict", ",", "message", "=", "layer2dict", "(", "layer", ")", "if", "not", "layer_dict", ":", ...
Sync a layer in Solr.
[ "Sync", "a", "layer", "in", "Solr", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/solr.py#L52-L81
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/solr.py
SolrHypermap.clear_solr
def clear_solr(self, catalog="hypermap"): """Clear all indexes in the solr core""" solr_url = "{0}/solr/{1}".format(SEARCH_URL, catalog) solr = pysolr.Solr(solr_url, timeout=60) solr.delete(q='*:*') LOGGER.debug('Solr core cleared')
python
def clear_solr(self, catalog="hypermap"): """Clear all indexes in the solr core""" solr_url = "{0}/solr/{1}".format(SEARCH_URL, catalog) solr = pysolr.Solr(solr_url, timeout=60) solr.delete(q='*:*') LOGGER.debug('Solr core cleared')
[ "def", "clear_solr", "(", "self", ",", "catalog", "=", "\"hypermap\"", ")", ":", "solr_url", "=", "\"{0}/solr/{1}\"", ".", "format", "(", "SEARCH_URL", ",", "catalog", ")", "solr", "=", "pysolr", ".", "Solr", "(", "solr_url", ",", "timeout", "=", "60", "...
Clear all indexes in the solr core
[ "Clear", "all", "indexes", "in", "the", "solr", "core" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/solr.py#L83-L88
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/solr.py
SolrHypermap.update_schema
def update_schema(self, catalog="hypermap"): """ set the mapping in solr. :param catalog: core :return: """ schema_url = "{0}/solr/{1}/schema".format(SEARCH_URL, catalog) print schema_url # create a special type to draw better heatmaps. location_r...
python
def update_schema(self, catalog="hypermap"): """ set the mapping in solr. :param catalog: core :return: """ schema_url = "{0}/solr/{1}/schema".format(SEARCH_URL, catalog) print schema_url # create a special type to draw better heatmaps. location_r...
[ "def", "update_schema", "(", "self", ",", "catalog", "=", "\"hypermap\"", ")", ":", "schema_url", "=", "\"{0}/solr/{1}/schema\"", ".", "format", "(", "SEARCH_URL", ",", "catalog", ")", "print", "schema_url", "# create a special type to draw better heatmaps.", "location_...
set the mapping in solr. :param catalog: core :return:
[ "set", "the", "mapping", "in", "solr", ".", ":", "param", "catalog", ":", "core", ":", "return", ":" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/solr.py#L99-L221
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
create_layer_from_metadata_xml
def create_layer_from_metadata_xml(resourcetype, xml, monitor=False, service=None, catalog=None): """ Create a layer / keyword list from a metadata record if it does not already exist. """ from models import gen_anytext, Layer if resourcetype == 'http://www.opengis.net/cat/csw/2.0.2': # Dublin cor...
python
def create_layer_from_metadata_xml(resourcetype, xml, monitor=False, service=None, catalog=None): """ Create a layer / keyword list from a metadata record if it does not already exist. """ from models import gen_anytext, Layer if resourcetype == 'http://www.opengis.net/cat/csw/2.0.2': # Dublin cor...
[ "def", "create_layer_from_metadata_xml", "(", "resourcetype", ",", "xml", ",", "monitor", "=", "False", ",", "service", "=", "None", ",", "catalog", "=", "None", ")", ":", "from", "models", "import", "gen_anytext", ",", "Layer", "if", "resourcetype", "==", "...
Create a layer / keyword list from a metadata record if it does not already exist.
[ "Create", "a", "layer", "/", "keyword", "list", "from", "a", "metadata", "record", "if", "it", "does", "not", "already", "exist", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L28-L59
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
create_service_from_endpoint
def create_service_from_endpoint(endpoint, service_type, title=None, abstract=None, catalog=None): """ Create a service from an endpoint if it does not already exists. """ from models import Service if Service.objects.filter(url=endpoint, catalog=catalog).count() == 0: # check if endpoint is...
python
def create_service_from_endpoint(endpoint, service_type, title=None, abstract=None, catalog=None): """ Create a service from an endpoint if it does not already exists. """ from models import Service if Service.objects.filter(url=endpoint, catalog=catalog).count() == 0: # check if endpoint is...
[ "def", "create_service_from_endpoint", "(", "endpoint", ",", "service_type", ",", "title", "=", "None", ",", "abstract", "=", "None", ",", "catalog", "=", "None", ")", ":", "from", "models", "import", "Service", "if", "Service", ".", "objects", ".", "filter"...
Create a service from an endpoint if it does not already exists.
[ "Create", "a", "service", "from", "an", "endpoint", "if", "it", "does", "not", "already", "exists", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L62-L82
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
create_services_from_endpoint
def create_services_from_endpoint(url, catalog, greedy_opt=True): """ Generate service/services from an endpoint. WMS, WMTS, TMS endpoints correspond to a single service. ESRI, CSW endpoints corrispond to many services. :return: imported, message """ # this variable will collect any excepti...
python
def create_services_from_endpoint(url, catalog, greedy_opt=True): """ Generate service/services from an endpoint. WMS, WMTS, TMS endpoints correspond to a single service. ESRI, CSW endpoints corrispond to many services. :return: imported, message """ # this variable will collect any excepti...
[ "def", "create_services_from_endpoint", "(", "url", ",", "catalog", ",", "greedy_opt", "=", "True", ")", ":", "# this variable will collect any exception message during the routine.", "# will be used in the last step to send a message if \"detected\" var is False.", "messages", "=", ...
Generate service/services from an endpoint. WMS, WMTS, TMS endpoints correspond to a single service. ESRI, CSW endpoints corrispond to many services. :return: imported, message
[ "Generate", "service", "/", "services", "from", "an", "endpoint", ".", "WMS", "WMTS", "TMS", "endpoints", "correspond", "to", "a", "single", "service", ".", "ESRI", "CSW", "endpoints", "corrispond", "to", "many", "services", ".", ":", "return", ":", "importe...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L85-L332
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
service_url_parse
def service_url_parse(url): """ Function that parses from url the service and folder of services. """ endpoint = get_sanitized_endpoint(url) url_split_list = url.split(endpoint + '/') if len(url_split_list) != 0: url_split_list = url_split_list[1].split('/') else: raise Excep...
python
def service_url_parse(url): """ Function that parses from url the service and folder of services. """ endpoint = get_sanitized_endpoint(url) url_split_list = url.split(endpoint + '/') if len(url_split_list) != 0: url_split_list = url_split_list[1].split('/') else: raise Excep...
[ "def", "service_url_parse", "(", "url", ")", ":", "endpoint", "=", "get_sanitized_endpoint", "(", "url", ")", "url_split_list", "=", "url", ".", "split", "(", "endpoint", "+", "'/'", ")", "if", "len", "(", "url_split_list", ")", "!=", "0", ":", "url_split_...
Function that parses from url the service and folder of services.
[ "Function", "that", "parses", "from", "url", "the", "service", "and", "folder", "of", "services", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L335-L349
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
inverse_mercator
def inverse_mercator(xy): """ Given coordinates in spherical mercator, return a lon,lat tuple. """ lon = (xy[0] / 20037508.34) * 180 lat = (xy[1] / 20037508.34) * 180 lat = 180 / math.pi * \ (2 * math.atan(math.exp(lat * math.pi / 180)) - math.pi / 2) return (lon, lat)
python
def inverse_mercator(xy): """ Given coordinates in spherical mercator, return a lon,lat tuple. """ lon = (xy[0] / 20037508.34) * 180 lat = (xy[1] / 20037508.34) * 180 lat = 180 / math.pi * \ (2 * math.atan(math.exp(lat * math.pi / 180)) - math.pi / 2) return (lon, lat)
[ "def", "inverse_mercator", "(", "xy", ")", ":", "lon", "=", "(", "xy", "[", "0", "]", "/", "20037508.34", ")", "*", "180", "lat", "=", "(", "xy", "[", "1", "]", "/", "20037508.34", ")", "*", "180", "lat", "=", "180", "/", "math", ".", "pi", "...
Given coordinates in spherical mercator, return a lon,lat tuple.
[ "Given", "coordinates", "in", "spherical", "mercator", "return", "a", "lon", "lat", "tuple", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L404-L412
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
get_wms_version_negotiate
def get_wms_version_negotiate(url, timeout=10): """ OWSLib wrapper function to perform version negotiation against owslib.wms.WebMapService """ try: LOGGER.debug('Trying a WMS 1.3.0 GetCapabilities request') return WebMapService(url, version='1.3.0', timeout=timeout) except Exceptio...
python
def get_wms_version_negotiate(url, timeout=10): """ OWSLib wrapper function to perform version negotiation against owslib.wms.WebMapService """ try: LOGGER.debug('Trying a WMS 1.3.0 GetCapabilities request') return WebMapService(url, version='1.3.0', timeout=timeout) except Exceptio...
[ "def", "get_wms_version_negotiate", "(", "url", ",", "timeout", "=", "10", ")", ":", "try", ":", "LOGGER", ".", "debug", "(", "'Trying a WMS 1.3.0 GetCapabilities request'", ")", "return", "WebMapService", "(", "url", ",", "version", "=", "'1.3.0'", ",", "timeou...
OWSLib wrapper function to perform version negotiation against owslib.wms.WebMapService
[ "OWSLib", "wrapper", "function", "to", "perform", "version", "negotiation", "against", "owslib", ".", "wms", ".", "WebMapService" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L415-L426
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
get_sanitized_endpoint
def get_sanitized_endpoint(url): """ Sanitize an endpoint, as removing unneeded parameters """ # sanitize esri sanitized_url = url.rstrip() esri_string = '/rest/services' if esri_string in url: match = re.search(esri_string, sanitized_url) sanitized_url = url[0:(match.start(0...
python
def get_sanitized_endpoint(url): """ Sanitize an endpoint, as removing unneeded parameters """ # sanitize esri sanitized_url = url.rstrip() esri_string = '/rest/services' if esri_string in url: match = re.search(esri_string, sanitized_url) sanitized_url = url[0:(match.start(0...
[ "def", "get_sanitized_endpoint", "(", "url", ")", ":", "# sanitize esri", "sanitized_url", "=", "url", ".", "rstrip", "(", ")", "esri_string", "=", "'/rest/services'", "if", "esri_string", "in", "url", ":", "match", "=", "re", ".", "search", "(", "esri_string"...
Sanitize an endpoint, as removing unneeded parameters
[ "Sanitize", "an", "endpoint", "as", "removing", "unneeded", "parameters" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L435-L445
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
get_esri_service_name
def get_esri_service_name(url): """ A method to get a service name from an esri endpoint. For example: http://example.com/arcgis/rest/services/myservice/mylayer/MapServer/?f=json Will return: myservice/mylayer """ result = re.search('rest/services/(.*)/[MapServer|ImageServer]', url) if resul...
python
def get_esri_service_name(url): """ A method to get a service name from an esri endpoint. For example: http://example.com/arcgis/rest/services/myservice/mylayer/MapServer/?f=json Will return: myservice/mylayer """ result = re.search('rest/services/(.*)/[MapServer|ImageServer]', url) if resul...
[ "def", "get_esri_service_name", "(", "url", ")", ":", "result", "=", "re", ".", "search", "(", "'rest/services/(.*)/[MapServer|ImageServer]'", ",", "url", ")", "if", "result", "is", "None", ":", "return", "url", "else", ":", "return", "result", ".", "group", ...
A method to get a service name from an esri endpoint. For example: http://example.com/arcgis/rest/services/myservice/mylayer/MapServer/?f=json Will return: myservice/mylayer
[ "A", "method", "to", "get", "a", "service", "name", "from", "an", "esri", "endpoint", ".", "For", "example", ":", "http", ":", "//", "example", ".", "com", "/", "arcgis", "/", "rest", "/", "services", "/", "myservice", "/", "mylayer", "/", "MapServer",...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L448-L458
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
get_esri_extent
def get_esri_extent(esriobj): """ Get the extent of an ESRI resource """ extent = None srs = None if 'fullExtent' in esriobj._json_struct: extent = esriobj._json_struct['fullExtent'] if 'extent' in esriobj._json_struct: extent = esriobj._json_struct['extent'] try: ...
python
def get_esri_extent(esriobj): """ Get the extent of an ESRI resource """ extent = None srs = None if 'fullExtent' in esriobj._json_struct: extent = esriobj._json_struct['fullExtent'] if 'extent' in esriobj._json_struct: extent = esriobj._json_struct['extent'] try: ...
[ "def", "get_esri_extent", "(", "esriobj", ")", ":", "extent", "=", "None", "srs", "=", "None", "if", "'fullExtent'", "in", "esriobj", ".", "_json_struct", ":", "extent", "=", "esriobj", ".", "_json_struct", "[", "'fullExtent'", "]", "if", "'extent'", "in", ...
Get the extent of an ESRI resource
[ "Get", "the", "extent", "of", "an", "ESRI", "resource" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L461-L479
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
bbox2wktpolygon
def bbox2wktpolygon(bbox): """ Return OGC WKT Polygon of a simple bbox list of strings """ minx = float(bbox[0]) miny = float(bbox[1]) maxx = float(bbox[2]) maxy = float(bbox[3]) return 'POLYGON((%.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f))' \ % (minx, miny, minx, max...
python
def bbox2wktpolygon(bbox): """ Return OGC WKT Polygon of a simple bbox list of strings """ minx = float(bbox[0]) miny = float(bbox[1]) maxx = float(bbox[2]) maxy = float(bbox[3]) return 'POLYGON((%.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f))' \ % (minx, miny, minx, max...
[ "def", "bbox2wktpolygon", "(", "bbox", ")", ":", "minx", "=", "float", "(", "bbox", "[", "0", "]", ")", "miny", "=", "float", "(", "bbox", "[", "1", "]", ")", "maxx", "=", "float", "(", "bbox", "[", "2", "]", ")", "maxy", "=", "float", "(", "...
Return OGC WKT Polygon of a simple bbox list of strings
[ "Return", "OGC", "WKT", "Polygon", "of", "a", "simple", "bbox", "list", "of", "strings" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L503-L513
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
get_solr_date
def get_solr_date(pydate, is_negative): """ Returns a date in a valid Solr format from a string. """ # check if date is valid and then set it to solr format YYYY-MM-DDThh:mm:ssZ try: if isinstance(pydate, datetime.datetime): solr_date = '%sZ' % pydate.isoformat()[0:19] ...
python
def get_solr_date(pydate, is_negative): """ Returns a date in a valid Solr format from a string. """ # check if date is valid and then set it to solr format YYYY-MM-DDThh:mm:ssZ try: if isinstance(pydate, datetime.datetime): solr_date = '%sZ' % pydate.isoformat()[0:19] ...
[ "def", "get_solr_date", "(", "pydate", ",", "is_negative", ")", ":", "# check if date is valid and then set it to solr format YYYY-MM-DDThh:mm:ssZ", "try", ":", "if", "isinstance", "(", "pydate", ",", "datetime", ".", "datetime", ")", ":", "solr_date", "=", "'%sZ'", "...
Returns a date in a valid Solr format from a string.
[ "Returns", "a", "date", "in", "a", "valid", "Solr", "format", "from", "a", "string", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L516-L532
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
get_date
def get_date(layer): """ Returns a custom date representation. A date can be detected or from metadata. It can be a range or a simple date in isoformat. """ date = None sign = '+' date_type = 1 layer_dates = layer.get_layer_dates() # we index the first date! if layer_dates: ...
python
def get_date(layer): """ Returns a custom date representation. A date can be detected or from metadata. It can be a range or a simple date in isoformat. """ date = None sign = '+' date_type = 1 layer_dates = layer.get_layer_dates() # we index the first date! if layer_dates: ...
[ "def", "get_date", "(", "layer", ")", ":", "date", "=", "None", "sign", "=", "'+'", "date_type", "=", "1", "layer_dates", "=", "layer", ".", "get_layer_dates", "(", ")", "# we index the first date!", "if", "layer_dates", ":", "sign", "=", "layer_dates", "[",...
Returns a custom date representation. A date can be detected or from metadata. It can be a range or a simple date in isoformat.
[ "Returns", "a", "custom", "date", "representation", ".", "A", "date", "can", "be", "detected", "or", "from", "metadata", ".", "It", "can", "be", "a", "range", "or", "a", "simple", "date", "in", "isoformat", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L535-L559
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
layer2dict
def layer2dict(layer): """ Return a json representation for a layer. """ category = None username = None # bbox must be valid before proceeding if not layer.has_valid_bbox(): message = 'Layer id: %s has a not valid bbox' % layer.id return None, message # we can proceed...
python
def layer2dict(layer): """ Return a json representation for a layer. """ category = None username = None # bbox must be valid before proceeding if not layer.has_valid_bbox(): message = 'Layer id: %s has a not valid bbox' % layer.id return None, message # we can proceed...
[ "def", "layer2dict", "(", "layer", ")", ":", "category", "=", "None", "username", "=", "None", "# bbox must be valid before proceeding", "if", "not", "layer", ".", "has_valid_bbox", "(", ")", ":", "message", "=", "'Layer id: %s has a not valid bbox'", "%", "layer", ...
Return a json representation for a layer.
[ "Return", "a", "json", "representation", "for", "a", "layer", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L570-L661
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/utils.py
detect_metadata_url_scheme
def detect_metadata_url_scheme(url): """detect whether a url is a Service type that HHypermap supports""" scheme = None url_lower = url.lower() if any(x in url_lower for x in ['wms', 'service=wms']): scheme = 'OGC:WMS' if any(x in url_lower for x in ['wmts', 'service=wmts']): schem...
python
def detect_metadata_url_scheme(url): """detect whether a url is a Service type that HHypermap supports""" scheme = None url_lower = url.lower() if any(x in url_lower for x in ['wms', 'service=wms']): scheme = 'OGC:WMS' if any(x in url_lower for x in ['wmts', 'service=wmts']): schem...
[ "def", "detect_metadata_url_scheme", "(", "url", ")", ":", "scheme", "=", "None", "url_lower", "=", "url", ".", "lower", "(", ")", "if", "any", "(", "x", "in", "url_lower", "for", "x", "in", "[", "'wms'", ",", "'service=wms'", "]", ")", ":", "scheme", ...
detect whether a url is a Service type that HHypermap supports
[ "detect", "whether", "a", "url", "is", "a", "Service", "type", "that", "HHypermap", "supports" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L664-L679
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/views.py
serialize_checks
def serialize_checks(check_set): """ Serialize a check_set for raphael """ check_set_list = [] for check in check_set.all()[:25]: check_set_list.append( { 'datetime': check.checked_datetime.isoformat(), 'value': check.response_time, ...
python
def serialize_checks(check_set): """ Serialize a check_set for raphael """ check_set_list = [] for check in check_set.all()[:25]: check_set_list.append( { 'datetime': check.checked_datetime.isoformat(), 'value': check.response_time, ...
[ "def", "serialize_checks", "(", "check_set", ")", ":", "check_set_list", "=", "[", "]", "for", "check", "in", "check_set", ".", "all", "(", ")", "[", ":", "25", "]", ":", "check_set_list", ".", "append", "(", "{", "'datetime'", ":", "check", ".", "chec...
Serialize a check_set for raphael
[ "Serialize", "a", "check_set", "for", "raphael" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/views.py#L45-L58
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/views.py
domains
def domains(request): """ A page with number of services and layers faceted on domains. """ url = '' query = '*:*&facet=true&facet.limit=-1&facet.pivot=domain_name,service_id&wt=json&indent=true&rows=0' if settings.SEARCH_TYPE == 'elasticsearch': url = '%s/select?q=%s' % (settings.SEARCH...
python
def domains(request): """ A page with number of services and layers faceted on domains. """ url = '' query = '*:*&facet=true&facet.limit=-1&facet.pivot=domain_name,service_id&wt=json&indent=true&rows=0' if settings.SEARCH_TYPE == 'elasticsearch': url = '%s/select?q=%s' % (settings.SEARCH...
[ "def", "domains", "(", "request", ")", ":", "url", "=", "''", "query", "=", "'*:*&facet=true&facet.limit=-1&facet.pivot=domain_name,service_id&wt=json&indent=true&rows=0'", "if", "settings", ".", "SEARCH_TYPE", "==", "'elasticsearch'", ":", "url", "=", "'%s/select?q=%s'", ...
A page with number of services and layers faceted on domains.
[ "A", "page", "with", "number", "of", "services", "and", "layers", "faceted", "on", "domains", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/views.py#L62-L84
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/views.py
tasks_runner
def tasks_runner(request): """ A page that let the admin to run global tasks. """ # server info cached_layers_number = 0 cached_layers = cache.get('layers') if cached_layers: cached_layers_number = len(cached_layers) cached_deleted_layers_number = 0 cached_deleted_layers = ...
python
def tasks_runner(request): """ A page that let the admin to run global tasks. """ # server info cached_layers_number = 0 cached_layers = cache.get('layers') if cached_layers: cached_layers_number = len(cached_layers) cached_deleted_layers_number = 0 cached_deleted_layers = ...
[ "def", "tasks_runner", "(", "request", ")", ":", "# server info", "cached_layers_number", "=", "0", "cached_layers", "=", "cache", ".", "get", "(", "'layers'", ")", "if", "cached_layers", ":", "cached_layers_number", "=", "len", "(", "cached_layers", ")", "cache...
A page that let the admin to run global tasks.
[ "A", "page", "that", "let", "the", "admin", "to", "run", "global", "tasks", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/views.py#L254-L307
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/views.py
layer_mapproxy
def layer_mapproxy(request, catalog_slug, layer_uuid, path_info): """ Get Layer with matching catalog and uuid """ layer = get_object_or_404(Layer, uuid=layer_uuid, catalog__slug=catalog_slug) # for WorldMap layers we need to use the url o...
python
def layer_mapproxy(request, catalog_slug, layer_uuid, path_info): """ Get Layer with matching catalog and uuid """ layer = get_object_or_404(Layer, uuid=layer_uuid, catalog__slug=catalog_slug) # for WorldMap layers we need to use the url o...
[ "def", "layer_mapproxy", "(", "request", ",", "catalog_slug", ",", "layer_uuid", ",", "path_info", ")", ":", "layer", "=", "get_object_or_404", "(", "Layer", ",", "uuid", "=", "layer_uuid", ",", "catalog__slug", "=", "catalog_slug", ")", "# for WorldMap layers we ...
Get Layer with matching catalog and uuid
[ "Get", "Layer", "with", "matching", "catalog", "and", "uuid" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/views.py#L310-L350
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
parse_datetime
def parse_datetime(date_str): """ Parses a date string to date object. for BCE dates, only supports the year part. """ is_common_era = True date_str_parts = date_str.split("-") if date_str_parts and date_str_parts[0] == '': is_common_era = False # for now, only support BCE ye...
python
def parse_datetime(date_str): """ Parses a date string to date object. for BCE dates, only supports the year part. """ is_common_era = True date_str_parts = date_str.split("-") if date_str_parts and date_str_parts[0] == '': is_common_era = False # for now, only support BCE ye...
[ "def", "parse_datetime", "(", "date_str", ")", ":", "is_common_era", "=", "True", "date_str_parts", "=", "date_str", ".", "split", "(", "\"-\"", ")", "if", "date_str_parts", "and", "date_str_parts", "[", "0", "]", "==", "''", ":", "is_common_era", "=", "Fals...
Parses a date string to date object. for BCE dates, only supports the year part.
[ "Parses", "a", "date", "string", "to", "date", "object", ".", "for", "BCE", "dates", "only", "supports", "the", "year", "part", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L24-L57
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
parse_solr_time_range_as_pair
def parse_solr_time_range_as_pair(time_filter): """ :param time_filter: [2013-03-01 TO 2013-05-01T00:00:00] :return: (2013-03-01, 2013-05-01T00:00:00) """ pattern = "\\[(.*) TO (.*)\\]" matcher = re.search(pattern, time_filter) if matcher: return matcher.group(1), matcher.group(2) ...
python
def parse_solr_time_range_as_pair(time_filter): """ :param time_filter: [2013-03-01 TO 2013-05-01T00:00:00] :return: (2013-03-01, 2013-05-01T00:00:00) """ pattern = "\\[(.*) TO (.*)\\]" matcher = re.search(pattern, time_filter) if matcher: return matcher.group(1), matcher.group(2) ...
[ "def", "parse_solr_time_range_as_pair", "(", "time_filter", ")", ":", "pattern", "=", "\"\\\\[(.*) TO (.*)\\\\]\"", "matcher", "=", "re", ".", "search", "(", "pattern", ",", "time_filter", ")", "if", "matcher", ":", "return", "matcher", ".", "group", "(", "1", ...
:param time_filter: [2013-03-01 TO 2013-05-01T00:00:00] :return: (2013-03-01, 2013-05-01T00:00:00)
[ ":", "param", "time_filter", ":", "[", "2013", "-", "03", "-", "01", "TO", "2013", "-", "05", "-", "01T00", ":", "00", ":", "00", "]", ":", "return", ":", "(", "2013", "-", "03", "-", "01", "2013", "-", "05", "-", "01T00", ":", "00", ":", "...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L60-L70
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
parse_datetime_range
def parse_datetime_range(time_filter): """ Parse the url param to python objects. From what time range to divide by a.time.gap into intervals. Defaults to q.time and otherwise 90 days. Validate in API: re.search("\\[(.*) TO (.*)\\]", value) :param time_filter: [2013-03-01 TO 2013-05-01T00:00:00]...
python
def parse_datetime_range(time_filter): """ Parse the url param to python objects. From what time range to divide by a.time.gap into intervals. Defaults to q.time and otherwise 90 days. Validate in API: re.search("\\[(.*) TO (.*)\\]", value) :param time_filter: [2013-03-01 TO 2013-05-01T00:00:00]...
[ "def", "parse_datetime_range", "(", "time_filter", ")", ":", "if", "not", "time_filter", ":", "time_filter", "=", "\"[* TO *]\"", "start", ",", "end", "=", "parse_solr_time_range_as_pair", "(", "time_filter", ")", "start", ",", "end", "=", "parse_datetime", "(", ...
Parse the url param to python objects. From what time range to divide by a.time.gap into intervals. Defaults to q.time and otherwise 90 days. Validate in API: re.search("\\[(.*) TO (.*)\\]", value) :param time_filter: [2013-03-01 TO 2013-05-01T00:00:00] :return: datetime.datetime(2013, 3, 1, 0, 0), ...
[ "Parse", "the", "url", "param", "to", "python", "objects", ".", "From", "what", "time", "range", "to", "divide", "by", "a", ".", "time", ".", "gap", "into", "intervals", ".", "Defaults", "to", "q", ".", "time", "and", "otherwise", "90", "days", ".", ...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L73-L88
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
parse_ISO8601
def parse_ISO8601(time_gap): """ P1D to (1, ("DAYS", isodate.Duration(days=1)). P1Y to (1, ("YEARS", isodate.Duration(years=1)). :param time_gap: ISO8601 string. :return: tuple with quantity and unit of time. """ matcher = None if time_gap.count("T"): units = { "H": ...
python
def parse_ISO8601(time_gap): """ P1D to (1, ("DAYS", isodate.Duration(days=1)). P1Y to (1, ("YEARS", isodate.Duration(years=1)). :param time_gap: ISO8601 string. :return: tuple with quantity and unit of time. """ matcher = None if time_gap.count("T"): units = { "H": ...
[ "def", "parse_ISO8601", "(", "time_gap", ")", ":", "matcher", "=", "None", "if", "time_gap", ".", "count", "(", "\"T\"", ")", ":", "units", "=", "{", "\"H\"", ":", "(", "\"HOURS\"", ",", "isodate", ".", "Duration", "(", "hours", "=", "1", ")", ")", ...
P1D to (1, ("DAYS", isodate.Duration(days=1)). P1Y to (1, ("YEARS", isodate.Duration(years=1)). :param time_gap: ISO8601 string. :return: tuple with quantity and unit of time.
[ "P1D", "to", "(", "1", "(", "DAYS", "isodate", ".", "Duration", "(", "days", "=", "1", "))", ".", "P1Y", "to", "(", "1", "(", "YEARS", "isodate", ".", "Duration", "(", "years", "=", "1", "))", ".", ":", "param", "time_gap", ":", "ISO8601", "strin...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L109-L145
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
compute_gap
def compute_gap(start, end, time_limit): """ Compute a gap that seems reasonable, considering natural time units and limit. # TODO: make it to be reasonable. # TODO: make it to be small unit of time sensitive. :param start: datetime :param end: datetime :param time_limit: gaps count :ret...
python
def compute_gap(start, end, time_limit): """ Compute a gap that seems reasonable, considering natural time units and limit. # TODO: make it to be reasonable. # TODO: make it to be small unit of time sensitive. :param start: datetime :param end: datetime :param time_limit: gaps count :ret...
[ "def", "compute_gap", "(", "start", ",", "end", ",", "time_limit", ")", ":", "if", "is_range_common_era", "(", "start", ",", "end", ")", ":", "duration", "=", "end", ".", "get", "(", "\"parsed_datetime\"", ")", "-", "start", ".", "get", "(", "\"parsed_da...
Compute a gap that seems reasonable, considering natural time units and limit. # TODO: make it to be reasonable. # TODO: make it to be small unit of time sensitive. :param start: datetime :param end: datetime :param time_limit: gaps count :return: solr's format duration.
[ "Compute", "a", "gap", "that", "seems", "reasonable", "considering", "natural", "time", "units", "and", "limit", ".", "#", "TODO", ":", "make", "it", "to", "be", "reasonable", ".", "#", "TODO", ":", "make", "it", "to", "be", "small", "unit", "of", "tim...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L148-L166
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
gap_to_sorl
def gap_to_sorl(time_gap): """ P1D to +1DAY :param time_gap: :return: solr's format duration. """ quantity, unit = parse_ISO8601(time_gap) if unit[0] == "WEEKS": return "+{0}DAYS".format(quantity * 7) else: return "+{0}{1}".format(quantity, unit[0])
python
def gap_to_sorl(time_gap): """ P1D to +1DAY :param time_gap: :return: solr's format duration. """ quantity, unit = parse_ISO8601(time_gap) if unit[0] == "WEEKS": return "+{0}DAYS".format(quantity * 7) else: return "+{0}{1}".format(quantity, unit[0])
[ "def", "gap_to_sorl", "(", "time_gap", ")", ":", "quantity", ",", "unit", "=", "parse_ISO8601", "(", "time_gap", ")", "if", "unit", "[", "0", "]", "==", "\"WEEKS\"", ":", "return", "\"+{0}DAYS\"", ".", "format", "(", "quantity", "*", "7", ")", "else", ...
P1D to +1DAY :param time_gap: :return: solr's format duration.
[ "P1D", "to", "+", "1DAY", ":", "param", "time_gap", ":", ":", "return", ":", "solr", "s", "format", "duration", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L185-L195
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
request_time_facet
def request_time_facet(field, time_filter, time_gap, time_limit=100): """ time facet query builder :param field: map the query to this field. :param time_limit: Non-0 triggers time/date range faceting. This value is the maximum number of time ranges to return when a.time.gap is unspecified. This is ...
python
def request_time_facet(field, time_filter, time_gap, time_limit=100): """ time facet query builder :param field: map the query to this field. :param time_limit: Non-0 triggers time/date range faceting. This value is the maximum number of time ranges to return when a.time.gap is unspecified. This is ...
[ "def", "request_time_facet", "(", "field", ",", "time_filter", ",", "time_gap", ",", "time_limit", "=", "100", ")", ":", "start", ",", "end", "=", "parse_datetime_range", "(", "time_filter", ")", "key_range_start", "=", "\"f.{0}.facet.range.start\"", ".", "format"...
time facet query builder :param field: map the query to this field. :param time_limit: Non-0 triggers time/date range faceting. This value is the maximum number of time ranges to return when a.time.gap is unspecified. This is a soft maximum; less will usually be returned. A suggested value is 100. N...
[ "time", "facet", "query", "builder", ":", "param", "field", ":", "map", "the", "query", "to", "this", "field", ".", ":", "param", "time_limit", ":", "Non", "-", "0", "triggers", "time", "/", "date", "range", "faceting", ".", "This", "value", "is", "the...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L198-L244
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
parse_solr_geo_range_as_pair
def parse_solr_geo_range_as_pair(geo_box_str): """ :param geo_box_str: [-90,-180 TO 90,180] :return: ("-90,-180", "90,180") """ pattern = "\\[(.*) TO (.*)\\]" matcher = re.search(pattern, geo_box_str) if matcher: return matcher.group(1), matcher.group(2) else: raise Excep...
python
def parse_solr_geo_range_as_pair(geo_box_str): """ :param geo_box_str: [-90,-180 TO 90,180] :return: ("-90,-180", "90,180") """ pattern = "\\[(.*) TO (.*)\\]" matcher = re.search(pattern, geo_box_str) if matcher: return matcher.group(1), matcher.group(2) else: raise Excep...
[ "def", "parse_solr_geo_range_as_pair", "(", "geo_box_str", ")", ":", "pattern", "=", "\"\\\\[(.*) TO (.*)\\\\]\"", "matcher", "=", "re", ".", "search", "(", "pattern", ",", "geo_box_str", ")", "if", "matcher", ":", "return", "matcher", ".", "group", "(", "1", ...
:param geo_box_str: [-90,-180 TO 90,180] :return: ("-90,-180", "90,180")
[ ":", "param", "geo_box_str", ":", "[", "-", "90", "-", "180", "TO", "90", "180", "]", ":", "return", ":", "(", "-", "90", "-", "180", "90", "180", ")" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L247-L257
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
parse_geo_box
def parse_geo_box(geo_box_str): """ parses [-90,-180 TO 90,180] to a shapely.geometry.box :param geo_box_str: :return: """ from_point_str, to_point_str = parse_solr_geo_range_as_pair(geo_box_str) from_point = parse_lat_lon(from_point_str) to_point = parse_lat_lon(to_point_str) recta...
python
def parse_geo_box(geo_box_str): """ parses [-90,-180 TO 90,180] to a shapely.geometry.box :param geo_box_str: :return: """ from_point_str, to_point_str = parse_solr_geo_range_as_pair(geo_box_str) from_point = parse_lat_lon(from_point_str) to_point = parse_lat_lon(to_point_str) recta...
[ "def", "parse_geo_box", "(", "geo_box_str", ")", ":", "from_point_str", ",", "to_point_str", "=", "parse_solr_geo_range_as_pair", "(", "geo_box_str", ")", "from_point", "=", "parse_lat_lon", "(", "from_point_str", ")", "to_point", "=", "parse_lat_lon", "(", "to_point_...
parses [-90,-180 TO 90,180] to a shapely.geometry.box :param geo_box_str: :return:
[ "parses", "[", "-", "90", "-", "180", "TO", "90", "180", "]", "to", "a", "shapely", ".", "geometry", ".", "box", ":", "param", "geo_box_str", ":", ":", "return", ":" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L265-L276
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
request_heatmap_facet
def request_heatmap_facet(field, hm_filter, hm_grid_level, hm_limit): """ heatmap facet query builder :param field: map the query to this field. :param hm_filter: From what region to plot the heatmap. Defaults to q.geo or otherwise the world. :param hm_grid_level: To explicitly specify the grid leve...
python
def request_heatmap_facet(field, hm_filter, hm_grid_level, hm_limit): """ heatmap facet query builder :param field: map the query to this field. :param hm_filter: From what region to plot the heatmap. Defaults to q.geo or otherwise the world. :param hm_grid_level: To explicitly specify the grid leve...
[ "def", "request_heatmap_facet", "(", "field", ",", "hm_filter", ",", "hm_grid_level", ",", "hm_limit", ")", ":", "if", "not", "hm_filter", ":", "hm_filter", "=", "'[-90,-180 TO 90,180]'", "params", "=", "{", "'facet'", ":", "'on'", ",", "'facet.heatmap'", ":", ...
heatmap facet query builder :param field: map the query to this field. :param hm_filter: From what region to plot the heatmap. Defaults to q.geo or otherwise the world. :param hm_grid_level: To explicitly specify the grid level, e.g. to let a user ask for greater or courser resolution than the most rece...
[ "heatmap", "facet", "query", "builder", ":", "param", "field", ":", "map", "the", "query", "to", "this", "field", ".", ":", "param", "hm_filter", ":", "From", "what", "region", "to", "plot", "the", "heatmap", ".", "Defaults", "to", "q", ".", "geo", "or...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L279-L315
train
cga-harvard/Hypermap-Registry
hypermap/search_api/utils.py
asterisk_to_min_max
def asterisk_to_min_max(field, time_filter, search_engine_endpoint, actual_params=None): """ traduce [* TO *] to something like [MIN-INDEXED-DATE TO MAX-INDEXED-DATE] :param field: map the stats to this field. :param time_filter: this is the value to be translated. think in "[* TO 2000]" :param sear...
python
def asterisk_to_min_max(field, time_filter, search_engine_endpoint, actual_params=None): """ traduce [* TO *] to something like [MIN-INDEXED-DATE TO MAX-INDEXED-DATE] :param field: map the stats to this field. :param time_filter: this is the value to be translated. think in "[* TO 2000]" :param sear...
[ "def", "asterisk_to_min_max", "(", "field", ",", "time_filter", ",", "search_engine_endpoint", ",", "actual_params", "=", "None", ")", ":", "if", "actual_params", ":", "raise", "NotImplemented", "(", "\"actual_params\"", ")", "start", ",", "end", "=", "parse_solr_...
traduce [* TO *] to something like [MIN-INDEXED-DATE TO MAX-INDEXED-DATE] :param field: map the stats to this field. :param time_filter: this is the value to be translated. think in "[* TO 2000]" :param search_engine_endpoint: solr core :param actual_params: (not implemented) to merge with other params....
[ "traduce", "[", "*", "TO", "*", "]", "to", "something", "like", "[", "MIN", "-", "INDEXED", "-", "DATE", "TO", "MAX", "-", "INDEXED", "-", "DATE", "]", ":", "param", "field", ":", "map", "the", "stats", "to", "this", "field", ".", ":", "param", "...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L322-L359
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
get_service
def get_service(raw_xml): """ Set a service object based on the XML metadata <dct:references scheme="OGC:WMS">http://ngamaps.geointapps.org/arcgis /services/RIO/Rio_Foundation_Transportation/MapServer/WMSServer </dct:references> :param instance: :return: Layer """ from pycsw...
python
def get_service(raw_xml): """ Set a service object based on the XML metadata <dct:references scheme="OGC:WMS">http://ngamaps.geointapps.org/arcgis /services/RIO/Rio_Foundation_Transportation/MapServer/WMSServer </dct:references> :param instance: :return: Layer """ from pycsw...
[ "def", "get_service", "(", "raw_xml", ")", ":", "from", "pycsw", ".", "core", ".", "etree", "import", "etree", "parsed", "=", "etree", ".", "fromstring", "(", "raw_xml", ",", "etree", ".", "XMLParser", "(", "resolve_entities", "=", "False", ")", ")", "# ...
Set a service object based on the XML metadata <dct:references scheme="OGC:WMS">http://ngamaps.geointapps.org/arcgis /services/RIO/Rio_Foundation_Transportation/MapServer/WMSServer </dct:references> :param instance: :return: Layer
[ "Set", "a", "service", "object", "based", "on", "the", "XML", "metadata", "<dct", ":", "references", "scheme", "=", "OGC", ":", "WMS", ">", "http", ":", "//", "ngamaps", ".", "geointapps", ".", "org", "/", "arcgis", "/", "services", "/", "RIO", "/", ...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L56-L95
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository.query_ids
def query_ids(self, ids): """ Query by list of identifiers """ results = self._get_repo_filter(Layer.objects).filter(uuid__in=ids).all() if len(results) == 0: # try services results = self._get_repo_filter(Service.objects).filter(uuid__in=ids).all() return...
python
def query_ids(self, ids): """ Query by list of identifiers """ results = self._get_repo_filter(Layer.objects).filter(uuid__in=ids).all() if len(results) == 0: # try services results = self._get_repo_filter(Service.objects).filter(uuid__in=ids).all() return...
[ "def", "query_ids", "(", "self", ",", "ids", ")", ":", "results", "=", "self", ".", "_get_repo_filter", "(", "Layer", ".", "objects", ")", ".", "filter", "(", "uuid__in", "=", "ids", ")", ".", "all", "(", ")", "if", "len", "(", "results", ")", "=="...
Query by list of identifiers
[ "Query", "by", "list", "of", "identifiers" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L152-L162
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository.query_domain
def query_domain(self, domain, typenames, domainquerytype='list', count=False): """ Query by property domain values """ objects = self._get_repo_filter(Layer.objects) if domainquerytype == 'range': return [tuple(objects.aggregate(Min(domain), Max(domain)).values())]...
python
def query_domain(self, domain, typenames, domainquerytype='list', count=False): """ Query by property domain values """ objects = self._get_repo_filter(Layer.objects) if domainquerytype == 'range': return [tuple(objects.aggregate(Min(domain), Max(domain)).values())]...
[ "def", "query_domain", "(", "self", ",", "domain", ",", "typenames", ",", "domainquerytype", "=", "'list'", ",", "count", "=", "False", ")", ":", "objects", "=", "self", ".", "_get_repo_filter", "(", "Layer", ".", "objects", ")", "if", "domainquerytype", "...
Query by property domain values
[ "Query", "by", "property", "domain", "values" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L164-L178
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository.query_insert
def query_insert(self, direction='max'): """ Query to get latest (default) or earliest update to repository """ if direction == 'min': return Layer.objects.aggregate( Min('last_updated'))['last_updated__min'].strftime('%Y-%m-%dT%H:%M:%SZ') return self....
python
def query_insert(self, direction='max'): """ Query to get latest (default) or earliest update to repository """ if direction == 'min': return Layer.objects.aggregate( Min('last_updated'))['last_updated__min'].strftime('%Y-%m-%dT%H:%M:%SZ') return self....
[ "def", "query_insert", "(", "self", ",", "direction", "=", "'max'", ")", ":", "if", "direction", "==", "'min'", ":", "return", "Layer", ".", "objects", ".", "aggregate", "(", "Min", "(", "'last_updated'", ")", ")", "[", "'last_updated__min'", "]", ".", "...
Query to get latest (default) or earliest update to repository
[ "Query", "to", "get", "latest", "(", "default", ")", "or", "earliest", "update", "to", "repository" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L180-L188
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository.query_source
def query_source(self, source): """ Query by source """ return self._get_repo_filter(Layer.objects).filter(url=source)
python
def query_source(self, source): """ Query by source """ return self._get_repo_filter(Layer.objects).filter(url=source)
[ "def", "query_source", "(", "self", ",", "source", ")", ":", "return", "self", ".", "_get_repo_filter", "(", "Layer", ".", "objects", ")", ".", "filter", "(", "url", "=", "source", ")" ]
Query by source
[ "Query", "by", "source" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L190-L194
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository.query
def query(self, constraint, sortby=None, typenames=None, maxrecords=10, startposition=0): """ Query records from underlying repository """ # run the raw query and get total # we want to exclude layers which are not valid, as it is done in the search engine if 'where' in ...
python
def query(self, constraint, sortby=None, typenames=None, maxrecords=10, startposition=0): """ Query records from underlying repository """ # run the raw query and get total # we want to exclude layers which are not valid, as it is done in the search engine if 'where' in ...
[ "def", "query", "(", "self", ",", "constraint", ",", "sortby", "=", "None", ",", "typenames", "=", "None", ",", "maxrecords", "=", "10", ",", "startposition", "=", "0", ")", ":", "# run the raw query and get total", "# we want to exclude layers which are not valid, ...
Query records from underlying repository
[ "Query", "records", "from", "underlying", "repository" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L196-L231
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository.insert
def insert(self, resourcetype, source, insert_date=None): """ Insert a record into the repository """ caller = inspect.stack()[1][3] if caller == 'transaction': # insert of Layer hhclass = 'Layer' source = resourcetype resourcetype = resourc...
python
def insert(self, resourcetype, source, insert_date=None): """ Insert a record into the repository """ caller = inspect.stack()[1][3] if caller == 'transaction': # insert of Layer hhclass = 'Layer' source = resourcetype resourcetype = resourc...
[ "def", "insert", "(", "self", ",", "resourcetype", ",", "source", ",", "insert_date", "=", "None", ")", ":", "caller", "=", "inspect", ".", "stack", "(", ")", "[", "1", "]", "[", "3", "]", "if", "caller", "==", "'transaction'", ":", "# insert of Layer"...
Insert a record into the repository
[ "Insert", "a", "record", "into", "the", "repository" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L233-L249
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository._insert_or_update
def _insert_or_update(self, resourcetype, source, mode='insert', hhclass='Service'): """ Insert or update a record in the repository """ keywords = [] if self.filter is not None: catalog = Catalog.objects.get(id=int(self.filter.split()[-1])) try: ...
python
def _insert_or_update(self, resourcetype, source, mode='insert', hhclass='Service'): """ Insert or update a record in the repository """ keywords = [] if self.filter is not None: catalog = Catalog.objects.get(id=int(self.filter.split()[-1])) try: ...
[ "def", "_insert_or_update", "(", "self", ",", "resourcetype", ",", "source", ",", "mode", "=", "'insert'", ",", "hhclass", "=", "'Service'", ")", ":", "keywords", "=", "[", "]", "if", "self", ".", "filter", "is", "not", "None", ":", "catalog", "=", "Ca...
Insert or update a record in the repository
[ "Insert", "or", "update", "a", "record", "in", "the", "repository" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L251-L321
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository.delete
def delete(self, constraint): """ Delete a record from the repository """ results = self._get_repo_filter(Service.objects).extra(where=[constraint['where']], params=constraint['values']).all() deleted = len(results) ...
python
def delete(self, constraint): """ Delete a record from the repository """ results = self._get_repo_filter(Service.objects).extra(where=[constraint['where']], params=constraint['values']).all() deleted = len(results) ...
[ "def", "delete", "(", "self", ",", "constraint", ")", ":", "results", "=", "self", ".", "_get_repo_filter", "(", "Service", ".", "objects", ")", ".", "extra", "(", "where", "=", "[", "constraint", "[", "'where'", "]", "]", ",", "params", "=", "constrai...
Delete a record from the repository
[ "Delete", "a", "record", "from", "the", "repository" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L323-L332
train
cga-harvard/Hypermap-Registry
hypermap/search/pycsw_plugin.py
HHypermapRepository._get_repo_filter
def _get_repo_filter(self, query): """ Apply repository wide side filter / mask query """ if self.filter is not None: return query.extra(where=[self.filter]) return query
python
def _get_repo_filter(self, query): """ Apply repository wide side filter / mask query """ if self.filter is not None: return query.extra(where=[self.filter]) return query
[ "def", "_get_repo_filter", "(", "self", ",", "query", ")", ":", "if", "self", ".", "filter", "is", "not", "None", ":", "return", "query", ".", "extra", "(", "where", "=", "[", "self", ".", "filter", "]", ")", "return", "query" ]
Apply repository wide side filter / mask query
[ "Apply", "repository", "wide", "side", "filter", "/", "mask", "query" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L334-L340
train
hni14/jismesh
jismesh/utils.py
to_meshcode
def to_meshcode(lat, lon, level): """緯度経度から指定次の地域メッシュコードを算出する。 Args: lat: 世界測地系の緯度(度単位) lon: 世界測地系の経度(度単位) level: 地域メッシュコードの次数 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 ...
python
def to_meshcode(lat, lon, level): """緯度経度から指定次の地域メッシュコードを算出する。 Args: lat: 世界測地系の緯度(度単位) lon: 世界測地系の経度(度単位) level: 地域メッシュコードの次数 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 ...
[ "def", "to_meshcode", "(", "lat", ",", "lon", ",", "level", ")", ":", "if", "not", "0", "<=", "lat", "<", "66.66", ":", "raise", "ValueError", "(", "'the latitude is out of bound.'", ")", "if", "not", "100", "<=", "lon", "<", "180", ":", "raise", "Valu...
緯度経度から指定次の地域メッシュコードを算出する。 Args: lat: 世界測地系の緯度(度単位) lon: 世界測地系の経度(度単位) level: 地域メッシュコードの次数 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 8倍(8km四方):8000 ...
[ "緯度経度から指定次の地域メッシュコードを算出する。" ]
bda486ac7828d0adaea2a128154d0a554be7ef37
https://github.com/hni14/jismesh/blob/bda486ac7828d0adaea2a128154d0a554be7ef37/jismesh/utils.py#L64-L238
train
hni14/jismesh
jismesh/utils.py
to_meshlevel
def to_meshlevel(meshcode): """メッシュコードから次数を算出する。 Args: meshcode: メッシュコード Return: 地域メッシュコードの次数 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 8倍(8km四方):8000 ...
python
def to_meshlevel(meshcode): """メッシュコードから次数を算出する。 Args: meshcode: メッシュコード Return: 地域メッシュコードの次数 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 8倍(8km四方):8000 ...
[ "def", "to_meshlevel", "(", "meshcode", ")", ":", "length", "=", "len", "(", "str", "(", "meshcode", ")", ")", "if", "length", "==", "4", ":", "return", "1", "if", "length", "==", "5", ":", "return", "40000", "if", "length", "==", "6", ":", "return...
メッシュコードから次数を算出する。 Args: meshcode: メッシュコード Return: 地域メッシュコードの次数 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 8倍(8km四方):8000 5倍(5km四方):5000 ...
[ "メッシュコードから次数を算出する。" ]
bda486ac7828d0adaea2a128154d0a554be7ef37
https://github.com/hni14/jismesh/blob/bda486ac7828d0adaea2a128154d0a554be7ef37/jismesh/utils.py#L240-L310
train
hni14/jismesh
jismesh/utils.py
to_meshpoint
def to_meshpoint(meshcode, lat_multiplier, lon_multiplier): """地域メッシュコードから緯度経度を算出する。 下記のメッシュに対応している。 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 8倍(8km四方):8000 ...
python
def to_meshpoint(meshcode, lat_multiplier, lon_multiplier): """地域メッシュコードから緯度経度を算出する。 下記のメッシュに対応している。 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 8倍(8km四方):8000 ...
[ "def", "to_meshpoint", "(", "meshcode", ",", "lat_multiplier", ",", "lon_multiplier", ")", ":", "def", "mesh_cord", "(", "func_higher_cord", ",", "func_unit_cord", ",", "func_multiplier", ")", ":", "return", "func_higher_cord", "(", ")", "+", "func_unit_cord", "("...
地域メッシュコードから緯度経度を算出する。 下記のメッシュに対応している。 1次(80km四方):1 40倍(40km四方):40000 20倍(20km四方):20000 16倍(16km四方):16000 2次(10km四方):2 8倍(8km四方):8000 5倍(5km四方):5000 4倍(4km四方):4000 2.5倍(...
[ "地域メッシュコードから緯度経度を算出する。", "下記のメッシュに対応している。", "1次", "(", "80km四方", ")", ":", "1", "40倍", "(", "40km四方", ")", ":", "40000", "20倍", "(", "20km四方", ")", ":", "20000", "16倍", "(", "16km四方", ")", ":", "16000", "2次", "(", "10km四方", ")", ":", "2", "8倍", "(", ...
bda486ac7828d0adaea2a128154d0a554be7ef37
https://github.com/hni14/jismesh/blob/bda486ac7828d0adaea2a128154d0a554be7ef37/jismesh/utils.py#L312-L811
train
caffeinehit/django-follow
follow/views.py
check
def check(func): """ Check the permissions, http method and login state. """ def iCheck(request, *args, **kwargs): if not request.method == "POST": return HttpResponseBadRequest("Must be POST request.") follow = func(request, *args, **kwargs) if request.is_ajax(): ...
python
def check(func): """ Check the permissions, http method and login state. """ def iCheck(request, *args, **kwargs): if not request.method == "POST": return HttpResponseBadRequest("Must be POST request.") follow = func(request, *args, **kwargs) if request.is_ajax(): ...
[ "def", "check", "(", "func", ")", ":", "def", "iCheck", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "request", ".", "method", "==", "\"POST\"", ":", "return", "HttpResponseBadRequest", "(", "\"Must be POST request.\"",...
Check the permissions, http method and login state.
[ "Check", "the", "permissions", "http", "method", "and", "login", "state", "." ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/views.py#L7-L30
train
caffeinehit/django-follow
follow/utils.py
register
def register(model, field_name=None, related_name=None, lookup_method_name='get_follows'): """ This registers any model class to be follow-able. """ if model in registry: return registry.append(model) if not field_name: field_name = 'target_%s' % model._meta.module_nam...
python
def register(model, field_name=None, related_name=None, lookup_method_name='get_follows'): """ This registers any model class to be follow-able. """ if model in registry: return registry.append(model) if not field_name: field_name = 'target_%s' % model._meta.module_nam...
[ "def", "register", "(", "model", ",", "field_name", "=", "None", ",", "related_name", "=", "None", ",", "lookup_method_name", "=", "'get_follows'", ")", ":", "if", "model", "in", "registry", ":", "return", "registry", ".", "append", "(", "model", ")", "if"...
This registers any model class to be follow-able.
[ "This", "registers", "any", "model", "class", "to", "be", "follow", "-", "able", "." ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/utils.py#L9-L30
train
caffeinehit/django-follow
follow/utils.py
follow
def follow(user, obj): """ Make a user follow an object """ follow, created = Follow.objects.get_or_create(user, obj) return follow
python
def follow(user, obj): """ Make a user follow an object """ follow, created = Follow.objects.get_or_create(user, obj) return follow
[ "def", "follow", "(", "user", ",", "obj", ")", ":", "follow", ",", "created", "=", "Follow", ".", "objects", ".", "get_or_create", "(", "user", ",", "obj", ")", "return", "follow" ]
Make a user follow an object
[ "Make", "a", "user", "follow", "an", "object" ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/utils.py#L32-L35
train
caffeinehit/django-follow
follow/utils.py
unfollow
def unfollow(user, obj): """ Make a user unfollow an object """ try: follow = Follow.objects.get_follows(obj).get(user=user) follow.delete() return follow except Follow.DoesNotExist: pass
python
def unfollow(user, obj): """ Make a user unfollow an object """ try: follow = Follow.objects.get_follows(obj).get(user=user) follow.delete() return follow except Follow.DoesNotExist: pass
[ "def", "unfollow", "(", "user", ",", "obj", ")", ":", "try", ":", "follow", "=", "Follow", ".", "objects", ".", "get_follows", "(", "obj", ")", ".", "get", "(", "user", "=", "user", ")", "follow", ".", "delete", "(", ")", "return", "follow", "excep...
Make a user unfollow an object
[ "Make", "a", "user", "unfollow", "an", "object" ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/utils.py#L37-L44
train
caffeinehit/django-follow
follow/utils.py
toggle
def toggle(user, obj): """ Toggles a follow status. Useful function if you don't want to perform follow checks but just toggle it on / off. """ if Follow.objects.is_following(user, obj): return unfollow(user, obj) return follow(user, obj)
python
def toggle(user, obj): """ Toggles a follow status. Useful function if you don't want to perform follow checks but just toggle it on / off. """ if Follow.objects.is_following(user, obj): return unfollow(user, obj) return follow(user, obj)
[ "def", "toggle", "(", "user", ",", "obj", ")", ":", "if", "Follow", ".", "objects", ".", "is_following", "(", "user", ",", "obj", ")", ":", "return", "unfollow", "(", "user", ",", "obj", ")", "return", "follow", "(", "user", ",", "obj", ")" ]
Toggles a follow status. Useful function if you don't want to perform follow checks but just toggle it on / off.
[ "Toggles", "a", "follow", "status", ".", "Useful", "function", "if", "you", "don", "t", "want", "to", "perform", "follow", "checks", "but", "just", "toggle", "it", "on", "/", "off", "." ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/utils.py#L46-L51
train
cga-harvard/Hypermap-Registry
hypermap/search_api/serializers.py
SearchSerializer.validate_q_time
def validate_q_time(self, value): """ Would be for example: [2013-03-01 TO 2013-04-01T00:00:00] and/or [* TO *] Returns a valid sorl value. [2013-03-01T00:00:00Z TO 2013-04-01T00:00:00Z] and/or [* TO *] """ if value: try: range = utils.parse_datetime_r...
python
def validate_q_time(self, value): """ Would be for example: [2013-03-01 TO 2013-04-01T00:00:00] and/or [* TO *] Returns a valid sorl value. [2013-03-01T00:00:00Z TO 2013-04-01T00:00:00Z] and/or [* TO *] """ if value: try: range = utils.parse_datetime_r...
[ "def", "validate_q_time", "(", "self", ",", "value", ")", ":", "if", "value", ":", "try", ":", "range", "=", "utils", ".", "parse_datetime_range_to_solr", "(", "value", ")", "return", "range", "except", "Exception", "as", "e", ":", "raise", "serializers", ...
Would be for example: [2013-03-01 TO 2013-04-01T00:00:00] and/or [* TO *] Returns a valid sorl value. [2013-03-01T00:00:00Z TO 2013-04-01T00:00:00Z] and/or [* TO *]
[ "Would", "be", "for", "example", ":", "[", "2013", "-", "03", "-", "01", "TO", "2013", "-", "04", "-", "01T00", ":", "00", ":", "00", "]", "and", "/", "or", "[", "*", "TO", "*", "]", "Returns", "a", "valid", "sorl", "value", ".", "[", "2013",...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/serializers.py#L114-L126
train
cga-harvard/Hypermap-Registry
hypermap/search_api/serializers.py
SearchSerializer.validate_q_geo
def validate_q_geo(self, value): """ Would be for example: [-90,-180 TO 90,180] """ if value: try: rectangle = utils.parse_geo_box(value) return "[{0},{1} TO {2},{3}]".format( rectangle.bounds[0], rectang...
python
def validate_q_geo(self, value): """ Would be for example: [-90,-180 TO 90,180] """ if value: try: rectangle = utils.parse_geo_box(value) return "[{0},{1} TO {2},{3}]".format( rectangle.bounds[0], rectang...
[ "def", "validate_q_geo", "(", "self", ",", "value", ")", ":", "if", "value", ":", "try", ":", "rectangle", "=", "utils", ".", "parse_geo_box", "(", "value", ")", "return", "\"[{0},{1} TO {2},{3}]\"", ".", "format", "(", "rectangle", ".", "bounds", "[", "0"...
Would be for example: [-90,-180 TO 90,180]
[ "Would", "be", "for", "example", ":", "[", "-", "90", "-", "180", "TO", "90", "180", "]" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/serializers.py#L128-L144
train
cga-harvard/Hypermap-Registry
hypermap/search_api/serializers.py
SearchSerializer.validate_a_time_filter
def validate_a_time_filter(self, value): """ Would be for example: [2013-03-01 TO 2013-04-01:00:00:00] and/or [* TO *] """ if value: try: utils.parse_datetime_range(value) except Exception as e: raise serializers.ValidationError(e.m...
python
def validate_a_time_filter(self, value): """ Would be for example: [2013-03-01 TO 2013-04-01:00:00:00] and/or [* TO *] """ if value: try: utils.parse_datetime_range(value) except Exception as e: raise serializers.ValidationError(e.m...
[ "def", "validate_a_time_filter", "(", "self", ",", "value", ")", ":", "if", "value", ":", "try", ":", "utils", ".", "parse_datetime_range", "(", "value", ")", "except", "Exception", "as", "e", ":", "raise", "serializers", ".", "ValidationError", "(", "e", ...
Would be for example: [2013-03-01 TO 2013-04-01:00:00:00] and/or [* TO *]
[ "Would", "be", "for", "example", ":", "[", "2013", "-", "03", "-", "01", "TO", "2013", "-", "04", "-", "01", ":", "00", ":", "00", ":", "00", "]", "and", "/", "or", "[", "*", "TO", "*", "]" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/serializers.py#L146-L156
train
caffeinehit/django-follow
follow/models.py
FollowManager.fname
def fname(self, model_or_obj_or_qs): """ Return the field name on the :class:`Follow` model for ``model_or_obj_or_qs``. """ if isinstance(model_or_obj_or_qs, QuerySet): _, fname = model_map[model_or_obj_or_qs.model] else: cls = model_or_obj_or_qs if inspe...
python
def fname(self, model_or_obj_or_qs): """ Return the field name on the :class:`Follow` model for ``model_or_obj_or_qs``. """ if isinstance(model_or_obj_or_qs, QuerySet): _, fname = model_map[model_or_obj_or_qs.model] else: cls = model_or_obj_or_qs if inspe...
[ "def", "fname", "(", "self", ",", "model_or_obj_or_qs", ")", ":", "if", "isinstance", "(", "model_or_obj_or_qs", ",", "QuerySet", ")", ":", "_", ",", "fname", "=", "model_map", "[", "model_or_obj_or_qs", ".", "model", "]", "else", ":", "cls", "=", "model_o...
Return the field name on the :class:`Follow` model for ``model_or_obj_or_qs``.
[ "Return", "the", "field", "name", "on", "the", ":", "class", ":", "Follow", "model", "for", "model_or_obj_or_qs", "." ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L10-L19
train
caffeinehit/django-follow
follow/models.py
FollowManager.create
def create(self, user, obj, **kwargs): """ Create a new follow link between a user and an object of a registered model type. """ follow = Follow(user=user) follow.target = obj follow.save() return follow
python
def create(self, user, obj, **kwargs): """ Create a new follow link between a user and an object of a registered model type. """ follow = Follow(user=user) follow.target = obj follow.save() return follow
[ "def", "create", "(", "self", ",", "user", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "follow", "=", "Follow", "(", "user", "=", "user", ")", "follow", ".", "target", "=", "obj", "follow", ".", "save", "(", ")", "return", "follow" ]
Create a new follow link between a user and an object of a registered model type.
[ "Create", "a", "new", "follow", "link", "between", "a", "user", "and", "an", "object", "of", "a", "registered", "model", "type", "." ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L21-L30
train
caffeinehit/django-follow
follow/models.py
FollowManager.get_or_create
def get_or_create(self, user, obj, **kwargs): """ Almost the same as `FollowManager.objects.create` - behaves the same as the normal `get_or_create` methods in django though. Returns a tuple with the `Follow` and either `True` or `False` """ if not self.is_following(...
python
def get_or_create(self, user, obj, **kwargs): """ Almost the same as `FollowManager.objects.create` - behaves the same as the normal `get_or_create` methods in django though. Returns a tuple with the `Follow` and either `True` or `False` """ if not self.is_following(...
[ "def", "get_or_create", "(", "self", ",", "user", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_following", "(", "user", ",", "obj", ")", ":", "return", "self", ".", "create", "(", "user", ",", "obj", ",", "*", "*",...
Almost the same as `FollowManager.objects.create` - behaves the same as the normal `get_or_create` methods in django though. Returns a tuple with the `Follow` and either `True` or `False`
[ "Almost", "the", "same", "as", "FollowManager", ".", "objects", ".", "create", "-", "behaves", "the", "same", "as", "the", "normal", "get_or_create", "methods", "in", "django", "though", "." ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L32-L42
train
caffeinehit/django-follow
follow/models.py
FollowManager.is_following
def is_following(self, user, obj): """ Returns `True` or `False` """ if isinstance(user, AnonymousUser): return False return 0 < self.get_follows(obj).filter(user=user).count()
python
def is_following(self, user, obj): """ Returns `True` or `False` """ if isinstance(user, AnonymousUser): return False return 0 < self.get_follows(obj).filter(user=user).count()
[ "def", "is_following", "(", "self", ",", "user", ",", "obj", ")", ":", "if", "isinstance", "(", "user", ",", "AnonymousUser", ")", ":", "return", "False", "return", "0", "<", "self", ".", "get_follows", "(", "obj", ")", ".", "filter", "(", "user", "=...
Returns `True` or `False`
[ "Returns", "True", "or", "False" ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L44-L48
train
caffeinehit/django-follow
follow/models.py
FollowManager.get_follows
def get_follows(self, model_or_obj_or_qs): """ Returns all the followers of a model, an object or a queryset. """ fname = self.fname(model_or_obj_or_qs) if isinstance(model_or_obj_or_qs, QuerySet): return self.filter(**{'%s__in' % fname: model_or_obj_or_qs}) ...
python
def get_follows(self, model_or_obj_or_qs): """ Returns all the followers of a model, an object or a queryset. """ fname = self.fname(model_or_obj_or_qs) if isinstance(model_or_obj_or_qs, QuerySet): return self.filter(**{'%s__in' % fname: model_or_obj_or_qs}) ...
[ "def", "get_follows", "(", "self", ",", "model_or_obj_or_qs", ")", ":", "fname", "=", "self", ".", "fname", "(", "model_or_obj_or_qs", ")", "if", "isinstance", "(", "model_or_obj_or_qs", ",", "QuerySet", ")", ":", "return", "self", ".", "filter", "(", "*", ...
Returns all the followers of a model, an object or a queryset.
[ "Returns", "all", "the", "followers", "of", "a", "model", "an", "object", "or", "a", "queryset", "." ]
765a4795e58f57fbf96efdb7838d0c7222db2e56
https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L50-L62
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.create_event_regressors
def create_event_regressors(self, event_times_indices, covariates = None, durations = None): """create_event_regressors creates the part of the design matrix corresponding to one event type. :param event_times_indices: indices in the resampled data, on which the events occurred. :type ...
python
def create_event_regressors(self, event_times_indices, covariates = None, durations = None): """create_event_regressors creates the part of the design matrix corresponding to one event type. :param event_times_indices: indices in the resampled data, on which the events occurred. :type ...
[ "def", "create_event_regressors", "(", "self", ",", "event_times_indices", ",", "covariates", "=", "None", ",", "durations", "=", "None", ")", ":", "# check covariates", "if", "covariates", "is", "None", ":", "covariates", "=", "np", ".", "ones", "(", "self", ...
create_event_regressors creates the part of the design matrix corresponding to one event type. :param event_times_indices: indices in the resampled data, on which the events occurred. :type event_times_indices: numpy array, (nr_events) :param covariates: covariates belonging to thi...
[ "create_event_regressors", "creates", "the", "part", "of", "the", "design", "matrix", "corresponding", "to", "one", "event", "type", "." ]
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L121-L172
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.create_design_matrix
def create_design_matrix(self, demean = False, intercept = True): """create_design_matrix calls create_event_regressors for each of the covariates in the self.covariates dict. self.designmatrix is created and is shaped (nr_regressors, self.resampled_signal.shape[-1]) """ self.design_matrix = np....
python
def create_design_matrix(self, demean = False, intercept = True): """create_design_matrix calls create_event_regressors for each of the covariates in the self.covariates dict. self.designmatrix is created and is shaped (nr_regressors, self.resampled_signal.shape[-1]) """ self.design_matrix = np....
[ "def", "create_design_matrix", "(", "self", ",", "demean", "=", "False", ",", "intercept", "=", "True", ")", ":", "self", ".", "design_matrix", "=", "np", ".", "zeros", "(", "(", "int", "(", "self", ".", "number_of_event_types", "*", "self", ".", "deconv...
create_design_matrix calls create_event_regressors for each of the covariates in the self.covariates dict. self.designmatrix is created and is shaped (nr_regressors, self.resampled_signal.shape[-1])
[ "create_design_matrix", "calls", "create_event_regressors", "for", "each", "of", "the", "covariates", "in", "the", "self", ".", "covariates", "dict", ".", "self", ".", "designmatrix", "is", "created", "and", "is", "shaped", "(", "nr_regressors", "self", ".", "re...
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L174-L200
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.add_continuous_regressors_to_design_matrix
def add_continuous_regressors_to_design_matrix(self, regressors): """add_continuous_regressors_to_design_matrix appends continuously sampled regressors to the existing design matrix. One uses this addition to the design matrix when one expects the data to contain nuisance factors that aren't tied to the moments...
python
def add_continuous_regressors_to_design_matrix(self, regressors): """add_continuous_regressors_to_design_matrix appends continuously sampled regressors to the existing design matrix. One uses this addition to the design matrix when one expects the data to contain nuisance factors that aren't tied to the moments...
[ "def", "add_continuous_regressors_to_design_matrix", "(", "self", ",", "regressors", ")", ":", "previous_design_matrix_shape", "=", "self", ".", "design_matrix", ".", "shape", "if", "len", "(", "regressors", ".", "shape", ")", "==", "1", ":", "regressors", "=", ...
add_continuous_regressors_to_design_matrix appends continuously sampled regressors to the existing design matrix. One uses this addition to the design matrix when one expects the data to contain nuisance factors that aren't tied to the moments of specific events. For instance, in fMRI analysis this allows us to add car...
[ "add_continuous_regressors_to_design_matrix", "appends", "continuously", "sampled", "regressors", "to", "the", "existing", "design", "matrix", ".", "One", "uses", "this", "addition", "to", "the", "design", "matrix", "when", "one", "expects", "the", "data", "to", "co...
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L202-L215
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.regress
def regress(self, method = 'lstsq'): """regress performs linear least squares regression of the designmatrix on the data. :param method: method, or backend to be used for the regression analysis. :type method: string, one of ['lstsq', 'sm_ols'] :returns: instance variables ...
python
def regress(self, method = 'lstsq'): """regress performs linear least squares regression of the designmatrix on the data. :param method: method, or backend to be used for the regression analysis. :type method: string, one of ['lstsq', 'sm_ols'] :returns: instance variables ...
[ "def", "regress", "(", "self", ",", "method", "=", "'lstsq'", ")", ":", "if", "method", "is", "'lstsq'", ":", "self", ".", "betas", ",", "residuals_sum", ",", "rank", ",", "s", "=", "LA", ".", "lstsq", "(", "self", ".", "design_matrix", ".", "T", "...
regress performs linear least squares regression of the designmatrix on the data. :param method: method, or backend to be used for the regression analysis. :type method: string, one of ['lstsq', 'sm_ols'] :returns: instance variables 'betas' (nr_betas x nr_signals) and 'residuals' ...
[ "regress", "performs", "linear", "least", "squares", "regression", "of", "the", "designmatrix", "on", "the", "data", "." ]
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L217-L239
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.ridge_regress
def ridge_regress(self, cv = 20, alphas = None ): """perform k-folds cross-validated ridge regression on the design_matrix. To be used when the design matrix contains very collinear regressors. For cross-validation and ridge fitting, we use sklearn's RidgeCV functionality. Note: intercept is not fit, and data a...
python
def ridge_regress(self, cv = 20, alphas = None ): """perform k-folds cross-validated ridge regression on the design_matrix. To be used when the design matrix contains very collinear regressors. For cross-validation and ridge fitting, we use sklearn's RidgeCV functionality. Note: intercept is not fit, and data a...
[ "def", "ridge_regress", "(", "self", ",", "cv", "=", "20", ",", "alphas", "=", "None", ")", ":", "if", "alphas", "is", "None", ":", "alphas", "=", "np", ".", "logspace", "(", "7", ",", "0", ",", "20", ")", "self", ".", "rcv", "=", "linear_model",...
perform k-folds cross-validated ridge regression on the design_matrix. To be used when the design matrix contains very collinear regressors. For cross-validation and ridge fitting, we use sklearn's RidgeCV functionality. Note: intercept is not fit, and data are not prenormalized. :param cv: cross-validate...
[ "perform", "k", "-", "folds", "cross", "-", "validated", "ridge", "regression", "on", "the", "design_matrix", ".", "To", "be", "used", "when", "the", "design", "matrix", "contains", "very", "collinear", "regressors", ".", "For", "cross", "-", "validation", "...
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L241-L260
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.betas_for_cov
def betas_for_cov(self, covariate = '0'): """betas_for_cov returns the beta values (i.e. IRF) associated with a specific covariate. :param covariate: name of covariate. :type covariate: string """ # find the index in the designmatrix of the current covariate this...
python
def betas_for_cov(self, covariate = '0'): """betas_for_cov returns the beta values (i.e. IRF) associated with a specific covariate. :param covariate: name of covariate. :type covariate: string """ # find the index in the designmatrix of the current covariate this...
[ "def", "betas_for_cov", "(", "self", ",", "covariate", "=", "'0'", ")", ":", "# find the index in the designmatrix of the current covariate", "this_covariate_index", "=", "list", "(", "self", ".", "covariates", ".", "keys", "(", ")", ")", ".", "index", "(", "covar...
betas_for_cov returns the beta values (i.e. IRF) associated with a specific covariate. :param covariate: name of covariate. :type covariate: string
[ "betas_for_cov", "returns", "the", "beta", "values", "(", "i", ".", "e", ".", "IRF", ")", "associated", "with", "a", "specific", "covariate", "." ]
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L262-L270
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.betas_for_events
def betas_for_events(self): """betas_for_events creates an internal self.betas_per_event_type array, of (nr_covariates x self.devonvolution_interval_size), which holds the outcome betas per event type,in the order generated by self.covariates.keys() """ self.betas_per_event_type = np.ze...
python
def betas_for_events(self): """betas_for_events creates an internal self.betas_per_event_type array, of (nr_covariates x self.devonvolution_interval_size), which holds the outcome betas per event type,in the order generated by self.covariates.keys() """ self.betas_per_event_type = np.ze...
[ "def", "betas_for_events", "(", "self", ")", ":", "self", ".", "betas_per_event_type", "=", "np", ".", "zeros", "(", "(", "len", "(", "self", ".", "covariates", ")", ",", "self", ".", "deconvolution_interval_size", ",", "self", ".", "resampled_signal", ".", ...
betas_for_events creates an internal self.betas_per_event_type array, of (nr_covariates x self.devonvolution_interval_size), which holds the outcome betas per event type,in the order generated by self.covariates.keys()
[ "betas_for_events", "creates", "an", "internal", "self", ".", "betas_per_event_type", "array", "of", "(", "nr_covariates", "x", "self", ".", "devonvolution_interval_size", ")", "which", "holds", "the", "outcome", "betas", "per", "event", "type", "in", "the", "orde...
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L272-L278
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.predict_from_design_matrix
def predict_from_design_matrix(self, design_matrix): """predict_from_design_matrix predicts signals given a design matrix. :param design_matrix: design matrix from which to predict a signal. :type design_matrix: numpy array, (nr_samples x betas.shape) :returns: predicted sig...
python
def predict_from_design_matrix(self, design_matrix): """predict_from_design_matrix predicts signals given a design matrix. :param design_matrix: design matrix from which to predict a signal. :type design_matrix: numpy array, (nr_samples x betas.shape) :returns: predicted sig...
[ "def", "predict_from_design_matrix", "(", "self", ",", "design_matrix", ")", ":", "# check if we have already run the regression - which is necessary", "assert", "hasattr", "(", "self", ",", "'betas'", ")", ",", "'no betas found, please run regression before prediction'", "assert...
predict_from_design_matrix predicts signals given a design matrix. :param design_matrix: design matrix from which to predict a signal. :type design_matrix: numpy array, (nr_samples x betas.shape) :returns: predicted signal(s) :rtype: numpy array (nr_signals x nr_samples...
[ "predict_from_design_matrix", "predicts", "signals", "given", "a", "design", "matrix", "." ]
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L280-L298
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.calculate_rsq
def calculate_rsq(self): """calculate_rsq calculates coefficient of determination, or r-squared, defined here as 1.0 - SS_res / SS_tot. rsq is only calculated for those timepoints in the data for which the design matrix is non-zero. """ assert hasattr(self, 'betas'), 'no betas found, please run ...
python
def calculate_rsq(self): """calculate_rsq calculates coefficient of determination, or r-squared, defined here as 1.0 - SS_res / SS_tot. rsq is only calculated for those timepoints in the data for which the design matrix is non-zero. """ assert hasattr(self, 'betas'), 'no betas found, please run ...
[ "def", "calculate_rsq", "(", "self", ")", ":", "assert", "hasattr", "(", "self", ",", "'betas'", ")", ",", "'no betas found, please run regression before rsq'", "explained_times", "=", "self", ".", "design_matrix", ".", "sum", "(", "axis", "=", "0", ")", "!=", ...
calculate_rsq calculates coefficient of determination, or r-squared, defined here as 1.0 - SS_res / SS_tot. rsq is only calculated for those timepoints in the data for which the design matrix is non-zero.
[ "calculate_rsq", "calculates", "coefficient", "of", "determination", "or", "r", "-", "squared", "defined", "here", "as", "1", ".", "0", "-", "SS_res", "/", "SS_tot", ".", "rsq", "is", "only", "calculated", "for", "those", "timepoints", "in", "the", "data", ...
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L300-L310
train
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
FIRDeconvolution.bootstrap_on_residuals
def bootstrap_on_residuals(self, nr_repetitions = 1000): """bootstrap_on_residuals bootstraps, by shuffling the residuals. bootstrap_on_residuals should only be used on single-channel data, as otherwise the memory load might increase too much. This uses the lstsq backend regression for a single-pass fit across ...
python
def bootstrap_on_residuals(self, nr_repetitions = 1000): """bootstrap_on_residuals bootstraps, by shuffling the residuals. bootstrap_on_residuals should only be used on single-channel data, as otherwise the memory load might increase too much. This uses the lstsq backend regression for a single-pass fit across ...
[ "def", "bootstrap_on_residuals", "(", "self", ",", "nr_repetitions", "=", "1000", ")", ":", "assert", "self", ".", "resampled_signal", ".", "shape", "[", "0", "]", "==", "1", ",", "'signal input into bootstrap_on_residuals cannot contain signals from multiple channels at ...
bootstrap_on_residuals bootstraps, by shuffling the residuals. bootstrap_on_residuals should only be used on single-channel data, as otherwise the memory load might increase too much. This uses the lstsq backend regression for a single-pass fit across repetitions. Please note that shuffling the residuals may change the...
[ "bootstrap_on_residuals", "bootstraps", "by", "shuffling", "the", "residuals", ".", "bootstrap_on_residuals", "should", "only", "be", "used", "on", "single", "-", "channel", "data", "as", "otherwise", "the", "memory", "load", "might", "increase", "too", "much", "....
6263496a356c449062fe4c216fef56541f6dc151
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L312-L337
train
cga-harvard/Hypermap-Registry
hypermap/context_processors.py
resource_urls
def resource_urls(request): """Global values to pass to templates""" url_parsed = urlparse(settings.SEARCH_URL) defaults = dict( APP_NAME=__description__, APP_VERSION=__version__, SITE_URL=settings.SITE_URL.rstrip('/'), SEARCH_TYPE=settings.SEARCH_TYPE, SEARCH_URL=se...
python
def resource_urls(request): """Global values to pass to templates""" url_parsed = urlparse(settings.SEARCH_URL) defaults = dict( APP_NAME=__description__, APP_VERSION=__version__, SITE_URL=settings.SITE_URL.rstrip('/'), SEARCH_TYPE=settings.SEARCH_TYPE, SEARCH_URL=se...
[ "def", "resource_urls", "(", "request", ")", ":", "url_parsed", "=", "urlparse", "(", "settings", ".", "SEARCH_URL", ")", "defaults", "=", "dict", "(", "APP_NAME", "=", "__description__", ",", "APP_VERSION", "=", "__version__", ",", "SITE_URL", "=", "settings"...
Global values to pass to templates
[ "Global", "values", "to", "pass", "to", "templates" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/context_processors.py#L7-L19
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
index_cached_layers
def index_cached_layers(self): """ Index and unindex all layers in the Django cache (Index all layers who have been checked). """ from hypermap.aggregator.models import Layer if SEARCH_TYPE == 'solr': from hypermap.aggregator.solr import SolrHypermap solrobject = SolrHypermap() ...
python
def index_cached_layers(self): """ Index and unindex all layers in the Django cache (Index all layers who have been checked). """ from hypermap.aggregator.models import Layer if SEARCH_TYPE == 'solr': from hypermap.aggregator.solr import SolrHypermap solrobject = SolrHypermap() ...
[ "def", "index_cached_layers", "(", "self", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Layer", "if", "SEARCH_TYPE", "==", "'solr'", ":", "from", "hypermap", ".", "aggregator", ".", "solr", "import", "SolrHypermap", "solrobject", ...
Index and unindex all layers in the Django cache (Index all layers who have been checked).
[ "Index", "and", "unindex", "all", "layers", "in", "the", "Django", "cache", "(", "Index", "all", "layers", "who", "have", "been", "checked", ")", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L94-L177
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
remove_service_checks
def remove_service_checks(self, service_id): """ Remove all checks from a service. """ from hypermap.aggregator.models import Service service = Service.objects.get(id=service_id) service.check_set.all().delete() layer_to_process = service.layer_set.all() for layer in layer_to_process: ...
python
def remove_service_checks(self, service_id): """ Remove all checks from a service. """ from hypermap.aggregator.models import Service service = Service.objects.get(id=service_id) service.check_set.all().delete() layer_to_process = service.layer_set.all() for layer in layer_to_process: ...
[ "def", "remove_service_checks", "(", "self", ",", "service_id", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Service", "service", "=", "Service", ".", "objects", ".", "get", "(", "id", "=", "service_id", ")", "service", ".", "...
Remove all checks from a service.
[ "Remove", "all", "checks", "from", "a", "service", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L195-L205
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
index_service
def index_service(self, service_id): """ Index a service in search engine. """ from hypermap.aggregator.models import Service service = Service.objects.get(id=service_id) if not service.is_valid: LOGGER.debug('Not indexing service with id %s in search engine as it is not valid' % servi...
python
def index_service(self, service_id): """ Index a service in search engine. """ from hypermap.aggregator.models import Service service = Service.objects.get(id=service_id) if not service.is_valid: LOGGER.debug('Not indexing service with id %s in search engine as it is not valid' % servi...
[ "def", "index_service", "(", "self", ",", "service_id", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Service", "service", "=", "Service", ".", "objects", ".", "get", "(", "id", "=", "service_id", ")", "if", "not", "service", ...
Index a service in search engine.
[ "Index", "a", "service", "in", "search", "engine", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L209-L228
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
index_layer
def index_layer(self, layer_id, use_cache=False): """ Index a layer in the search backend. If cache is set, append it to the list, if it isn't send the transaction right away. cache needs memcached to be available. """ from hypermap.aggregator.models import Layer layer = Layer.objects.get(i...
python
def index_layer(self, layer_id, use_cache=False): """ Index a layer in the search backend. If cache is set, append it to the list, if it isn't send the transaction right away. cache needs memcached to be available. """ from hypermap.aggregator.models import Layer layer = Layer.objects.get(i...
[ "def", "index_layer", "(", "self", ",", "layer_id", ",", "use_cache", "=", "False", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Layer", "layer", "=", "Layer", ".", "objects", ".", "get", "(", "id", "=", "layer_id", ")", "...
Index a layer in the search backend. If cache is set, append it to the list, if it isn't send the transaction right away. cache needs memcached to be available.
[ "Index", "a", "layer", "in", "the", "search", "backend", ".", "If", "cache", "is", "set", "append", "it", "to", "the", "list", "if", "it", "isn", "t", "send", "the", "transaction", "right", "away", ".", "cache", "needs", "memcached", "to", "be", "avail...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L232-L291
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
unindex_layers_with_issues
def unindex_layers_with_issues(self, use_cache=False): """ Remove the index for layers in search backend, which are linked to an issue. """ from hypermap.aggregator.models import Issue, Layer, Service from django.contrib.contenttypes.models import ContentType layer_type = ContentType.objects.ge...
python
def unindex_layers_with_issues(self, use_cache=False): """ Remove the index for layers in search backend, which are linked to an issue. """ from hypermap.aggregator.models import Issue, Layer, Service from django.contrib.contenttypes.models import ContentType layer_type = ContentType.objects.ge...
[ "def", "unindex_layers_with_issues", "(", "self", ",", "use_cache", "=", "False", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Issue", ",", "Layer", ",", "Service", "from", "django", ".", "contrib", ".", "contenttypes", ".", "mo...
Remove the index for layers in search backend, which are linked to an issue.
[ "Remove", "the", "index", "for", "layers", "in", "search", "backend", "which", "are", "linked", "to", "an", "issue", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L295-L310
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
unindex_layer
def unindex_layer(self, layer_id, use_cache=False): """ Remove the index for a layer in the search backend. If cache is set, append it to the list of removed layers, if it isn't send the transaction right away. """ from hypermap.aggregator.models import Layer layer = Layer.objects.get(id=layer_...
python
def unindex_layer(self, layer_id, use_cache=False): """ Remove the index for a layer in the search backend. If cache is set, append it to the list of removed layers, if it isn't send the transaction right away. """ from hypermap.aggregator.models import Layer layer = Layer.objects.get(id=layer_...
[ "def", "unindex_layer", "(", "self", ",", "layer_id", ",", "use_cache", "=", "False", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Layer", "layer", "=", "Layer", ".", "objects", ".", "get", "(", "id", "=", "layer_id", ")", ...
Remove the index for a layer in the search backend. If cache is set, append it to the list of removed layers, if it isn't send the transaction right away.
[ "Remove", "the", "index", "for", "a", "layer", "in", "the", "search", "backend", ".", "If", "cache", "is", "set", "append", "it", "to", "the", "list", "of", "removed", "layers", "if", "it", "isn", "t", "send", "the", "transaction", "right", "away", "."...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L314-L343
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
index_all_layers
def index_all_layers(self): """ Index all layers in search engine. """ from hypermap.aggregator.models import Layer if not settings.REGISTRY_SKIP_CELERY: layers_cache = set(Layer.objects.filter(is_valid=True).values_list('id', flat=True)) deleted_layers_cache = set(Layer.objects.fil...
python
def index_all_layers(self): """ Index all layers in search engine. """ from hypermap.aggregator.models import Layer if not settings.REGISTRY_SKIP_CELERY: layers_cache = set(Layer.objects.filter(is_valid=True).values_list('id', flat=True)) deleted_layers_cache = set(Layer.objects.fil...
[ "def", "index_all_layers", "(", "self", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Layer", "if", "not", "settings", ".", "REGISTRY_SKIP_CELERY", ":", "layers_cache", "=", "set", "(", "Layer", ".", "objects", ".", "filter", "("...
Index all layers in search engine.
[ "Index", "all", "layers", "in", "search", "engine", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L347-L360
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
update_last_wm_layers
def update_last_wm_layers(self, service_id, num_layers=10): """ Update and index the last added and deleted layers (num_layers) in WorldMap service. """ from hypermap.aggregator.models import Service LOGGER.debug( 'Updating the index the last %s added and %s deleted layers in WorldMap servi...
python
def update_last_wm_layers(self, service_id, num_layers=10): """ Update and index the last added and deleted layers (num_layers) in WorldMap service. """ from hypermap.aggregator.models import Service LOGGER.debug( 'Updating the index the last %s added and %s deleted layers in WorldMap servi...
[ "def", "update_last_wm_layers", "(", "self", ",", "service_id", ",", "num_layers", "=", "10", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Service", "LOGGER", ".", "debug", "(", "'Updating the index the last %s added and %s deleted layers...
Update and index the last added and deleted layers (num_layers) in WorldMap service.
[ "Update", "and", "index", "the", "last", "added", "and", "deleted", "layers", "(", "num_layers", ")", "in", "WorldMap", "service", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L364-L399
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
bbox2wktpolygon
def bbox2wktpolygon(bbox): """ Return OGC WKT Polygon of a simple bbox list """ try: minx = float(bbox[0]) miny = float(bbox[1]) maxx = float(bbox[2]) maxy = float(bbox[3]) except: LOGGER.debug("Invalid bbox, setting it to a zero POLYGON") minx = 0 ...
python
def bbox2wktpolygon(bbox): """ Return OGC WKT Polygon of a simple bbox list """ try: minx = float(bbox[0]) miny = float(bbox[1]) maxx = float(bbox[2]) maxy = float(bbox[3]) except: LOGGER.debug("Invalid bbox, setting it to a zero POLYGON") minx = 0 ...
[ "def", "bbox2wktpolygon", "(", "bbox", ")", ":", "try", ":", "minx", "=", "float", "(", "bbox", "[", "0", "]", ")", "miny", "=", "float", "(", "bbox", "[", "1", "]", ")", "maxx", "=", "float", "(", "bbox", "[", "2", "]", ")", "maxy", "=", "fl...
Return OGC WKT Polygon of a simple bbox list
[ "Return", "OGC", "WKT", "Polygon", "of", "a", "simple", "bbox", "list" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L975-L994
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
create_metadata_record
def create_metadata_record(**kwargs): """ Create a csw:Record XML document from harvested metadata """ if 'srs' in kwargs: srs = kwargs['srs'] else: srs = '4326' modified = '%sZ' % datetime.datetime.utcnow().isoformat().split('.')[0] nsmap = Namespaces().get_namespaces(['c...
python
def create_metadata_record(**kwargs): """ Create a csw:Record XML document from harvested metadata """ if 'srs' in kwargs: srs = kwargs['srs'] else: srs = '4326' modified = '%sZ' % datetime.datetime.utcnow().isoformat().split('.')[0] nsmap = Namespaces().get_namespaces(['c...
[ "def", "create_metadata_record", "(", "*", "*", "kwargs", ")", ":", "if", "'srs'", "in", "kwargs", ":", "srs", "=", "kwargs", "[", "'srs'", "]", "else", ":", "srs", "=", "'4326'", "modified", "=", "'%sZ'", "%", "datetime", ".", "datetime", ".", "utcnow...
Create a csw:Record XML document from harvested metadata
[ "Create", "a", "csw", ":", "Record", "XML", "document", "from", "harvested", "metadata" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L997-L1042
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
gen_anytext
def gen_anytext(*args): """ Convenience function to create bag of words for anytext property """ bag = [] for term in args: if term is not None: if isinstance(term, list): for term2 in term: if term2 is not None: bag.a...
python
def gen_anytext(*args): """ Convenience function to create bag of words for anytext property """ bag = [] for term in args: if term is not None: if isinstance(term, list): for term2 in term: if term2 is not None: bag.a...
[ "def", "gen_anytext", "(", "*", "args", ")", ":", "bag", "=", "[", "]", "for", "term", "in", "args", ":", "if", "term", "is", "not", "None", ":", "if", "isinstance", "(", "term", ",", "list", ")", ":", "for", "term2", "in", "term", ":", "if", "...
Convenience function to create bag of words for anytext property
[ "Convenience", "function", "to", "create", "bag", "of", "words", "for", "anytext", "property" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1045-L1060
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
update_layers_wmts
def update_layers_wmts(service): """ Update layers for an OGC:WMTS service. Sample endpoint: http://map1.vis.earthdata.nasa.gov/wmts-geo/1.0.0/WMTSCapabilities.xml """ try: wmts = WebMapTileService(service.url) # set srs # WMTS is always in 4326 srs, created = Spatia...
python
def update_layers_wmts(service): """ Update layers for an OGC:WMTS service. Sample endpoint: http://map1.vis.earthdata.nasa.gov/wmts-geo/1.0.0/WMTSCapabilities.xml """ try: wmts = WebMapTileService(service.url) # set srs # WMTS is always in 4326 srs, created = Spatia...
[ "def", "update_layers_wmts", "(", "service", ")", ":", "try", ":", "wmts", "=", "WebMapTileService", "(", "service", ".", "url", ")", "# set srs", "# WMTS is always in 4326", "srs", ",", "created", "=", "SpatialReferenceSystem", ".", "objects", ".", "get_or_create...
Update layers for an OGC:WMTS service. Sample endpoint: http://map1.vis.earthdata.nasa.gov/wmts-geo/1.0.0/WMTSCapabilities.xml
[ "Update", "layers", "for", "an", "OGC", ":", "WMTS", "service", ".", "Sample", "endpoint", ":", "http", ":", "//", "map1", ".", "vis", ".", "earthdata", ".", "nasa", ".", "gov", "/", "wmts", "-", "geo", "/", "1", ".", "0", ".", "0", "/", "WMTSCap...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1156-L1235
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
update_layers_geonode_wm
def update_layers_geonode_wm(service, num_layers=None): """ Update layers for a WorldMap instance. Sample endpoint: http://localhost:8000/ """ wm_api_url = urlparse.urljoin(service.url, 'worldmap/api/2.8/layer/?format=json') if num_layers: total = num_layers else: response =...
python
def update_layers_geonode_wm(service, num_layers=None): """ Update layers for a WorldMap instance. Sample endpoint: http://localhost:8000/ """ wm_api_url = urlparse.urljoin(service.url, 'worldmap/api/2.8/layer/?format=json') if num_layers: total = num_layers else: response =...
[ "def", "update_layers_geonode_wm", "(", "service", ",", "num_layers", "=", "None", ")", ":", "wm_api_url", "=", "urlparse", ".", "urljoin", "(", "service", ".", "url", ",", "'worldmap/api/2.8/layer/?format=json'", ")", "if", "num_layers", ":", "total", "=", "num...
Update layers for a WorldMap instance. Sample endpoint: http://localhost:8000/
[ "Update", "layers", "for", "a", "WorldMap", "instance", ".", "Sample", "endpoint", ":", "http", ":", "//", "localhost", ":", "8000", "/" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1238-L1390
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
update_layers_warper
def update_layers_warper(service): """ Update layers for a Warper service. Sample endpoint: http://warp.worldmap.harvard.edu/maps """ params = {'field': 'title', 'query': '', 'show_warped': '1', 'format': 'json'} headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} re...
python
def update_layers_warper(service): """ Update layers for a Warper service. Sample endpoint: http://warp.worldmap.harvard.edu/maps """ params = {'field': 'title', 'query': '', 'show_warped': '1', 'format': 'json'} headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} re...
[ "def", "update_layers_warper", "(", "service", ")", ":", "params", "=", "{", "'field'", ":", "'title'", ",", "'query'", ":", "''", ",", "'show_warped'", ":", "'1'", ",", "'format'", ":", "'json'", "}", "headers", "=", "{", "'Content-Type'", ":", "'applicat...
Update layers for a Warper service. Sample endpoint: http://warp.worldmap.harvard.edu/maps
[ "Update", "layers", "for", "a", "Warper", "service", ".", "Sample", "endpoint", ":", "http", ":", "//", "warp", ".", "worldmap", ".", "harvard", ".", "edu", "/", "maps" ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1541-L1632
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
update_layers_esri_mapserver
def update_layers_esri_mapserver(service, greedy_opt=False): """ Update layers for an ESRI REST MapServer. Sample endpoint: https://gis.ngdc.noaa.gov/arcgis/rest/services/SampleWorldCities/MapServer/?f=json """ try: esri_service = ArcMapService(service.url) # set srs # both m...
python
def update_layers_esri_mapserver(service, greedy_opt=False): """ Update layers for an ESRI REST MapServer. Sample endpoint: https://gis.ngdc.noaa.gov/arcgis/rest/services/SampleWorldCities/MapServer/?f=json """ try: esri_service = ArcMapService(service.url) # set srs # both m...
[ "def", "update_layers_esri_mapserver", "(", "service", ",", "greedy_opt", "=", "False", ")", ":", "try", ":", "esri_service", "=", "ArcMapService", "(", "service", ".", "url", ")", "# set srs", "# both mapserver and imageserver exposes just one srs at the service level", ...
Update layers for an ESRI REST MapServer. Sample endpoint: https://gis.ngdc.noaa.gov/arcgis/rest/services/SampleWorldCities/MapServer/?f=json
[ "Update", "layers", "for", "an", "ESRI", "REST", "MapServer", ".", "Sample", "endpoint", ":", "https", ":", "//", "gis", ".", "ngdc", ".", "noaa", ".", "gov", "/", "arcgis", "/", "rest", "/", "services", "/", "SampleWorldCities", "/", "MapServer", "/", ...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1635-L1749
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
update_layers_esri_imageserver
def update_layers_esri_imageserver(service): """ Update layers for an ESRI REST ImageServer. Sample endpoint: https://gis.ngdc.noaa.gov/arcgis/rest/services/bag_bathymetry/ImageServer/?f=json """ try: esri_service = ArcImageService(service.url) # set srs # both mapserver and ...
python
def update_layers_esri_imageserver(service): """ Update layers for an ESRI REST ImageServer. Sample endpoint: https://gis.ngdc.noaa.gov/arcgis/rest/services/bag_bathymetry/ImageServer/?f=json """ try: esri_service = ArcImageService(service.url) # set srs # both mapserver and ...
[ "def", "update_layers_esri_imageserver", "(", "service", ")", ":", "try", ":", "esri_service", "=", "ArcImageService", "(", "service", ".", "url", ")", "# set srs", "# both mapserver and imageserver exposes just one srs at the service level", "# not sure if other ones are support...
Update layers for an ESRI REST ImageServer. Sample endpoint: https://gis.ngdc.noaa.gov/arcgis/rest/services/bag_bathymetry/ImageServer/?f=json
[ "Update", "layers", "for", "an", "ESRI", "REST", "ImageServer", ".", "Sample", "endpoint", ":", "https", ":", "//", "gis", ".", "ngdc", ".", "noaa", ".", "gov", "/", "arcgis", "/", "rest", "/", "services", "/", "bag_bathymetry", "/", "ImageServer", "/", ...
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1752-L1813
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
endpointlist_post_save
def endpointlist_post_save(instance, *args, **kwargs): """ Used to process the lines of the endpoint list. """ with open(instance.upload.file.name, mode='rb') as f: lines = f.readlines() for url in lines: if len(url) > 255: LOGGER.debug('Skipping this endpoint, as it is m...
python
def endpointlist_post_save(instance, *args, **kwargs): """ Used to process the lines of the endpoint list. """ with open(instance.upload.file.name, mode='rb') as f: lines = f.readlines() for url in lines: if len(url) > 255: LOGGER.debug('Skipping this endpoint, as it is m...
[ "def", "endpointlist_post_save", "(", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "open", "(", "instance", ".", "upload", ".", "file", ".", "name", ",", "mode", "=", "'rb'", ")", "as", "f", ":", "lines", "=", "f", ".", ...
Used to process the lines of the endpoint list.
[ "Used", "to", "process", "the", "lines", "of", "the", "endpoint", "list", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1818-L1835
train
cga-harvard/Hypermap-Registry
hypermap/aggregator/models.py
service_pre_save
def service_pre_save(instance, *args, **kwargs): """ Used to do a service full check when saving it. """ # check if service is unique # we cannot use unique_together as it relies on a combination of fields # from different models (service, resource) exists = Service.objects.filter(url=insta...
python
def service_pre_save(instance, *args, **kwargs): """ Used to do a service full check when saving it. """ # check if service is unique # we cannot use unique_together as it relies on a combination of fields # from different models (service, resource) exists = Service.objects.filter(url=insta...
[ "def", "service_pre_save", "(", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# check if service is unique", "# we cannot use unique_together as it relies on a combination of fields", "# from different models (service, resource)", "exists", "=", "Service", "...
Used to do a service full check when saving it.
[ "Used", "to", "do", "a", "service", "full", "check", "when", "saving", "it", "." ]
899a5385b15af7fba190ab4fae1d41e47d155a1b
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1851-L1868
train