micropython-stubber 1.24.1__py3-none-any.whl → 1.24.4__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 (90) hide show
  1. {micropython_stubber-1.24.1.dist-info → micropython_stubber-1.24.4.dist-info}/METADATA +9 -29
  2. micropython_stubber-1.24.4.dist-info/RECORD +107 -0
  3. {micropython_stubber-1.24.1.dist-info → micropython_stubber-1.24.4.dist-info}/WHEEL +1 -1
  4. stubber/__init__.py +1 -1
  5. stubber/board/createstubs.py +44 -38
  6. stubber/board/createstubs_db.py +17 -12
  7. stubber/board/createstubs_db_min.py +63 -63
  8. stubber/board/createstubs_db_mpy.mpy +0 -0
  9. stubber/board/createstubs_mem.py +17 -12
  10. stubber/board/createstubs_mem_min.py +99 -99
  11. stubber/board/createstubs_mem_mpy.mpy +0 -0
  12. stubber/board/createstubs_min.py +111 -112
  13. stubber/board/createstubs_mpy.mpy +0 -0
  14. stubber/board/modulelist.txt +27 -27
  15. stubber/codemod/board.py +1 -1
  16. stubber/codemod/enrich.py +13 -13
  17. stubber/codemod/merge_docstub.py +83 -53
  18. stubber/codemod/visitors/type_helpers.py +143 -41
  19. stubber/commands/enrich_folder_cmd.py +17 -17
  20. stubber/commands/get_docstubs_cmd.py +27 -9
  21. stubber/commands/get_frozen_cmd.py +1 -0
  22. stubber/commands/merge_cmd.py +2 -4
  23. stubber/merge_config.py +5 -36
  24. stubber/minify.py +3 -3
  25. stubber/modcat.py +118 -0
  26. stubber/publish/merge_docstubs.py +22 -5
  27. stubber/publish/stubpackage.py +33 -28
  28. stubber/rst/lookup.py +6 -23
  29. stubber/rst/reader.py +8 -13
  30. stubber/stubs_from_docs.py +2 -1
  31. stubber/tools/manifestfile.py +2 -1
  32. stubber/{cst_transformer.py → typing_collector.py} +36 -4
  33. micropython_stubber-1.24.1.dist-info/RECORD +0 -161
  34. mpflash/README.md +0 -220
  35. mpflash/libusb_flash.ipynb +0 -203
  36. mpflash/mpflash/__init__.py +0 -0
  37. mpflash/mpflash/add_firmware.py +0 -98
  38. mpflash/mpflash/ask_input.py +0 -236
  39. mpflash/mpflash/basicgit.py +0 -324
  40. mpflash/mpflash/bootloader/__init__.py +0 -2
  41. mpflash/mpflash/bootloader/activate.py +0 -60
  42. mpflash/mpflash/bootloader/detect.py +0 -82
  43. mpflash/mpflash/bootloader/manual.py +0 -101
  44. mpflash/mpflash/bootloader/micropython.py +0 -12
  45. mpflash/mpflash/bootloader/touch1200.py +0 -36
  46. mpflash/mpflash/cli_download.py +0 -129
  47. mpflash/mpflash/cli_flash.py +0 -224
  48. mpflash/mpflash/cli_group.py +0 -111
  49. mpflash/mpflash/cli_list.py +0 -87
  50. mpflash/mpflash/cli_main.py +0 -39
  51. mpflash/mpflash/common.py +0 -217
  52. mpflash/mpflash/config.py +0 -44
  53. mpflash/mpflash/connected.py +0 -96
  54. mpflash/mpflash/download.py +0 -364
  55. mpflash/mpflash/downloaded.py +0 -138
  56. mpflash/mpflash/errors.py +0 -9
  57. mpflash/mpflash/flash/__init__.py +0 -55
  58. mpflash/mpflash/flash/esp.py +0 -59
  59. mpflash/mpflash/flash/stm32.py +0 -19
  60. mpflash/mpflash/flash/stm32_dfu.py +0 -104
  61. mpflash/mpflash/flash/uf2/__init__.py +0 -88
  62. mpflash/mpflash/flash/uf2/boardid.py +0 -15
  63. mpflash/mpflash/flash/uf2/linux.py +0 -136
  64. mpflash/mpflash/flash/uf2/macos.py +0 -42
  65. mpflash/mpflash/flash/uf2/uf2disk.py +0 -12
  66. mpflash/mpflash/flash/uf2/windows.py +0 -43
  67. mpflash/mpflash/flash/worklist.py +0 -170
  68. mpflash/mpflash/list.py +0 -106
  69. mpflash/mpflash/logger.py +0 -41
  70. mpflash/mpflash/mpboard_id/__init__.py +0 -98
  71. mpflash/mpflash/mpboard_id/add_boards.py +0 -262
  72. mpflash/mpflash/mpboard_id/board.py +0 -37
  73. mpflash/mpflash/mpboard_id/board_id.py +0 -90
  74. mpflash/mpflash/mpboard_id/board_info.zip +0 -0
  75. mpflash/mpflash/mpboard_id/store.py +0 -48
  76. mpflash/mpflash/mpremoteboard/__init__.py +0 -271
  77. mpflash/mpflash/mpremoteboard/mpy_fw_info.py +0 -152
  78. mpflash/mpflash/mpremoteboard/runner.py +0 -140
  79. mpflash/mpflash/vendor/board_database.py +0 -185
  80. mpflash/mpflash/vendor/click_aliases.py +0 -91
  81. mpflash/mpflash/vendor/dfu.py +0 -165
  82. mpflash/mpflash/vendor/pydfu.py +0 -605
  83. mpflash/mpflash/vendor/readme.md +0 -12
  84. mpflash/mpflash/versions.py +0 -123
  85. mpflash/poetry.lock +0 -2603
  86. mpflash/pyproject.toml +0 -66
  87. mpflash/stm32_udev_rules.md +0 -63
  88. stubber/codemod/test_enrich.py +0 -87
  89. {micropython_stubber-1.24.1.dist-info → micropython_stubber-1.24.4.dist-info}/LICENSE +0 -0
  90. {micropython_stubber-1.24.1.dist-info → micropython_stubber-1.24.4.dist-info}/entry_points.txt +0 -0
