micropython-stubber 1.17.6__py3-none-any.whl → 1.20.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. {micropython_stubber-1.17.6.dist-info → micropython_stubber-1.20.0.dist-info}/METADATA +7 -6
  2. micropython_stubber-1.20.0.dist-info/RECORD +147 -0
  3. mpflash/README.md +18 -2
  4. mpflash/libusb_flash.ipynb +203 -0
  5. mpflash/mpflash/ask_input.py +234 -0
  6. mpflash/mpflash/cli_download.py +107 -0
  7. mpflash/mpflash/cli_flash.py +170 -0
  8. mpflash/mpflash/cli_group.py +40 -7
  9. mpflash/mpflash/cli_list.py +41 -0
  10. mpflash/mpflash/cli_main.py +13 -8
  11. mpflash/mpflash/common.py +33 -121
  12. mpflash/mpflash/config.py +9 -0
  13. mpflash/mpflash/{downloader.py → download.py} +110 -96
  14. mpflash/mpflash/downloaded.py +108 -0
  15. mpflash/mpflash/errors.py +5 -0
  16. mpflash/mpflash/flash.py +69 -0
  17. mpflash/mpflash/flash_esp.py +17 -23
  18. mpflash/mpflash/flash_stm32.py +16 -113
  19. mpflash/mpflash/flash_stm32_cube.py +111 -0
  20. mpflash/mpflash/flash_stm32_dfu.py +101 -0
  21. mpflash/mpflash/flash_uf2.py +8 -8
  22. mpflash/mpflash/flash_uf2_linux.py +13 -6
  23. mpflash/mpflash/flash_uf2_windows.py +24 -12
  24. mpflash/mpflash/list.py +56 -39
  25. mpflash/mpflash/logger.py +12 -13
  26. mpflash/mpflash/mpboard_id/__init__.py +96 -0
  27. mpflash/mpflash/mpboard_id/board_id.py +63 -0
  28. mpflash/mpflash/mpboard_id/board_info.csv +2213 -0
  29. mpflash/mpflash/mpboard_id/board_info.json +19910 -0
  30. mpflash/mpflash/mpremoteboard/__init__.py +209 -0
  31. mpflash/mpflash/mpremoteboard/mpy_fw_info.py +141 -0
  32. {stubber/bulk → mpflash/mpflash/mpremoteboard}/runner.py +19 -4
  33. mpflash/mpflash/vendor/dfu.py +164 -0
  34. mpflash/mpflash/vendor/pydfu.py +605 -0
  35. mpflash/mpflash/vendor/readme.md +3 -0
  36. mpflash/mpflash/vendor/versions.py +113 -0
  37. mpflash/mpflash/worklist.py +147 -0
  38. mpflash/poetry.lock +427 -610
  39. mpflash/pyproject.toml +22 -6
  40. mpflash/stm32_udev_rules.md +63 -0
  41. stubber/__init__.py +1 -1
  42. stubber/basicgit.py +1 -0
  43. stubber/board/createstubs.py +11 -4
  44. stubber/board/createstubs_db.py +11 -5
  45. stubber/board/createstubs_db_min.py +61 -58
  46. stubber/board/createstubs_db_mpy.mpy +0 -0
  47. stubber/board/createstubs_mem.py +11 -5
  48. stubber/board/createstubs_mem_min.py +56 -53
  49. stubber/board/createstubs_mem_mpy.mpy +0 -0
  50. stubber/board/createstubs_min.py +54 -51
  51. stubber/board/createstubs_mpy.mpy +0 -0
  52. stubber/board/modulelist.txt +1 -0
  53. stubber/bulk/mcu_stubber.py +9 -5
  54. stubber/codemod/_partials/db_main.py +14 -25
  55. stubber/codemod/_partials/lvgl_main.py +2 -2
  56. stubber/codemod/board.py +10 -3
  57. stubber/commands/clone_cmd.py +7 -7
  58. stubber/commands/config_cmd.py +3 -0
  59. stubber/commands/{mcu_cmd.py → get_mcu_cmd.py} +20 -3
  60. stubber/freeze/get_frozen.py +0 -2
  61. stubber/publish/candidates.py +1 -1
  62. stubber/publish/package.py +1 -1
  63. stubber/publish/pathnames.py +1 -1
  64. stubber/publish/stubpackage.py +1 -0
  65. stubber/rst/lookup.py +1 -1
  66. stubber/stubber.py +1 -9
  67. stubber/tools/manifestfile.py +5 -3
  68. stubber/update_fallback.py +104 -104
  69. stubber/utils/config.py +32 -36
  70. stubber/utils/repos.py +2 -2
  71. stubber/utils/versions.py +1 -0
  72. micropython_stubber-1.17.6.dist-info/RECORD +0 -132
  73. mpflash/mpflash/flasher.py +0 -276
  74. stubber/bulk/board_id.py +0 -40
  75. stubber/bulk/mpremoteboard.py +0 -141
  76. stubber/commands/get_lobo_cmd.py +0 -58
  77. stubber/commands/minify_cmd.py +0 -60
  78. stubber/commands/upd_fallback_cmd.py +0 -36
  79. stubber/commands/upd_module_list_cmd.py +0 -18
  80. {micropython_stubber-1.17.6.dist-info → micropython_stubber-1.20.0.dist-info}/LICENSE +0 -0
  81. {micropython_stubber-1.17.6.dist-info → micropython_stubber-1.20.0.dist-info}/WHEEL +0 -0
  82. {micropython_stubber-1.17.6.dist-info → micropython_stubber-1.20.0.dist-info}/entry_points.txt +0 -0
  83. /mpflash/mpflash/{uf2_boardid.py → flash_uf2_boardid.py} +0 -0
