From b9741f658417892f91728280508360d776e0175e Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 2 Mar 2023 15:34:39 +0100 Subject: [PATCH 1/2] cbor2: Remove u-module prefix from imports. --- python-ecosys/cbor2/cbor2/decoder.py | 6 +++--- python-ecosys/cbor2/cbor2/encoder.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python-ecosys/cbor2/cbor2/decoder.py b/python-ecosys/cbor2/cbor2/decoder.py index 2460d87a0..f0784d4be 100644 --- a/python-ecosys/cbor2/cbor2/decoder.py +++ b/python-ecosys/cbor2/cbor2/decoder.py @@ -24,8 +24,8 @@ """ -import uio -import ustruct as struct +import io +import struct class CBORDecodeError(Exception): @@ -248,7 +248,7 @@ def loads(payload, **kwargs): :param kwargs: keyword arguments passed to :class:`~.CBORDecoder` :return: the deserialized object """ - fp = uio.BytesIO(payload) + fp = io.BytesIO(payload) return CBORDecoder(fp, **kwargs).decode() diff --git a/python-ecosys/cbor2/cbor2/encoder.py b/python-ecosys/cbor2/cbor2/encoder.py index 436886876..d739cea40 100644 --- a/python-ecosys/cbor2/cbor2/encoder.py +++ b/python-ecosys/cbor2/cbor2/encoder.py @@ -24,9 +24,9 @@ """ -import uio +import io import math -import ustruct as struct +import struct class CBOREncodeError(Exception): @@ -169,7 +169,7 @@ def dumps(obj, **kwargs): :return: the serialized output :rtype: bytes """ - fp = uio.BytesIO() + fp = io.BytesIO() dump(obj, fp, **kwargs) return fp.getvalue() From 295a9e300a60f749c5aa54556be98614ad439f41 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 2 Mar 2023 15:35:25 +0100 Subject: [PATCH 2/2] senml: Remove u-module prefix from imports. Signed-off-by: Damien George --- micropython/senml/examples/base.py | 2 +- micropython/senml/examples/basic.py | 2 +- micropython/senml/examples/basic2.py | 2 +- micropython/senml/examples/basic_cbor.py | 2 +- micropython/senml/examples/custom_record.py | 2 +- micropython/senml/examples/gateway.py | 2 +- micropython/senml/examples/supported_data_types.py | 2 +- micropython/senml/senml/senml_pack.py | 6 +++--- micropython/senml/senml/senml_record.py | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/micropython/senml/examples/base.py b/micropython/senml/examples/base.py index c68188863..426cbbd0e 100644 --- a/micropython/senml/examples/base.py +++ b/micropython/senml/examples/base.py @@ -25,7 +25,7 @@ from senml import * -import utime as time +import time pack = SenmlPack("device_name") diff --git a/micropython/senml/examples/basic.py b/micropython/senml/examples/basic.py index 470364f1b..18a3a9a06 100644 --- a/micropython/senml/examples/basic.py +++ b/micropython/senml/examples/basic.py @@ -25,7 +25,7 @@ from senml import * -import utime as time +import time pack = SenmlPack("device") diff --git a/micropython/senml/examples/basic2.py b/micropython/senml/examples/basic2.py index 7c4dee267..c2ea153bd 100644 --- a/micropython/senml/examples/basic2.py +++ b/micropython/senml/examples/basic2.py @@ -25,7 +25,7 @@ from senml import * -import utime as time +import time pack = SenmlPack("device_name") diff --git a/micropython/senml/examples/basic_cbor.py b/micropython/senml/examples/basic_cbor.py index de696b1a9..f5e92af37 100644 --- a/micropython/senml/examples/basic_cbor.py +++ b/micropython/senml/examples/basic_cbor.py @@ -25,7 +25,7 @@ from senml import * -import utime as time +import time from cbor2 import decoder pack = SenmlPack("device_name") diff --git a/micropython/senml/examples/custom_record.py b/micropython/senml/examples/custom_record.py index 07e4e177c..e754c897c 100644 --- a/micropython/senml/examples/custom_record.py +++ b/micropython/senml/examples/custom_record.py @@ -26,7 +26,7 @@ from senml import * -import utime as time +import time class Coordinates(SenmlRecord): diff --git a/micropython/senml/examples/gateway.py b/micropython/senml/examples/gateway.py index c3bef12da..d28e4cffc 100644 --- a/micropython/senml/examples/gateway.py +++ b/micropython/senml/examples/gateway.py @@ -25,7 +25,7 @@ from senml import * -import utime as time +import time gateway_pack = SenmlPack("gateway") diff --git a/micropython/senml/examples/supported_data_types.py b/micropython/senml/examples/supported_data_types.py index 59799cb9c..3149f49d2 100644 --- a/micropython/senml/examples/supported_data_types.py +++ b/micropython/senml/examples/supported_data_types.py @@ -25,7 +25,7 @@ from senml import * -import utime as time +import time pack = SenmlPack("device_name") diff --git a/micropython/senml/senml/senml_pack.py b/micropython/senml/senml/senml_pack.py index 03ca612ac..d528911ff 100644 --- a/micropython/senml/senml/senml_pack.py +++ b/micropython/senml/senml/senml_pack.py @@ -26,7 +26,7 @@ from senml.senml_record import SenmlRecord from senml.senml_base import SenmlBase -import ujson +import json from cbor2 import encoder from cbor2 import decoder @@ -166,7 +166,7 @@ def from_json(self, data): :param data: a string containing json data. :return: None, will r """ - records = ujson.loads(data) # load the raw senml data + records = json.loads(data) # load the raw senml data self._process_incomming_data(records, SenmlPack.json_mappings) def _process_incomming_data(self, records, naming_map): @@ -242,7 +242,7 @@ def to_json(self): """ converted = [] self._build_rec_dict(SenmlPack.json_mappings, converted) - return ujson.dumps(converted) + return json.dumps(converted) def _build_rec_dict(self, naming_map, appendTo): """ diff --git a/micropython/senml/senml/senml_record.py b/micropython/senml/senml/senml_record.py index be280d3ae..5c99a4474 100644 --- a/micropython/senml/senml/senml_record.py +++ b/micropython/senml/senml/senml_record.py @@ -24,7 +24,7 @@ """ -import ubinascii +import binascii from senml.senml_base import SenmlBase @@ -229,7 +229,7 @@ def _from_raw(self, raw, naming_map): elif naming_map["vb"] in raw: val = raw[naming_map["vb"]] elif naming_map["vd"] in raw: - val = ubinascii.a2b_base64(raw[naming_map["vb"]]) + val = binascii.a2b_base64(raw[naming_map["vb"]]) else: val = None self.value = val