EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit 084278ff authored by Nikola Jankovic's avatar Nikola Jankovic :computer:
Browse files

updated scheme to handle proper datetime regex and id template

update configure.sh to include env var fix #105
parent 5294fc60
No related branches found
No related tags found
1 merge request!73multiple crs fix for single-file scheme
......@@ -50,6 +50,7 @@
echo "USE_X_FORWARDED_HOST = True" >> pvs_instance/settings.py
echo "SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')" >> pvs_instance/settings.py
sed -e "s/SECRET_KEY = '.*'/SECRET_KEY = '${DJANGO_SECRET_KEY}'/" -i pvs_instance/settings.py
chmod g+w -R .
chgrp users -R .
} 1>&2
......@@ -288,11 +288,13 @@ class STACItemScheme(RegistrationScheme):
class SingleFileRegistrationScheme(RegistrationScheme):
name = "single-file"
def __init__(self, footprint: str, product_type: str, level: str, date_format: str):
def __init__(self, footprint: str, product_type: str, level: str,
date_format: str, id_template: str=None):
self.footprint = footprint
self.product_type = product_type
self.level = level
self.date_format = date_format
self.id_template = id_template
def get_context(self, source: Source, path: str) -> List[Context]:
......@@ -318,10 +320,16 @@ class SingleFileRegistrationScheme(RegistrationScheme):
]
def _get_identifier(self, path: str, begin_time: datetime, end_time: datetime) -> str:
return f"{self.product_type}_{isoformat(begin_time)}_{isoformat(end_time)}"
begin_time=isoformat(begin_time)
end_time=isoformat(end_time)
if not self.id_template:
return f"{self.product_type}_{begin_time}_{end_time}"
return self.id_template.format(product_type=self.product_type, begin_time=begin_time, end_time=end_time)
def _get_datetimes(self, path: str) -> Tuple[datetime, datetime]:
dt = path.split("/")[-1].split(".")[0]
dt = re.search(r'\d{4}-\d{2}-\d{2}', dt).group()
begin = datetime.strptime(dt, self.date_format)
end = begin.replace(hour=23, minute=59, second=59)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment