1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +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
class Config:

View File

@ -1,3 +1,4 @@
from typing import *
# extmod/modtrezorcrypto/modtrezorcrypto-aes.h
class AES:
@ -5,7 +6,7 @@ class AES:
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.
'''

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
from typing import *
def calcsize(fmt: str) -> int: ...
def pack(fmt: str, *args: Any) -> bytes: ...
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):
for package, line in parts:
dir_path = os.path.abspath(dest)
dirpath = os.path.abspath(dest)
filename = package
if not os.path.exists(dir_path):
os.makedirs(dir_path)
open(os.path.join(dir_path, '__init__.py'), 'w').close()
open(os.path.join(dir_path, '.mock-generated'), 'w').close()
if not os.path.exists(dirpath):
os.makedirs(dirpath)
open(os.path.join(dirpath, '__init__.py'), '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)