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.
Files changed (55) hide show
  1. {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/METADATA +2 -1
  2. {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/RECORD +54 -54
  3. stubber/__init__.py +1 -1
  4. stubber/basicgit.py +27 -33
  5. stubber/board/board_info.csv +137 -103
  6. stubber/board/createstubs.py +222 -189
  7. stubber/board/createstubs_db.py +284 -214
  8. stubber/board/createstubs_db_min.py +286 -265
  9. stubber/board/createstubs_db_mpy.mpy +0 -0
  10. stubber/board/createstubs_lvgl.py +171 -113
  11. stubber/board/createstubs_lvgl_min.py +738 -275
  12. stubber/board/createstubs_lvgl_mpy.mpy +0 -0
  13. stubber/board/createstubs_mem.py +237 -174
  14. stubber/board/createstubs_mem_min.py +263 -247
  15. stubber/board/createstubs_mem_mpy.mpy +0 -0
  16. stubber/board/createstubs_min.py +242 -227
  17. stubber/board/createstubs_mpy.mpy +0 -0
  18. stubber/board/fw_info.py +135 -0
  19. stubber/board/modulelist.txt +1 -2
  20. stubber/codemod/_partials/__init__.py +1 -1
  21. stubber/codemod/_partials/db_main.py +90 -72
  22. stubber/codemod/_partials/modules_reader.py +29 -17
  23. stubber/codemod/board.py +2 -4
  24. stubber/codemod/enrich.py +1 -1
  25. stubber/commands/build_cmd.py +6 -4
  26. stubber/commands/get_docstubs_cmd.py +6 -11
  27. stubber/commands/get_frozen_cmd.py +6 -11
  28. stubber/commands/switch_cmd.py +6 -4
  29. stubber/data/board_info.csv +134 -101
  30. stubber/data/board_info.json +1357 -901
  31. stubber/freeze/freeze_manifest_2.py +2 -1
  32. stubber/freeze/get_frozen.py +28 -13
  33. stubber/minify.py +56 -43
  34. stubber/publish/candidates.py +15 -23
  35. stubber/publish/defaults.py +2 -2
  36. stubber/publish/merge_docstubs.py +5 -7
  37. stubber/publish/missing_class_methods.py +2 -2
  38. stubber/publish/pathnames.py +2 -2
  39. stubber/publish/publish.py +2 -1
  40. stubber/publish/stubpackage.py +20 -40
  41. stubber/rst/lookup.py +9 -7
  42. stubber/rst/reader.py +2 -1
  43. stubber/stubber.py +5 -6
  44. stubber/update_fallback.py +3 -1
  45. stubber/update_module_list.py +1 -1
  46. stubber/utils/__init__.py +1 -1
  47. stubber/utils/config.py +7 -9
  48. stubber/utils/post.py +1 -1
  49. stubber/utils/repos.py +10 -7
  50. stubber/utils/versions.py +48 -7
  51. stubber/variants.py +3 -3
  52. stubber/board/logging.py +0 -99
  53. {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/LICENSE +0 -0
  54. {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/WHEEL +0 -0
  55. {micropython_stubber-1.16.2.dist-info → micropython_stubber-1.17.0.dist-info}/entry_points.txt +0 -0
@@ -1,257 +1,274 @@
1
- w='pyb'
2
- v='stubber'
3
- u='{}/{}'
4
- t='logging'
5
- s='sys'
6
- r='method'
7
- q='function'
8
- p='bool'
9
- o='str'
10
- n='float'
11
- m='int'
12
- l=NameError
1
+ z='No report file'
2
+ y='Failed to create the report.'
3
+ x='{}/{}'
4
+ w='logging'
5
+ v='sys'
6
+ u='method'
7
+ t='function'
8
+ s='bool'
9
+ r='str'
10
+ q='float'
11
+ p='int'
12
+ o='stubber'
13
+ n=TypeError
14
+ m=Exception
15
+ l=KeyError
13
16
  k=sorted
14
17
  j=NotImplementedError
15
- b='pycom'
16
- a=',\n'
17
- Z='dict'
18
- Y='list'
19
- X='tuple'
20
- W='micropython'
21
- V=open
22
- U=repr
23
- S='_'
18
+ f='pycom'
19
+ e=',\n'
20
+ d='dict'
21
+ c='list'
22
+ b='tuple'
23
+ a='micropython'
24
+ Z=repr
25
+ Y=print
26
+ V='-preview'
27
+ U=True
28
+ T='-'
29
+ S='board'
24
30
  R=len
25
- Q=KeyError
31
+ Q=open
26
32
  P=IndexError
27
- O=dir
28
- M=print
33
+ O='family'
29
34
  N=ImportError
30
- K=True
31
- L='family'
32
- J='board'
33
- I='.'
34
- H=AttributeError
35
- A=False
35
+ M=dir
36
+ K='port'
37
+ J='.'
38
+ I=AttributeError
39
+ H=False
36
40
  G='/'
37
- E=None
38
- F=OSError
39
- D='version'
41
+ E=OSError
42
+ D=None
43
+ C='version'
40
44
  B=''
41
- import gc as C,os,sys
42
- from ujson import dumps as c
45
+ import gc as F,os,sys
46
+ from time import sleep
47
+ try:from ujson import dumps
48
+ except:from json import dumps
43
49
  try:from machine import reset
44
50
  except N:pass
45
- try:from collections import OrderedDict as d
46
- except N:from ucollections import OrderedDict as d
47
- __version__='v1.16.2'
48
- x=2
49
- y=2
50
- z=[I,'/lib','/sd/lib','/flash/lib','lib']
51
- from time import sleep
51
+ try:from collections import OrderedDict as g
52
+ except N:from ucollections import OrderedDict as g
53
+ __version__='v1.17.0'
54
+ A0=2
55
+ A1=2
56
+ A5=['lib','/lib','/sd/lib','/flash/lib',J]
57
+ class L:
58
+ INFO=20;WARNING=30;ERROR=40;level=INFO;prnt=Y
59
+ @staticmethod
60
+ def getLogger(name):return L()
61
+ @classmethod
62
+ def basicConfig(A,level):A.level=level
63
+ def info(A,msg):
64
+ if A.level<=L.INFO:A.prnt('INFO :',msg)
65
+ def warning(A,msg):
66
+ if A.level<=L.WARNING:A.prnt('WARN :',msg)
67
+ def error(A,msg):
68
+ if A.level<=L.ERROR:A.prnt('ERROR :',msg)
69
+ A=L.getLogger(o)
70
+ L.basicConfig(level=L.INFO)
52
71
  class Stubber:
53
- def __init__(A,path=E,firmware_id=E):
54
- B=firmware_id
72
+ def __init__(B,path=D,firmware_id=D):
73
+ C=firmware_id
55
74
  try:
56
75
  if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise j('MicroPython 1.13.0 cannot be stubbed')
57
- except H:pass
58
- A._report=[];A.info=_info();C.collect()
59
- if B:A._fwid=B.lower()
60
- elif A.info[L]==W:A._fwid='{family}-{ver}-{port}-{board}'.format(**A.info)
61
- else:A._fwid='{family}-{ver}-{port}'.format(**A.info)
62
- A._start_free=C.mem_free()
76
+ except I:pass
77
+ B.info=_info();A.info('Port: {}'.format(B.info[K]));A.info('Board: {}'.format(B.info[S]));F.collect()
78
+ if C:B._fwid=C.lower()
79
+ elif B.info[O]==a:B._fwid='{family}-v{version}-{port}-{board}'.format(**B.info).rstrip(T)
80
+ else:B._fwid='{family}-v{version}-{port}'.format(**B.info)
81
+ B._start_free=F.mem_free()
63
82
  if path:
64
83
  if path.endswith(G):path=path[:-1]
65
84
  else:path=get_root()
66
- A.path='{}/stubs/{}'.format(path,A.flat_fwid).replace('//',G)
67
- try:e(path+G)
68
- except F:M('error creating stub folder {}'.format(path))
69
- A.problematic=['upip','upysh','webrepl_setup','http_client','http_client_ssl','http_server','http_server_ssl'];A.excluded=['webrepl','_webrepl','port_diag','example_sub_led.py','example_pub_button.py'];A.modules=[]
85
+ B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',G)
86
+ try:W(path+G)
87
+ except E:A.error('error creating stub folder {}'.format(path))
88
+ 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
70
89
  def get_obj_attributes(L,item_instance):
71
- I=item_instance;D=[];J=[]
72
- for A in O(I):
73
- if A.startswith(S)and not A in L.modules:continue
90
+ H=item_instance;C=[];K=[]
91
+ for A in M(H):
92
+ if A.startswith('__')and not A in L.modules:continue
74
93
  try:
75
- E=getattr(I,A)
76
- try:F=U(type(E)).split("'")[1]
77
- except P:F=B
78
- if F in{m,n,o,p,X,Y,Z}:G=1
79
- elif F in{q,r}:G=2
80
- elif F in'class':G=3
94
+ D=getattr(H,A)
95
+ try:E=Z(type(D)).split("'")[1]
96
+ except P:E=B
97
+ if E in{p,q,r,s,b,c,d}:G=1
98
+ elif E in{t,u}:G=2
99
+ elif E in'class':G=3
81
100
  else:G=4
82
- D.append((A,U(E),U(type(E)),E,G))
83
- except H as K:J.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,I,K))
84
- except MemoryError as K:sleep(1);reset()
85
- D=k([A for A in D if not A[0].startswith('__')],key=lambda x:x[4]);C.collect();return D,J
101
+ C.append((A,Z(D),Z(type(D)),D,G))
102
+ except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
103
+ except MemoryError as J:Y('MemoryError: {}'.format(J));sleep(1);reset()
104
+ C=k([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
86
105
  def add_modules(A,modules):A.modules=k(set(A.modules)|set(modules))
87
- def create_all_stubs(A):
88
- C.collect()
89
- for B in A.modules:A.create_one_stub(B)
90
- def create_one_stub(B,module_name):
91
- D=module_name
92
- if D in B.problematic:return A
93
- if D in B.excluded:return A
94
- H='{}/{}.py'.format(B.path,D.replace(I,G));C.collect();E=A
95
- try:E=B.create_module_stub(D,H)
96
- except F:return A
97
- C.collect();return E
98
- def create_module_stub(J,module_name,file_name=E):
99
- H=file_name;D=module_name
100
- if H is E:O=D.replace(I,S)+'.py';H=J.path+G+O
101
- else:O=H.split(G)[-1]
102
- if G in D:D=D.replace(G,I)
103
- L=E
104
- try:L=__import__(D,E,E,'*');T=C.mem_free()
105
- except N:return A
106
- e(H)
107
- with V(H,'w')as M:P=str(J.info).replace('OrderedDict(',B).replace('})','}');R='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(D,J._fwid,P,__version__);M.write(R);M.write('from typing import Any\nfrom _typeshed import Incomplete\n\n');J.write_object_stub(M,L,D,B)
108
- J._report.append('{{"module": "{}", "file": "{}"}}'.format(D,H.replace('\\',G)))
109
- if D not in{'os',s,t,'gc'}:
110
- try:del L
111
- except(F,Q):pass
112
- try:del sys.modules[D]
113
- except Q:pass
114
- C.collect();return K
106
+ def create_all_stubs(B):
107
+ A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();F.collect()
108
+ for C in B.modules:B.create_one_stub(C)
109
+ B.report_end();A.info('Finally done')
110
+ def create_one_stub(C,module_name):
111
+ B=module_name
112
+ if B in C.problematic:A.warning('Skip module: {:<25} : Known problematic'.format(B));return H
113
+ if B in C.excluded:A.warning('Skip module: {:<25} : Excluded'.format(B));return H
114
+ I='{}/{}.pyi'.format(C.path,B.replace(J,G));F.collect();D=H
115
+ try:D=C.create_module_stub(B,I)
116
+ except E:return H
117
+ F.collect();return D
118
+ def create_module_stub(K,module_name,file_name=D):
119
+ I=file_name;C=module_name
120
+ if I is D:L=C.replace(J,'_')+'.pyi';I=K.path+G+L
121
+ else:L=I.split(G)[-1]
122
+ if G in C:C=C.replace(G,J)
123
+ M=D
124
+ try:M=__import__(C,D,D,'*');P=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,P))
125
+ except N:return H
126
+ W(I)
127
+ with Q(I,'w')as O:R=str(K.info).replace('OrderedDict(',B).replace('})','}');S='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,K._fwid,R,__version__);O.write(S);O.write('from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n');K.write_object_stub(O,M,C,B)
128
+ K.report_add(C,I)
129
+ if C not in{'os',v,w,'gc'}:
130
+ try:del M
131
+ except(E,l):A.warning('could not del new_module')
132
+ F.collect();return U
115
133
  def write_object_stub(K,fp,object_expr,obj_name,indent,in_class=0):
116
- d='{0}{1} = {2} # type: {3}\n';c='bound_method';b='Incomplete';P=in_class;O=object_expr;N='Exception';H=fp;D=indent;C.collect()
117
- if O in K.problematic:return
118
- S,L=K.get_obj_attributes(O)
119
- if L:M(L)
120
- for(E,J,G,T,f)in S:
121
- if E in['classmethod','staticmethod','BaseException',N]:continue
122
- if E[0].isdigit():continue
123
- if G=="<class 'type'>"and R(D)<=y*4:
124
- U=B;V=E.endswith(N)or E.endswith('Error')or E in['KeyboardInterrupt','StopIteration','SystemExit']
125
- if V:U=N
126
- A='\n{}class {}({}):\n'.format(D,E,U)
127
- if V:A+=D+' ...\n';H.write(A);return
128
- H.write(A);K.write_object_stub(H,T,'{0}.{1}'.format(obj_name,E),D+' ',P+1);A=D+' def __init__(self, *argv, **kwargs) -> None:\n';A+=D+' ...\n\n';H.write(A)
129
- elif any(A in G for A in[r,q,'closure']):
130
- W=b;a=B
131
- if P>0:a='self, '
132
- if c in G or c in J:A='{}@classmethod\n'.format(D)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(D,E,W)
133
- else:A='{}def {}({}*args, **kwargs) -> {}:\n'.format(D,E,a,W)
134
- A+=D+' ...\n\n';H.write(A)
135
- elif G=="<class 'module'>":0
136
- elif G.startswith("<class '"):
137
- I=G[8:-2];A=B
138
- if I in[o,m,n,p,'bytearray','bytes']:A=d.format(D,E,J,I)
139
- elif I in[Z,Y,X]:e={Z:'{}',Y:'[]',X:'()'};A=d.format(D,E,e[I],I)
140
- else:
141
- if I not in['object','set','frozenset']:I=b
142
- A='{0}{1} : {2} ## {3} = {4}\n'.format(D,E,I,G,J)
143
- H.write(A)
144
- else:H.write("# all other, type = '{0}'\n".format(G));H.write(D+E+' # type: Incomplete\n')
145
- del S;del L
146
- try:del E,J,G,T
147
- except(F,Q,l):pass
134
+ 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()
135
+ if L in K.problematic:A.warning('SKIPPING problematic module:{}'.format(L));return
136
+ Y,O=K.get_obj_attributes(L)
137
+ if O:A.error(O)
138
+ for(E,J,H,Z,e)in Y:
139
+ if E in['classmethod','staticmethod','BaseException',M]:continue
140
+ if E[0].isdigit():A.warning('NameError: invalid name {}'.format(E));continue
141
+ if H=="<class 'type'>"and R(D)<=A1*4:
142
+ P=B;Q=E.endswith(M)or E.endswith('Error')or E in['KeyboardInterrupt','StopIteration','SystemExit']
143
+ if Q:P=M
144
+ C='\n{}class {}({}):\n'.format(D,E,P)
145
+ if Q:C+=D+' ...\n';I.write(C);continue
146
+ 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)
147
+ elif any(A in H for A in[u,t,'closure']):
148
+ S=U;T=B
149
+ if N>0:T='self, '
150
+ if V in H or V in J:C='{}@classmethod\n'.format(D)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(D,E,S)
151
+ else:C='{}def {}({}*args, **kwargs) -> {}:\n'.format(D,E,T,S)
152
+ C+=D+' ...\n\n';I.write(C)
153
+ elif H=="<class 'module'>":0
154
+ elif H.startswith("<class '"):
155
+ G=H[8:-2];C=B
156
+ if G in(r,p,q,s,'bytearray','bytes'):C=W.format(D,E,J,G)
157
+ elif G in(d,c,b):a={d:'{}',c:'[]',b:'()'};C=W.format(D,E,a[G],G)
158
+ elif G in('object','set','frozenset','Pin',X):
159
+ if G==X:G='Generator'
160
+ C='{0}{1}: {2} ## = {4}\n'.format(D,E,G,H,J)
161
+ else:G=U;C='{0}{1}: {2} ## {3} = {4}\n'.format(D,E,G,H,J)
162
+ I.write(C)
163
+ else:I.write("# all other, type = '{0}'\n".format(H));I.write(D+E+' # type: Incomplete\n')
148
164
  @property
149
165
  def flat_fwid(self):
150
166
  A=self._fwid;B=' .()/\\:$'
151
- for C in B:A=A.replace(C,S)
167
+ for C in B:A=A.replace(C,'_')
152
168
  return A
153
- def clean(B,path=E):
154
- if path is E:path=B.path
155
- try:os.stat(path);C=os.listdir(path)
156
- except(F,H):return
157
- for D in C:
158
- A=u.format(path,D)
159
- try:os.remove(A)
160
- except F:
161
- try:B.clean(A);os.rmdir(A)
162
- except F:pass
163
- def report(B,filename='modules.json'):
164
- G=u.format(B.path,filename);C.collect()
169
+ def clean(C,path=D):
170
+ if path is D:path=C.path
171
+ A.info('Clean/remove files in folder: {}'.format(path))
172
+ try:os.stat(path);F=os.listdir(path)
173
+ except(E,I):return
174
+ for G in F:
175
+ B=x.format(path,G)
176
+ try:os.remove(B)
177
+ except E:
178
+ try:C.clean(B);os.rmdir(B)
179
+ except E:pass
180
+ def report_start(B,filename='modules.json'):
181
+ H='firmware';B._json_name=x.format(B.path,filename);B._json_first=U;W(B._json_name);A.info('Report file: {}'.format(B._json_name));F.collect()
182
+ try:
183
+ with Q(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')
184
+ except E as I:A.error(y);B._json_name=D;raise I
185
+ def report_add(B,module_name,stub_file):
186
+ if not B._json_name:raise m(z)
165
187
  try:
166
- with V(G,'w')as D:
167
- B.write_json_header(D);E=K
168
- for H in B._report:B.write_json_node(D,H,E);E=A
169
- B.write_json_end(D)
170
- I=B._start_free-C.mem_free()
171
- except F:M('Failed to create the report.')
172
- def write_json_header(B,f):A='firmware';f.write('{');f.write(c({A:B.info})[1:-1]);f.write(a);f.write(c({v:{D:__version__},'stubtype':A})[1:-1]);f.write(a);f.write('"modules" :[\n')
173
- def write_json_node(A,f,n,first):
174
- if not first:f.write(a)
175
- f.write(n)
176
- def write_json_end(A,f):f.write('\n]}')
177
- def e(path):
178
- A=C=0
179
- while A!=-1:
180
- A=path.find(G,C)
181
- if A!=-1:
182
- B=path[0]if A==0 else path[:A]
183
- try:H=os.stat(B)
184
- except F as D:
185
- if D.args[0]==x:
186
- try:os.mkdir(B)
187
- except F as E:M('failed to create folder {}'.format(B));raise E
188
- C=A+1
189
- def T(s):
190
- A=' on '
188
+ with Q(B._json_name,'a')as C:
189
+ if not B._json_first:C.write(e)
190
+ else:B._json_first=H
191
+ D='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',G));C.write(D)
192
+ except E:A.error(y)
193
+ def report_end(B):
194
+ if not B._json_name:raise m(z)
195
+ with Q(B._json_name,'a')as C:C.write('\n]}')
196
+ A.info('Path: {}'.format(B.path))
197
+ def W(path):
198
+ B=D=0
199
+ while B!=-1:
200
+ B=path.find(G,D)
201
+ if B!=-1:
202
+ C=path[0]if B==0 else path[:B]
203
+ try:I=os.stat(C)
204
+ except E as F:
205
+ if F.args[0]==A0:
206
+ try:os.mkdir(C)
207
+ except E as H:A.error('failed to create folder {}'.format(C));raise H
208
+ D=B+1
209
+ def X(s):
210
+ C=' on '
191
211
  if not s:return B