@@ -1,185 +0,0 @@
1
- """
2
- The micropython git repo contains many 'board.json' files.
3
-
4
- This is an example:
5
- ports/stm32/boards/PYBV11/board.json
6
-
7
- {
8
- "deploy": [
9
- "../PYBV10/deploy.md"
10
- ],
11
- "docs": "",
12
- "features": [],
13
- "images": [
14
- "PYBv1_1.jpg",
15
- "PYBv1_1-C.jpg",
16
- "PYBv1_1-E.jpg"
17
- ],
18
- "mcu": "stm32f4",
19
- "product": "Pyboard v1.1",
20
- "thumbnail": "",
21
- "url": "https://store.micropython.org/product/PYBv1.1",
22
- "variants": {
23
- "DP": "Double-precision float",
24
- "DP_THREAD": "Double precision float + Threads",
25
- "NETWORK": "Wiznet 5200 Driver",
26
- "THREAD": "Threading"
27
- },
28
- "vendor": "George Robotics"
29
- }
30
-
31
- This module implements `class Database` which reads all 'board.json' files and
32
- provides a way to browse it's data.
33
- """
34
-
35
- from __future__ import annotations
36
-
37
- import json
38
- from dataclasses import dataclass, field
39
- from glob import glob
40
- from pathlib import Path
41
-
42
-
43
- @dataclass(order=True)
44
- class Variant:
45
- name: str
46
- """
47
- Example: "DP_THREAD"
48
- """
49
- text: str
50
- """
51
- Example: "Double precision float + Threads"
52
- """
53
- board: Board = field(repr=False)
54
-
55
-
56
- @dataclass(order=True)
57
- class Board:
58
- name: str
59
- """
60
- Example: "PYBV11"
61
- """
62
- variants: list[Variant]
63
- """
64
- List of variants available for this board.
65
- Variants are sorted. May be an empty list if no variants are available.
66
- Example key: "DP_THREAD"
67
- """
68
- url: str
69
- """
70
- Primary URL to link to this board.
71
- """
72
- mcu: str
73
- """
74
- Example: "stm32f4"
75
- """
76
- product: str
77
- """
78
- Example: "Pyboard v1.1"
79
- """
80
- vendor: str
81
- """
82
- Example: "George Robotics"
83
- """
84
- images: list[str]
85
- """
86
- Images of this board, stored in the micropython-media repository.
87
- Example: ["PYBv1_1.jpg", "PYBv1_1-C.jpg", "PYBv1_1-E.jpg"]
88
- """
89
- deploy: list[str]
90
- """
91
- Files that explain how to deploy for this board:
92
- Example: ["../PYBV10/deploy.md"]
93
- """
94
- port: Port | None = field(default=None, compare=False)
95
-
96
- @staticmethod
97
- def factory(filename_json: Path) -> Board:
98
- with filename_json.open() as f:
99
- board_json = json.load(f)
100
-
101
- board = Board(
102
- name=filename_json.parent.name,
103
- variants=[],
104
- url=board_json["url"],
105
- mcu=board_json["mcu"],
106
- product=board_json["product"],
107
- vendor=board_json["vendor"],
108
- images=board_json["images"],
109
- deploy=board_json["deploy"],
110
- )
111
- board.variants.extend(
112
- sorted([Variant(*v, board) for v in board_json.get("variants", {}).items()]) # type: ignore
113
- )
114
- return board
115
-
116
-
117
- @dataclass(order=True)
118
- class Port:
119
- name: str
120
- """
121
- Example: "stm32"
122
- """
123
- boards: dict[str, Board] = field(default_factory=dict, repr=False)
124
- """
125
- Example key: "PYBV11"
126
- """
127
-
128
-
129
- @dataclass
130
- class Database:
131
- """
132
- This database contains all information retrieved from all 'board.json' files.
133
- """
134
-
135
- mpy_root_directory: Path = field(repr=False)
136
- port_filter: str = field(default="", repr=False)
137
-
138
- ports: dict[str, Port] = field(default_factory=dict)
139
- boards: dict[str, Board] = field(default_factory=dict)
140
-
141
- def __post_init__(self) -> None:
142
- mpy_dir = self.mpy_root_directory
143
- # Take care to avoid using Path.glob! Performance was 15x slower.
144
- for p in glob(f"{mpy_dir}/ports/**/boards/**/board.json"):
145
- filename_json = Path(p)
146
- port_name = filename_json.parent.parent.parent.name
147
- if self.port_filter and self.port_filter != port_name:
148
- continue
149
-
150
- # Create a port
151
- port = self.ports.get(port_name, None)
152
- if port is None:
153
- port = Port(port_name)
154
- self.ports[port_name] = port
155
-
156
- # Load board.json and attach it to the board
157
- board = Board.factory(filename_json)
158
- board.port = port
159
-
160
- port.boards[board.name] = board
161
- self.boards[board.name] = board
162
-
163
- # Add 'special' ports, that don't have boards
164
- # TODO(mst) Tidy up later (variant descriptions etc)
165
- for special_port_name in ["unix", "webassembly", "windows"]:
166
- if self.port_filter and self.port_filter != special_port_name:
167
- continue
168
- path = Path(mpy_dir, "ports", special_port_name)
169
- variant_names = [var.name for var in path.glob("variants/*") if var.is_dir()]
170
- board = Board(
171
- special_port_name,
172
- [],
173
- f"https://github.com/micropython/micropython/blob/master/ports/{special_port_name}/README.md",
174
- "",
175
- "",
176
- "",
177
- [],
178
- [],
179
- )
180
- board.variants = [Variant(v, "", board) for v in variant_names]
181
- port = Port(special_port_name, {special_port_name: board})
182
- board.port = port
183
-
184
- self.ports[special_port_name] = port
185
- self.boards[board.name] = board
@@ -1,91 +0,0 @@
1
- # Copyright (c) 2016 Robbin Bonthond
2
-
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
-
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- # ------------------------------------------------------------------------------------
13
- # modified to avoid conflcts with rich_click
14
-
15
- # sourcery skip: assign-if-exp, use-named-expression
16
-
17
- import rich_click as click
18
-
19
- _click7 = click.__version__[0] >= "7"
20
-
21
-
22
- class ClickAliasedGroup(click.RichGroup):
23
- def __init__(self, *args, **kwargs):
24
- super().__init__(*args, **kwargs)
25
- self._commands = {}
26
- self._aliases = {}
27
-
28
- def add_command(self, *args, **kwargs):
29
- aliases = kwargs.pop("aliases", [])
30
- super().add_command(*args, **kwargs)
31
- if aliases:
32
- cmd = args[0]
33
- name = args[1] if len(args) > 1 else None
34
- name = name or cmd.name
35
- if name is None:
36
- raise TypeError("Command has no name.")
37
-
38
- self._commands[name] = aliases
39
- for alias in aliases:
40
- self._aliases[alias] = cmd.name
41
-
42
- def command(self, *args, **kwargs):
43
- aliases = kwargs.pop("aliases", [])
44
- decorator = super().command(*args, **kwargs)
45
- if not aliases:
46
- return decorator
47
-
48
- def _decorator(f):
49
- cmd = decorator(f)
50
- if aliases:
51
- self._commands[cmd.name] = aliases
52
- for alias in aliases:
53
- self._aliases[alias] = cmd.name
54
- return cmd
55
-
56
- return _decorator
57
-
58
- def group(self, *args, **kwargs):
59
- aliases = kwargs.pop("aliases", [])
60
- decorator = super().group(*args, **kwargs)
61
- if not aliases:
62
- return decorator
63
-
64
- def _decorator(f):
65
- cmd = decorator(f)
66
- if aliases:
67
- self._commands[cmd.name] = aliases
68
- for alias in aliases:
69
- self._aliases[alias] = cmd.name
70
- return cmd
71
-
72
- return _decorator
73
-
74
- def resolve_alias(self, cmd_name):
75
- if cmd_name in self._aliases:
76
- return self._aliases[cmd_name]
77
- return cmd_name
78
-
79
- def get_command(self, ctx, cmd_name):
80
- cmd_name = self.resolve_alias(cmd_name)
81
- command = super().get_command(ctx, cmd_name)
82
- if command:
83
- return command
84
- return None
85
-
86
- # def format_commands(self, ctx, formatter):
87
- # TODO: output alias with commands - but that is a significant re-write
88
- # for now add alias to help text
89
-
90
-
91
- # ------------------------------------------------------------------------------------
@@ -1,165 +0,0 @@
1
- # sourcery skip: require-parameter-annotation
2
- # sourcery skip: replace-interpolation-with-fstring
3
- # type: ignore
4
- #!/usr/bin/python
5
-
6
- # Written by Antonio Galea - 2010/11/18
7
- # Distributed under Gnu LGPL 3.0
8
- # see http://www.gnu.org/licenses/lgpl-3.0.txt
9
-
10
- import os
11
- import struct
12
- import sys
13
- import zlib
14
- from optparse import OptionParser
15
-
16
- DEFAULT_DEVICE = "0x0483:0xdf11"
17
-
18
-
19
- def named(tuple, names):
20
- return dict(zip(names.split(), tuple))
21
-
22
-
23
- def consume(fmt, data, names):
24
- n = struct.calcsize(fmt)
25
- return named(struct.unpack(fmt, data[:n]), names), data[n:]
26
-
27
-
28
- def cstring(string):
29
- return string.split(b"\0", 1)[0]
30
-
31
-
32
- def compute_crc(data):
33
- return 0xFFFFFFFF & -zlib.crc32(data) - 1
34
-
35
-
36
- def parse(file, dump_images=False):
37
- print('File: "%s"' % file)
38
- data = open(file, "rb").read()
39
- crc = compute_crc(data[:-4])
40
- prefix, data = consume("<5sBIB", data, "signature version size targets")
41
- print("%(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d" % prefix)
42
- for t in range(prefix["targets"]):
43
- tprefix, data = consume("<6sBI255s2I", data, "signature altsetting named name size elements")
44
- tprefix["num"] = t
45
- if tprefix["named"]:
46
- tprefix["name"] = cstring(tprefix["name"])
47
- else:
48
- tprefix["name"] = ""
49
- print(
50
- '%(signature)s %(num)d, alt setting: %(altsetting)s, name: "%(name)s", size: %(size)d, elements: %(elements)d'
51
- % tprefix
52
- )
53
- tsize = tprefix["size"]
54
- target, data = data[:tsize], data[tsize:]
55
- for e in range(tprefix["elements"]):
56
- eprefix, target = consume("<2I", target, "address size")
57
- eprefix["num"] = e
58
- print(" %(num)d, address: 0x%(address)08x, size: %(size)d" % eprefix)
59
- esize = eprefix["size"]
60
- image, target = target[:esize], target[esize:]
61
- if dump_images:
62
- out = "%s.target%d.image%d.bin" % (file, t, e)
63
- open(out, "wb").write(image)
64
- print(' DUMPED IMAGE TO "%s"' % out)
65
- if len(target):
66
- print("target %d: PARSE ERROR" % t)
67
- suffix = named(struct.unpack("<4H3sBI", data[:16]), "device product vendor dfu ufd len crc")
68
- print(
69
- "usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x"
70
- % suffix
71
- )
72
- if crc != suffix["crc"]:
73
- print("CRC ERROR: computed crc32 is 0x%08x" % crc)
74
- data = data[16:]
75
- if data:
76
- print("PARSE ERROR")
77
-
78
-
79
- def build(file, targets, device=DEFAULT_DEVICE):
80
- data = b""
81
- for _, target in enumerate(targets):
82
- tdata = b""
83
- for image in target:
84
- # pad image to 8 bytes (needed at least for L476)
85
- pad = (8 - len(image["data"]) % 8) % 8
86
- image["data"] = image["data"] + bytes(bytearray(8)[0:pad])
87
- #
88
- tdata += struct.pack("<2I", image["address"], len(image["data"])) + image["data"]
89
- tdata = struct.pack("<6sBI255s2I", b"Target", 0, 1, b"ST...", len(tdata), len(target)) + tdata
90
- data += tdata
91
- data = struct.pack("<5sBIB", b"DfuSe", 1, len(data) + 11, len(targets)) + data
92
- v, d = map(lambda x: int(x, 0) & 0xFFFF, device.split(":", 1))
93
- data += struct.pack("<4H3sB", 0, d, v, 0x011A, b"UFD", 16)
94
- crc = compute_crc(data)
95
- data += struct.pack("<I", crc)
96
- open(file, "wb").write(data)
97
-
98
-
99
- if __name__ == "__main__":
100
- usage = """
101
- %prog [-d|--dump] infile.dfu
102
- %prog {-b|--build} address:file.bin [-b address:file.bin ...] [{-D|--device}=vendor:device] outfile.dfu"""
103
- parser = OptionParser(usage=usage)
104
- parser.add_option(
105
- "-b",
106
- "--build",
107
- action="append",
108
- dest="binfiles",
109
- help="build a DFU file from given BINFILES",
110
- metavar="BINFILES",
111
- )
112
- parser.add_option(
113
- "-D",
114
- "--device",
115
- action="store",
116
- dest="device",
117
- help="build for DEVICE, defaults to %s" % DEFAULT_DEVICE,
118
- metavar="DEVICE",
119
- )
120
- parser.add_option(
121
- "-d",
122
- "--dump",
123
- action="store_true",
124
- dest="dump_images",
125
- default=False,
126
- help="dump contained images to current directory",
127
- )
128
- (options, args) = parser.parse_args()
129
-
130
- if options.binfiles and len(args) == 1:
131
- target = []
132
- for arg in options.binfiles:
133
- try:
134
- address, binfile = arg.split(":", 1)
135
- except ValueError:
136
- print("Address:file couple '%s' invalid." % arg)
137
- sys.exit(1)
138
- try:
139
- address = int(address, 0) & 0xFFFFFFFF
140
- except ValueError:
141
- print("Address %s invalid." % address)
142
- sys.exit(1)
143
- if not os.path.isfile(binfile):
144
- print("Unreadable file '%s'." % binfile)
145
- sys.exit(1)
146
- target.append({"address": address, "data": open(binfile, "rb").read()})
147
- outfile = args[0]
148
- device = DEFAULT_DEVICE
149
- if options.device:
150
- device = options.device
151
- try:
152
- v, d = map(lambda x: int(x, 0) & 0xFFFF, device.split(":", 1))
153
- except:
154
- print("Invalid device '%s'." % device)
155
- sys.exit(1)
156
- build(outfile, [target], device)
157
- elif len(args) == 1:
158
- infile = args[0]
159
- if not os.path.isfile(infile):
160
- print("Unreadable file '%s'." % infile)
161
- sys.exit(1)
162
- parse(infile, dump_images=options.dump_images)
163
- else:
164
- parser.print_help()
165
- sys.exit(1)