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