192
- if A in s:s=s.split(A,1)[0]
193
- return s.split('-')[1]if'-'in s else B
212
+ s=s.split(C,1)[0]if C in s else s
213
+ if s.startswith('v'):
214
+ if not T in s:return B
215
+ A=s.split(T)[1];return A
216
+ if not V in s:return B
217
+ A=s.split(V)[1].split(J)[1];return A
194
218
  def _info():
195
- l='ev3-pybricks';k='pycopy';j='unix';i='win32';h='GENERIC';e='arch';c='cpu';a='ver';X='with';K='mpy';G='port';F='build';A=d({L:sys.implementation.name,D:B,F:B,a:B,G:sys.platform,J:h,c:B,K:B,e:B})
196
- if A[G].startswith(w):A[G]='stm32'
197
- elif A[G]==i:A[G]='windows'
198
- elif A[G]=='linux':A[G]=j
199
- try:A[D]=I.join([str(A)for A in sys.implementation.version])
200
- except H:pass
201
- try:Y=sys.implementation._machine if'_machine'in O(sys.implementation)else os.uname().machine;A[J]=Y.strip();A[c]=Y.split(X)[1].strip();A[K]=sys.implementation._mpy if'_mpy'in O(sys.implementation)else sys.implementation.mpy if K in O(sys.implementation)else B
202
- except(H,P):pass
203
- C.collect()
204
- for U in[A+'/board_info.csv'for A in z]:
205
- if g(U):
206
- M=A[J].strip()
207
- if f(A,M,U):break
208
- if X in M:
209
- M=M.split(X)[0].strip()
210
- if f(A,M,U):break
211
- A[J]=h
212
- A[J]=A[J].replace(' ',S);C.collect()
219
+ Y='ev3-pybricks';W='pycopy';U='unix';T='win32';R='arch';Q='cpu';L='ver';F='mpy';E='build';A=g({O:sys.implementation.name,C:B,E:B,L:B,K:sys.platform,S:'UNKNOWN',Q:B,F:B,R:B})
220
+ if A[K].startswith('pyb'):A[K]='stm32'
221
+ elif A[K]==T:A[K]='windows'
222
+ elif A[K]=='linux':A[K]=U
223
+ try:A[C]=A2(sys.implementation.version)
224
+ except I:pass
225
+ try:H=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[S]=H;A[Q]=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
226
+ except(I,P):pass
227
+ A[S]=A3()
213
228
  try:
