annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
1 import typing as t
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
2
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
3 import bson
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
4 import pytz
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
5
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
6 BSON_OPTIONS = bson.DEFAULT_CODEC_OPTIONS.with_options(
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
7 tz_aware=True, tzinfo=pytz.UTC)
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
8
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
9
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
10 def bson_encode(data: t.Dict[str, t.Any]) -> bytes:
efe7a1eff167 Create initial logger for weather server.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
11 return bson.BSON.encode(data, codec_options=BSON_OPTIONS)