micropython-stubber 1.16.2__py3-none-any.whl → 1.17.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.
- {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/METADATA +2 -1
- {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/RECORD +54 -54
- stubber/__init__.py +1 -1
- stubber/basicgit.py +27 -33
- stubber/board/board_info.csv +137 -103
- stubber/board/createstubs.py +222 -189
- stubber/board/createstubs_db.py +284 -214
- stubber/board/createstubs_db_min.py +286 -265
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_lvgl.py +171 -113
- stubber/board/createstubs_lvgl_min.py +738 -275
- stubber/board/createstubs_lvgl_mpy.mpy +0 -0
- stubber/board/createstubs_mem.py +237 -174
- stubber/board/createstubs_mem_min.py +263 -247
- stubber/board/createstubs_mem_mpy.mpy +0 -0
- stubber/board/createstubs_min.py +242 -227
- stubber/board/createstubs_mpy.mpy +0 -0
- stubber/board/fw_info.py +135 -0
- stubber/board/modulelist.txt +1 -2
- stubber/codemod/_partials/__init__.py +1 -1
- stubber/codemod/_partials/db_main.py +90 -72
- stubber/codemod/_partials/modules_reader.py +29 -17
- stubber/codemod/board.py +2 -4
- stubber/codemod/enrich.py +1 -1
- stubber/commands/build_cmd.py +6 -4
- stubber/commands/get_docstubs_cmd.py +6 -11
- stubber/commands/get_frozen_cmd.py +6 -11
- stubber/commands/switch_cmd.py +6 -4
- stubber/data/board_info.csv +134 -101
- stubber/data/board_info.json +1357 -901
- stubber/freeze/freeze_manifest_2.py +2 -1
- stubber/freeze/get_frozen.py +28 -13
- stubber/minify.py +56 -43
- stubber/publish/candidates.py +15 -23
- stubber/publish/defaults.py +2 -2
- stubber/publish/merge_docstubs.py +5 -7
- stubber/publish/missing_class_methods.py +2 -2
- stubber/publish/pathnames.py +2 -2
- stubber/publish/publish.py +2 -1
- stubber/publish/stubpackage.py +20 -40
- stubber/rst/lookup.py +9 -7
- stubber/rst/reader.py +2 -1
- stubber/stubber.py +5 -6
- stubber/update_fallback.py +3 -1
- stubber/update_module_list.py +1 -1
- stubber/utils/__init__.py +1 -1
- stubber/utils/config.py +7 -9
- stubber/utils/post.py +1 -1
- stubber/utils/repos.py +10 -7
- stubber/utils/versions.py +48 -7
- stubber/variants.py +3 -3
- stubber/board/logging.py +0 -99
- {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/LICENSE +0 -0
- {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/WHEEL +0 -0
- {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/entry_points.txt +0 -0
@@ -1,304 +1,325 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
1
|
+
A2='No report file'
|
2
|
+
A1='Failed to create the report.'
|
3
|
+
A0='method'
|
4
|
+
z='function'
|
5
|
+
y='bool'
|
6
|
+
x='str'
|
7
|
+
w='float'
|
8
|
+
v='int'
|
9
|
+
u='micropython'
|
10
|
+
t='stubber'
|
11
|
+
s=TypeError
|
12
|
+
r=Exception
|
13
|
+
q=KeyError
|
14
|
+
p=sorted
|
15
|
+
o=MemoryError
|
16
|
+
n=NotImplementedError
|
17
|
+
j=',\n'
|
18
|
+
i='modules.json'
|
19
|
+
h='{}/{}'
|
20
|
+
g='w'
|
21
|
+
f='dict'
|
22
|
+
e='list'
|
23
|
+
d='tuple'
|
24
|
+
c=str
|
25
|
+
b=repr
|
26
|
+
W='-preview'
|
27
|
+
V='-'
|
28
|
+
U='board'
|
29
|
+
T=IndexError
|
30
|
+
S=print
|
31
|
+
R=True
|
32
|
+
Q='family'
|
33
|
+
P=len
|
34
|
+
O=ImportError
|
35
|
+
N=dir
|
36
|
+
M=open
|
37
|
+
K='port'
|
30
38
|
J='.'
|
31
|
-
I=
|
32
|
-
H=
|
39
|
+
I=AttributeError
|
40
|
+
H=False
|
33
41
|
G='/'
|
34
|
-
F=False
|
35
42
|
E=None
|
36
|
-
D=
|
37
|
-
|
38
|
-
|
39
|
-
import gc as
|
40
|
-
from ujson import dumps as c
|
41
|
-
try:from machine import reset
|
42
|
-
except P:pass
|
43
|
-
try:from collections import OrderedDict as d
|
44
|
-
except P:from ucollections import OrderedDict as d
|
45
|
-
__version__='v1.16.2'
|
46
|
-
w=2
|
47
|
-
x=2
|
48
|
-
e=[J,'/lib','/sd/lib','/flash/lib','lib']
|
43
|
+
D=OSError
|
44
|
+
C='version'
|
45
|
+
B=''
|
46
|
+
import gc as F,os,sys
|
49
47
|
from time import sleep
|
48
|
+
try:from ujson import dumps
|
49
|
+
except:from json import dumps
|
50
|
+
try:from machine import reset
|
51
|
+
except O:pass
|
52
|
+
try:from collections import OrderedDict as k
|
53
|
+
except O:from ucollections import OrderedDict as k
|
54
|
+
__version__='v1.17.0'
|
55
|
+
A3=2
|
56
|
+
A4=2
|
57
|
+
A5=['lib','/lib','/sd/lib','/flash/lib',J]
|
58
|
+
class L:
|
59
|
+
INFO=20;WARNING=30;ERROR=40;level=INFO;prnt=S
|
60
|
+
@staticmethod
|
61
|
+
def getLogger(name):return L()
|
62
|
+
@classmethod
|
63
|
+
def basicConfig(A,level):A.level=level
|
64
|
+
def info(A,msg):
|
65
|
+
if A.level<=L.INFO:A.prnt('INFO :',msg)
|
66
|
+
def warning(A,msg):
|
67
|
+
if A.level<=L.WARNING:A.prnt('WARN :',msg)
|
68
|
+
def error(A,msg):
|
69
|
+
if A.level<=L.ERROR:A.prnt('ERROR :',msg)
|
70
|
+
A=L.getLogger(t)
|
71
|
+
L.basicConfig(level=L.INFO)
|
50
72
|
class Stubber:
|
51
|
-
def __init__(
|
52
|
-
|
73
|
+
def __init__(B,path=E,firmware_id=E):
|
74
|
+
C=firmware_id
|
53
75
|
try:
|
54
|
-
if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise
|
55
|
-
except
|
56
|
-
|
57
|
-
if
|
58
|
-
elif
|
59
|
-
else:
|
60
|
-
|
76
|
+
if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise n('MicroPython 1.13.0 cannot be stubbed')
|
77
|
+
except I:pass
|
78
|
+
B.info=_info();A.info('Port: {}'.format(B.info[K]));A.info('Board: {}'.format(B.info[U]));F.collect()
|
79
|
+
if C:B._fwid=C.lower()
|
80
|
+
elif B.info[Q]==u:B._fwid='{family}-v{version}-{port}-{board}'.format(**B.info).rstrip(V)
|
81
|
+
else:B._fwid='{family}-v{version}-{port}'.format(**B.info)
|
82
|
+
B._start_free=F.mem_free()
|
61
83
|
if path:
|
62
84
|
if path.endswith(G):path=path[:-1]
|
63
85
|
else:path=get_root()
|
64
|
-
|
65
|
-
try:
|
66
|
-
except A
|
67
|
-
|
86
|
+
B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',G)
|
87
|
+
try:X(path+G)
|
88
|
+
except D:A.error('error creating stub folder {}'.format(path))
|
89
|
+
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=E;B._json_first=H
|
68
90
|
def get_obj_attributes(L,item_instance):
|
69
|
-
|
70
|
-
for A in
|
71
|
-
if A.startswith(
|
91
|
+
H=item_instance;C=[];K=[]
|
92
|
+
for A in N(H):
|
93
|
+
if A.startswith('__')and not A in L.modules:continue
|
72
94
|
try:
|
73
|
-
|
74
|
-
try:
|
75
|
-
except
|
76
|
-
if
|
77
|
-
elif
|
78
|
-
elif
|
95
|
+
D=getattr(H,A)
|
96
|
+
try:E=b(type(D)).split("'")[1]
|
97
|
+
except T:E=B
|
98
|
+
if E in{v,w,x,y,d,e,f}:G=1
|
99
|
+
elif E in{z,A0}:G=2
|
100
|
+
elif E in'class':G=3
|
79
101
|
else:G=4
|
80
|
-
|
81
|
-
except
|
82
|
-
except
|
83
|
-
|
84
|
-
def add_modules(A,modules):A.modules=
|
85
|
-
def create_all_stubs(
|
86
|
-
B.collect()
|
87
|
-
for C in
|
102
|
+
C.append((A,b(D),b(type(D)),D,G))
|
103
|
+
except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
|
104
|
+
except o as J:S('MemoryError: {}'.format(J));sleep(1);reset()
|
105
|
+
C=p([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
|
106
|
+
def add_modules(A,modules):A.modules=p(set(A.modules)|set(modules))
|
107
|
+
def create_all_stubs(B):
|
108
|
+
A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();F.collect()
|
109
|
+
for C in B.modules:B.create_one_stub(C)
|
110
|
+
B.report_end();A.info('Finally done')
|
88
111
|
def create_one_stub(C,module_name):
|
89
|
-
|
90
|
-
if
|
91
|
-
if
|
92
|
-
|
93
|
-
try:E=C.create_module_stub(
|
94
|
-
except
|
95
|
-
|
112
|
+
B=module_name
|
113
|
+
if B in C.problematic:A.warning('Skip module: {:<25} : Known problematic'.format(B));return H
|
114
|
+
if B in C.excluded:A.warning('Skip module: {:<25} : Excluded'.format(B));return H
|
115
|
+
I='{}/{}.pyi'.format(C.path,B.replace(J,G));F.collect();E=H
|
116
|
+
try:E=C.create_module_stub(B,I)
|
117
|
+
except D:return H
|
118
|
+
F.collect();return E
|
96
119
|
def create_module_stub(K,module_name,file_name=E):
|
97
|
-
|
98
|
-
if
|
99
|
-
else:
|
100
|
-
if G in
|
101
|
-
|
102
|
-
try:
|
103
|
-
except
|
104
|
-
|
105
|
-
with I
|
106
|
-
K.
|
107
|
-
if
|
108
|
-
try:del
|
109
|
-
except(
|
110
|
-
|
111
|
-
except S:pass
|
112
|
-
B.collect();return M
|
120
|
+
I=file_name;C=module_name
|
121
|
+
if I is E:L=C.replace(J,'_')+'.pyi';I=K.path+G+L
|
122
|
+
else:L=I.split(G)[-1]
|
123
|
+
if G in C:C=C.replace(G,J)
|
124
|
+
N=E
|
125
|
+
try:N=__import__(C,E,E,'*');Q=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,Q))
|
126
|
+
except O:return H
|
127
|
+
X(I)
|
128
|
+
with M(I,g)as P:S=c(K.info).replace('OrderedDict(',B).replace('})','}');T='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,K._fwid,S,__version__);P.write(T);P.write('from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n');K.write_object_stub(P,N,C,B)
|
129
|
+
K.report_add(C,I)
|
130
|
+
if C not in{'os','sys','logging','gc'}:
|
131
|
+
try:del N
|
132
|
+
except(D,q):A.warning('could not del new_module')
|
133
|
+
F.collect();return R
|
113
134
|
def write_object_stub(K,fp,object_expr,obj_name,indent,in_class=0):
|
114
|
-
|
115
|
-
if
|
116
|
-
|
117
|
-
if
|
118
|
-
for(
|
119
|
-
if
|
120
|
-
if
|
121
|
-
if
|
122
|
-
|
123
|
-
if
|
124
|
-
|
125
|
-
if
|
126
|
-
|
127
|
-
elif any(A in
|
128
|
-
|
129
|
-
if
|
130
|
-
if
|
131
|
-
else:
|
132
|
-
D
|
133
|
-
elif
|
134
|
-
elif
|
135
|
-
|
136
|
-
if
|
137
|
-
elif
|
138
|
-
|
139
|
-
if
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
try:del F,J,G,T
|
145
|
-
except(A,S,n):pass
|
135
|
+
X='generator';W='{0}{1}: {3} = {2}\n';V='bound_method';U='Incomplete';N=in_class;M='Exception';L=object_expr;I=fp;D=indent;F.collect()
|
136
|
+
if L in K.problematic:A.warning('SKIPPING problematic module:{}'.format(L));return
|
137
|
+
Y,O=K.get_obj_attributes(L)
|
138
|
+
if O:A.error(O)
|
139
|
+
for(E,J,H,Z,b)in Y:
|
140
|
+
if E in['classmethod','staticmethod','BaseException',M]:continue
|
141
|
+
if E[0].isdigit():A.warning('NameError: invalid name {}'.format(E));continue
|
142
|
+
if H=="<class 'type'>"and P(D)<=A4*4:
|
143
|
+
Q=B;R=E.endswith(M)or E.endswith('Error')or E in['KeyboardInterrupt','StopIteration','SystemExit']
|
144
|
+
if R:Q=M
|
145
|
+
C='\n{}class {}({}):\n'.format(D,E,Q)
|
146
|
+
if R:C+=D+' ...\n';I.write(C);continue
|
147
|
+
I.write(C);K.write_object_stub(I,Z,'{0}.{1}'.format(obj_name,E),D+' ',N+1);C=D+' def __init__(self, *argv, **kwargs) -> None:\n';C+=D+' ...\n\n';I.write(C)
|
148
|
+
elif any(A in H for A in[A0,z,'closure']):
|
149
|
+
S=U;T=B
|
150
|
+
if N>0:T='self, '
|
151
|
+
if V in H or V in J:C='{}@classmethod\n'.format(D)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(D,E,S)
|
152
|
+
else:C='{}def {}({}*args, **kwargs) -> {}:\n'.format(D,E,T,S)
|
153
|
+
C+=D+' ...\n\n';I.write(C)
|
154
|
+
elif H=="<class 'module'>":0
|
155
|
+
elif H.startswith("<class '"):
|
156
|
+
G=H[8:-2];C=B
|
157
|
+
if G in(x,v,w,y,'bytearray','bytes'):C=W.format(D,E,J,G)
|
158
|
+
elif G in(f,e,d):a={f:'{}',e:'[]',d:'()'};C=W.format(D,E,a[G],G)
|
159
|
+
elif G in('object','set','frozenset','Pin',X):
|
160
|
+
if G==X:G='Generator'
|
161
|
+
C='{0}{1}: {2} ## = {4}\n'.format(D,E,G,H,J)
|
162
|
+
else:G=U;C='{0}{1}: {2} ## {3} = {4}\n'.format(D,E,G,H,J)
|
163
|
+
I.write(C)
|
164
|
+
else:I.write("# all other, type = '{0}'\n".format(H));I.write(D+E+' # type: Incomplete\n')
|
146
165
|
@property
|
147
166
|
def flat_fwid(self):
|
148
167
|
A=self._fwid;B=' .()/\\:$'
|
149
|
-
for C in B:A=A.replace(C,
|
168
|
+
for C in B:A=A.replace(C,'_')
|
150
169
|
return A
|
151
170
|
def clean(C,path=E):
|
152
171
|
if path is E:path=C.path
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
172
|
+
A.info('Clean/remove files in folder: {}'.format(path))
|
173
|
+
try:os.stat(path);F=os.listdir(path)
|
174
|
+
except(D,I):return
|
175
|
+
for G in F:
|
176
|
+
B=h.format(path,G)
|
157
177
|
try:os.remove(B)
|
158
|
-
except
|
178
|
+
except D:
|
159
179
|
try:C.clean(B);os.rmdir(B)
|
160
|
-
except
|
161
|
-
def
|
162
|
-
|
180
|
+
except D:pass
|
181
|
+
def report_start(B,filename=i):
|
182
|
+
H='firmware';B._json_name=h.format(B.path,filename);B._json_first=R;X(B._json_name);A.info('Report file: {}'.format(B._json_name));F.collect()
|
183
|
+
try:
|
184
|
+
with M(B._json_name,g)as G:G.write('{');G.write(dumps({H:B.info})[1:-1]);G.write(j);G.write(dumps({t:{C:__version__},'stubtype':H})[1:-1]);G.write(j);G.write('"modules" :[\n')
|
185
|
+
except D as I:A.error(A1);B._json_name=E;raise I
|
186
|
+
def report_add(B,module_name,stub_file):
|
187
|
+
if not B._json_name:raise r(A2)
|
163
188
|
try:
|
164
|
-
with
|
165
|
-
C.
|
166
|
-
|
167
|
-
C.
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
def f(path):
|
176
|
-
B=D=0
|
189
|
+
with M(B._json_name,'a')as C:
|
190
|
+
if not B._json_first:C.write(j)
|
191
|
+
else:B._json_first=H
|
192
|
+
E='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',G));C.write(E)
|
193
|
+
except D:A.error(A1)
|
194
|
+
def report_end(B):
|
195
|
+
if not B._json_name:raise r(A2)
|
196
|
+
with M(B._json_name,'a')as C:C.write('\n]}')
|
197
|
+
A.info('Path: {}'.format(B.path))
|
198
|
+
def X(path):
|
199
|
+
B=E=0
|
177
200
|
while B!=-1:
|
178
|
-
B=path.find(G,
|
201
|
+
B=path.find(G,E)
|
179
202
|
if B!=-1:
|
180
203
|
C=path[0]if B==0 else path[:B]
|
181
|
-
try:
|
182
|
-
except
|
183
|
-
if
|
204
|
+
try:I=os.stat(C)
|
205
|
+
except D as F:
|
206
|
+
if F.args[0]==A3:
|
184
207
|
try:os.mkdir(C)
|
185
|
-
except
|
186
|
-
|
187
|
-
def
|
188
|
-
|
189
|
-
if not s:return
|
190
|
-
|
191
|
-
|
208
|
+
except D as H:A.error('failed to create folder {}'.format(C));raise H
|
209
|
+
E=B+1
|
210
|
+
def Y(s):
|
211
|
+
C=' on '
|
212
|
+
if not s:return B
|
213
|
+
s=s.split(C,1)[0]if C in s else s
|
214
|
+
if s.startswith('v'):
|
215
|
+
if not V in s:return B
|
216
|
+
A=s.split(V)[1];return A
|
217
|
+
if not W in s:return B
|
218
|
+
A=s.split(W)[1].split(J)[1];return A
|
192
219
|
def _info():
|
193
|
-
|
194
|
-
if A[
|
195
|
-
elif A[
|
196
|
-
elif A[
|
197
|
-
try:A[
|
198
|
-
except
|
199
|
-
try:
|
200
|
-
except(
|
201
|
-
|
202
|
-
for N in[A+'/board_info.csv'for A in e]:
|
203
|
-
if h(N):
|
204
|
-
M=A[K].strip()
|
205
|
-
if g(A,M,N):break
|
206
|
-
if Y in M:
|
207
|
-
M=M.split(Y)[0].strip()
|
208
|
-
if g(A,M,N):break
|
209
|
-
A[K]=i
|
210
|
-
A[K]=A[K].replace(' ',T);B.collect()
|
220
|
+
Z='ev3-pybricks';X='pycom';V='pycopy';S='unix';R='win32';P='arch';M='cpu';L='ver';F='mpy';D='build';A=k({Q:sys.implementation.name,C:B,D:B,L:B,K:sys.platform,U:'UNKNOWN',M:B,F:B,P:B})
|
221
|
+
if A[K].startswith('pyb'):A[K]='stm32'
|
222
|
+
elif A[K]==R:A[K]='windows'
|
223
|
+
elif A[K]=='linux':A[K]=S
|
224
|
+
try:A[C]=A6(sys.implementation.version)
|
225
|
+
except I:pass
|
226
|
+
try:H=sys.implementation._machine if'_machine'in N(sys.implementation)else os.uname().machine;A[U]=H;A[M]=H.split('with')[-1].strip();A[F]=sys.implementation._mpy if'_mpy'in N(sys.implementation)else sys.implementation.mpy if F in N(sys.implementation)else B
|
227
|
+
except(I,T):pass
|
228
|
+
A[U]=A7()
|
211
229
|
try:
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
if A[
|
218
|
-
try:
|
219
|
-
except(
|
220
|
-
for(
|
221
|
-
try:
|
222
|
-
except(
|
223
|
-
if A[
|
224
|
-
if A[
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
A[
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
try:B=os.getcwd()
|
241
|
-
except(A,H):B=J
|
242
|
-
C=B
|
243
|
-
for C in[B,'/sd','/flash',G,J]:
|
244
|
-
try:D=os.stat(C);break
|
245
|
-
except A:continue
|
230
|
+
if'uname'in N(os):
|
231
|
+
A[D]=Y(os.uname()[3])
|
232
|
+
if not A[D]:A[D]=Y(os.uname()[2])
|
233
|
+
elif C in N(sys):A[D]=Y(sys.version)
|
234
|
+
except(I,T,s):pass
|
235
|
+
if A[C]==B and sys.platform not in(S,R):
|
236
|
+
try:a=os.uname();A[C]=a.release
|
237
|
+
except(T,I,s):pass
|
238
|
+
for(b,c,d)in[(V,V,'const'),(X,X,'FAT'),(Z,'pybricks.hubs','EV3Brick')]:
|
239
|
+
try:e=__import__(c,E,E,d);A[Q]=b;del e;break
|
240
|
+
except(O,q):pass
|
241
|
+
if A[Q]==Z:A['release']='2.0.0'
|
242
|
+
if A[Q]==u:
|
243
|
+
A[C]
|
244
|
+
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]
|
245
|
+
if F in A and A[F]:
|
246
|
+
G=int(A[F]);J=[E,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][G>>10]
|
247
|
+
if J:A[P]=J
|
248
|
+
A[F]='v{}.{}'.format(G&255,G>>8&3)
|
249
|
+
if A[D]and not A[C].endswith(W):A[C]=A[C]+W
|
250
|
+
A[L]=f"{A[C]}-{A[D]}"if A[D]else f"{A[C]}";return A
|
251
|
+
def A6(version):
|
252
|
+
A=version;B=J.join([c(A)for A in A[:3]])
|
253
|
+
if P(A)>3 and A[3]:B+=V+A[3]
|
254
|
+
return B
|
255
|
+
def A7():
|
256
|
+
try:from boardname import BOARDNAME as C;A.info('Found BOARDNAME: {}'.format(C))
|
257
|
+
except O:A.warning('BOARDNAME not found');C=B
|
246
258
|
return C
|
247
|
-
def
|
259
|
+
def get_root():
|
260
|
+
try:A=os.getcwd()
|
261
|
+
except(D,I):A=J
|
262
|
+
B=A
|
263
|
+
for B in[A,'/sd','/flash',G,J]:
|
264
|
+
try:C=os.stat(B);break
|
265
|
+
except D:continue
|
266
|
+
return B
|
267
|
+
def Z(filename):
|
248
268
|
try:
|
249
|
-
if os.stat(filename)[0]>>14:return
|
250
|
-
return
|
251
|
-
except
|
252
|
-
def
|
269
|
+
if os.stat(filename)[0]>>14:return R
|
270
|
+
return H
|
271
|
+
except D:return H
|
272
|
+
def l():S("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
|
253
273
|
def read_path():
|
254
|
-
path=
|
255
|
-
if
|
274
|
+
path=B
|
275
|
+
if P(sys.argv)==3:
|
256
276
|
A=sys.argv[1].lower()
|
257
277
|
if A in('--path','-p'):path=sys.argv[2]
|
258
|
-
else:
|
259
|
-
elif
|
278
|
+
else:l()
|
279
|
+
elif P(sys.argv)==2:l()
|
260
280
|
return path
|
261
|
-
def
|
262
|
-
try:A=bytes('abc',encoding='utf8');B=
|
263
|
-
except(
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
if not N:stubber.clean()
|
270
|
-
y(stubber);D={}
|
271
|
-
try:
|
272
|
-
with I(G)as C:
|
273
|
-
for E in C.read().split('\n'):
|
274
|
-
E=E.strip();B.collect()
|
275
|
-
if L(E)>0:P,Q=E.split('=',1);D[P]=Q
|
276
|
-
except(A,SyntaxError):pass
|
277
|
-
B.collect();R=[A for A in stubber.modules if A not in D.keys()];B.collect()
|
278
|
-
for H in R:
|
279
|
-
J=F
|
280
|
-
try:J=stubber.create_one_stub(H)
|
281
|
-
except l:O.reset()
|
282
|
-
B.collect();D[H]=W(stubber._report[-1]if J else K)
|
283
|
-
with I(G,'a')as C:C.write('{}={}\n'.format(H,'ok'if J else K))
|
284
|
-
if D:stubber._report=[A for(B,A)in D.items()if A!=K];stubber.report()
|
285
|
-
def y(stubber):
|
286
|
-
E='/modulelist.txt';stubber.modules=[]
|
287
|
-
for D in e:
|
281
|
+
def m():
|
282
|
+
try:A=bytes('abc',encoding='utf8');B=m.__module__;return H
|
283
|
+
except(n,I):return R
|
284
|
+
a='modulelist.done'
|
285
|
+
def A8(skip=0):
|
286
|
+
for E in A5:
|
287
|
+
B=E+'/modulelist.txt'
|
288
|
+
if not Z(B):continue
|
288
289
|
try:
|
289
|
-
with
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
if
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
290
|
+
with M(B)as F:
|
291
|
+
C=0
|
292
|
+
while R:
|
293
|
+
A=F.readline().strip()
|
294
|
+
if not A:break
|
295
|
+
if P(A)>0 and A[0]=='#':continue
|
296
|
+
C+=1
|
297
|
+
if C<skip:continue
|
298
|
+
yield A
|
299
|
+
break
|
300
|
+
except D:pass
|
301
|
+
def A9(done):
|
302
|
+
with M(a,g)as A:A.write(c(done)+'\n')
|
303
|
+
def AA():
|
304
|
+
A=0
|
305
|
+
try:
|
306
|
+
with M(a)as B:A=int(B.readline().strip())
|
307
|
+
except D:pass
|
308
|
+
return A
|
309
|
+
def main():
|
310
|
+
import machine as D;C=Z(a)
|
311
|
+
if C:A.info('Continue from last run')
|
312
|
+
else:A.info('Starting new run')
|
313
|
+
stubber=Stubber(path=read_path());B=0
|
314
|
+
if not C:stubber.clean();stubber.report_start(i)
|
315
|
+
else:B=AA();stubber._json_name=h.format(stubber.path,i)
|
316
|
+
for E in A8(B):
|
317
|
+
try:stubber.create_one_stub(E)
|
318
|
+
except o:D.reset()
|
319
|
+
F.collect();B+=1;A9(B)
|
320
|
+
S('All modules have been processed, Finalizing report');stubber.report_end()
|
321
|
+
if __name__=='__main__'or m():
|
322
|
+
if not Z('no_auto_stubber.txt'):
|
323
|
+
try:F.threshold(4*1024);F.enable()
|
303
324
|
except BaseException:pass
|
304
325
|
main()
|
Binary file
|