214
- A[F]=T(os.uname()[3])
215
- if not A[F]:A[F]=T(os.uname()[2])
216
- if not A[F]and';'in sys.version:A[F]=T(sys.version.split(';')[1])
217
- except(H,P):pass
218
- if A[F]and R(A[F])>5:A[F]=B
219
- if A[D]==B and sys.platform not in(j,i):
220
- try:m=os.uname();A[D]=m.release
221
- except(P,H,TypeError):pass
222
- for(n,o,p)in[(k,k,'const'),(b,b,'FAT'),(l,'pybricks.hubs','EV3Brick')]:
223
- try:q=__import__(o,E,E,p);A[L]=n;del q;break
224
- except(N,Q):pass
225
- if A[L]==l:A['release']='2.0.0'
226
- if A[L]==W:
227
- if A[D]and A[D].endswith('.0')and A[D]>='1.10.0'and A[D]<='1.19.9':A[D]=A[D][:-2]
228
- if K in A and A[K]:
229
- V=int(A[K]);Z=[E,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][V>>10]
230
- if Z:A[e]=Z
231
- A[K]='v{}.{}'.format(V&255,V>>8&3)
232
- A[a]=f"v{A[D]}-{A[F]}"if A[F]else f"v{A[D]}";return A
233
- def f(info,board_descr,filename):
234
- with V(filename,'r')as C:
235
- while 1:
236
- B=C.readline()
237
- if not B:break
238
- D,E=B.split(',')[0].strip(),B.split(',')[1].strip()
239
- if D==board_descr:info[J]=E;return K
240
- return A
229
+ if'uname'in M(os):
230
+ A[E]=X(os.uname()[3])
231
+ if not A[E]:A[E]=X(os.uname()[2])
232
+ elif C in M(sys):A[E]=X(sys.version)
233
+ except(I,P,n):pass
234
+ if A[C]==B and sys.platform not in(U,T):
235
+ try:Z=os.uname();A[C]=Z.release
236
+ except(P,I,n):pass
237
+ for(b,c,d)in[(W,W,'const'),(f,f,'FAT'),(Y,'pybricks.hubs','EV3Brick')]:
238
+ try:e=__import__(c,D,D,d);A[O]=b;del e;break
239
+ except(N,l):pass
240
+ if A[O]==Y:A['release']='2.0.0'
241
+ if A[O]==a:
242
+ A[C]
243
+ 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]
244
+ if F in A and A[F]:
245
+ G=int(A[F]);J=[D,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][G>>10]
246
+ if J:A[R]=J
247
+ A[F]='v{}.{}'.format(G&255,G>>8&3)
248
+ if A[E]and not A[C].endswith(V):A[C]=A[C]+V
249
+ A[L]=f"{A[C]}-{A[E]}"if A[E]else f"{A[C]}";return A
250
+ def A2(version):
251
+ A=version;B=J.join([str(A)for A in A[:3]])
252
+ if R(A)>3 and A[3]:B+=T+A[3]
253
+ return B
254
+ def A3():
255
+ try:from boardname import BOARDNAME as C;A.info('Found BOARDNAME: {}'.format(C))
256
+ except N:A.warning('BOARDNAME not found');C=B
257
+ return C
241
258
  def get_root():
