diff weather_server/common.py @ 0:efe7a1eff167

Create initial logger for weather server.
author Paul Fisher <paul@pfish.zone>
date Sat, 28 Sep 2019 23:17:21 -0400
parents
children 52ef21607b31
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/weather_server/common.py	Sat Sep 28 23:17:21 2019 -0400
@@ -0,0 +1,11 @@
+import typing as t
+
+import bson
+import pytz
+
+BSON_OPTIONS = bson.DEFAULT_CODEC_OPTIONS.with_options(
+    tz_aware=True, tzinfo=pytz.UTC)
+
+
+def bson_encode(data: t.Dict[str, t.Any]) -> bytes:
+    return bson.BSON.encode(data, codec_options=BSON_OPTIONS)