From 407169af012c1f092de27c111298959ee60554ad Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Thu, 29 Sep 2016 12:29:43 +0200 Subject: [PATCH] import qualified const() --- src/apps/common/storage.py | 3 ++- src/apps/management/layout_reset_device.py | 1 + src/lib/protobuf.py | 2 ++ src/trezor/debug.py | 2 ++ src/trezor/log.py | 1 + src/trezor/loop.py | 2 +- src/trezor/ui/button.py | 3 ++- src/trezor/ui/confirm.py | 3 ++- src/trezor/ui/loader.py | 1 + src/trezor/ui/pin.py | 7 ++++--- src/trezor/ui/scroll.py | 3 ++- src/trezor/ui/swipe.py | 4 ++-- src/trezor/ui/text.py | 1 + src/trezor/wire/wire_codec.py | 1 + src/trezor/wire/wire_codec_v1.py | 1 + src/trezor/wire/wire_io.py | 6 ++---- 16 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/apps/common/storage.py b/src/apps/common/storage.py index 83d10ebf81..5d8ca17fb8 100644 --- a/src/apps/common/storage.py +++ b/src/apps/common/storage.py @@ -1,3 +1,4 @@ +from micropython import const from trezor import config @@ -14,4 +15,4 @@ def set_storage(session_id, buf): def clear_storage(session_id): - set_storage(session_id, '') + set_storage(session_id, b'') diff --git a/src/apps/management/layout_reset_device.py b/src/apps/management/layout_reset_device.py index c0238a6eea..72ddd85dbf 100644 --- a/src/apps/management/layout_reset_device.py +++ b/src/apps/management/layout_reset_device.py @@ -1,3 +1,4 @@ +from micropython import const from trezor import wire, ui from trezor.utils import unimport, chunks diff --git a/src/lib/protobuf.py b/src/lib/protobuf.py index 7e2ab55b94..9dfb2c91e7 100644 --- a/src/lib/protobuf.py +++ b/src/lib/protobuf.py @@ -10,6 +10,8 @@ Value format: ((field_type, field_flags, field_name), field_value) field_value: Depends on field_type. EmbeddedMessage has `field_value == None`. ''' +from micropython import const + def build_protobuf_message(message_type, callback, *args): message = message_type() diff --git a/src/trezor/debug.py b/src/trezor/debug.py index 2217e614f2..798e069398 100644 --- a/src/trezor/debug.py +++ b/src/trezor/debug.py @@ -1,3 +1,5 @@ +from micropython import const + if not __debug__: raise ImportError('This module can be loaded only in DEBUG mode') diff --git a/src/trezor/log.py b/src/trezor/log.py index 59b8577f00..e988f71b9b 100644 --- a/src/trezor/log.py +++ b/src/trezor/log.py @@ -1,3 +1,4 @@ +from micropython import const import uio import sys import utime diff --git a/src/trezor/loop.py b/src/trezor/loop.py index 2105e0b6c5..7094371f10 100644 --- a/src/trezor/loop.py +++ b/src/trezor/loop.py @@ -1,5 +1,5 @@ import utime - +from micropython import const from uheapq import heappop, heappush, heapify from .utils import type_gen from . import msg diff --git a/src/trezor/ui/button.py b/src/trezor/ui/button.py index 70bd713624..ef50b894db 100644 --- a/src/trezor/ui/button.py +++ b/src/trezor/ui/button.py @@ -1,5 +1,6 @@ -from . import display, in_area, rotate_coords +from micropython import const from trezor import ui, loop +from . import display, in_area, rotate_coords DEFAULT_BUTTON = { diff --git a/src/trezor/ui/confirm.py b/src/trezor/ui/confirm.py index 2beb188e9b..6d00fec1b6 100644 --- a/src/trezor/ui/confirm.py +++ b/src/trezor/ui/confirm.py @@ -1,8 +1,9 @@ +from micropython import const +from trezor import loop from .button import Button, BTN_CLICKED, BTN_STARTED from .button import CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE from .button import CANCEL_BUTTON, CANCEL_BUTTON_ACTIVE from .loader import Loader -from trezor import loop CONFIRMED = const(1) diff --git a/src/trezor/ui/loader.py b/src/trezor/ui/loader.py index 6131067d2b..613e503715 100644 --- a/src/trezor/ui/loader.py +++ b/src/trezor/ui/loader.py @@ -1,4 +1,5 @@ import utime +from micropython import const from trezor import ui diff --git a/src/trezor/ui/pin.py b/src/trezor/ui/pin.py index 0b9a073fc5..55fbb20d6d 100644 --- a/src/trezor/ui/pin.py +++ b/src/trezor/ui/pin.py @@ -1,7 +1,8 @@ -from . import display -from .button import Button, BTN_CLICKED, CLEAR_BUTTON, CLEAR_BUTTON_ACTIVE -from trezor import ui, res +from micropython import const from trezor.crypto import random +from trezor import ui, res +from .button import Button, BTN_CLICKED, CLEAR_BUTTON, CLEAR_BUTTON_ACTIVE +from . import display def digit_area(i): diff --git a/src/trezor/ui/scroll.py b/src/trezor/ui/scroll.py index 1649aa867e..c36bd12f14 100644 --- a/src/trezor/ui/scroll.py +++ b/src/trezor/ui/scroll.py @@ -1,5 +1,6 @@ -from .swipe import Swipe, SWIPE_UP, SWIPE_DOWN +from micropython import const from trezor import loop, ui +from .swipe import Swipe, SWIPE_UP, SWIPE_DOWN async def change_page(page, page_count): diff --git a/src/trezor/ui/swipe.py b/src/trezor/ui/swipe.py index 5a758fc1d0..9332c6cd75 100644 --- a/src/trezor/ui/swipe.py +++ b/src/trezor/ui/swipe.py @@ -1,7 +1,7 @@ import utime - -from . import in_area, rotate_coords +from micropython import const from trezor import loop +from . import in_area, rotate_coords SWIPE_DISTANCE_THRESHOLD = const(20) # Min pixels in the primary direction diff --git a/src/trezor/ui/text.py b/src/trezor/ui/text.py index cbd804f276..575beaa727 100644 --- a/src/trezor/ui/text.py +++ b/src/trezor/ui/text.py @@ -1,3 +1,4 @@ +from micropython import const from trezor import ui TEXT_HEADER_HEIGHT = const(44) diff --git a/src/trezor/wire/wire_codec.py b/src/trezor/wire/wire_codec.py index 7edee03235..168abbe595 100644 --- a/src/trezor/wire/wire_codec.py +++ b/src/trezor/wire/wire_codec.py @@ -1,3 +1,4 @@ +from micropython import const import ustruct import ubinascii diff --git a/src/trezor/wire/wire_codec_v1.py b/src/trezor/wire/wire_codec_v1.py index c0c1b29664..2c58dce182 100644 --- a/src/trezor/wire/wire_codec_v1.py +++ b/src/trezor/wire/wire_codec_v1.py @@ -1,3 +1,4 @@ +from micropython import const import ustruct SESSION_V1 = const(0) diff --git a/src/trezor/wire/wire_io.py b/src/trezor/wire/wire_io.py index 6dc5d2f6af..67d926f744 100644 --- a/src/trezor/wire/wire_io.py +++ b/src/trezor/wire/wire_io.py @@ -1,8 +1,6 @@ import ubinascii - -from trezor import msg -from trezor import loop -from trezor import log +from micropython import const +from trezor import msg, loop, log _DEFAULT_IFACE = const(0)