@@ -0,0 +1,96 @@
1
+ """
2
+ Access to the micropython port and board information that is stored in the board_info.json file
3
+ that is included in the module.
4
+
5
+ """
6
+
7
+ import json
8
+ from functools import lru_cache
9
+ from pathlib import Path
10
+ from typing import List, Optional, Tuple, TypedDict, Union
11
+
12
+ from mpflash.errors import MPFlashError
13
+ from mpflash.common import PORT_FWTYPES
14
+ from mpflash.vendor.versions import clean_version
15
+
16
+
17
+ # Board based on the dataclass Board but changed to TypedDict
18
+ # - source : get_boardnames.py
19
+ class Board(TypedDict):
20
+ """MicroPython Board definition"""
21
+
22
+ description: str
23
+ port: str
24
+ board: str
25
+ board_name: str
26
+ mcu_name: str
27
+ path: Union[Path, str]
28
+ version: str
29
+ cpu: str
30
+
31
+
32
+ @lru_cache(maxsize=None)
33
+ def read_stored_boardinfo() -> List[Board]:
34
+ """Reads the board_info.json file and returns the data as a list of Board objects"""
35
+ with open(Path(__file__).parent / "board_info.json", "r") as file:
36
+ return json.load(file)
37
+
38
+
39
+ def local_mp_ports() -> List[str]:
40
+ # TODO: Filter for Version
41
+ mp_boards = read_stored_boardinfo()
42
+ # select the unique ports from info
43
+ ports = set({board["port"] for board in mp_boards if board["port"] in PORT_FWTYPES.keys()})
44
+ return sorted(list(ports))
45
+
46
+
47
+ def get_stored_boards_for_port(port: str, versions: Optional[List[str]] = None):
48
+ """
49
+ Returns a list of boards for the given port and version(s)
50
+
51
+ port : str : The Micropython port to filter for
52
+ versions : List[str] : The Micropython versions to filter for (actual versions required)"""
53
+ mp_boards = read_stored_boardinfo()
54
+
55
+ # filter for 'preview' as they are not in the board_info.json
56
+ # instead use stable version
57
+ versions = versions or []
58
+ if "preview" in versions:
59
+ versions.remove("preview")
60
+ versions.append("stable")
61
+ if versions:
62
+ # make sure of the v prefix
63
+ versions = [clean_version(v) for v in versions]
64
+ # filter for the version(s)
65
+ mp_boards = [board for board in mp_boards if board["version"] in versions]
66
+ # filter for the port
67
+ mp_boards = [board for board in mp_boards if board["port"] == port]
68
+ return mp_boards
69
+
70
+
71
+ def known_stored_boards(port: str, versions: Optional[List[str]] = None) -> List[Tuple[str, str]]:
72
+ """
73
+ Returns a list of tuples with the description and board name for the given port and version
74
+
75
+ port : str : The Micropython port to filter for
76
+ versions : List[str] : The Micropython versions to filter for (actual versions required)
77
+ """
78
+ mp_boards = get_stored_boards_for_port(port, versions)
79
+
80
+ boards = set({(f'{board["version"]} {board["description"]}', board["board"]) for board in mp_boards})
81
+ return sorted(list(boards))
82
+
83
+
84
+ @lru_cache(maxsize=20)
85
+ def find_stored_board(board_id: str) -> Board:
86
+ """Find the board for the given board_ID or 'board description' and return the board info as a Board object"""
87
+ info = read_stored_boardinfo()
88
+ for board_info in info:
89
+ if board_id in (board_info["board"], board_info["description"]):
90
+ if "cpu" not in board_info or not board_info["cpu"]:
91
+ if " with " in board_info["description"]:
92
+ board_info["cpu"] = board_info["description"].split(" with ")[-1]
93
+ else:
94
+ board_info["cpu"] = board_info["port"]
95
+ return board_info
96
+ raise MPFlashError(f"Board {board_id} not found")
@@ -0,0 +1,63 @@
1
+ """
2
+ Translate board description to board designator
3
+ """
4
+
5
+ import functools
6
+ import json
7
+ from pathlib import Path
8
+ from typing import Optional
9
+
10
+ from mpflash.errors import MPFlashError
11
+ from mpflash.vendor.versions import clean_version
12
+
13
+ ###############################################################################################
14
+ HERE = Path(__file__).parent
15
+ ###############################################################################################
16
+
17
+
18
+ def find_board_id(
19
+ descr: str, short_descr: str, board_info: Optional[Path] = None, version: str = "stable"
20
+ ) -> Optional[str]:
21
+ # TODO: use the json file instead of the csv and get the cpu
22
+ boards = find_board_by_description(
23
+ descr=descr,
24
+ short_descr=short_descr,
25
+ board_info=board_info,
26
+ version=clean_version(version),
27
+ )
28
+ return boards[-1]["board"]
29
+
30
+
31
+ @functools.lru_cache(maxsize=20)
32
+ def find_board_by_description(*, descr: str, short_descr: str, version="v1.21.0", board_info: Optional[Path] = None):
33
+ """
34
+ Find the MicroPython BOARD designator based on the description in the firmware
35
+ using the pre-built board_info.json file
36
+ """
37
+ if not board_info:
38
+ board_info = HERE / "board_info.json"
39
+ if not board_info.exists():
40
+ raise FileNotFoundError(f"Board info file not found: {board_info}")
41
+
42
+ info = _read_board_info(board_info)
43
+
44
+ # filter for matching version
45
+ if version == "preview":
46
+ # TODO: match last stable
47
+ version = "v1.22.2"
48
+ version_matches = [b for b in info if b["version"].startswith(version)]
49
+ if not version_matches:
50
+ raise MPFlashError(f"No board info found for version {version}")
51
+ matches = [b for b in version_matches if b["description"] == descr]
52
+ if not matches and short_descr:
53
+ matches = [b for b in version_matches if b["description"] == short_descr]
54
+ if not matches:
55
+ raise MPFlashError(f"No board info found for description {descr}")
56
+ return sorted(matches, key=lambda x: x["version"])
57
+
58
+
59
+ @functools.lru_cache(maxsize=20)
60
+ def _read_board_info(board_info):
61
+ with open(board_info, "r") as file:
62
+ info = json.load(file)
63
+ return info