1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-08 22:40:59 +00:00

style: skip formatting in special cases

This commit is contained in:
Jan Pochyla 2018-07-03 14:28:17 +02:00
parent 93d1b0751b
commit 6751d84236
6 changed files with 60 additions and 54 deletions

View File

@ -45,8 +45,9 @@ class CoinInfo:
self.sign_hash_double = True
# the following list is generated using tools/codegen/gen_coins.py
# generated using tools/codegen/gen_coins.py
# do not edit manually!
# fmt: off
COINS = [
CoinInfo(
coin_name='Bitcoin',

View File

@ -8,6 +8,7 @@ HOMESCREEN_MAXSIZE = 16384
_STORAGE_VERSION = b'\x01'
# fmt: off
_APP = const(0x01) # app namespace
_DEVICE_ID = const(0x00) # bytes
_VERSION = const(0x01) # int
@ -22,6 +23,7 @@ _U2F_COUNTER = const(0x09) # int
_PASSPHRASE_SOURCE = const(0x0A) # int
_UNFINISHED_BACKUP = const(0x0B) # bool (0x01 or empty)
_AUTOLOCK_DELAY_MS = const(0x0C) # int
# fmt: on
def _new_device_id() -> str:

View File

@ -1,3 +1,25 @@
def shortcut_by_chain_id(chain_id, tx_type=None):
if tx_type in [1, 6] and chain_id in [1, 3]:
return 'WAN'
else:
n = by_chain_id(chain_id)
return n.shortcut if n is not None else 'UNKN'
def by_chain_id(chain_id):
for n in NETWORKS:
if n.chain_id == chain_id:
return n
return None
def by_slip44(slip44):
for n in NETWORKS:
if n.slip44 == slip44:
return n
return None
class NetworkInfo:
def __init__(
@ -15,8 +37,9 @@ class NetworkInfo:
self.rskip60 = rskip60
# the following list is generated using tools/codegen/gen_eth_networks.py
# generated using tools/codegen/gen_eth_networks.py
# do not edit manually!
# fmt: off
NETWORKS = [
NetworkInfo(
chain_id=1,
@ -124,25 +147,3 @@ NETWORKS = [
rskip60=False,
),
]
def shortcut_by_chain_id(chain_id, tx_type=None):
if tx_type in [1, 6] and chain_id in [1, 3]:
return 'WAN'
else:
n = by_chain_id(chain_id)
return n.shortcut if n is not None else 'UNKN'
def by_chain_id(chain_id):
for n in NETWORKS:
if n.chain_id == chain_id:
return n
return None
def by_slip44(slip44):
for n in NETWORKS:
if n.slip44 == slip44:
return n
return None

View File

@ -1,3 +1,5 @@
# isort:skip_file
# unlock the device
import boot # noqa: F401

View File

@ -1,35 +1,31 @@
from micropython import const
import math
import utime
from micropython import const
from trezorui import Display
from trezor import io
from trezor import loop
from trezor import res
from trezor import workflow
from trezor import io, loop, res, workflow
from trezor.utils import model
display = Display()
# in debug mode, display an indicator in top right corner
if __debug__:
def debug_display_refresh():
display.bar(Display.WIDTH - 8, 0, 8, 8, 0xF800)
display.refresh()
loop.after_step_hook = debug_display_refresh
# in both debug and production, emulator needs to draw the screen explicitly
elif model() == 'EMU':
elif model() == "EMU":
loop.after_step_hook = display.refresh
# import constants from modtrezorui
SIZE = Display.FONT_SIZE
# re-export constants from modtrezorui
NORMAL = Display.FONT_NORMAL
BOLD = Display.FONT_BOLD
MONO = Display.FONT_MONO
SIZE = Display.FONT_SIZE
WIDTH = Display.WIDTH
HEIGHT = Display.HEIGHT
@ -46,10 +42,12 @@ def blend(ca: int, cb: int, t: float) -> int:
return rgb(
lerpi((ca >> 8) & 0xF8, (cb >> 8) & 0xF8, t),
lerpi((ca >> 3) & 0xFC, (cb >> 3) & 0xFC, t),
lerpi((ca << 3) & 0xF8, (cb << 3) & 0xF8, t))
lerpi((ca << 3) & 0xF8, (cb << 3) & 0xF8, t),
)
from trezor.ui.style import *
# import style definitions
from trezor.ui.style import * # isort:skip
def contains(area: tuple, pos: tuple) -> bool:
@ -77,7 +75,7 @@ def pulse(delay: int):
yield 0.5 + 0.5 * math.sin(utime.ticks_us() / delay)
async def alert(count: int=3):
async def alert(count: int = 3):
short_sleep = loop.sleep(20000)
long_sleep = loop.sleep(80000)
current = display.backlight()
@ -104,7 +102,7 @@ async def click() -> tuple:
return pos
async def backlight_slide(val: int, delay: int=35000, step: int=20):
async def backlight_slide(val: int, delay: int = 35000, step: int = 20):
sleep = loop.sleep(delay)
current = display.backlight()
for i in range(current, val, -step if current > val else step):
@ -129,11 +127,9 @@ def layout(f):
return inner
def header(title: str,
icon: bytes=ICON_DEFAULT,
fg: int=FG,
bg: int=BG,
ifg: int=GREEN):
def header(
title: str, icon: bytes = ICON_DEFAULT, fg: int = FG, bg: int = BG, ifg: int = GREEN
):
if icon is not None:
display.icon(14, 15, res.load(icon), ifg, bg)
display.text(44, 35, title, BOLD, fg, bg)
@ -143,16 +139,18 @@ VIEWX = const(6)
VIEWY = const(9)
def grid(i: int,
n_x: int=3,
n_y: int=5,
start_x: int=VIEWX,
start_y: int=VIEWY,
end_x: int=(WIDTH - VIEWX),
end_y: int=(HEIGHT - VIEWY),
cells_x: int=1,
cells_y: int=1,
spacing: int=0):
def grid(
i: int,
n_x: int = 3,
n_y: int = 5,
start_x: int = VIEWX,
start_y: int = VIEWY,
end_x: int = (WIDTH - VIEWX),
end_y: int = (HEIGHT - VIEWY),
cells_x: int = 1,
cells_y: int = 1,
spacing: int = 0,
):
w = (end_x - start_x) // n_x
h = (end_y - start_y) // n_y
x = (i % n_x) * w

View File

@ -2,6 +2,8 @@ from trezor import io
from apps.common.storage import get_device_id
# fmt: off
# interface used for trezor wire protocol
iface_wire = io.WebUSB(
iface_num=0,