Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pygeometa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
# =================================================================

from collections.abc import Mapping
from datetime import date, datetime
from importlib.metadata import version, PackageNotFoundError
import datetime
import json
import logging
import os
Expand Down Expand Up @@ -125,14 +125,14 @@ def normalize_datestring(datestring: str, format_: str = 'default') -> str:
:returns: string of properly formatted datestring
"""

today_and_now = datetime.utcnow()
today_and_now = datetime.datetime.now(datetime.UTC)

re1 = r'\$Date: (?P<year>\d{4})'
re2 = r'\$Date: (?P<date>\d{4}-\d{2}-\d{2}) (?P<time>\d{2}:\d{2}:\d{2})'
re3 = r'(?P<start>.*)\$Date: (?P<year>\d{4}).*\$(?P<end>.*)'

try:
if isinstance(datestring, date):
if isinstance(datestring, datetime.date):
if datestring.year < 1900:
datestring2 = '{0.day:02d}.{0.month:02d}.{0.year:4d}'.format(
datestring)
Expand Down
2 changes: 1 addition & 1 deletion pygeometa/schemas/cwl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def import_(self, metadata: str) -> dict:

now = datetime.datetime.now(datetime.UTC)

wf = list(filter(lambda x: x['class'] == 'Workflow', metadata['$graph']))[0] # noqa
wf = list(filter(lambda x: x['class'] == 'Workflow', metadata.get('$graph')))[0] # noqa

mcf['metadata']['identifier'] = wf['id']
mcf['metadata']['hierarchylevel'] = 'application'
Expand Down
12 changes: 8 additions & 4 deletions pygeometa/schemas/iso19139/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,19 @@ def import_(self, metadata: str) -> dict:

mcf['identification']['extents'] = {
'spatial': [{
'bbox': [
'bbox': []
}],
'temporal': []
}
try:
mcf['identification']['extents']['spatial'][0]['bbox'] = [
ast.literal_eval(identification.extent.boundingBox.minx),
ast.literal_eval(identification.extent.boundingBox.miny),
ast.literal_eval(identification.extent.boundingBox.maxx),
ast.literal_eval(identification.extent.boundingBox.maxy)
]
}],
'temporal': []
}
except ValueError as err:
LOGGER.info(f'boundingBox missing: {err}')

temp_extent = {
'begin': None,
Expand Down
Loading