mpflash 1.0.1__py3-none-any.whl → 1.0.3__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 (53) hide show
  1. mpflash/add_firmware.py +98 -98
  2. mpflash/ask_input.py +236 -236
  3. mpflash/basicgit.py +284 -284
  4. mpflash/bootloader/__init__.py +2 -2
  5. mpflash/bootloader/activate.py +60 -60
  6. mpflash/bootloader/detect.py +82 -82
  7. mpflash/bootloader/manual.py +101 -101
  8. mpflash/bootloader/micropython.py +12 -12
  9. mpflash/bootloader/touch1200.py +36 -36
  10. mpflash/cli_download.py +129 -129
  11. mpflash/cli_flash.py +224 -216
  12. mpflash/cli_group.py +111 -111
  13. mpflash/cli_list.py +87 -87
  14. mpflash/cli_main.py +39 -39
  15. mpflash/common.py +210 -177
  16. mpflash/config.py +44 -44
  17. mpflash/connected.py +96 -77
  18. mpflash/download.py +364 -364
  19. mpflash/downloaded.py +130 -130
  20. mpflash/errors.py +9 -9
  21. mpflash/flash/__init__.py +55 -55
  22. mpflash/flash/esp.py +59 -59
  23. mpflash/flash/stm32.py +19 -19
  24. mpflash/flash/stm32_dfu.py +104 -104
  25. mpflash/flash/uf2/__init__.py +88 -88
  26. mpflash/flash/uf2/boardid.py +15 -15
  27. mpflash/flash/uf2/linux.py +136 -130
  28. mpflash/flash/uf2/macos.py +42 -42
  29. mpflash/flash/uf2/uf2disk.py +12 -12
  30. mpflash/flash/uf2/windows.py +43 -43
  31. mpflash/flash/worklist.py +170 -170
  32. mpflash/list.py +106 -106
  33. mpflash/logger.py +41 -41
  34. mpflash/mpboard_id/__init__.py +93 -93
  35. mpflash/mpboard_id/add_boards.py +251 -251
  36. mpflash/mpboard_id/board.py +37 -37
  37. mpflash/mpboard_id/board_id.py +86 -86
  38. mpflash/mpboard_id/boardinfo.csv +2389 -0
  39. mpflash/mpboard_id/store.py +48 -43
  40. mpflash/mpremoteboard/__init__.py +266 -266
  41. mpflash/mpremoteboard/mpy_fw_info.py +152 -141
  42. mpflash/mpremoteboard/runner.py +140 -140
  43. mpflash/vendor/click_aliases.py +91 -91
  44. mpflash/vendor/dfu.py +165 -165
  45. mpflash/vendor/pydfu.py +605 -605
  46. mpflash/vendor/readme.md +2 -2
  47. mpflash/versions.py +135 -135
  48. {mpflash-1.0.1.dist-info → mpflash-1.0.3.dist-info}/LICENSE +20 -20
  49. {mpflash-1.0.1.dist-info → mpflash-1.0.3.dist-info}/METADATA +1 -1
  50. mpflash-1.0.3.dist-info/RECORD +54 -0
  51. mpflash-1.0.1.dist-info/RECORD +0 -53
  52. {mpflash-1.0.1.dist-info → mpflash-1.0.3.dist-info}/WHEEL +0 -0
  53. {mpflash-1.0.1.dist-info → mpflash-1.0.3.dist-info}/entry_points.txt +0 -0