242
259
  try:A=os.getcwd()
243
- except(F,H):A=I
260
+ except(E,I):A=J
244
261
  B=A
245
- for B in[A,'/sd','/flash',G,I]:
262
+ for B in[A,'/sd','/flash',G,J]:
246
263
  try:C=os.stat(B);break
247
- except F:continue
264
+ except E:continue
248
265
  return B
249
- def g(filename):
266
+ def A4(filename):
250
267
  try:
251
- if os.stat(filename)[0]>>14:return K
252
- return A
253
- except F:return A
254
- def h():sys.exit(1)
268
+ if os.stat(filename)[0]>>14:return U
269
+ return H
270
+ except E:return H
271
+ def h():Y("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
255
272
  def read_path():
256
273
  path=B
257
274
  if R(sys.argv)==3:
@@ -261,13 +278,11 @@ def read_path():
261
278
  elif R(sys.argv)==2:h()
262
279
  return path
263
280
  def i():
264
- try:B=bytes('abc',encoding='utf8');C=i.__module__;return A
265
- except(j,H):return K
266
- def main():stubber=Stubber(path=read_path());stubber.clean();stubber.modules=['WM8960','_OTA','_asyncio','_boot_fat','_coap','_espnow','_flash_control_OTA','_main_pybytes','_mqtt','_mqtt_core','_msg_handl','_onewire','_periodical_pin','_pybytes','_pybytes_ca','_pybytes_config','_pybytes_config_reader','_pybytes_connection','_pybytes_constants','_pybytes_debug','_pybytes_library','_pybytes_machine_learning','_pybytes_main','_pybytes_protocol','_pybytes_pyconfig','_pybytes_pymesh_config','_rp2','_terminal','_thread','_uasyncio','_urequest','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','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','cmath','collections','crypto','cryptolib','curl','deflate','dht','display','display_driver_utils','ds18x20','encoder','errno','esp','esp32','espidf','espnow','ffi','flashbdev','framebuf','freesans20','fs_driver','functools','galactic','gc','gfx_pack','gsm','hashlib','heapq','hub75','ili9341','ili9XXX','imagetools','inisetup','interstate75','io','jpegdec','json','lcd160cr','lodepng',t,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','math','microWebSocket','microWebSrv','microWebTemplate',W,'mip','mip/__init__','mip/__main__','motor','mpu6500','mpu9250','neopixel','network','ntptime','onewire','os','pcf85063a','picoexplorer','picographics','picokeypad','picoscroll','picounicorn','picowireless','pimoroni','pimoroni_bus','pimoroni_i2c','plasma','platform',w,b,'pye','qrcode','queue','random','requests','requests/__init__','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stm','struct',s,'termios','time','tpcalib','uarray','uasyncio/__init__','uasyncio/core','uasyncio/event','uasyncio/funcs','uasyncio/lock','uasyncio/stream','uasyncio/tasks','ubinascii','ubluetooth','ucollections','ucrypto','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','uos','uplatform','uqueue','urandom','ure','urequests','urllib/urequest','uselect','usocket','ussl','ustruct','usys','utelnetserver','utime','utimeq','uwebsocket','uzlib',D,'websocket','websocket_helper','wipy','writer','xpt2046','ymodem','zephyr','zlib'];C.collect();stubber.create_all_stubs();stubber.report()
281
+ try:A=bytes('abc',encoding='utf8');B=i.__module__;return H
282
+ except(j,I):return U
283
+ def main():stubber=Stubber(path=read_path());stubber.clean();stubber.modules=['WM8960','_OTA','_asyncio','_boot_fat','_coap','_espnow','_flash_control_OTA','_main_pybytes','_mqtt','_mqtt_core','_msg_handl','_onewire','_periodical_pin','_pybytes','_pybytes_ca','_pybytes_config','_pybytes_config_reader','_pybytes_connection','_pybytes_constants','_pybytes_debug','_pybytes_library','_pybytes_machine_learning','_pybytes_main','_pybytes_protocol','_pybytes_pyconfig','_pybytes_pymesh_config','_rp2','_terminal','_thread','_uasyncio','_urequest','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','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','cmath','collections','crypto','cryptolib','curl','deflate','dht','display','display_driver_utils','ds18x20','encoder','errno','esp','esp32','espidf','espnow','ffi','flashbdev','framebuf','freesans20','fs_driver','functools','galactic','gc','gfx_pack','gsm','hashlib','heapq','hub75','ili9341','ili9XXX','imagetools','inisetup','interstate75','io','jpegdec','json','lcd160cr','lodepng',w,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','math','microWebSocket','microWebSrv','microWebTemplate',a,'mip','mip/__init__','mip/__main__','motor','mpu6500','mpu9250','neopixel','network','ntptime','onewire','os','pcf85063a','picoexplorer','picographics','picokeypad','picoscroll','picounicorn','picowireless','pimoroni','pimoroni_bus','pimoroni_i2c','plasma','platform','pyb',f,'pye','qrcode','queue','random','requests','requests/__init__','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stm','struct',v,'termios','time','tpcalib','uarray','uasyncio/__init__','uasyncio/core','uasyncio/event','uasyncio/funcs','uasyncio/lock','uasyncio/stream','uasyncio/tasks','ubinascii','ubluetooth','ucollections','ucrypto','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','uos','uplatform','uqueue','urandom','ure','urequests','urllib/urequest','uselect','usocket','ussl','ustruct','usys','utelnetserver','utime','utimeq','uwebsocket','uzlib',C,'websocket','websocket_helper','wipy','writer','xpt2046','ymodem','zephyr','zlib'];F.collect();stubber.create_all_stubs()
267
284
  if __name__=='__main__'or i():
268
- try:A0=logging.getLogger(v);logging.basicConfig(level=logging.INFO)
269
- except l:pass
270
- if not g('no_auto_stubber.txt'):
271
- try:C.threshold(4*1024);C.enable()
285
+ if not A4('no_auto_stubber.txt'):
286
+ try:F.threshold(4*1024);F.enable()
272
287
  except BaseException:pass
273
288
  main()
Binary file