diff --git a/python/helper-scripts/relicence.py b/python/helper-scripts/relicence.py index 94e3c6531..85deb81a6 100755 --- a/python/helper-scripts/relicence.py +++ b/python/helper-scripts/relicence.py @@ -24,7 +24,8 @@ SHEBANG_HEADER = """\ """ -EXCLUDE_FILES = ["trezorlib/__init__.py", "trezorlib/_ed25519.py"] +EXCLUDE_FILES = ["src/trezorlib/__init__.py", "src/trezorlib/_ed25519.py"] +EXCLUDE_DIRS = ["src/trezorlib/messages"] def one_file(fp): @@ -56,14 +57,22 @@ def one_file(fp): import glob import os +import sys -for fn in glob.glob("trezorlib/**/*.py", recursive=True): - if fn.startswith("trezorlib/messages/"): - continue - if fn in EXCLUDE_FILES: - continue - statinfo = os.stat(fn) - if statinfo.st_size == 0: - continue - with open(fn, "r+") as fp: - one_file(fp) + +def main(paths): + for path in paths: + for fn in glob.glob(f"{path}/**/*.py", recursive=True): + if any(exclude in fn for exclude in EXCLUDE_DIRS): + continue + if fn in EXCLUDE_FILES: + continue + statinfo = os.stat(fn) + if statinfo.st_size == 0: + continue + with open(fn, "r+") as fp: + one_file(fp) + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/tests/device_tests/common.py b/tests/device_tests/common.py index 27be144cb..373b1ab04 100644 --- a/tests/device_tests/common.py +++ b/tests/device_tests/common.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - from trezorlib.messages import ButtonRequestType as B # fmt: off diff --git a/tests/device_tests/test_basic.py b/tests/device_tests/test_basic.py index 189a7a9f8..d4ec51632 100644 --- a/tests/device_tests/test_basic.py +++ b/tests/device_tests/test_basic.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - from trezorlib import device, messages from .common import TrezorTest diff --git a/tests/device_tests/test_msg_binance_get_address.py b/tests/device_tests/test_msg_binance_get_address.py index fb89cbc64..8fe0845fd 100644 --- a/tests/device_tests/test_msg_binance_get_address.py +++ b/tests/device_tests/test_msg_binance_get_address.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import pytest from trezorlib.binance import get_address diff --git a/tests/device_tests/test_msg_binance_get_public_key.py b/tests/device_tests/test_msg_binance_get_public_key.py index 8d253444a..97c9ccab2 100644 --- a/tests/device_tests/test_msg_binance_get_public_key.py +++ b/tests/device_tests/test_msg_binance_get_public_key.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import pytest from trezorlib import binance diff --git a/tests/device_tests/test_msg_binance_sign_tx.py b/tests/device_tests/test_msg_binance_sign_tx.py index 05411730b..b7da21d0c 100644 --- a/tests/device_tests/test_msg_binance_sign_tx.py +++ b/tests/device_tests/test_msg_binance_sign_tx.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import pytest from trezorlib import binance diff --git a/tests/device_tests/test_msg_eos_signtx.py b/tests/device_tests/test_msg_eos_signtx.py index 234f2cd2c..b4ba05132 100644 --- a/tests/device_tests/test_msg_eos_signtx.py +++ b/tests/device_tests/test_msg_eos_signtx.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - import pytest from trezorlib import eos diff --git a/tests/device_tests/test_msg_nem_signtx_mosaics_t2.py b/tests/device_tests/test_msg_nem_signtx_mosaics_t2.py index d7c775d93..b815268e9 100644 --- a/tests/device_tests/test_msg_nem_signtx_mosaics_t2.py +++ b/tests/device_tests/test_msg_nem_signtx_mosaics_t2.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - import pytest from trezorlib import messages as proto, nem diff --git a/tests/device_tests/test_msg_recoverydevice_shamir.py b/tests/device_tests/test_msg_recoverydevice_shamir.py index d8ded7897..c89abd199 100644 --- a/tests/device_tests/test_msg_recoverydevice_shamir.py +++ b/tests/device_tests/test_msg_recoverydevice_shamir.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - import pytest from trezorlib import device, exceptions, messages diff --git a/tests/device_tests/test_msg_recoverydevice_shamir_dryrun.py b/tests/device_tests/test_msg_recoverydevice_shamir_dryrun.py index ac8074aee..af178daf2 100644 --- a/tests/device_tests/test_msg_recoverydevice_shamir_dryrun.py +++ b/tests/device_tests/test_msg_recoverydevice_shamir_dryrun.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import pytest from trezorlib import device, messages diff --git a/tests/device_tests/test_msg_recoverydevice_supershamir.py b/tests/device_tests/test_msg_recoverydevice_supershamir.py index 4bd72364e..90c20c2ad 100644 --- a/tests/device_tests/test_msg_recoverydevice_supershamir.py +++ b/tests/device_tests/test_msg_recoverydevice_supershamir.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - import pytest from trezorlib import device, exceptions, messages diff --git a/tests/device_tests/test_msg_recoverydevice_supershamir_dryrun.py b/tests/device_tests/test_msg_recoverydevice_supershamir_dryrun.py index d95af91fa..89a834291 100644 --- a/tests/device_tests/test_msg_recoverydevice_supershamir_dryrun.py +++ b/tests/device_tests/test_msg_recoverydevice_supershamir_dryrun.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import pytest from trezorlib import device, messages diff --git a/tests/device_tests/test_msg_recoverydevice_t2.py b/tests/device_tests/test_msg_recoverydevice_t2.py index 699bf10ab..8b72ae376 100644 --- a/tests/device_tests/test_msg_recoverydevice_t2.py +++ b/tests/device_tests/test_msg_recoverydevice_t2.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - import pytest from trezorlib import device, messages as proto diff --git a/tests/device_tests/test_msg_resetdevice_shamir.py b/tests/device_tests/test_msg_resetdevice_shamir.py index 373433561..07a558e47 100644 --- a/tests/device_tests/test_msg_resetdevice_shamir.py +++ b/tests/device_tests/test_msg_resetdevice_shamir.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + from itertools import combinations from unittest import mock diff --git a/tests/device_tests/test_msg_resetdevice_supershamir.py b/tests/device_tests/test_msg_resetdevice_supershamir.py index 481ff147b..44db92162 100644 --- a/tests/device_tests/test_msg_resetdevice_supershamir.py +++ b/tests/device_tests/test_msg_resetdevice_supershamir.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + from unittest import mock import pytest diff --git a/tests/device_tests/test_msg_signtx_segwit_native.py b/tests/device_tests/test_msg_signtx_segwit_native.py index 7363901be..663894d5b 100644 --- a/tests/device_tests/test_msg_signtx_segwit_native.py +++ b/tests/device_tests/test_msg_signtx_segwit_native.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - from trezorlib import btc, messages as proto from trezorlib.ckd_public import deserialize from trezorlib.tools import H_, parse_path diff --git a/tests/device_tests/test_msg_tezos_sign_tx.py b/tests/device_tests/test_msg_tezos_sign_tx.py index 3c92e7e98..da39f6930 100644 --- a/tests/device_tests/test_msg_tezos_sign_tx.py +++ b/tests/device_tests/test_msg_tezos_sign_tx.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - import pytest from trezorlib import messages, tezos diff --git a/tests/device_tests/test_msg_verifymessage_segwit.py b/tests/device_tests/test_msg_verifymessage_segwit.py index 5c4312548..53bec957e 100644 --- a/tests/device_tests/test_msg_verifymessage_segwit.py +++ b/tests/device_tests/test_msg_verifymessage_segwit.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - from trezorlib import btc from .common import TrezorTest diff --git a/tests/device_tests/test_msg_verifymessage_segwit_native.py b/tests/device_tests/test_msg_verifymessage_segwit_native.py index e5cadf08d..54e1c9387 100644 --- a/tests/device_tests/test_msg_verifymessage_segwit_native.py +++ b/tests/device_tests/test_msg_verifymessage_segwit_native.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - from trezorlib import btc from .common import TrezorTest diff --git a/tests/device_tests/test_shamir_passphrase.py b/tests/device_tests/test_shamir_passphrase.py index 2e09b37d4..5d1829687 100644 --- a/tests/device_tests/test_shamir_passphrase.py +++ b/tests/device_tests/test_shamir_passphrase.py @@ -14,7 +14,6 @@ # You should have received a copy of the License along with this library. # If not, see . - import pytest from trezorlib import btc diff --git a/tests/device_tests/test_shamir_reset_recovery.py b/tests/device_tests/test_shamir_reset_recovery.py index 75c4c59af..1ea0c5345 100644 --- a/tests/device_tests/test_shamir_reset_recovery.py +++ b/tests/device_tests/test_shamir_reset_recovery.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import itertools import pytest diff --git a/tests/device_tests/test_shamir_reset_recovery_groups.py b/tests/device_tests/test_shamir_reset_recovery_groups.py index 9387b6d00..60eb2cb4b 100644 --- a/tests/device_tests/test_shamir_reset_recovery_groups.py +++ b/tests/device_tests/test_shamir_reset_recovery_groups.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import pytest from trezorlib import btc, device, messages diff --git a/tests/upgrade_tests/emulator_wrapper.py b/tests/upgrade_tests/emulator_wrapper.py index adbb22f30..e05fa27b3 100644 --- a/tests/upgrade_tests/emulator_wrapper.py +++ b/tests/upgrade_tests/emulator_wrapper.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import os import subprocess import tempfile diff --git a/tests/upgrade_tests/test_firmware_upgrades.py b/tests/upgrade_tests/test_firmware_upgrades.py index 0cc67133e..533c91983 100644 --- a/tests/upgrade_tests/test_firmware_upgrades.py +++ b/tests/upgrade_tests/test_firmware_upgrades.py @@ -1,3 +1,19 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + import os from collections import defaultdict