@@ -1,86 +1,86 @@
1
- """
2
- Translate board description to board designator
3
- """
4
-
5
- import functools
6
- from pathlib import Path
7
- from typing import Optional
8
-
9
- from mpflash.errors import MPFlashError
10
- from mpflash.logger import log
11
- from mpflash.mpboard_id.store import read_known_boardinfo
12
- from mpflash.versions import clean_version, get_stable_mp_version
13
-
14
-
15
- def find_board_id_by_description(
16
- descr: str,
17
- short_descr: str,
18
- *,
19
- version: str,
20
- board_info: Optional[Path] = None,
21
- ) -> Optional[str]:
22
- """Find the MicroPython BOARD_ID based on the description in the firmware"""
23
-
24
- try:
25
- boards = _find_board_id_by_description(
26
- descr=descr,
27
- short_descr=short_descr,
28
- board_info=board_info,
29
- version=clean_version(version) if version else None,
30
- )
31
- return boards[-1].board_id
32
- except MPFlashError:
33
- return "UNKNOWN_BOARD"
34
-
35
-
36
- @functools.lru_cache(maxsize=20)
37
- def _find_board_id_by_description(
38
- *,
39
- descr: str,
40
- short_descr: str,
41
- version: Optional[str] = None,
42
- board_info: Optional[Path] = None,
43
- ):
44
- """
45
- Find the MicroPython BOARD_ID based on the description in the firmware
46
- using the pre-built board_info.json file
47
-
48
- Parameters:
49
- descr: str
50
- Description of the board
51
- short_descr: str
52
- Short description of the board (optional)
53
- version: str
54
- Version of the MicroPython firmware
55
- board_info: Path
56
- Path to the board_info.json file (optional)
57
-
58
- """
59
- # FIXME: functional overlap with
60
- # src\mpflash\mpflash\mpboard_id\__init__.py find_known_board
61
-
62
- if not short_descr and " with " in descr:
63
- short_descr = descr.split(" with ")[0]
64
-
65
- candidate_boards = read_known_boardinfo(board_info)
66
-
67
- if version:
68
- # filter for matching version
69
- if version in ("preview", "stable"):
70
- # match last stable
71
- version = get_stable_mp_version()
72
- known_versions = sorted({b.version for b in candidate_boards})
73
- if version not in known_versions:
74
- # FIXME if latest stable is newer than the last version in the boardlist this will fail
75
- log.trace(f"Version {version} not found in board info, using latest known version {known_versions[-1]}")
76
- version = known_versions[-1]
77
- if version_matches := [b for b in candidate_boards if b.version.startswith(version)]:
78
- candidate_boards = version_matches
79
- else:
80
- raise MPFlashError(f"No board info found for version {version}")
81
- matches = [b for b in candidate_boards if b.description == descr]
82
- if not matches and short_descr:
83
- matches = [b for b in candidate_boards if b.description == short_descr]
84
- if not matches:
85
- raise MPFlashError(f"No board info found for description '{descr}' or '{short_descr}'")
86
- return sorted(matches, key=lambda x: x.version)
1
+ """
2
+ Translate board description to board designator
3
+ """
4
+
5
+ import functools
6
+ from pathlib import Path
7
+ from typing import Optional
8
+
9
+ from mpflash.errors import MPFlashError
10
+ from mpflash.logger import log
11
+ from mpflash.mpboard_id.store import read_known_boardinfo
12
+ from mpflash.versions import clean_version, get_stable_mp_version
13
+
14
+
15
+ def find_board_id_by_description(
16
+ descr: str,
17
+ short_descr: str,
18
+ *,
19
+ version: str,
20
+ board_info: Optional[Path] = None,
21
+ ) -> Optional[str]:
22
+ """Find the MicroPython BOARD_ID based on the description in the firmware"""
23
+
24
+ try:
25
+ boards = _find_board_id_by_description(
26
+ descr=descr,
27
+ short_descr=short_descr,
28
+ board_info=board_info,
29
+ version=clean_version(version) if version else None,
30
+ )
31
+ return boards[-1].board_id
32
+ except MPFlashError:
33
+ return "UNKNOWN_BOARD"
34
+
35
+
36
+ @functools.lru_cache(maxsize=20)
37
+ def _find_board_id_by_description(
38
+ *,
39
+ descr: str,
40
+ short_descr: str,
41
+ version: Optional[str] = None,
42
+ board_info: Optional[Path] = None,
43
+ ):
44
+ """
45
+ Find the MicroPython BOARD_ID based on the description in the firmware
46
+ using the pre-built board_info.json file
47
+
48
+ Parameters:
49
+ descr: str
50
+ Description of the board
51
+ short_descr: str
52
+ Short description of the board (optional)
53
+ version: str
54
+ Version of the MicroPython firmware
55
+ board_info: Path
56
+ Path to the board_info.json file (optional)
57
+
58
+ """
59
+ # FIXME: functional overlap with
60
+ # src\mpflash\mpflash\mpboard_id\__init__.py find_known_board
61
+
62
+ if not short_descr and " with " in descr:
63
+ short_descr = descr.split(" with ")[0]
64
+
65
+ candidate_boards = read_known_boardinfo(board_info)
66
+
67
+ if version:
68
+ # filter for matching version
69
+ if version in ("preview", "stable"):
70
+ # match last stable
71
+ version = get_stable_mp_version()
72
+ known_versions = sorted({b.version for b in candidate_boards})
73
+ if version not in known_versions:
74
+ # FIXME if latest stable is newer than the last version in the boardlist this will fail
75
+ log.trace(f"Version {version} not found in board info, using latest known version {known_versions[-1]}")
76
+ version = known_versions[-1]
77
+ if version_matches := [b for b in candidate_boards if b.version.startswith(version)]:
78
+ candidate_boards = version_matches
79
+ else:
80
+ raise MPFlashError(f"No board info found for version {version}")
81
+ matches = [b for b in candidate_boards if b.description == descr]
82
+ if not matches and short_descr:
83
+ matches = [b for b in candidate_boards if b.description == short_descr]
84
+ if not matches:
85
+ raise MPFlashError(f"No board info found for description '{descr}' or '{short_descr}'")
86
+ return sorted(matches, key=lambda x: x.version)