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