1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-16 17:42:02 +00:00

mocks: add typing module

This commit is contained in:
Jan Pochyla 2017-06-14 19:27:02 +02:00
parent 803c47dca8
commit 181a2ad8c9
9 changed files with 23 additions and 7 deletions

View File

@ -1,3 +1,4 @@
from typing import *
# extmod/modtrezorconfig/modtrezorconfig.c # extmod/modtrezorconfig/modtrezorconfig.c
class Config: class Config:

View File

@ -1,3 +1,4 @@
from typing import *
# extmod/modtrezorcrypto/modtrezorcrypto-aes.h # extmod/modtrezorcrypto/modtrezorcrypto-aes.h
class AES: class AES:
@ -5,7 +6,7 @@ class AES:
AES context. AES context.
''' '''
def __init__(self, mode: int, key: bytes, iv: bytes = ...) -> None: def __init__(self, mode: int, key: bytes, iv: bytes = None) -> None:
''' '''
Initialize AES context. Initialize AES context.
''' '''

View File

@ -1,3 +1,4 @@
from typing import *
# extmod/modtrezorio/modtrezorio-sdcard.h # extmod/modtrezorio/modtrezorio-sdcard.h
class SDCard: class SDCard:

View File

@ -1,3 +1,4 @@
from typing import *
# extmod/modtrezormsg/modtrezormsg.c # extmod/modtrezormsg/modtrezormsg.c
class HID: class HID:

View File

@ -1,3 +1,4 @@
from typing import *
# extmod/modtrezorui/modtrezorui-display.h # extmod/modtrezorui/modtrezorui-display.h
class Display: class Display:

View File

@ -1,3 +1,4 @@
from typing import *
# extmod/modtrezorutils/modtrezorutils.c # extmod/modtrezorutils/modtrezorutils.c
def memcpy(dst: bytearray, dst_ofs: int, def memcpy(dst: bytearray, dst_ofs: int,

View File

@ -1,3 +1,5 @@
from typing import *
def exit(retval: Any = ...) -> None: def exit(retval: Any = ...) -> None:
raise SystemExit() raise SystemExit()

View File

@ -1,3 +1,5 @@
from typing import *
def calcsize(fmt: str) -> int: ... def calcsize(fmt: str) -> int: ...
def pack(fmt: str, *args: Any) -> bytes: ... def pack(fmt: str, *args: Any) -> bytes: ...
def pack_into(fmt: str, buffer: bytearray, offset: int, *args: Any) -> None: ... def pack_into(fmt: str, buffer: bytearray, offset: int, *args: Any) -> None: ...

View File

@ -38,15 +38,21 @@ def split_to_parts(line, mod_desc=None):
def store_to_file(dest, parts): def store_to_file(dest, parts):
for package, line in parts: for package, line in parts:
dir_path = os.path.abspath(dest) dirpath = os.path.abspath(dest)
filename = package filename = package
if not os.path.exists(dir_path): if not os.path.exists(dirpath):
os.makedirs(dir_path) os.makedirs(dirpath)
open(os.path.join(dir_path, '__init__.py'), 'w').close() open(os.path.join(dirpath, '__init__.py'), 'w').close()
open(os.path.join(dir_path, '.mock-generated'), 'w').close() open(os.path.join(dirpath, '.mock-generated'), 'w').close()
with open(os.path.join(dir_path, filename + '.py'), 'a') as f: filepath = os.path.join(dirpath, filename + '.py')
if not os.path.exists(filepath):
with open(filepath, 'a') as f:
f.write('from typing import *\n')
with open(filepath, 'a') as f:
f.write(line) f.write(line)