partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | get_esri_extent | Get the extent of an ESRI resource | hypermap/aggregator/utils.py | 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):
"""
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:
... | [
"Get",
"the",
"extent",
"of",
"an",
"ESRI",
"resource"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L461-L479 | [
"def",
"get_esri_extent",
"(",
"esriobj",
")",
":",
"extent",
"=",
"None",
"srs",
"=",
"None",
"if",
"'fullExtent'",
"in",
"esriobj",
".",
"_json_struct",
":",
"extent",
"=",
"esriobj",
".",
"_json_struct",
"[",
"'fullExtent'",
"]",
"if",
"'extent'",
"in",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | bbox2wktpolygon | Return OGC WKT Polygon of a simple bbox list of strings | hypermap/aggregator/utils.py | 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):
"""
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... | [
"Return",
"OGC",
"WKT",
"Polygon",
"of",
"a",
"simple",
"bbox",
"list",
"of",
"strings"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L503-L513 | [
"def",
"bbox2wktpolygon",
"(",
"bbox",
")",
":",
"minx",
"=",
"float",
"(",
"bbox",
"[",
"0",
"]",
")",
"miny",
"=",
"float",
"(",
"bbox",
"[",
"1",
"]",
")",
"maxx",
"=",
"float",
"(",
"bbox",
"[",
"2",
"]",
")",
"maxy",
"=",
"float",
"(",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | get_solr_date | Returns a date in a valid Solr format from a string. | hypermap/aggregator/utils.py | 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):
"""
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]
... | [
"Returns",
"a",
"date",
"in",
"a",
"valid",
"Solr",
"format",
"from",
"a",
"string",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L516-L532 | [
"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'",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | get_date | Returns a custom date representation. A date can be detected or from metadata.
It can be a range or a simple date in isoformat. | hypermap/aggregator/utils.py | 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):
"""
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:
... | [
"Returns",
"a",
"custom",
"date",
"representation",
".",
"A",
"date",
"can",
"be",
"detected",
"or",
"from",
"metadata",
".",
"It",
"can",
"be",
"a",
"range",
"or",
"a",
"simple",
"date",
"in",
"isoformat",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L535-L559 | [
"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",
"[",... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | layer2dict | Return a json representation for a layer. | hypermap/aggregator/utils.py | 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):
"""
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... | [
"Return",
"a",
"json",
"representation",
"for",
"a",
"layer",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L570-L661 | [
"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",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | detect_metadata_url_scheme | detect whether a url is a Service type that HHypermap supports | hypermap/aggregator/utils.py | 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):
"""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... | [
"detect",
"whether",
"a",
"url",
"is",
"a",
"Service",
"type",
"that",
"HHypermap",
"supports"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L664-L679 | [
"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",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | serialize_checks | Serialize a check_set for raphael | hypermap/aggregator/views.py | 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):
"""
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,
... | [
"Serialize",
"a",
"check_set",
"for",
"raphael"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/views.py#L45-L58 | [
"def",
"serialize_checks",
"(",
"check_set",
")",
":",
"check_set_list",
"=",
"[",
"]",
"for",
"check",
"in",
"check_set",
".",
"all",
"(",
")",
"[",
":",
"25",
"]",
":",
"check_set_list",
".",
"append",
"(",
"{",
"'datetime'",
":",
"check",
".",
"chec... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | domains | A page with number of services and layers faceted on domains. | hypermap/aggregator/views.py | 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):
"""
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... | [
"A",
"page",
"with",
"number",
"of",
"services",
"and",
"layers",
"faceted",
"on",
"domains",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/views.py#L62-L84 | [
"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'",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | tasks_runner | A page that let the admin to run global tasks. | hypermap/aggregator/views.py | 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):
"""
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 = ... | [
"A",
"page",
"that",
"let",
"the",
"admin",
"to",
"run",
"global",
"tasks",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/views.py#L254-L307 | [
"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... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | layer_mapproxy | Get Layer with matching catalog and uuid | hypermap/aggregator/views.py | 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):
"""
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... | [
"Get",
"Layer",
"with",
"matching",
"catalog",
"and",
"uuid"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/views.py#L310-L350 | [
"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 ... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | parse_datetime | Parses a date string to date object.
for BCE dates, only supports the year part. | hypermap/search_api/utils.py | 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):
"""
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... | [
"Parses",
"a",
"date",
"string",
"to",
"date",
"object",
".",
"for",
"BCE",
"dates",
"only",
"supports",
"the",
"year",
"part",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L24-L57 | [
"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... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | parse_solr_time_range_as_pair | :param time_filter: [2013-03-01 TO 2013-05-01T00:00:00]
:return: (2013-03-01, 2013-05-01T00:00:00) | hypermap/search_api/utils.py | 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):
"""
: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)
... | [
":",
"param",
"time_filter",
":",
"[",
"2013",
"-",
"03",
"-",
"01",
"TO",
"2013",
"-",
"05",
"-",
"01T00",
":",
"00",
":",
"00",
"]",
":",
"return",
":",
"(",
"2013",
"-",
"03",
"-",
"01",
"2013",
"-",
"05",
"-",
"01T00",
":",
"00",
":",
"... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L60-L70 | [
"def",
"parse_solr_time_range_as_pair",
"(",
"time_filter",
")",
":",
"pattern",
"=",
"\"\\\\[(.*) TO (.*)\\\\]\"",
"matcher",
"=",
"re",
".",
"search",
"(",
"pattern",
",",
"time_filter",
")",
"if",
"matcher",
":",
"return",
"matcher",
".",
"group",
"(",
"1",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | parse_datetime_range | 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), ... | hypermap/search_api/utils.py | 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):
"""
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]... | [
"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",
".",
... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L73-L88 | [
"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",
"(",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | parse_ISO8601 | 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. | hypermap/search_api/utils.py | 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):
"""
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": ... | [
"P1D",
"to",
"(",
"1",
"(",
"DAYS",
"isodate",
".",
"Duration",
"(",
"days",
"=",
"1",
"))",
".",
"P1Y",
"to",
"(",
"1",
"(",
"YEARS",
"isodate",
".",
"Duration",
"(",
"years",
"=",
"1",
"))",
".",
":",
"param",
"time_gap",
":",
"ISO8601",
"strin... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L109-L145 | [
"def",
"parse_ISO8601",
"(",
"time_gap",
")",
":",
"matcher",
"=",
"None",
"if",
"time_gap",
".",
"count",
"(",
"\"T\"",
")",
":",
"units",
"=",
"{",
"\"H\"",
":",
"(",
"\"HOURS\"",
",",
"isodate",
".",
"Duration",
"(",
"hours",
"=",
"1",
")",
")",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | compute_gap | 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. | hypermap/search_api/utils.py | 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):
"""
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... | [
"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... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L148-L166 | [
"def",
"compute_gap",
"(",
"start",
",",
"end",
",",
"time_limit",
")",
":",
"if",
"is_range_common_era",
"(",
"start",
",",
"end",
")",
":",
"duration",
"=",
"end",
".",
"get",
"(",
"\"parsed_datetime\"",
")",
"-",
"start",
".",
"get",
"(",
"\"parsed_da... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | gap_to_sorl | P1D to +1DAY
:param time_gap:
:return: solr's format duration. | hypermap/search_api/utils.py | 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):
"""
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]) | [
"P1D",
"to",
"+",
"1DAY",
":",
"param",
"time_gap",
":",
":",
"return",
":",
"solr",
"s",
"format",
"duration",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L185-L195 | [
"def",
"gap_to_sorl",
"(",
"time_gap",
")",
":",
"quantity",
",",
"unit",
"=",
"parse_ISO8601",
"(",
"time_gap",
")",
"if",
"unit",
"[",
"0",
"]",
"==",
"\"WEEKS\"",
":",
"return",
"\"+{0}DAYS\"",
".",
"format",
"(",
"quantity",
"*",
"7",
")",
"else",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | request_time_facet | 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... | hypermap/search_api/utils.py | 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):
"""
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 ... | [
"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... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L198-L244 | [
"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"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | parse_solr_geo_range_as_pair | :param geo_box_str: [-90,-180 TO 90,180]
:return: ("-90,-180", "90,180") | hypermap/search_api/utils.py | 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):
"""
: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... | [
":",
"param",
"geo_box_str",
":",
"[",
"-",
"90",
"-",
"180",
"TO",
"90",
"180",
"]",
":",
"return",
":",
"(",
"-",
"90",
"-",
"180",
"90",
"180",
")"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L247-L257 | [
"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",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | parse_geo_box | parses [-90,-180 TO 90,180] to a shapely.geometry.box
:param geo_box_str:
:return: | hypermap/search_api/utils.py | 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):
"""
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... | [
"parses",
"[",
"-",
"90",
"-",
"180",
"TO",
"90",
"180",
"]",
"to",
"a",
"shapely",
".",
"geometry",
".",
"box",
":",
"param",
"geo_box_str",
":",
":",
"return",
":"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L265-L276 | [
"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_... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | request_heatmap_facet | 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... | hypermap/search_api/utils.py | 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):
"""
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... | [
"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... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L279-L315 | [
"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'",
":",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | asterisk_to_min_max | 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.... | hypermap/search_api/utils.py | 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):
"""
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... | [
"traduce",
"[",
"*",
"TO",
"*",
"]",
"to",
"something",
"like",
"[",
"MIN",
"-",
"INDEXED",
"-",
"DATE",
"TO",
"MAX",
"-",
"INDEXED",
"-",
"DATE",
"]",
":",
"param",
"field",
":",
"map",
"the",
"stats",
"to",
"this",
"field",
".",
":",
"param",
"... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/utils.py#L322-L359 | [
"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_... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | get_service | 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 | hypermap/search/pycsw_plugin.py | 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):
"""
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... | [
"Set",
"a",
"service",
"object",
"based",
"on",
"the",
"XML",
"metadata",
"<dct",
":",
"references",
"scheme",
"=",
"OGC",
":",
"WMS",
">",
"http",
":",
"//",
"ngamaps",
".",
"geointapps",
".",
"org",
"/",
"arcgis",
"/",
"services",
"/",
"RIO",
"/",
... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L56-L95 | [
"def",
"get_service",
"(",
"raw_xml",
")",
":",
"from",
"pycsw",
".",
"core",
".",
"etree",
"import",
"etree",
"parsed",
"=",
"etree",
".",
"fromstring",
"(",
"raw_xml",
",",
"etree",
".",
"XMLParser",
"(",
"resolve_entities",
"=",
"False",
")",
")",
"# ... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository.query_ids | Query by list of identifiers | hypermap/search/pycsw_plugin.py | 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):
"""
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... | [
"Query",
"by",
"list",
"of",
"identifiers"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L152-L162 | [
"def",
"query_ids",
"(",
"self",
",",
"ids",
")",
":",
"results",
"=",
"self",
".",
"_get_repo_filter",
"(",
"Layer",
".",
"objects",
")",
".",
"filter",
"(",
"uuid__in",
"=",
"ids",
")",
".",
"all",
"(",
")",
"if",
"len",
"(",
"results",
")",
"=="... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository.query_domain | Query by property domain values | hypermap/search/pycsw_plugin.py | 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):
"""
Query by property domain values
"""
objects = self._get_repo_filter(Layer.objects)
if domainquerytype == 'range':
return [tuple(objects.aggregate(Min(domain), Max(domain)).values())]... | [
"Query",
"by",
"property",
"domain",
"values"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L164-L178 | [
"def",
"query_domain",
"(",
"self",
",",
"domain",
",",
"typenames",
",",
"domainquerytype",
"=",
"'list'",
",",
"count",
"=",
"False",
")",
":",
"objects",
"=",
"self",
".",
"_get_repo_filter",
"(",
"Layer",
".",
"objects",
")",
"if",
"domainquerytype",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository.query_insert | Query to get latest (default) or earliest update to repository | hypermap/search/pycsw_plugin.py | 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'):
"""
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.... | [
"Query",
"to",
"get",
"latest",
"(",
"default",
")",
"or",
"earliest",
"update",
"to",
"repository"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L180-L188 | [
"def",
"query_insert",
"(",
"self",
",",
"direction",
"=",
"'max'",
")",
":",
"if",
"direction",
"==",
"'min'",
":",
"return",
"Layer",
".",
"objects",
".",
"aggregate",
"(",
"Min",
"(",
"'last_updated'",
")",
")",
"[",
"'last_updated__min'",
"]",
".",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository.query_source | Query by source | hypermap/search/pycsw_plugin.py | def query_source(self, source):
"""
Query by source
"""
return self._get_repo_filter(Layer.objects).filter(url=source) | def query_source(self, source):
"""
Query by source
"""
return self._get_repo_filter(Layer.objects).filter(url=source) | [
"Query",
"by",
"source"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L190-L194 | [
"def",
"query_source",
"(",
"self",
",",
"source",
")",
":",
"return",
"self",
".",
"_get_repo_filter",
"(",
"Layer",
".",
"objects",
")",
".",
"filter",
"(",
"url",
"=",
"source",
")"
] | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository.query | Query records from underlying repository | hypermap/search/pycsw_plugin.py | 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):
"""
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 ... | [
"Query",
"records",
"from",
"underlying",
"repository"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L196-L231 | [
"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, ... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository.insert | Insert a record into the repository | hypermap/search/pycsw_plugin.py | 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):
"""
Insert a record into the repository
"""
caller = inspect.stack()[1][3]
if caller == 'transaction': # insert of Layer
hhclass = 'Layer'
source = resourcetype
resourcetype = resourc... | [
"Insert",
"a",
"record",
"into",
"the",
"repository"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L233-L249 | [
"def",
"insert",
"(",
"self",
",",
"resourcetype",
",",
"source",
",",
"insert_date",
"=",
"None",
")",
":",
"caller",
"=",
"inspect",
".",
"stack",
"(",
")",
"[",
"1",
"]",
"[",
"3",
"]",
"if",
"caller",
"==",
"'transaction'",
":",
"# insert of Layer"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository._insert_or_update | Insert or update a record in the repository | hypermap/search/pycsw_plugin.py | 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'):
"""
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:
... | [
"Insert",
"or",
"update",
"a",
"record",
"in",
"the",
"repository"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L251-L321 | [
"def",
"_insert_or_update",
"(",
"self",
",",
"resourcetype",
",",
"source",
",",
"mode",
"=",
"'insert'",
",",
"hhclass",
"=",
"'Service'",
")",
":",
"keywords",
"=",
"[",
"]",
"if",
"self",
".",
"filter",
"is",
"not",
"None",
":",
"catalog",
"=",
"Ca... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository.delete | Delete a record from the repository | hypermap/search/pycsw_plugin.py | 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):
"""
Delete a record from the repository
"""
results = self._get_repo_filter(Service.objects).extra(where=[constraint['where']],
params=constraint['values']).all()
deleted = len(results)
... | [
"Delete",
"a",
"record",
"from",
"the",
"repository"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L323-L332 | [
"def",
"delete",
"(",
"self",
",",
"constraint",
")",
":",
"results",
"=",
"self",
".",
"_get_repo_filter",
"(",
"Service",
".",
"objects",
")",
".",
"extra",
"(",
"where",
"=",
"[",
"constraint",
"[",
"'where'",
"]",
"]",
",",
"params",
"=",
"constrai... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | HHypermapRepository._get_repo_filter | Apply repository wide side filter / mask query | hypermap/search/pycsw_plugin.py | 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):
"""
Apply repository wide side filter / mask query
"""
if self.filter is not None:
return query.extra(where=[self.filter])
return query | [
"Apply",
"repository",
"wide",
"side",
"filter",
"/",
"mask",
"query"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/pycsw_plugin.py#L334-L340 | [
"def",
"_get_repo_filter",
"(",
"self",
",",
"query",
")",
":",
"if",
"self",
".",
"filter",
"is",
"not",
"None",
":",
"return",
"query",
".",
"extra",
"(",
"where",
"=",
"[",
"self",
".",
"filter",
"]",
")",
"return",
"query"
] | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | to_meshcode | 緯度経度から指定次の地域メッシュコードを算出する。
Args:
lat: 世界測地系の緯度(度単位)
lon: 世界測地系の経度(度単位)
level: 地域メッシュコードの次数
1次(80km四方):1
40倍(40km四方):40000
20倍(20km四方):20000
16倍(16km四方):16000
2次(10km四方):2
8倍(8km四方):8000
... | jismesh/utils.py | 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):
"""緯度経度から指定次の地域メッシュコードを算出する。
Args:
lat: 世界測地系の緯度(度単位)
lon: 世界測地系の経度(度単位)
level: 地域メッシュコードの次数
1次(80km四方):1
40倍(40km四方):40000
20倍(20km四方):20000
16倍(16km四方):16000
2次(10km四方):2
... | [
"緯度経度から指定次の地域メッシュコードを算出する。"
] | hni14/jismesh | python | https://github.com/hni14/jismesh/blob/bda486ac7828d0adaea2a128154d0a554be7ef37/jismesh/utils.py#L64-L238 | [
"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... | bda486ac7828d0adaea2a128154d0a554be7ef37 |
train | to_meshlevel | メッシュコードから次数を算出する。
Args:
meshcode: メッシュコード
Return:
地域メッシュコードの次数
1次(80km四方):1
40倍(40km四方):40000
20倍(20km四方):20000
16倍(16km四方):16000
2次(10km四方):2
8倍(8km四方):8000
5倍(5km四方):5000
... | jismesh/utils.py | 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):
"""メッシュコードから次数を算出する。
Args:
meshcode: メッシュコード
Return:
地域メッシュコードの次数
1次(80km四方):1
40倍(40km四方):40000
20倍(20km四方):20000
16倍(16km四方):16000
2次(10km四方):2
8倍(8km四方):8000
... | [
"メッシュコードから次数を算出する。"
] | hni14/jismesh | python | https://github.com/hni14/jismesh/blob/bda486ac7828d0adaea2a128154d0a554be7ef37/jismesh/utils.py#L240-L310 | [
"def",
"to_meshlevel",
"(",
"meshcode",
")",
":",
"length",
"=",
"len",
"(",
"str",
"(",
"meshcode",
")",
")",
"if",
"length",
"==",
"4",
":",
"return",
"1",
"if",
"length",
"==",
"5",
":",
"return",
"40000",
"if",
"length",
"==",
"6",
":",
"return... | bda486ac7828d0adaea2a128154d0a554be7ef37 |
train | to_meshpoint | 地域メッシュコードから緯度経度を算出する。
下記のメッシュに対応している。
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倍(... | jismesh/utils.py | 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):
"""地域メッシュコードから緯度経度を算出する。
下記のメッシュに対応している。
1次(80km四方):1
40倍(40km四方):40000
20倍(20km四方):20000
16倍(16km四方):16000
2次(10km四方):2
8倍(8km四方):8000
... | [
"地域メッシュコードから緯度経度を算出する。",
"下記のメッシュに対応している。",
"1次",
"(",
"80km四方",
")",
":",
"1",
"40倍",
"(",
"40km四方",
")",
":",
"40000",
"20倍",
"(",
"20km四方",
")",
":",
"20000",
"16倍",
"(",
"16km四方",
")",
":",
"16000",
"2次",
"(",
"10km四方",
")",
":",
"2",
"8倍",
"(",
... | hni14/jismesh | python | https://github.com/hni14/jismesh/blob/bda486ac7828d0adaea2a128154d0a554be7ef37/jismesh/utils.py#L312-L811 | [
"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",
"("... | bda486ac7828d0adaea2a128154d0a554be7ef37 |
train | check | Check the permissions, http method and login state. | follow/views.py | 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):
"""
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():
... | [
"Check",
"the",
"permissions",
"http",
"method",
"and",
"login",
"state",
"."
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/views.py#L7-L30 | [
"def",
"check",
"(",
"func",
")",
":",
"def",
"iCheck",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"request",
".",
"method",
"==",
"\"POST\"",
":",
"return",
"HttpResponseBadRequest",
"(",
"\"Must be POST request.\"",... | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | register | This registers any model class to be follow-able. | follow/utils.py | 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'):
"""
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... | [
"This",
"registers",
"any",
"model",
"class",
"to",
"be",
"follow",
"-",
"able",
"."
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/utils.py#L9-L30 | [
"def",
"register",
"(",
"model",
",",
"field_name",
"=",
"None",
",",
"related_name",
"=",
"None",
",",
"lookup_method_name",
"=",
"'get_follows'",
")",
":",
"if",
"model",
"in",
"registry",
":",
"return",
"registry",
".",
"append",
"(",
"model",
")",
"if"... | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | follow | Make a user follow an object | follow/utils.py | 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):
""" Make a user follow an object """
follow, created = Follow.objects.get_or_create(user, obj)
return follow | [
"Make",
"a",
"user",
"follow",
"an",
"object"
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/utils.py#L32-L35 | [
"def",
"follow",
"(",
"user",
",",
"obj",
")",
":",
"follow",
",",
"created",
"=",
"Follow",
".",
"objects",
".",
"get_or_create",
"(",
"user",
",",
"obj",
")",
"return",
"follow"
] | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | unfollow | Make a user unfollow an object | follow/utils.py | 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):
""" Make a user unfollow an object """
try:
follow = Follow.objects.get_follows(obj).get(user=user)
follow.delete()
return follow
except Follow.DoesNotExist:
pass | [
"Make",
"a",
"user",
"unfollow",
"an",
"object"
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/utils.py#L37-L44 | [
"def",
"unfollow",
"(",
"user",
",",
"obj",
")",
":",
"try",
":",
"follow",
"=",
"Follow",
".",
"objects",
".",
"get_follows",
"(",
"obj",
")",
".",
"get",
"(",
"user",
"=",
"user",
")",
"follow",
".",
"delete",
"(",
")",
"return",
"follow",
"excep... | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | toggle | Toggles a follow status. Useful function if you don't want to perform follow
checks but just toggle it on / off. | follow/utils.py | 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):
""" 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) | [
"Toggles",
"a",
"follow",
"status",
".",
"Useful",
"function",
"if",
"you",
"don",
"t",
"want",
"to",
"perform",
"follow",
"checks",
"but",
"just",
"toggle",
"it",
"on",
"/",
"off",
"."
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/utils.py#L46-L51 | [
"def",
"toggle",
"(",
"user",
",",
"obj",
")",
":",
"if",
"Follow",
".",
"objects",
".",
"is_following",
"(",
"user",
",",
"obj",
")",
":",
"return",
"unfollow",
"(",
"user",
",",
"obj",
")",
"return",
"follow",
"(",
"user",
",",
"obj",
")"
] | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | SearchSerializer.validate_q_time | 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 *] | hypermap/search_api/serializers.py | 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):
"""
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... | [
"Would",
"be",
"for",
"example",
":",
"[",
"2013",
"-",
"03",
"-",
"01",
"TO",
"2013",
"-",
"04",
"-",
"01T00",
":",
"00",
":",
"00",
"]",
"and",
"/",
"or",
"[",
"*",
"TO",
"*",
"]",
"Returns",
"a",
"valid",
"sorl",
"value",
".",
"[",
"2013",... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/serializers.py#L114-L126 | [
"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",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | SearchSerializer.validate_q_geo | Would be for example: [-90,-180 TO 90,180] | hypermap/search_api/serializers.py | 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):
"""
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... | [
"Would",
"be",
"for",
"example",
":",
"[",
"-",
"90",
"-",
"180",
"TO",
"90",
"180",
"]"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/serializers.py#L128-L144 | [
"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"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | SearchSerializer.validate_a_time_filter | Would be for example: [2013-03-01 TO 2013-04-01:00:00:00] and/or [* TO *] | hypermap/search_api/serializers.py | 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):
"""
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... | [
"Would",
"be",
"for",
"example",
":",
"[",
"2013",
"-",
"03",
"-",
"01",
"TO",
"2013",
"-",
"04",
"-",
"01",
":",
"00",
":",
"00",
":",
"00",
"]",
"and",
"/",
"or",
"[",
"*",
"TO",
"*",
"]"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search_api/serializers.py#L146-L156 | [
"def",
"validate_a_time_filter",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
":",
"try",
":",
"utils",
".",
"parse_datetime_range",
"(",
"value",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"serializers",
".",
"ValidationError",
"(",
"e",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | FollowManager.fname | Return the field name on the :class:`Follow` model for ``model_or_obj_or_qs``. | follow/models.py | 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):
"""
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... | [
"Return",
"the",
"field",
"name",
"on",
"the",
":",
"class",
":",
"Follow",
"model",
"for",
"model_or_obj_or_qs",
"."
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L10-L19 | [
"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... | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | FollowManager.create | Create a new follow link between a user and an object
of a registered model type. | follow/models.py | 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):
"""
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 | [
"Create",
"a",
"new",
"follow",
"link",
"between",
"a",
"user",
"and",
"an",
"object",
"of",
"a",
"registered",
"model",
"type",
"."
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L21-L30 | [
"def",
"create",
"(",
"self",
",",
"user",
",",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"follow",
"=",
"Follow",
"(",
"user",
"=",
"user",
")",
"follow",
".",
"target",
"=",
"obj",
"follow",
".",
"save",
"(",
")",
"return",
"follow"
] | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | FollowManager.get_or_create | 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` | follow/models.py | 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):
"""
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(... | [
"Almost",
"the",
"same",
"as",
"FollowManager",
".",
"objects",
".",
"create",
"-",
"behaves",
"the",
"same",
"as",
"the",
"normal",
"get_or_create",
"methods",
"in",
"django",
"though",
"."
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L32-L42 | [
"def",
"get_or_create",
"(",
"self",
",",
"user",
",",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"is_following",
"(",
"user",
",",
"obj",
")",
":",
"return",
"self",
".",
"create",
"(",
"user",
",",
"obj",
",",
"*",
"*",... | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | FollowManager.is_following | Returns `True` or `False` | follow/models.py | 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):
""" Returns `True` or `False` """
if isinstance(user, AnonymousUser):
return False
return 0 < self.get_follows(obj).filter(user=user).count() | [
"Returns",
"True",
"or",
"False"
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L44-L48 | [
"def",
"is_following",
"(",
"self",
",",
"user",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"user",
",",
"AnonymousUser",
")",
":",
"return",
"False",
"return",
"0",
"<",
"self",
".",
"get_follows",
"(",
"obj",
")",
".",
"filter",
"(",
"user",
"=... | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | FollowManager.get_follows | Returns all the followers of a model, an object or a queryset. | follow/models.py | 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):
"""
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})
... | [
"Returns",
"all",
"the",
"followers",
"of",
"a",
"model",
"an",
"object",
"or",
"a",
"queryset",
"."
] | caffeinehit/django-follow | python | https://github.com/caffeinehit/django-follow/blob/765a4795e58f57fbf96efdb7838d0c7222db2e56/follow/models.py#L50-L62 | [
"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",
"(",
"*",
... | 765a4795e58f57fbf96efdb7838d0c7222db2e56 |
train | FIRDeconvolution.create_event_regressors | 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... | src/FIRDeconvolution.py | 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):
"""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 ... | [
"create_event_regressors",
"creates",
"the",
"part",
"of",
"the",
"design",
"matrix",
"corresponding",
"to",
"one",
"event",
"type",
"."
] | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L121-L172 | [
"def",
"create_event_regressors",
"(",
"self",
",",
"event_times_indices",
",",
"covariates",
"=",
"None",
",",
"durations",
"=",
"None",
")",
":",
"# check covariates",
"if",
"covariates",
"is",
"None",
":",
"covariates",
"=",
"np",
".",
"ones",
"(",
"self",
... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.create_design_matrix | 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]) | src/FIRDeconvolution.py | 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):
"""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.... | [
"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... | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L174-L200 | [
"def",
"create_design_matrix",
"(",
"self",
",",
"demean",
"=",
"False",
",",
"intercept",
"=",
"True",
")",
":",
"self",
".",
"design_matrix",
"=",
"np",
".",
"zeros",
"(",
"(",
"int",
"(",
"self",
".",
"number_of_event_types",
"*",
"self",
".",
"deconv... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.add_continuous_regressors_to_design_matrix | 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... | src/FIRDeconvolution.py | 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):
"""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... | [
"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... | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L202-L215 | [
"def",
"add_continuous_regressors_to_design_matrix",
"(",
"self",
",",
"regressors",
")",
":",
"previous_design_matrix_shape",
"=",
"self",
".",
"design_matrix",
".",
"shape",
"if",
"len",
"(",
"regressors",
".",
"shape",
")",
"==",
"1",
":",
"regressors",
"=",
... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.regress | 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' ... | src/FIRDeconvolution.py | 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'):
"""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 ... | [
"regress",
"performs",
"linear",
"least",
"squares",
"regression",
"of",
"the",
"designmatrix",
"on",
"the",
"data",
"."
] | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L217-L239 | [
"def",
"regress",
"(",
"self",
",",
"method",
"=",
"'lstsq'",
")",
":",
"if",
"method",
"is",
"'lstsq'",
":",
"self",
".",
"betas",
",",
"residuals_sum",
",",
"rank",
",",
"s",
"=",
"LA",
".",
"lstsq",
"(",
"self",
".",
"design_matrix",
".",
"T",
"... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.ridge_regress | 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... | src/FIRDeconvolution.py | 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 ):
"""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... | [
"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",
"... | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L241-L260 | [
"def",
"ridge_regress",
"(",
"self",
",",
"cv",
"=",
"20",
",",
"alphas",
"=",
"None",
")",
":",
"if",
"alphas",
"is",
"None",
":",
"alphas",
"=",
"np",
".",
"logspace",
"(",
"7",
",",
"0",
",",
"20",
")",
"self",
".",
"rcv",
"=",
"linear_model",... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.betas_for_cov | betas_for_cov returns the beta values (i.e. IRF) associated with a specific covariate.
:param covariate: name of covariate.
:type covariate: string | src/FIRDeconvolution.py | 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'):
"""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... | [
"betas_for_cov",
"returns",
"the",
"beta",
"values",
"(",
"i",
".",
"e",
".",
"IRF",
")",
"associated",
"with",
"a",
"specific",
"covariate",
"."
] | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L262-L270 | [
"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... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.betas_for_events | 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() | src/FIRDeconvolution.py | 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):
"""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... | [
"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... | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L272-L278 | [
"def",
"betas_for_events",
"(",
"self",
")",
":",
"self",
".",
"betas_per_event_type",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"self",
".",
"covariates",
")",
",",
"self",
".",
"deconvolution_interval_size",
",",
"self",
".",
"resampled_signal",
".",
... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.predict_from_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 signal(s)
:rtype: numpy array (nr_signals x nr_samples... | src/FIRDeconvolution.py | 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):
"""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... | [
"predict_from_design_matrix",
"predicts",
"signals",
"given",
"a",
"design",
"matrix",
"."
] | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L280-L298 | [
"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... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.calculate_rsq | 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. | src/FIRDeconvolution.py | 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):
"""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 ... | [
"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",
... | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L300-L310 | [
"def",
"calculate_rsq",
"(",
"self",
")",
":",
"assert",
"hasattr",
"(",
"self",
",",
"'betas'",
")",
",",
"'no betas found, please run regression before rsq'",
"explained_times",
"=",
"self",
".",
"design_matrix",
".",
"sum",
"(",
"axis",
"=",
"0",
")",
"!=",
... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | FIRDeconvolution.bootstrap_on_residuals | 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... | src/FIRDeconvolution.py | 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):
"""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 ... | [
"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",
".... | tknapen/FIRDeconvolution | python | https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L312-L337 | [
"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 ... | 6263496a356c449062fe4c216fef56541f6dc151 |
train | resource_urls | Global values to pass to templates | hypermap/context_processors.py | 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):
"""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... | [
"Global",
"values",
"to",
"pass",
"to",
"templates"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/context_processors.py#L7-L19 | [
"def",
"resource_urls",
"(",
"request",
")",
":",
"url_parsed",
"=",
"urlparse",
"(",
"settings",
".",
"SEARCH_URL",
")",
"defaults",
"=",
"dict",
"(",
"APP_NAME",
"=",
"__description__",
",",
"APP_VERSION",
"=",
"__version__",
",",
"SITE_URL",
"=",
"settings"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | index_cached_layers | Index and unindex all layers in the Django cache (Index all layers who have been checked). | hypermap/aggregator/tasks.py | 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):
"""
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()
... | [
"Index",
"and",
"unindex",
"all",
"layers",
"in",
"the",
"Django",
"cache",
"(",
"Index",
"all",
"layers",
"who",
"have",
"been",
"checked",
")",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L94-L177 | [
"def",
"index_cached_layers",
"(",
"self",
")",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"models",
"import",
"Layer",
"if",
"SEARCH_TYPE",
"==",
"'solr'",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"solr",
"import",
"SolrHypermap",
"solrobject",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | remove_service_checks | Remove all checks from a service. | hypermap/aggregator/tasks.py | 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):
"""
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:
... | [
"Remove",
"all",
"checks",
"from",
"a",
"service",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L195-L205 | [
"def",
"remove_service_checks",
"(",
"self",
",",
"service_id",
")",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"models",
"import",
"Service",
"service",
"=",
"Service",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"service_id",
")",
"service",
".",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | index_service | Index a service in search engine. | hypermap/aggregator/tasks.py | 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):
"""
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... | [
"Index",
"a",
"service",
"in",
"search",
"engine",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L209-L228 | [
"def",
"index_service",
"(",
"self",
",",
"service_id",
")",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"models",
"import",
"Service",
"service",
"=",
"Service",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"service_id",
")",
"if",
"not",
"service",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | index_layer | 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. | hypermap/aggregator/tasks.py | 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):
"""
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... | [
"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... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L232-L291 | [
"def",
"index_layer",
"(",
"self",
",",
"layer_id",
",",
"use_cache",
"=",
"False",
")",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"models",
"import",
"Layer",
"layer",
"=",
"Layer",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"layer_id",
")",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | unindex_layers_with_issues | Remove the index for layers in search backend, which are linked to an issue. | hypermap/aggregator/tasks.py | 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):
"""
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... | [
"Remove",
"the",
"index",
"for",
"layers",
"in",
"search",
"backend",
"which",
"are",
"linked",
"to",
"an",
"issue",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L295-L310 | [
"def",
"unindex_layers_with_issues",
"(",
"self",
",",
"use_cache",
"=",
"False",
")",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"models",
"import",
"Issue",
",",
"Layer",
",",
"Service",
"from",
"django",
".",
"contrib",
".",
"contenttypes",
".",
"mo... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | unindex_layer | 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. | hypermap/aggregator/tasks.py | 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):
"""
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_... | [
"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",
"."... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L314-L343 | [
"def",
"unindex_layer",
"(",
"self",
",",
"layer_id",
",",
"use_cache",
"=",
"False",
")",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"models",
"import",
"Layer",
"layer",
"=",
"Layer",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"layer_id",
")",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | index_all_layers | Index all layers in search engine. | hypermap/aggregator/tasks.py | 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):
"""
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... | [
"Index",
"all",
"layers",
"in",
"search",
"engine",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L347-L360 | [
"def",
"index_all_layers",
"(",
"self",
")",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"models",
"import",
"Layer",
"if",
"not",
"settings",
".",
"REGISTRY_SKIP_CELERY",
":",
"layers_cache",
"=",
"set",
"(",
"Layer",
".",
"objects",
".",
"filter",
"("... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | update_last_wm_layers | Update and index the last added and deleted layers (num_layers) in WorldMap service. | hypermap/aggregator/tasks.py | 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):
"""
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... | [
"Update",
"and",
"index",
"the",
"last",
"added",
"and",
"deleted",
"layers",
"(",
"num_layers",
")",
"in",
"WorldMap",
"service",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L364-L399 | [
"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... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | bbox2wktpolygon | Return OGC WKT Polygon of a simple bbox list | hypermap/aggregator/models.py | 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):
"""
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
... | [
"Return",
"OGC",
"WKT",
"Polygon",
"of",
"a",
"simple",
"bbox",
"list"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L975-L994 | [
"def",
"bbox2wktpolygon",
"(",
"bbox",
")",
":",
"try",
":",
"minx",
"=",
"float",
"(",
"bbox",
"[",
"0",
"]",
")",
"miny",
"=",
"float",
"(",
"bbox",
"[",
"1",
"]",
")",
"maxx",
"=",
"float",
"(",
"bbox",
"[",
"2",
"]",
")",
"maxy",
"=",
"fl... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | create_metadata_record | Create a csw:Record XML document from harvested metadata | hypermap/aggregator/models.py | 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):
"""
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... | [
"Create",
"a",
"csw",
":",
"Record",
"XML",
"document",
"from",
"harvested",
"metadata"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L997-L1042 | [
"def",
"create_metadata_record",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"'srs'",
"in",
"kwargs",
":",
"srs",
"=",
"kwargs",
"[",
"'srs'",
"]",
"else",
":",
"srs",
"=",
"'4326'",
"modified",
"=",
"'%sZ'",
"%",
"datetime",
".",
"datetime",
".",
"utcnow... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | gen_anytext | Convenience function to create bag of words for anytext property | hypermap/aggregator/models.py | 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):
"""
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... | [
"Convenience",
"function",
"to",
"create",
"bag",
"of",
"words",
"for",
"anytext",
"property"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1045-L1060 | [
"def",
"gen_anytext",
"(",
"*",
"args",
")",
":",
"bag",
"=",
"[",
"]",
"for",
"term",
"in",
"args",
":",
"if",
"term",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"term",
",",
"list",
")",
":",
"for",
"term2",
"in",
"term",
":",
"if",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | update_layers_wmts | Update layers for an OGC:WMTS service.
Sample endpoint: http://map1.vis.earthdata.nasa.gov/wmts-geo/1.0.0/WMTSCapabilities.xml | hypermap/aggregator/models.py | 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):
"""
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... | [
"Update",
"layers",
"for",
"an",
"OGC",
":",
"WMTS",
"service",
".",
"Sample",
"endpoint",
":",
"http",
":",
"//",
"map1",
".",
"vis",
".",
"earthdata",
".",
"nasa",
".",
"gov",
"/",
"wmts",
"-",
"geo",
"/",
"1",
".",
"0",
".",
"0",
"/",
"WMTSCap... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1156-L1235 | [
"def",
"update_layers_wmts",
"(",
"service",
")",
":",
"try",
":",
"wmts",
"=",
"WebMapTileService",
"(",
"service",
".",
"url",
")",
"# set srs",
"# WMTS is always in 4326",
"srs",
",",
"created",
"=",
"SpatialReferenceSystem",
".",
"objects",
".",
"get_or_create... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | update_layers_geonode_wm | Update layers for a WorldMap instance.
Sample endpoint: http://localhost:8000/ | hypermap/aggregator/models.py | 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):
"""
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 =... | [
"Update",
"layers",
"for",
"a",
"WorldMap",
"instance",
".",
"Sample",
"endpoint",
":",
"http",
":",
"//",
"localhost",
":",
"8000",
"/"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1238-L1390 | [
"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... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | update_layers_warper | Update layers for a Warper service.
Sample endpoint: http://warp.worldmap.harvard.edu/maps | hypermap/aggregator/models.py | 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):
"""
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... | [
"Update",
"layers",
"for",
"a",
"Warper",
"service",
".",
"Sample",
"endpoint",
":",
"http",
":",
"//",
"warp",
".",
"worldmap",
".",
"harvard",
".",
"edu",
"/",
"maps"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1541-L1632 | [
"def",
"update_layers_warper",
"(",
"service",
")",
":",
"params",
"=",
"{",
"'field'",
":",
"'title'",
",",
"'query'",
":",
"''",
",",
"'show_warped'",
":",
"'1'",
",",
"'format'",
":",
"'json'",
"}",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'applicat... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | update_layers_esri_mapserver | Update layers for an ESRI REST MapServer.
Sample endpoint: https://gis.ngdc.noaa.gov/arcgis/rest/services/SampleWorldCities/MapServer/?f=json | hypermap/aggregator/models.py | 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):
"""
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... | [
"Update",
"layers",
"for",
"an",
"ESRI",
"REST",
"MapServer",
".",
"Sample",
"endpoint",
":",
"https",
":",
"//",
"gis",
".",
"ngdc",
".",
"noaa",
".",
"gov",
"/",
"arcgis",
"/",
"rest",
"/",
"services",
"/",
"SampleWorldCities",
"/",
"MapServer",
"/",
... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1635-L1749 | [
"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",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | update_layers_esri_imageserver | Update layers for an ESRI REST ImageServer.
Sample endpoint: https://gis.ngdc.noaa.gov/arcgis/rest/services/bag_bathymetry/ImageServer/?f=json | hypermap/aggregator/models.py | 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):
"""
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 ... | [
"Update",
"layers",
"for",
"an",
"ESRI",
"REST",
"ImageServer",
".",
"Sample",
"endpoint",
":",
"https",
":",
"//",
"gis",
".",
"ngdc",
".",
"noaa",
".",
"gov",
"/",
"arcgis",
"/",
"rest",
"/",
"services",
"/",
"bag_bathymetry",
"/",
"ImageServer",
"/",
... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1752-L1813 | [
"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... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | endpointlist_post_save | Used to process the lines of the endpoint list. | hypermap/aggregator/models.py | 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):
"""
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... | [
"Used",
"to",
"process",
"the",
"lines",
"of",
"the",
"endpoint",
"list",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1818-L1835 | [
"def",
"endpointlist_post_save",
"(",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"open",
"(",
"instance",
".",
"upload",
".",
"file",
".",
"name",
",",
"mode",
"=",
"'rb'",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | service_pre_save | Used to do a service full check when saving it. | hypermap/aggregator/models.py | 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):
"""
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... | [
"Used",
"to",
"do",
"a",
"service",
"full",
"check",
"when",
"saving",
"it",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1851-L1868 | [
"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",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | service_post_save | Used to do a service full check when saving it. | hypermap/aggregator/models.py | def service_post_save(instance, *args, **kwargs):
"""
Used to do a service full check when saving it.
"""
# check service
if instance.is_monitored and settings.REGISTRY_SKIP_CELERY:
check_service(instance.id)
elif instance.is_monitored:
check_service.delay(instance.id) | def service_post_save(instance, *args, **kwargs):
"""
Used to do a service full check when saving it.
"""
# check service
if instance.is_monitored and settings.REGISTRY_SKIP_CELERY:
check_service(instance.id)
elif instance.is_monitored:
check_service.delay(instance.id) | [
"Used",
"to",
"do",
"a",
"service",
"full",
"check",
"when",
"saving",
"it",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1871-L1880 | [
"def",
"service_post_save",
"(",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# check service",
"if",
"instance",
".",
"is_monitored",
"and",
"settings",
".",
"REGISTRY_SKIP_CELERY",
":",
"check_service",
"(",
"instance",
".",
"id",
")",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | layer_pre_save | Used to check layer validity. | hypermap/aggregator/models.py | def layer_pre_save(instance, *args, **kwargs):
"""
Used to check layer validity.
"""
is_valid = True
# we do not need to check validity for WM layers
if not instance.service.type == 'Hypermap:WorldMap':
# 0. a layer is invalid if its service its invalid as well
if not instance... | def layer_pre_save(instance, *args, **kwargs):
"""
Used to check layer validity.
"""
is_valid = True
# we do not need to check validity for WM layers
if not instance.service.type == 'Hypermap:WorldMap':
# 0. a layer is invalid if its service its invalid as well
if not instance... | [
"Used",
"to",
"check",
"layer",
"validity",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1883-L1905 | [
"def",
"layer_pre_save",
"(",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"is_valid",
"=",
"True",
"# we do not need to check validity for WM layers",
"if",
"not",
"instance",
".",
"service",
".",
"type",
"==",
"'Hypermap:WorldMap'",
":",
"#... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | layer_post_save | Used to do a layer full check when saving it. | hypermap/aggregator/models.py | def layer_post_save(instance, *args, **kwargs):
"""
Used to do a layer full check when saving it.
"""
if instance.is_monitored and instance.service.is_monitored: # index and monitor
if not settings.REGISTRY_SKIP_CELERY:
check_layer.delay(instance.id)
else:
check_... | def layer_post_save(instance, *args, **kwargs):
"""
Used to do a layer full check when saving it.
"""
if instance.is_monitored and instance.service.is_monitored: # index and monitor
if not settings.REGISTRY_SKIP_CELERY:
check_layer.delay(instance.id)
else:
check_... | [
"Used",
"to",
"do",
"a",
"layer",
"full",
"check",
"when",
"saving",
"it",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1908-L1918 | [
"def",
"layer_post_save",
"(",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"instance",
".",
"is_monitored",
"and",
"instance",
".",
"service",
".",
"is_monitored",
":",
"# index and monitor",
"if",
"not",
"settings",
".",
"REGISTRY... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | issue_post_delete | Used to do reindex layers/services when a issue is removed form them. | hypermap/aggregator/models.py | def issue_post_delete(instance, *args, **kwargs):
"""
Used to do reindex layers/services when a issue is removed form them.
"""
LOGGER.debug('Re-adding layer/service to search engine index')
if isinstance(instance.content_object, Service):
if not settings.REGISTRY_SKIP_CELERY:
in... | def issue_post_delete(instance, *args, **kwargs):
"""
Used to do reindex layers/services when a issue is removed form them.
"""
LOGGER.debug('Re-adding layer/service to search engine index')
if isinstance(instance.content_object, Service):
if not settings.REGISTRY_SKIP_CELERY:
in... | [
"Used",
"to",
"do",
"reindex",
"layers",
"/",
"services",
"when",
"a",
"issue",
"is",
"removed",
"form",
"them",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L1921-L1935 | [
"def",
"issue_post_delete",
"(",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'Re-adding layer/service to search engine index'",
")",
"if",
"isinstance",
"(",
"instance",
".",
"content_object",
",",
"Service",
")... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | Resource.get_checks_admin_reliability_warning_url | When service Realiability is going down users should go to the
the check history to find problem causes.
:return: admin url with check list for this instance | hypermap/aggregator/models.py | def get_checks_admin_reliability_warning_url(self):
"""
When service Realiability is going down users should go to the
the check history to find problem causes.
:return: admin url with check list for this instance
"""
# TODO: cache this.
path = self.get_checks_adm... | def get_checks_admin_reliability_warning_url(self):
"""
When service Realiability is going down users should go to the
the check history to find problem causes.
:return: admin url with check list for this instance
"""
# TODO: cache this.
path = self.get_checks_adm... | [
"When",
"service",
"Realiability",
"is",
"going",
"down",
"users",
"should",
"go",
"to",
"the",
"the",
"check",
"history",
"to",
"find",
"problem",
"causes",
".",
":",
"return",
":",
"admin",
"url",
"with",
"check",
"list",
"for",
"this",
"instance"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L261-L275 | [
"def",
"get_checks_admin_reliability_warning_url",
"(",
"self",
")",
":",
"# TODO: cache this.",
"path",
"=",
"self",
".",
"get_checks_admin_url",
"(",
")",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"self",
")",
"params",
"=",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | Service.update_layers | Update layers for a service. | hypermap/aggregator/models.py | def update_layers(self):
"""
Update layers for a service.
"""
signals.post_save.disconnect(layer_post_save, sender=Layer)
try:
LOGGER.debug('Updating layers for service id %s' % self.id)
if self.type == 'OGC:WMS':
update_layers_wms(self)
... | def update_layers(self):
"""
Update layers for a service.
"""
signals.post_save.disconnect(layer_post_save, sender=Layer)
try:
LOGGER.debug('Updating layers for service id %s' % self.id)
if self.type == 'OGC:WMS':
update_layers_wms(self)
... | [
"Update",
"layers",
"for",
"a",
"service",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L309-L336 | [
"def",
"update_layers",
"(",
"self",
")",
":",
"signals",
".",
"post_save",
".",
"disconnect",
"(",
"layer_post_save",
",",
"sender",
"=",
"Layer",
")",
"try",
":",
"LOGGER",
".",
"debug",
"(",
"'Updating layers for service id %s'",
"%",
"self",
".",
"id",
"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | Service.check_available | Check for availability of a service and provide run metrics. | hypermap/aggregator/models.py | def check_available(self):
"""
Check for availability of a service and provide run metrics.
"""
success = True
start_time = datetime.datetime.utcnow()
message = ''
LOGGER.debug('Checking service id %s' % self.id)
try:
title = None
... | def check_available(self):
"""
Check for availability of a service and provide run metrics.
"""
success = True
start_time = datetime.datetime.utcnow()
message = ''
LOGGER.debug('Checking service id %s' % self.id)
try:
title = None
... | [
"Check",
"for",
"availability",
"of",
"a",
"service",
"and",
"provide",
"run",
"metrics",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L338-L453 | [
"def",
"check_available",
"(",
"self",
")",
":",
"success",
"=",
"True",
"start_time",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"message",
"=",
"''",
"LOGGER",
".",
"debug",
"(",
"'Checking service id %s'",
"%",
"self",
".",
"id",
")",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | Service.update_validity | Update validity of a service. | hypermap/aggregator/models.py | def update_validity(self):
"""
Update validity of a service.
"""
# WM is always valid
if self.type == 'Hypermap:WorldMap':
return
signals.post_save.disconnect(service_post_save, sender=Service)
try:
# some service now must be considered... | def update_validity(self):
"""
Update validity of a service.
"""
# WM is always valid
if self.type == 'Hypermap:WorldMap':
return
signals.post_save.disconnect(service_post_save, sender=Service)
try:
# some service now must be considered... | [
"Update",
"validity",
"of",
"a",
"service",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L455-L497 | [
"def",
"update_validity",
"(",
"self",
")",
":",
"# WM is always valid",
"if",
"self",
".",
"type",
"==",
"'Hypermap:WorldMap'",
":",
"return",
"signals",
".",
"post_save",
".",
"disconnect",
"(",
"service_post_save",
",",
"sender",
"=",
"Service",
")",
"try",
... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | Catalog.get_search_url | resolve the search url no matter if local or remote.
:return: url or exception | hypermap/aggregator/models.py | def get_search_url(self):
"""
resolve the search url no matter if local or remote.
:return: url or exception
"""
if self.is_remote:
return self.url
return reverse('search_api', args=[self.slug]) | def get_search_url(self):
"""
resolve the search url no matter if local or remote.
:return: url or exception
"""
if self.is_remote:
return self.url
return reverse('search_api', args=[self.slug]) | [
"resolve",
"the",
"search",
"url",
"no",
"matter",
"if",
"local",
"or",
"remote",
".",
":",
"return",
":",
"url",
"or",
"exception"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L525-L534 | [
"def",
"get_search_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_remote",
":",
"return",
"self",
".",
"url",
"return",
"reverse",
"(",
"'search_api'",
",",
"args",
"=",
"[",
"self",
".",
"slug",
"]",
")"
] | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | Layer.get_url_endpoint | Returns the Hypermap endpoint for a layer.
This endpoint will be the WMTS MapProxy endpoint, only for WM we use the original endpoint. | hypermap/aggregator/models.py | def get_url_endpoint(self):
"""
Returns the Hypermap endpoint for a layer.
This endpoint will be the WMTS MapProxy endpoint, only for WM we use the original endpoint.
"""
endpoint = self.url
if self.type not in ('Hypermap:WorldMap',):
endpoint = 'registry/%s/l... | def get_url_endpoint(self):
"""
Returns the Hypermap endpoint for a layer.
This endpoint will be the WMTS MapProxy endpoint, only for WM we use the original endpoint.
"""
endpoint = self.url
if self.type not in ('Hypermap:WorldMap',):
endpoint = 'registry/%s/l... | [
"Returns",
"the",
"Hypermap",
"endpoint",
"for",
"a",
"layer",
".",
"This",
"endpoint",
"will",
"be",
"the",
"WMTS",
"MapProxy",
"endpoint",
"only",
"for",
"WM",
"we",
"use",
"the",
"original",
"endpoint",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L573-L584 | [
"def",
"get_url_endpoint",
"(",
"self",
")",
":",
"endpoint",
"=",
"self",
".",
"url",
"if",
"self",
".",
"type",
"not",
"in",
"(",
"'Hypermap:WorldMap'",
",",
")",
":",
"endpoint",
"=",
"'registry/%s/layer/%s/map/wmts/1.0.0/WMTSCapabilities.xml'",
"%",
"(",
"se... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | Layer.check_available | Check for availability of a layer and provide run metrics. | hypermap/aggregator/models.py | def check_available(self):
"""
Check for availability of a layer and provide run metrics.
"""
success = True
start_time = datetime.datetime.utcnow()
message = ''
LOGGER.debug('Checking layer id %s' % self.id)
signals.post_save.disconnect(layer_post_save, ... | def check_available(self):
"""
Check for availability of a layer and provide run metrics.
"""
success = True
start_time = datetime.datetime.utcnow()
message = ''
LOGGER.debug('Checking layer id %s' % self.id)
signals.post_save.disconnect(layer_post_save, ... | [
"Check",
"for",
"availability",
"of",
"a",
"layer",
"and",
"provide",
"run",
"metrics",
"."
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L800-L837 | [
"def",
"check_available",
"(",
"self",
")",
":",
"success",
"=",
"True",
"start_time",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"message",
"=",
"''",
"LOGGER",
".",
"debug",
"(",
"'Checking layer id %s'",
"%",
"self",
".",
"id",
")",
"s... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | Layer.registry_tags | Get extra metadata tagged with a registry keyword.
For example:
<registry:property name="nomination/serviceOwner" value="True"/>
<registry:property name="nominator/name" value="Random Person"/>
<registry:property name="nominator/email" value="contact@example.com"/>
... | hypermap/aggregator/models.py | def registry_tags(self, query_string='{http://gis.harvard.edu/HHypermap/registry/0.1}property'):
"""
Get extra metadata tagged with a registry keyword.
For example:
<registry:property name="nomination/serviceOwner" value="True"/>
<registry:property name="nominator/name" v... | def registry_tags(self, query_string='{http://gis.harvard.edu/HHypermap/registry/0.1}property'):
"""
Get extra metadata tagged with a registry keyword.
For example:
<registry:property name="nomination/serviceOwner" value="True"/>
<registry:property name="nominator/name" v... | [
"Get",
"extra",
"metadata",
"tagged",
"with",
"a",
"registry",
"keyword",
".",
"For",
"example",
":",
"<registry",
":",
"property",
"name",
"=",
"nomination",
"/",
"serviceOwner",
"value",
"=",
"True",
"/",
">",
"<registry",
":",
"property",
"name",
"=",
"... | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/models.py#L839-L879 | [
"def",
"registry_tags",
"(",
"self",
",",
"query_string",
"=",
"'{http://gis.harvard.edu/HHypermap/registry/0.1}property'",
")",
":",
"from",
"pycsw",
".",
"core",
".",
"etree",
"import",
"etree",
"parsed",
"=",
"etree",
".",
"fromstring",
"(",
"self",
".",
"xml",... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | _input_github_repo | Grabs input from the user and saves
it as their trytravis target repo | trytravis.py | def _input_github_repo(url=None):
""" Grabs input from the user and saves
it as their trytravis target repo """
if url is None:
url = user_input('Input the URL of the GitHub repository '
'to use as a `trytravis` repository: ')
url = url.strip()
http_match = _HTTPS_RE... | def _input_github_repo(url=None):
""" Grabs input from the user and saves
it as their trytravis target repo """
if url is None:
url = user_input('Input the URL of the GitHub repository '
'to use as a `trytravis` repository: ')
url = url.strip()
http_match = _HTTPS_RE... | [
"Grabs",
"input",
"from",
"the",
"user",
"and",
"saves",
"it",
"as",
"their",
"trytravis",
"target",
"repo"
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L86-L125 | [
"def",
"_input_github_repo",
"(",
"url",
"=",
"None",
")",
":",
"if",
"url",
"is",
"None",
":",
"url",
"=",
"user_input",
"(",
"'Input the URL of the GitHub repository '",
"'to use as a `trytravis` repository: '",
")",
"url",
"=",
"url",
".",
"strip",
"(",
")",
... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | _load_github_repo | Loads the GitHub repository from the users config. | trytravis.py | def _load_github_repo():
""" Loads the GitHub repository from the users config. """
if 'TRAVIS' in os.environ:
raise RuntimeError('Detected that we are running in Travis. '
'Stopping to prevent infinite loops.')
try:
with open(os.path.join(config_dir, 'repo'), 'r')... | def _load_github_repo():
""" Loads the GitHub repository from the users config. """
if 'TRAVIS' in os.environ:
raise RuntimeError('Detected that we are running in Travis. '
'Stopping to prevent infinite loops.')
try:
with open(os.path.join(config_dir, 'repo'), 'r')... | [
"Loads",
"the",
"GitHub",
"repository",
"from",
"the",
"users",
"config",
"."
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L128-L138 | [
"def",
"_load_github_repo",
"(",
")",
":",
"if",
"'TRAVIS'",
"in",
"os",
".",
"environ",
":",
"raise",
"RuntimeError",
"(",
"'Detected that we are running in Travis. '",
"'Stopping to prevent infinite loops.'",
")",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path"... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | _submit_changes_to_github_repo | Temporarily commits local changes and submits them to
the GitHub repository that the user has specified. Then
reverts the changes to the git repository if a commit was
necessary. | trytravis.py | def _submit_changes_to_github_repo(path, url):
""" Temporarily commits local changes and submits them to
the GitHub repository that the user has specified. Then
reverts the changes to the git repository if a commit was
necessary. """
try:
repo = git.Repo(path)
except Exception:
r... | def _submit_changes_to_github_repo(path, url):
""" Temporarily commits local changes and submits them to
the GitHub repository that the user has specified. Then
reverts the changes to the git repository if a commit was
necessary. """
try:
repo = git.Repo(path)
except Exception:
r... | [
"Temporarily",
"commits",
"local",
"changes",
"and",
"submits",
"them",
"to",
"the",
"GitHub",
"repository",
"that",
"the",
"user",
"has",
"specified",
".",
"Then",
"reverts",
"the",
"changes",
"to",
"the",
"git",
"repository",
"if",
"a",
"commit",
"was",
"n... | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L141-L185 | [
"def",
"_submit_changes_to_github_repo",
"(",
"path",
",",
"url",
")",
":",
"try",
":",
"repo",
"=",
"git",
".",
"Repo",
"(",
"path",
")",
"except",
"Exception",
":",
"raise",
"RuntimeError",
"(",
"'Couldn\\'t locate a repository at `%s`.'",
"%",
"path",
")",
... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | _wait_for_travis_build | Waits for a Travis build to appear with the given commit SHA | trytravis.py | def _wait_for_travis_build(url, commit, committed_at):
""" Waits for a Travis build to appear with the given commit SHA """
print('Waiting for a Travis build to appear '
'for `%s` after `%s`...' % (commit, committed_at))
import requests
slug = _slug_from_url(url)
start_time = time.time()
... | def _wait_for_travis_build(url, commit, committed_at):
""" Waits for a Travis build to appear with the given commit SHA """
print('Waiting for a Travis build to appear '
'for `%s` after `%s`...' % (commit, committed_at))
import requests
slug = _slug_from_url(url)
start_time = time.time()
... | [
"Waits",
"for",
"a",
"Travis",
"build",
"to",
"appear",
"with",
"the",
"given",
"commit",
"SHA"
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L188-L234 | [
"def",
"_wait_for_travis_build",
"(",
"url",
",",
"commit",
",",
"committed_at",
")",
":",
"print",
"(",
"'Waiting for a Travis build to appear '",
"'for `%s` after `%s`...'",
"%",
"(",
"commit",
",",
"committed_at",
")",
")",
"import",
"requests",
"slug",
"=",
"_sl... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | _watch_travis_build | Watches and progressively outputs information
about a given Travis build | trytravis.py | def _watch_travis_build(build_id):
""" Watches and progressively outputs information
about a given Travis build """
import requests
try:
build_size = None # type: int
running = True
while running:
with requests.get('https://api.travis-ci.org/builds/%d' % build_id,
... | def _watch_travis_build(build_id):
""" Watches and progressively outputs information
about a given Travis build """
import requests
try:
build_size = None # type: int
running = True
while running:
with requests.get('https://api.travis-ci.org/builds/%d' % build_id,
... | [
"Watches",
"and",
"progressively",
"outputs",
"information",
"about",
"a",
"given",
"Travis",
"build"
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L237-L286 | [
"def",
"_watch_travis_build",
"(",
"build_id",
")",
":",
"import",
"requests",
"try",
":",
"build_size",
"=",
"None",
"# type: int",
"running",
"=",
"True",
"while",
"running",
":",
"with",
"requests",
".",
"get",
"(",
"'https://api.travis-ci.org/builds/%d'",
"%",... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | _travis_job_state | Converts a Travis state into a state character, color,
and whether it's still running or a stopped state. | trytravis.py | def _travis_job_state(state):
""" Converts a Travis state into a state character, color,
and whether it's still running or a stopped state. """
if state in [None, 'queued', 'created', 'received']:
return colorama.Fore.YELLOW, '*', True
elif state in ['started', 'running']:
return coloram... | def _travis_job_state(state):
""" Converts a Travis state into a state character, color,
and whether it's still running or a stopped state. """
if state in [None, 'queued', 'created', 'received']:
return colorama.Fore.YELLOW, '*', True
elif state in ['started', 'running']:
return coloram... | [
"Converts",
"a",
"Travis",
"state",
"into",
"a",
"state",
"character",
"color",
"and",
"whether",
"it",
"s",
"still",
"running",
"or",
"a",
"stopped",
"state",
"."
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L289-L305 | [
"def",
"_travis_job_state",
"(",
"state",
")",
":",
"if",
"state",
"in",
"[",
"None",
",",
"'queued'",
",",
"'created'",
",",
"'received'",
"]",
":",
"return",
"colorama",
".",
"Fore",
".",
"YELLOW",
",",
"'*'",
",",
"True",
"elif",
"state",
"in",
"[",... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | _slug_from_url | Parses a project slug out of either an HTTPS or SSH URL. | trytravis.py | def _slug_from_url(url):
""" Parses a project slug out of either an HTTPS or SSH URL. """
http_match = _HTTPS_REGEX.match(url)
ssh_match = _SSH_REGEX.match(url)
if not http_match and not ssh_match:
raise RuntimeError('Could not parse the URL (`%s`) '
'for your reposito... | def _slug_from_url(url):
""" Parses a project slug out of either an HTTPS or SSH URL. """
http_match = _HTTPS_REGEX.match(url)
ssh_match = _SSH_REGEX.match(url)
if not http_match and not ssh_match:
raise RuntimeError('Could not parse the URL (`%s`) '
'for your reposito... | [
"Parses",
"a",
"project",
"slug",
"out",
"of",
"either",
"an",
"HTTPS",
"or",
"SSH",
"URL",
"."
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L308-L318 | [
"def",
"_slug_from_url",
"(",
"url",
")",
":",
"http_match",
"=",
"_HTTPS_REGEX",
".",
"match",
"(",
"url",
")",
"ssh_match",
"=",
"_SSH_REGEX",
".",
"match",
"(",
"url",
")",
"if",
"not",
"http_match",
"and",
"not",
"ssh_match",
":",
"raise",
"RuntimeErro... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | _version_string | Gets the output for `trytravis --version`. | trytravis.py | def _version_string():
""" Gets the output for `trytravis --version`. """
platform_system = platform.system()
if platform_system == 'Linux':
os_name, os_version, _ = platform.dist()
else:
os_name = platform_system
os_version = platform.version()
python_version = platform.pyth... | def _version_string():
""" Gets the output for `trytravis --version`. """
platform_system = platform.system()
if platform_system == 'Linux':
os_name, os_version, _ = platform.dist()
else:
os_name = platform_system
os_version = platform.version()
python_version = platform.pyth... | [
"Gets",
"the",
"output",
"for",
"trytravis",
"--",
"version",
"."
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L321-L333 | [
"def",
"_version_string",
"(",
")",
":",
"platform_system",
"=",
"platform",
".",
"system",
"(",
")",
"if",
"platform_system",
"==",
"'Linux'",
":",
"os_name",
",",
"os_version",
",",
"_",
"=",
"platform",
".",
"dist",
"(",
")",
"else",
":",
"os_name",
"... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | _main | Function that acts just like main() except
doesn't catch exceptions. | trytravis.py | def _main(argv):
""" Function that acts just like main() except
doesn't catch exceptions. """
repo_input_argv = len(argv) == 2 and argv[0] in ['--repo', '-r', '-R']
# We only support a single argv parameter.
if len(argv) > 1 and not repo_input_argv:
_main(['--help'])
# Parse the comman... | def _main(argv):
""" Function that acts just like main() except
doesn't catch exceptions. """
repo_input_argv = len(argv) == 2 and argv[0] in ['--repo', '-r', '-R']
# We only support a single argv parameter.
if len(argv) > 1 and not repo_input_argv:
_main(['--help'])
# Parse the comman... | [
"Function",
"that",
"acts",
"just",
"like",
"main",
"()",
"except",
"doesn",
"t",
"catch",
"exceptions",
"."
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L343-L388 | [
"def",
"_main",
"(",
"argv",
")",
":",
"repo_input_argv",
"=",
"len",
"(",
"argv",
")",
"==",
"2",
"and",
"argv",
"[",
"0",
"]",
"in",
"[",
"'--repo'",
",",
"'-r'",
",",
"'-R'",
"]",
"# We only support a single argv parameter.",
"if",
"len",
"(",
"argv",... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | main | Main entry point when the user runs the `trytravis` command. | trytravis.py | def main(argv=None): # pragma: no coverage
""" Main entry point when the user runs the `trytravis` command. """
try:
colorama.init()
if argv is None:
argv = sys.argv[1:]
_main(argv)
except RuntimeError as e:
print(colorama.Fore.RED + 'ERROR: ' +
str... | def main(argv=None): # pragma: no coverage
""" Main entry point when the user runs the `trytravis` command. """
try:
colorama.init()
if argv is None:
argv = sys.argv[1:]
_main(argv)
except RuntimeError as e:
print(colorama.Fore.RED + 'ERROR: ' +
str... | [
"Main",
"entry",
"point",
"when",
"the",
"user",
"runs",
"the",
"trytravis",
"command",
"."
] | sethmlarson/trytravis | python | https://github.com/sethmlarson/trytravis/blob/d92ed708fe71d8db93a6df8077d23ee39ec0364e/trytravis.py#L391-L403 | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"# pragma: no coverage",
"try",
":",
"colorama",
".",
"init",
"(",
")",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"_main",
"(",
"argv",
")",
"except",
... | d92ed708fe71d8db93a6df8077d23ee39ec0364e |
train | csw_global_dispatch | pycsw wrapper | hypermap/search/views.py | def csw_global_dispatch(request, url=None, catalog_id=None):
"""pycsw wrapper"""
if request.user.is_authenticated(): # turn on CSW-T
settings.REGISTRY_PYCSW['manager']['transactions'] = 'true'
env = request.META.copy()
# TODO: remove this workaround
# HH should be able to pass env['wsgi.... | def csw_global_dispatch(request, url=None, catalog_id=None):
"""pycsw wrapper"""
if request.user.is_authenticated(): # turn on CSW-T
settings.REGISTRY_PYCSW['manager']['transactions'] = 'true'
env = request.META.copy()
# TODO: remove this workaround
# HH should be able to pass env['wsgi.... | [
"pycsw",
"wrapper"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/views.py#L19-L59 | [
"def",
"csw_global_dispatch",
"(",
"request",
",",
"url",
"=",
"None",
",",
"catalog_id",
"=",
"None",
")",
":",
"if",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
":",
"# turn on CSW-T",
"settings",
".",
"REGISTRY_PYCSW",
"[",
"'manager'",
"]"... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
train | csw_global_dispatch_by_catalog | pycsw wrapper for catalogs | hypermap/search/views.py | def csw_global_dispatch_by_catalog(request, catalog_slug):
"""pycsw wrapper for catalogs"""
catalog = get_object_or_404(Catalog, slug=catalog_slug)
if catalog: # define catalog specific settings
url = settings.SITE_URL.rstrip('/') + request.path.rstrip('/')
return csw_global_dispatch(requ... | def csw_global_dispatch_by_catalog(request, catalog_slug):
"""pycsw wrapper for catalogs"""
catalog = get_object_or_404(Catalog, slug=catalog_slug)
if catalog: # define catalog specific settings
url = settings.SITE_URL.rstrip('/') + request.path.rstrip('/')
return csw_global_dispatch(requ... | [
"pycsw",
"wrapper",
"for",
"catalogs"
] | cga-harvard/Hypermap-Registry | python | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/search/views.py#L63-L70 | [
"def",
"csw_global_dispatch_by_catalog",
"(",
"request",
",",
"catalog_slug",
")",
":",
"catalog",
"=",
"get_object_or_404",
"(",
"Catalog",
",",
"slug",
"=",
"catalog_slug",
")",
"if",
"catalog",
":",
"# define catalog specific settings",
"url",
"=",
"settings",
".... | 899a5385b15af7fba190ab4fae1d41e47d155a1b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.