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
17 changes: 15 additions & 2 deletions pygeoapi/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,26 @@ def path_representer(dumper, data):

yaml.add_multi_representer(pathlib.PurePath, path_representer)

def datetime_representer(dumper, data: datetime):
if data.tzinfo is None:
data = data.replace(tzinfo=timezone.utc)
else:
data = data.astimezone(timezone.utc)
value = data.strftime("%Y-%m-%dT%H:%M:%SZ")

# timestamp in a specified format, without string quotes
return dumper.represent_scalar(u'tag:yaml.org,2002:timestamp', value)

yaml.add_representer(datetime, datetime_representer)

lock = FileLock(f'{destfile}.lock')

with lock:
LOGGER.debug('Dumping YAML document')
with open(destfile, 'wb') as fh:
yaml.dump(dict_, fh, sort_keys=False, encoding='utf8', indent=4,
default_flow_style=False)
yaml.dump(dict_, fh, sort_keys=False, encoding='utf8',
indent=4, default_flow_style=False,
allow_unicode=True)

return True

Expand Down
2 changes: 1 addition & 1 deletion tests/data/mysql_data.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- A test database for the mysql provider; a simple geospatial app
-- A test database for the mysql provider; a simple geospatial app

-- Create the database
DROP DATABASE IF EXISTS test_geo_app;
Expand Down
Loading