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.
- {micropython_stubber-1.24.1.dist-info → micropython_stubber-1.24.4.dist-info}/METADATA +9 -29
- micropython_stubber-1.24.4.dist-info/RECORD +107 -0
- {micropython_stubber-1.24.1.dist-info → micropython_stubber-1.24.4.dist-info}/WHEEL +1 -1
- stubber/__init__.py +1 -1
- stubber/board/createstubs.py +44 -38
- stubber/board/createstubs_db.py +17 -12
- stubber/board/createstubs_db_min.py +63 -63
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_mem.py +17 -12
- stubber/board/createstubs_mem_min.py +99 -99
- stubber/board/createstubs_mem_mpy.mpy +0 -0
- stubber/board/createstubs_min.py +111 -112
- stubber/board/createstubs_mpy.mpy +0 -0
- stubber/board/modulelist.txt +27 -27
- stubber/codemod/board.py +1 -1
- stubber/codemod/enrich.py +13 -13
- stubber/codemod/merge_docstub.py +83 -53
- stubber/codemod/visitors/type_helpers.py +143 -41
- stubber/commands/enrich_folder_cmd.py +17 -17
- stubber/commands/get_docstubs_cmd.py +27 -9
- stubber/commands/get_frozen_cmd.py +1 -0
- stubber/commands/merge_cmd.py +2 -4
- stubber/merge_config.py +5 -36
- stubber/minify.py +3 -3
- stubber/modcat.py +118 -0
- stubber/publish/merge_docstubs.py +22 -5
- stubber/publish/stubpackage.py +33 -28
- stubber/rst/lookup.py +6 -23
- stubber/rst/reader.py +8 -13
- stubber/stubs_from_docs.py +2 -1
- stubber/tools/manifestfile.py +2 -1
- stubber/{cst_transformer.py → typing_collector.py} +36 -4
- micropython_stubber-1.24.1.dist-info/RECORD +0 -161
- mpflash/README.md +0 -220
- mpflash/libusb_flash.ipynb +0 -203
- mpflash/mpflash/__init__.py +0 -0
- mpflash/mpflash/add_firmware.py +0 -98
- mpflash/mpflash/ask_input.py +0 -236
- mpflash/mpflash/basicgit.py +0 -324
- mpflash/mpflash/bootloader/__init__.py +0 -2
- mpflash/mpflash/bootloader/activate.py +0 -60
- mpflash/mpflash/bootloader/detect.py +0 -82
- mpflash/mpflash/bootloader/manual.py +0 -101
- mpflash/mpflash/bootloader/micropython.py +0 -12
- mpflash/mpflash/bootloader/touch1200.py +0 -36
- mpflash/mpflash/cli_download.py +0 -129
- mpflash/mpflash/cli_flash.py +0 -224
- mpflash/mpflash/cli_group.py +0 -111
- mpflash/mpflash/cli_list.py +0 -87
- mpflash/mpflash/cli_main.py +0 -39
- mpflash/mpflash/common.py +0 -217
- mpflash/mpflash/config.py +0 -44
- mpflash/mpflash/connected.py +0 -96
- mpflash/mpflash/download.py +0 -364
- mpflash/mpflash/downloaded.py +0 -138
- mpflash/mpflash/errors.py +0 -9
- mpflash/mpflash/flash/__init__.py +0 -55
- mpflash/mpflash/flash/esp.py +0 -59
- mpflash/mpflash/flash/stm32.py +0 -19
- mpflash/mpflash/flash/stm32_dfu.py +0 -104
- mpflash/mpflash/flash/uf2/__init__.py +0 -88
- mpflash/mpflash/flash/uf2/boardid.py +0 -15
- mpflash/mpflash/flash/uf2/linux.py +0 -136
- mpflash/mpflash/flash/uf2/macos.py +0 -42
- mpflash/mpflash/flash/uf2/uf2disk.py +0 -12
- mpflash/mpflash/flash/uf2/windows.py +0 -43
- mpflash/mpflash/flash/worklist.py +0 -170
- mpflash/mpflash/list.py +0 -106
- mpflash/mpflash/logger.py +0 -41
- mpflash/mpflash/mpboard_id/__init__.py +0 -98
- mpflash/mpflash/mpboard_id/add_boards.py +0 -262
- mpflash/mpflash/mpboard_id/board.py +0 -37
- mpflash/mpflash/mpboard_id/board_id.py +0 -90
- mpflash/mpflash/mpboard_id/board_info.zip +0 -0
- mpflash/mpflash/mpboard_id/store.py +0 -48
- mpflash/mpflash/mpremoteboard/__init__.py +0 -271
- mpflash/mpflash/mpremoteboard/mpy_fw_info.py +0 -152
- mpflash/mpflash/mpremoteboard/runner.py +0 -140
- mpflash/mpflash/vendor/board_database.py +0 -185
- mpflash/mpflash/vendor/click_aliases.py +0 -91
- mpflash/mpflash/vendor/dfu.py +0 -165
- mpflash/mpflash/vendor/pydfu.py +0 -605
- mpflash/mpflash/vendor/readme.md +0 -12
- mpflash/mpflash/versions.py +0 -123
- mpflash/poetry.lock +0 -2603
- mpflash/pyproject.toml +0 -66
- mpflash/stm32_udev_rules.md +0 -63
- stubber/codemod/test_enrich.py +0 -87
- {micropython_stubber-1.24.1.dist-info → micropython_stubber-1.24.4.dist-info}/LICENSE +0 -0
- {micropython_stubber-1.24.1.dist-info → micropython_stubber-1.24.4.dist-info}/entry_points.txt +0 -0
stubber/board/createstubs_min.py
CHANGED
@@ -1,21 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
h='pycom'
|
1
|
+
A0='windows'
|
2
|
+
z='No report file'
|
3
|
+
y='Failed to create the report.'
|
4
|
+
x='{}/{}'
|
5
|
+
w='logging'
|
6
|
+
v='sys'
|
7
|
+
u='method'
|
8
|
+
t='function'
|
9
|
+
s='bool'
|
10
|
+
r='str'
|
11
|
+
q='float'
|
12
|
+
p='int'
|
13
|
+
o='stubber'
|
14
|
+
n=Exception
|
15
|
+
m=KeyError
|
16
|
+
l=sorted
|
17
|
+
k=NotImplementedError
|
19
18
|
g='unix'
|
20
19
|
f=',\n'
|
21
20
|
e='dict'
|
@@ -39,9 +38,9 @@ L='port'
|
|
39
38
|
K='.'
|
40
39
|
I=AttributeError
|
41
40
|
H=False
|
42
|
-
G=
|
43
|
-
E=
|
44
|
-
D=
|
41
|
+
G=None
|
42
|
+
E='/'
|
43
|
+
D=OSError
|
45
44
|
C='version'
|
46
45
|
B=''
|
47
46
|
import gc as F,os,sys
|
@@ -50,10 +49,11 @@ try:from ujson import dumps
|
|
50
49
|
except:from json import dumps
|
51
50
|
try:from machine import reset
|
52
51
|
except N:pass
|
53
|
-
try:from collections import OrderedDict as
|
54
|
-
except N:from ucollections import OrderedDict as
|
52
|
+
try:from collections import OrderedDict as h
|
53
|
+
except N:from ucollections import OrderedDict as h
|
55
54
|
__version__='v1.24.0'
|
56
|
-
|
55
|
+
A1=2
|
56
|
+
A2=44
|
57
57
|
A3=2
|
58
58
|
A7=['lib','/lib','/sd/lib','/flash/lib',K]
|
59
59
|
class J:
|
@@ -70,13 +70,13 @@ class J:
|
|
70
70
|
if A.level<=J.WARNING:A.prnt('WARN :',msg)
|
71
71
|
def error(A,msg):
|
72
72
|
if A.level<=J.ERROR:A.prnt('ERROR :',msg)
|
73
|
-
A=J.getLogger(
|
73
|
+
A=J.getLogger(o)
|
74
74
|
J.basicConfig(level=J.INFO)
|
75
75
|
class Stubber:
|
76
|
-
def __init__(B,path=
|
76
|
+
def __init__(B,path=B,firmware_id=B):
|
77
77
|
C=firmware_id
|
78
78
|
try:
|
79
|
-
if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise
|
79
|
+
if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise k('MicroPython 1.13.0 cannot be stubbed')
|
80
80
|
except I:pass
|
81
81
|
B.info=_info();A.info('Port: {}'.format(B.info[L]));A.info('Board: {}'.format(B.info[T]));F.collect()
|
82
82
|
if C:B._fwid=C.lower()
|
@@ -84,12 +84,12 @@ class Stubber:
|
|
84
84
|
else:B._fwid='{family}-v{version}-{port}'.format(**B.info)
|
85
85
|
B._start_free=F.mem_free()
|
86
86
|
if path:
|
87
|
-
if path.endswith(
|
87
|
+
if path.endswith(E):path=path[:-1]
|
88
88
|
else:path=get_root()
|
89
|
-
B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',
|
90
|
-
try:X(path+
|
91
|
-
except
|
92
|
-
B.problematic=['upip','upysh','webrepl_setup','http_client','http_client_ssl','http_server','http_server_ssl'];B.excluded=['webrepl','_webrepl','port_diag','example_sub_led.py','example_pub_button.py'];B.modules=[];B._json_name=
|
89
|
+
B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',E)
|
90
|
+
try:X(path+E)
|
91
|
+
except D:A.error('error creating stub folder {}'.format(path))
|
92
|
+
B.problematic=['upip','upysh','webrepl_setup','http_client','http_client_ssl','http_server','http_server_ssl'];B.excluded=['webrepl','_webrepl','port_diag','example_sub_led.py','example_pub_button.py'];B.modules=[];B._json_name=G;B._json_first=H
|
93
93
|
def get_obj_attributes(L,item_instance):
|
94
94
|
H=item_instance;C=[];K=[]
|
95
95
|
for A in M(H):
|
@@ -98,15 +98,15 @@ class Stubber:
|
|
98
98
|
D=getattr(H,A)
|
99
99
|
try:E=Z(type(D)).split("'")[1]
|
100
100
|
except O:E=B
|
101
|
-
if E in{q,r,s,
|
102
|
-
elif E in{u
|
101
|
+
if E in{p,q,r,s,c,d,e}:G=1
|
102
|
+
elif E in{t,u}:G=2
|
103
103
|
elif E in'class':G=3
|
104
104
|
else:G=4
|
105
105
|
C.append((A,Z(D),Z(type(D)),D,G))
|
106
106
|
except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
|
107
107
|
except MemoryError as J:Q('MemoryError: {}'.format(J));sleep(1);reset()
|
108
|
-
C=
|
109
|
-
def add_modules(A,modules):A.modules=
|
108
|
+
C=l([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
|
109
|
+
def add_modules(A,modules):A.modules=l(set(A.modules)|set(modules))
|
110
110
|
def create_all_stubs(B):
|
111
111
|
A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();F.collect()
|
112
112
|
for C in B.modules:B.create_one_stub(C)
|
@@ -115,31 +115,31 @@ class Stubber:
|
|
115
115
|
B=module_name
|
116
116
|
if B in C.problematic:A.warning('Skip module: {:<25} : Known problematic'.format(B));return H
|
117
117
|
if B in C.excluded:A.warning('Skip module: {:<25} : Excluded'.format(B));return H
|
118
|
-
I='{}/{}.pyi'.format(C.path,B.replace(K,
|
119
|
-
try:
|
120
|
-
except
|
121
|
-
F.collect();return
|
122
|
-
def create_module_stub(J,module_name,file_name=
|
118
|
+
I='{}/{}.pyi'.format(C.path,B.replace(K,E));F.collect();G=H
|
119
|
+
try:G=C.create_module_stub(B,I)
|
120
|
+
except D:return H
|
121
|
+
F.collect();return G
|
122
|
+
def create_module_stub(J,module_name,file_name=G):
|
123
123
|
I=file_name;C=module_name
|
124
|
-
if I is
|
125
|
-
else:L=I.split(
|
126
|
-
if
|
127
|
-
M=
|
128
|
-
try:M=__import__(C,
|
124
|
+
if I is G:L=C.replace(K,'_')+'.pyi';I=J.path+E+L
|
125
|
+
else:L=I.split(E)[-1]
|
126
|
+
if E in C:C=C.replace(E,K)
|
127
|
+
M=G
|
128
|
+
try:M=__import__(C,G,G,'*');P=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,P))
|
129
129
|
except N:return H
|
130
130
|
X(I)
|
131
|
-
with R(I,'w')as O:Q=str(J.info).replace('OrderedDict(',B).replace('})','}');S='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,J._fwid,Q,__version__);O.write(S);O.write('from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n');J.write_object_stub(O,M,C,B)
|
131
|
+
with R(I,'w')as O:Q=str(J.info).replace('OrderedDict(',B).replace('})','}');S='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,J._fwid,Q,__version__);O.write(S);O.write('from __future__ import annotations\nfrom typing import Any, Final, Generator\nfrom _typeshed import Incomplete\n\n');J.write_object_stub(O,M,C,B)
|
132
132
|
J.report_add(C,I)
|
133
|
-
if C not in{'os',w,
|
133
|
+
if C not in{'os',v,w,'gc'}:
|
134
134
|
try:del M
|
135
|
-
except(
|
135
|
+
except(D,m):A.warning('could not del new_module')
|
136
136
|
F.collect();return V
|
137
137
|
def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
|
138
|
-
|
138
|
+
Y=' at ...>';X='{0}{1}: {3} = {2}\n';W='bound_method';V='Incomplete';O=in_class;N='Exception';M=object_expr;K=' at ';J=fp;E=indent;F.collect()
|
139
139
|
if M in L.problematic:A.warning('SKIPPING problematic module:{}'.format(M));return
|
140
|
-
|
140
|
+
Z,P=L.get_obj_attributes(M)
|
141
141
|
if P:A.error(P)
|
142
|
-
for(C,H,I,
|
142
|
+
for(C,H,I,a,f)in Z:
|
143
143
|
if C in['classmethod','staticmethod','BaseException',N]:continue
|
144
144
|
if C[0].isdigit():A.warning('NameError: invalid name {}'.format(C));continue
|
145
145
|
if I=="<class 'type'>"and S(E)<=A3*4:
|
@@ -147,8 +147,8 @@ class Stubber:
|
|
147
147
|
if R:Q=N
|
148
148
|
D='\n{}class {}({}):\n'.format(E,C,Q)
|
149
149
|
if R:D+=E+' ...\n';J.write(D);continue
|
150
|
-
J.write(D);L.write_object_stub(J,
|
151
|
-
elif any(A in I for A in[
|
150
|
+
J.write(D);L.write_object_stub(J,a,'{0}.{1}'.format(obj_name,C),E+' ',O+1);D=E+' def __init__(self, *argv, **kwargs) -> None:\n';D+=E+' ...\n\n';J.write(D)
|
151
|
+
elif any(A in I for A in[u,t,'closure']):
|
152
152
|
T=V;U=B
|
153
153
|
if O>0:U='self, '
|
154
154
|
if W in I or W in H:D='{}@classmethod\n'.format(E)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(E,C,T)
|
@@ -157,17 +157,16 @@ class Stubber:
|
|
157
157
|
elif I=="<class 'module'>":0
|
158
158
|
elif I.startswith("<class '"):
|
159
159
|
G=I[8:-2];D=B
|
160
|
-
if G in(
|
160
|
+
if G in(r,p,q,s,'bytearray','bytes'):
|
161
161
|
if C.upper()==C:D='{0}{1}: Final[{3}] = {2}\n'.format(E,C,H,G)
|
162
162
|
else:D=X.format(E,C,H,G)
|
163
|
-
elif G in(e,d,c):
|
164
|
-
elif G in('object','set','frozenset','Pin',
|
165
|
-
|
166
|
-
D='{0}{1}: {2} ## = {4}\n'.format(E,C,G,I,H)
|
163
|
+
elif G in(e,d,c):b={e:'{}',d:'[]',c:'()'};D=X.format(E,C,b[G],G)
|
164
|
+
elif G in('object','set','frozenset','Pin'):D='{0}{1}: {2} ## = {4}\n'.format(E,C,G,I,H)
|
165
|
+
elif G=='generator':G='Generator';D='{0}def {1}(*args, **kwargs) -> Generator: ## = {4}\n{0} ...\n\n'.format(E,C,G,I,H)
|
167
166
|
else:
|
168
167
|
G=V
|
169
|
-
if K in H:H=H.split(K)[0]+
|
170
|
-
if K in H:H=H.split(K)[0]+
|
168
|
+
if K in H:H=H.split(K)[0]+Y
|
169
|
+
if K in H:H=H.split(K)[0]+Y
|
171
170
|
D='{0}{1}: {2} ## {3} = {4}\n'.format(E,C,G,I,H)
|
172
171
|
J.write(D)
|
173
172
|
else:J.write("# all other, type = '{0}'\n".format(I));J.write(E+C+' # type: Incomplete\n')
|
@@ -176,46 +175,46 @@ class Stubber:
|
|
176
175
|
A=self._fwid;B=' .()/\\:$'
|
177
176
|
for C in B:A=A.replace(C,'_')
|
178
177
|
return A
|
179
|
-
def clean(C,path=
|
180
|
-
if path
|
178
|
+
def clean(C,path=B):
|
179
|
+
if not path:path=C.path
|
181
180
|
A.info('Clean/remove files in folder: {}'.format(path))
|
182
|
-
try:os.stat(path);
|
183
|
-
except(
|
184
|
-
for
|
185
|
-
B=
|
181
|
+
try:os.stat(path);E=os.listdir(path)
|
182
|
+
except(D,I):return
|
183
|
+
for F in E:
|
184
|
+
B=x.format(path,F)
|
186
185
|
try:os.remove(B)
|
187
|
-
except
|
186
|
+
except D:
|
188
187
|
try:C.clean(B);os.rmdir(B)
|
189
|
-
except
|
188
|
+
except D:pass
|
190
189
|
def report_start(B,filename='modules.json'):
|
191
|
-
H='firmware';B._json_name=
|
190
|
+
H='firmware';B._json_name=x.format(B.path,filename);B._json_first=V;X(B._json_name);A.info('Report file: {}'.format(B._json_name));F.collect()
|
192
191
|
try:
|
193
|
-
with R(B._json_name,'w')as
|
194
|
-
except
|
192
|
+
with R(B._json_name,'w')as E:E.write('{');E.write(dumps({H:B.info})[1:-1]);E.write(f);E.write(dumps({o:{C:__version__},'stubtype':H})[1:-1]);E.write(f);E.write('"modules" :[\n')
|
193
|
+
except D as I:A.error(y);B._json_name=G;raise I
|
195
194
|
def report_add(B,module_name,stub_file):
|
196
|
-
if not B._json_name:raise
|
195
|
+
if not B._json_name:raise n(z)
|
197
196
|
try:
|
198
197
|
with R(B._json_name,'a')as C:
|
199
198
|
if not B._json_first:C.write(f)
|
200
199
|
else:B._json_first=H
|
201
|
-
|
202
|
-
except
|
200
|
+
F='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',E));C.write(F)
|
201
|
+
except D:A.error(y)
|
203
202
|
def report_end(B):
|
204
|
-
if not B._json_name:raise
|
203
|
+
if not B._json_name:raise n(z)
|
205
204
|
with R(B._json_name,'a')as C:C.write('\n]}')
|
206
205
|
A.info('Path: {}'.format(B.path))
|
207
206
|
def X(path):
|
208
|
-
B=
|
207
|
+
B=F=0
|
209
208
|
while B!=-1:
|
210
|
-
B=path.find(
|
209
|
+
B=path.find(E,F)
|
211
210
|
if B!=-1:
|
212
211
|
C=path[0]if B==0 else path[:B]
|
213
212
|
try:I=os.stat(C)
|
214
|
-
except
|
215
|
-
if
|
213
|
+
except D as G:
|
214
|
+
if G.args[0]in[A1,A2]:
|
216
215
|
try:A.debug('Create folder {}'.format(C));os.mkdir(C)
|
217
|
-
except
|
218
|
-
|
216
|
+
except D as H:A.error('failed to create folder {}'.format(C));raise H
|
217
|
+
F=B+1
|
219
218
|
def Y(s):
|
220
219
|
C=' on '
|
221
220
|
if not s:return B
|
@@ -226,42 +225,42 @@ def Y(s):
|
|
226
225
|
if not W in s:return B
|
227
226
|
A=s.split(W)[1].split(K)[1];return A
|
228
227
|
def _info():
|
229
|
-
|
228
|
+
Z='ev3-pybricks';X='pycom';V='pycopy';U='win32';S='arch';R='cpu';Q='ver';E='mpy';D='build'
|
230
229
|
try:J=sys.implementation[0]
|
231
230
|
except a:J=sys.implementation.name
|
232
|
-
A=
|
231
|
+
A=h({P:J,C:B,D:B,Q:B,L:sys.platform,T:'UNKNOWN',R:B,E:B,S:B})
|
233
232
|
if A[L].startswith('pyb'):A[L]='stm32'
|
234
|
-
elif A[L]==U:A[L]=
|
233
|
+
elif A[L]==U:A[L]=A0
|
235
234
|
elif A[L]=='linux':A[L]=g
|
236
235
|
try:A[C]=A4(sys.implementation.version)
|
237
236
|
except I:pass
|
238
|
-
try:K=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[T]=K;A[R]=K.split('with')[-1].strip();A[
|
237
|
+
try:K=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[T]=K;A[R]=K.split('with')[-1].strip();A[E]=sys.implementation._mpy if'_mpy'in M(sys.implementation)else sys.implementation.mpy if E in M(sys.implementation)else B
|
239
238
|
except(I,O):pass
|
240
239
|
A[T]=A5()
|
241
240
|
try:
|
242
241
|
if'uname'in M(os):
|
243
|
-
A[
|
244
|
-
if not A[
|
245
|
-
elif C in M(sys):A[
|
242
|
+
A[D]=Y(os.uname()[3])
|
243
|
+
if not A[D]:A[D]=Y(os.uname()[2])
|
244
|
+
elif C in M(sys):A[D]=Y(sys.version)
|
246
245
|
except(I,O,a):pass
|
247
246
|
if A[C]==B and sys.platform not in(g,U):
|
248
|
-
try:
|
247
|
+
try:c=os.uname();A[C]=c.release
|
249
248
|
except(O,I,a):pass
|
250
|
-
for(
|
251
|
-
try:
|
252
|
-
except(N,
|
253
|
-
if A[P]==
|
249
|
+
for(d,e,f)in[(V,V,'const'),(X,X,'FAT'),(Z,'pybricks.hubs','EV3Brick')]:
|
250
|
+
try:i=__import__(e,G,G,f);A[P]=d;del i;break
|
251
|
+
except(N,m):pass
|
252
|
+
if A[P]==Z:A['release']='2.0.0'
|
254
253
|
if A[P]==b:
|
255
254
|
A[C]
|
256
255
|
if A[C]and A[C].endswith('.0')and A[C]>='1.10.0'and A[C]<='1.19.9':A[C]=A[C][:-2]
|
257
|
-
if
|
258
|
-
|
259
|
-
try:H=[
|
256
|
+
if E in A and A[E]:
|
257
|
+
F=int(A[E])
|
258
|
+
try:H=[G,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin','rv32imc'][F>>10]
|
260
259
|
except O:H='unknown'
|
261
260
|
if H:A[S]=H
|
262
|
-
A[
|
263
|
-
if A[
|
264
|
-
A[Q]=f"{A[C]}-{A[
|
261
|
+
A[E]='v{}.{}'.format(F&255,F>>8&3)
|
262
|
+
if A[D]and not A[C].endswith(W):A[C]=A[C]+W
|
263
|
+
A[Q]=f"{A[C]}-{A[D]}"if A[D]else f"{A[C]}";return A
|
265
264
|
def A4(version):
|
266
265
|
A=version;B=K.join([str(A)for A in A[:3]])
|
267
266
|
if S(A)>3 and A[3]:B+=U+A[3]
|
@@ -272,31 +271,31 @@ def A5():
|
|
272
271
|
return C
|
273
272
|
def get_root():
|
274
273
|
try:A=os.getcwd()
|
275
|
-
except(
|
274
|
+
except(D,I):A=K
|
276
275
|
B=A
|
277
|
-
for B in['/remote','/sd','/flash',
|
276
|
+
for B in['/remote','/sd','/flash',E,A,K]:
|
278
277
|
try:C=os.stat(B);break
|
279
|
-
except
|
278
|
+
except D:continue
|
280
279
|
return B
|
281
280
|
def A6(filename):
|
282
281
|
try:
|
283
282
|
if os.stat(filename)[0]>>14:return V
|
284
283
|
return H
|
285
|
-
except
|
286
|
-
def
|
284
|
+
except D:return H
|
285
|
+
def i():Q("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
|
287
286
|
def read_path():
|
288
287
|
path=B
|
289
288
|
if S(sys.argv)==3:
|
290
289
|
A=sys.argv[1].lower()
|
291
290
|
if A in('--path','-p'):path=sys.argv[2]
|
292
|
-
else:
|
293
|
-
elif S(sys.argv)==2:
|
291
|
+
else:i()
|
292
|
+
elif S(sys.argv)==2:i()
|
294
293
|
return path
|
295
|
-
def
|
296
|
-
try:A=bytes('abc',encoding='utf8');B=
|
297
|
-
except(
|
298
|
-
def main():stubber=Stubber(path=read_path());stubber.clean();stubber.modules=['WM8960','
|
299
|
-
if __name__=='__main__'or
|
294
|
+
def j():
|
295
|
+
try:A=bytes('abc',encoding='utf8');B=j.__module__;return H
|
296
|
+
except(k,I):return V
|
297
|
+
def main():stubber=Stubber(path=read_path());stubber.clean();stubber.modules=['WM8960','_asyncio','_boot_fat','_espnow','_onewire','_rp2','_thread','_uasyncio','abc','adcfft','aioble/__init__','aioble/central','aioble/client','aioble/core','aioble/device','aioble/l2cap','aioble/peripheral','aioble/security','aioble/server','aioespnow','ak8963','apa102','apa106','argparse','array','asyncio/__init__','asyncio/core','asyncio/event','asyncio/funcs','asyncio/lock','asyncio/stream','base64','binascii','bluetooth','breakout_as7262','breakout_bh1745','breakout_bme280','breakout_bme68x','breakout_bmp280','breakout_dotmatrix','breakout_encoder','breakout_icp10125','breakout_ioexpander','breakout_ltr559','breakout_matrix11x7','breakout_mics6814','breakout_msa301','breakout_paa5100','breakout_pmw3901','breakout_potentiometer','breakout_rgbmatrix5x5','breakout_rtc','breakout_scd41','breakout_sgp30','breakout_trackball','breakout_vl53l5cx','btree','builtins','cc3200','cmath','collections','collections/__init__','collections/defaultdict','copy','crypto','cryptolib','curl','datetime','deflate','dht','display','display_driver_utils','ds18x20','embed','encoder','errno','esp','esp32','esp8266','espidf','espnow','ffi','flashbdev','fnmatch','framebuf','freesans20','fs_driver','functools','galactic','gc','gfx_pack','gsm','gzip','hashlib','heapq','hmac','html/__init__','hub75','ili9341','ili9XXX','imagetools','inisetup','inspect','interstate75','io','itertools','jpegdec','js','jsffi','json','lcd160cr','locale','lodepng',w,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','marshal','math','microWebSocket','microWebSrv','microWebTemplate',b,'mimxrt','mip','mip/__init__','mip/__main__','motor','mpu6500','mpu9250','neopixel','network','nrf','ntptime','onewire','openamp','operator','os','os/__init__','os/path','pathlib','pcf85063a','pic16bit','picoexplorer','picographics','picokeypad','picoscroll','picounicorn','picowireless','pimoroni','pimoroni_bus','pimoroni_i2c','plasma','platform','powerpc','pyb','pye','pyscript','pyscript/__init__','pyscript/fs','qemu','qrcode','random','renesas','renesas-ra','requests','requests/__init__','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stat','stm','stm32','string','struct',v,'tarfile/__init__','tarfile/write','termios','time','tls','tpcalib','types','uarray','uasyncio/__init__','uasyncio/core','uasyncio/event','uasyncio/funcs','uasyncio/lock','uasyncio/stream','uasyncio/tasks','ubinascii','ubluetooth','ucollections','ucryptolib','uctypes','uerrno','uftpd','uhashlib','uheapq','uio','ujson','ulab','ulab/approx','ulab/compare','ulab/fft','ulab/filter','ulab/linalg','ulab/numerical','ulab/poly','ulab/user','ulab/vector','umachine','umqtt/__init__','umqtt/robust','umqtt/simple','unittest/__init__',g,'uos','uplatform','urandom','ure','urequests','urllib/urequest','usb/device','usb/device/cdc','usb/device/hid','usb/device/keyboard','usb/device/midi','usb/device/mouse','uselect','usocket','ussl','ustruct','usys','utelnetserver','utime','utimeq','uu','uwebsocket','uzlib',C,'vfs','webassembly','websocket','websocket_helper',A0,'wipy','writer','xpt2046','ymodem','zephyr','zlib'];F.collect();stubber.create_all_stubs()
|
298
|
+
if __name__=='__main__'or j():
|
300
299
|
if not A6('no_auto_stubber.txt'):
|
301
300
|
Q(f"createstubs.py: {__version__}")
|
302
301
|
try:F.threshold(4096);F.enable()
|
Binary file
|
stubber/board/modulelist.txt
CHANGED
@@ -1,35 +1,13 @@
|
|
1
1
|
# list of modules to stub used by the memory optimised createstubs_mem.py
|
2
2
|
WM8960
|
3
|
-
_OTA
|
4
3
|
_asyncio
|
5
4
|
_boot_fat
|
6
|
-
_coap
|
7
5
|
_espnow
|
8
|
-
_flash_control_OTA
|
9
|
-
_main_pybytes
|
10
|
-
_mqtt
|
11
|
-
_mqtt_core
|
12
|
-
_msg_handl
|
13
6
|
_onewire
|
14
|
-
_periodical_pin
|
15
|
-
_pybytes
|
16
|
-
_pybytes_ca
|
17
|
-
_pybytes_config
|
18
|
-
_pybytes_config_reader
|
19
|
-
_pybytes_connection
|
20
|
-
_pybytes_constants
|
21
|
-
_pybytes_debug
|
22
|
-
_pybytes_library
|
23
|
-
_pybytes_machine_learning
|
24
|
-
_pybytes_main
|
25
|
-
_pybytes_protocol
|
26
|
-
_pybytes_pyconfig
|
27
|
-
_pybytes_pymesh_config
|
28
7
|
_rp2
|
29
|
-
_terminal
|
30
8
|
_thread
|
31
9
|
_uasyncio
|
32
|
-
|
10
|
+
abc
|
33
11
|
adcfft
|
34
12
|
aioble/__init__
|
35
13
|
aioble/central
|
@@ -52,6 +30,7 @@ asyncio/event
|
|
52
30
|
asyncio/funcs
|
53
31
|
asyncio/lock
|
54
32
|
asyncio/stream
|
33
|
+
base64
|
55
34
|
binascii
|
56
35
|
bluetooth
|
57
36
|
breakout_as7262
|
@@ -81,9 +60,13 @@ builtins
|
|
81
60
|
cc3200
|
82
61
|
cmath
|
83
62
|
collections
|
63
|
+
collections/__init__
|
64
|
+
collections/defaultdict
|
65
|
+
copy
|
84
66
|
crypto
|
85
67
|
cryptolib
|
86
68
|
curl
|
69
|
+
datetime
|
87
70
|
deflate
|
88
71
|
dht
|
89
72
|
display
|
@@ -99,6 +82,7 @@ espidf
|
|
99
82
|
espnow
|
100
83
|
ffi
|
101
84
|
flashbdev
|
85
|
+
fnmatch
|
102
86
|
framebuf
|
103
87
|
freesans20
|
104
88
|
fs_driver
|
@@ -107,20 +91,26 @@ galactic
|
|
107
91
|
gc
|
108
92
|
gfx_pack
|
109
93
|
gsm
|
94
|
+
gzip
|
110
95
|
hashlib
|
111
96
|
heapq
|
97
|
+
hmac
|
98
|
+
html/__init__
|
112
99
|
hub75
|
113
100
|
ili9341
|
114
101
|
ili9XXX
|
115
102
|
imagetools
|
116
103
|
inisetup
|
104
|
+
inspect
|
117
105
|
interstate75
|
118
106
|
io
|
107
|
+
itertools
|
119
108
|
jpegdec
|
120
109
|
js
|
121
110
|
jsffi
|
122
111
|
json
|
123
112
|
lcd160cr
|
113
|
+
locale
|
124
114
|
lodepng
|
125
115
|
logging
|
126
116
|
lsm6dsox
|
@@ -148,7 +138,11 @@ nrf
|
|
148
138
|
ntptime
|
149
139
|
onewire
|
150
140
|
openamp
|
141
|
+
operator
|
151
142
|
os
|
143
|
+
os/__init__
|
144
|
+
os/path
|
145
|
+
pathlib
|
152
146
|
pcf85063a
|
153
147
|
pic16bit
|
154
148
|
picoexplorer
|
@@ -164,11 +158,12 @@ plasma
|
|
164
158
|
platform
|
165
159
|
powerpc
|
166
160
|
pyb
|
167
|
-
pycom
|
168
161
|
pye
|
162
|
+
pyscript
|
163
|
+
pyscript/__init__
|
164
|
+
pyscript/fs
|
169
165
|
qemu
|
170
166
|
qrcode
|
171
|
-
queue
|
172
167
|
random
|
173
168
|
renesas
|
174
169
|
renesas-ra
|
@@ -183,14 +178,19 @@ socket
|
|
183
178
|
ssd1306
|
184
179
|
ssh
|
185
180
|
ssl
|
181
|
+
stat
|
186
182
|
stm
|
187
183
|
stm32
|
184
|
+
string
|
188
185
|
struct
|
189
186
|
sys
|
187
|
+
tarfile/__init__
|
188
|
+
tarfile/write
|
190
189
|
termios
|
191
190
|
time
|
192
191
|
tls
|
193
192
|
tpcalib
|
193
|
+
types
|
194
194
|
uarray
|
195
195
|
uasyncio/__init__
|
196
196
|
uasyncio/core
|
@@ -202,7 +202,6 @@ uasyncio/tasks
|
|
202
202
|
ubinascii
|
203
203
|
ubluetooth
|
204
204
|
ucollections
|
205
|
-
ucrypto
|
206
205
|
ucryptolib
|
207
206
|
uctypes
|
208
207
|
uerrno
|
@@ -225,10 +224,10 @@ umachine
|
|
225
224
|
umqtt/__init__
|
226
225
|
umqtt/robust
|
227
226
|
umqtt/simple
|
227
|
+
unittest/__init__
|
228
228
|
unix
|
229
229
|
uos
|
230
230
|
uplatform
|
231
|
-
uqueue
|
232
231
|
urandom
|
233
232
|
ure
|
234
233
|
urequests
|
@@ -247,6 +246,7 @@ usys
|
|
247
246
|
utelnetserver
|
248
247
|
utime
|
249
248
|
utimeq
|
249
|
+
uu
|
250
250
|
uwebsocket
|
251
251
|
uzlib
|
252
252
|
version
|
stubber/codemod/board.py
CHANGED
@@ -16,7 +16,7 @@ from packaging.version import Version
|
|
16
16
|
from stubber import __version__
|
17
17
|
from stubber.codemod._partials import Partial
|
18
18
|
from stubber.codemod.modify_list import ListChangeSet, ModifyListElements
|
19
|
-
from stubber.
|
19
|
+
from stubber.typing_collector import update_module_docstr
|
20
20
|
|
21
21
|
# matches on `stubber = Stubber()`
|
22
22
|
_STUBBER_MATCHER = m.Assign(
|
stubber/codemod/enrich.py
CHANGED
@@ -16,11 +16,8 @@ from libcst.tool import _default_config # type: ignore
|
|
16
16
|
|
17
17
|
import stubber.codemod.merge_docstub as merge_docstub
|
18
18
|
from mpflash.logger import log
|
19
|
-
from stubber.merge_config import
|
20
|
-
|
21
|
-
copy_type_modules,
|
22
|
-
)
|
23
|
-
from stubber.rst.lookup import U_MODULES
|
19
|
+
from stubber.merge_config import CP_REFERENCE_TO_DOCSTUB, copy_type_modules
|
20
|
+
from stubber.modcat import U_MODULES
|
24
21
|
from stubber.utils.post import run_black
|
25
22
|
|
26
23
|
|
@@ -165,7 +162,8 @@ def enrich_file(
|
|
165
162
|
diff: bool = False,
|
166
163
|
write_back: bool = False,
|
167
164
|
# package_name="", # not used
|
168
|
-
|
165
|
+
copy_params: bool = False,
|
166
|
+
copy_docstr: bool = False,
|
169
167
|
) -> Generator[str, None, None]:
|
170
168
|
"""
|
171
169
|
Enrich a MCU stubs using the doc-stubs in another folder.
|
@@ -200,7 +198,7 @@ def enrich_file(
|
|
200
198
|
old_code = current_code = target_path.read_text(encoding="utf-8")
|
201
199
|
# read source file
|
202
200
|
codemod_instance = merge_docstub.MergeCommand(
|
203
|
-
context, docstub_file=source_path,
|
201
|
+
context, docstub_file=source_path, copy_params=copy_params, copy_docstr=copy_docstr,
|
204
202
|
)
|
205
203
|
if new_code := exec_transform_with_prettyprint(
|
206
204
|
codemod_instance,
|
@@ -220,7 +218,7 @@ def enrich_file(
|
|
220
218
|
log.trace(f"Write back enriched file {target_path}")
|
221
219
|
target_path.write_text(current_code, encoding="utf-8")
|
222
220
|
if diff:
|
223
|
-
yield diff_code(old_code, current_code,
|
221
|
+
yield diff_code(old_code, current_code, 2, filename=target_path.name)
|
224
222
|
|
225
223
|
|
226
224
|
def merge_candidates(
|
@@ -282,8 +280,9 @@ def enrich_folder(
|
|
282
280
|
show_diff: bool = False,
|
283
281
|
write_back: bool = False,
|
284
282
|
require_docstub: bool = False,
|
285
|
-
|
283
|
+
copy_params: bool = False,
|
286
284
|
ext: Optional[str] = None,
|
285
|
+
copy_docstr: bool = False,
|
287
286
|
# package_name: str = "",
|
288
287
|
) -> int:
|
289
288
|
"""\
|
@@ -296,7 +295,7 @@ def enrich_folder(
|
|
296
295
|
if not source_folder.exists():
|
297
296
|
raise FileNotFoundError(f"Source {source_folder} does not exist")
|
298
297
|
ext = ext or ".py*"
|
299
|
-
log.info(f"
|
298
|
+
log.info(f"Enriching from {source_folder} to {target_folder}/**/*{ext}")
|
300
299
|
count = 0
|
301
300
|
|
302
301
|
candidates = source_target_candidates(source_folder, target_folder, ext)
|
@@ -315,7 +314,8 @@ def enrich_folder(
|
|
315
314
|
diff=True,
|
316
315
|
write_back=write_back,
|
317
316
|
# package_name=mm.target_pkg,
|
318
|
-
|
317
|
+
copy_params=copy_params,
|
318
|
+
copy_docstr=copy_docstr,
|
319
319
|
)
|
320
320
|
):
|
321
321
|
count += len(diff)
|
@@ -337,8 +337,8 @@ def enrich_folder(
|
|
337
337
|
run_black(target_folder)
|
338
338
|
# DO NOT run Autoflake as this removes some relevant (but unused) imports too early
|
339
339
|
|
340
|
-
if
|
341
|
-
|
340
|
+
# if copy_params:
|
341
|
+
# copy_type_modules(source_folder, target_folder, CP_REFERENCE_TO_DOCSTUB)
|
342
342
|
return count
|
343
343
|
|
344
344
|
|