2016-04-26 23:32:57 +00:00
|
|
|
import sys
|
2016-04-27 19:07:37 +00:00
|
|
|
from TrezorUtils import Utils
|
|
|
|
|
|
|
|
_utils = Utils()
|
|
|
|
|
2016-04-28 05:44:15 +00:00
|
|
|
type_gen = type((lambda: (yield))())
|
|
|
|
|
2016-04-27 19:07:37 +00:00
|
|
|
def memaccess(address, length):
|
|
|
|
return _utils.memaccess(address, length)
|
2016-04-11 17:39:01 +00:00
|
|
|
|
2016-04-28 05:44:15 +00:00
|
|
|
def unimport_func(func):
|
|
|
|
def inner(*args, **kwargs):
|
|
|
|
mods = set(sys.modules)
|
|
|
|
try:
|
|
|
|
ret = func(*args, **kwargs)
|
|
|
|
finally:
|
|
|
|
for to_remove in set(sys.modules) - mods:
|
|
|
|
del sys.modules[to_remove]
|
|
|
|
return ret
|
|
|
|
return inner
|
|
|
|
|
|
|
|
def unimport_gen(gen):
|
2016-04-26 23:32:57 +00:00
|
|
|
def inner(*args, **kwargs):
|
|
|
|
mods = set(sys.modules)
|
2016-04-28 05:44:15 +00:00
|
|
|
try:
|
|
|
|
ret = yield from gen(*args, **kwargs)
|
|
|
|
finally:
|
|
|
|
for to_remove in set(sys.modules) - mods:
|
|
|
|
del sys.modules[to_remove]
|
2016-04-26 23:32:57 +00:00
|
|
|
return ret
|
|
|
|
return inner
|