micropython-stubber 1.17.5__py3-none-any.whl → 1.19.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 (74) hide show
  1. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/METADATA +7 -6
  2. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/RECORD +71 -52
  3. mpflash/README.md +22 -3
  4. mpflash/libusb_flash.ipynb +203 -0
  5. mpflash/mpflash/ask_input.py +234 -0
  6. mpflash/mpflash/cli_download.py +107 -0
  7. mpflash/mpflash/cli_flash.py +165 -0
  8. mpflash/mpflash/cli_group.py +41 -8
  9. mpflash/mpflash/cli_list.py +41 -0
  10. mpflash/mpflash/cli_main.py +13 -8
  11. mpflash/mpflash/common.py +33 -122
  12. mpflash/mpflash/config.py +9 -0
  13. mpflash/mpflash/{downloader.py → download.py} +112 -120
  14. mpflash/mpflash/downloaded.py +108 -0
  15. mpflash/mpflash/errors.py +5 -0
  16. mpflash/mpflash/flash.py +69 -0
  17. mpflash/mpflash/flash_esp.py +17 -23
  18. mpflash/mpflash/flash_stm32.py +16 -113
  19. mpflash/mpflash/flash_stm32_cube.py +111 -0
  20. mpflash/mpflash/flash_stm32_dfu.py +101 -0
  21. mpflash/mpflash/flash_uf2.py +8 -8
  22. mpflash/mpflash/flash_uf2_linux.py +25 -12
  23. mpflash/mpflash/flash_uf2_windows.py +24 -12
  24. mpflash/mpflash/list.py +34 -37
  25. mpflash/mpflash/logger.py +12 -13
  26. mpflash/mpflash/mpboard_id/__init__.py +96 -0
  27. mpflash/mpflash/mpboard_id/board_id.py +63 -0
  28. mpflash/mpflash/mpboard_id/board_info.csv +2213 -0
  29. mpflash/mpflash/mpboard_id/board_info.json +19910 -0
  30. mpflash/mpflash/mpremoteboard/__init__.py +208 -0
  31. mpflash/mpflash/mpremoteboard/mpy_fw_info.py +141 -0
  32. {stubber/bulk → mpflash/mpflash/mpremoteboard}/runner.py +22 -5
  33. mpflash/mpflash/vendor/dfu.py +164 -0
  34. mpflash/mpflash/vendor/pydfu.py +605 -0
  35. mpflash/mpflash/vendor/readme.md +3 -0
  36. mpflash/mpflash/vendor/versions.py +113 -0
  37. mpflash/mpflash/worklist.py +147 -0
  38. mpflash/poetry.lock +411 -595
  39. mpflash/pyproject.toml +24 -8
  40. mpflash/stm32_udev_rules.md +63 -0
  41. stubber/__init__.py +1 -1
  42. stubber/basicgit.py +1 -0
  43. stubber/board/createstubs.py +10 -4
  44. stubber/board/createstubs_db.py +11 -5
  45. stubber/board/createstubs_db_min.py +61 -58
  46. stubber/board/createstubs_db_mpy.mpy +0 -0
  47. stubber/board/createstubs_mem.py +11 -5
  48. stubber/board/createstubs_mem_min.py +56 -53
  49. stubber/board/createstubs_mem_mpy.mpy +0 -0
  50. stubber/board/createstubs_min.py +54 -51
  51. stubber/board/createstubs_mpy.mpy +0 -0
  52. stubber/bulk/mcu_stubber.py +9 -5
  53. stubber/codemod/_partials/db_main.py +14 -25
  54. stubber/codemod/_partials/lvgl_main.py +2 -2
  55. stubber/codemod/board.py +10 -3
  56. stubber/commands/clone_cmd.py +7 -7
  57. stubber/commands/config_cmd.py +3 -0
  58. stubber/freeze/get_frozen.py +0 -2
  59. stubber/publish/candidates.py +1 -1
  60. stubber/publish/package.py +1 -1
  61. stubber/publish/pathnames.py +1 -1
  62. stubber/publish/stubpackage.py +1 -0
  63. stubber/rst/lookup.py +1 -1
  64. stubber/tools/manifestfile.py +5 -3
  65. stubber/utils/config.py +26 -36
  66. stubber/utils/repos.py +2 -2
  67. stubber/utils/versions.py +1 -0
  68. mpflash/mpflash/flasher.py +0 -287
  69. stubber/bulk/board_id.py +0 -40
  70. stubber/bulk/mpremoteboard.py +0 -141
  71. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/LICENSE +0 -0
  72. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/WHEEL +0 -0
  73. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/entry_points.txt +0 -0
  74. /mpflash/mpflash/{uf2_boardid.py → flash_uf2_boardid.py} +0 -0
@@ -8,16 +8,16 @@ r='str'
8
8
  q='float'
9
9
  p='int'
10
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'
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
21
  Z=repr
22
22
  W='-preview'
23
23
  V='-'
@@ -45,9 +45,9 @@ 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 f
49
- except N:from ucollections import OrderedDict as f
50
- __version__='v1.17.5'
48
+ try:from collections import OrderedDict as g
49
+ except N:from ucollections import OrderedDict as g
50
+ __version__='v1.19.0'
51
51
  y=2
52
52
  z=2
53
53
  A0=['lib','/lib','/sd/lib','/flash/lib',J]
@@ -69,11 +69,11 @@ class Stubber:
69
69
  def __init__(B,path=E,firmware_id=E):
70
70
  C=firmware_id
71
71
  try:
72
- if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise j('MicroPython 1.13.0 cannot be stubbed')
72
+ if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise k('MicroPython 1.13.0 cannot be stubbed')
73
73
  except I:pass
74
74
  B.info=_info();A.info('Port: {}'.format(B.info[K]));A.info('Board: {}'.format(B.info[U]));D.collect()
75
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)
76
+ elif B.info[Q]==b:B._fwid='{family}-v{version}-{port}-{board}'.format(**B.info).rstrip(V)
77
77
  else:B._fwid='{family}-v{version}-{port}'.format(**B.info)
78
78
  B._start_free=D.mem_free()
79
79
  if path:
@@ -91,15 +91,15 @@ class Stubber:
91
91
  E=getattr(H,A)
92
92
  try:F=Z(type(E)).split("'")[1]
93
93
  except T:F=B
94
- if F in{p,q,r,s,b,c,d}:G=1
94
+ if F in{p,q,r,s,c,d,e}:G=1
95
95
  elif F in{t,u}:G=2
96
96
  elif F in'class':G=3
97
97
  else:G=4
98
98
  C.append((A,Z(E),Z(type(E)),E,G))
99
99
  except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
100
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))
101
+ C=l([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=l(set(A.modules)|set(modules))
103
103
  def create_all_stubs(B):
104
104
  A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();D.collect()
105
105
  for C in B.modules:B.create_one_stub(C)
@@ -125,14 +125,14 @@ class Stubber:
125
125
  K.report_add(C,I)
126
126
  if C not in{'os','sys','logging','gc'}:
127
127
  try:del M
128
- except(F,l):A.warning('could not del new_module')
128
+ except(F,m):A.warning('could not del new_module')
129
129
  D.collect();return R
130
130
  def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
131
131
  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;E=indent;D.collect()
132
132
  if M in L.problematic:A.warning('SKIPPING problematic module:{}'.format(M));return
133
133
  a,Q=L.get_obj_attributes(M)
134
134
  if Q:A.error(Q)
135
- for(F,H,I,e,g)in a:
135
+ for(F,H,I,b,g)in a:
136
136
  if F in['classmethod','staticmethod','BaseException',N]:continue
137
137
  if F[0].isdigit():A.warning('NameError: invalid name {}'.format(F));continue
138
138
  if I=="<class 'type'>"and P(E)<=z*4:
@@ -140,7 +140,7 @@ class Stubber:
140
140
  if S:R=N
141
141
  C='\n{}class {}({}):\n'.format(E,F,R)
142
142
  if S:C+=E+' ...\n';J.write(C);continue
143
- J.write(C);L.write_object_stub(J,e,'{0}.{1}'.format(obj_name,F),E+' ',O+1);C=E+' def __init__(self, *argv, **kwargs) -> None:\n';C+=E+' ...\n\n';J.write(C)
143
+ J.write(C);L.write_object_stub(J,b,'{0}.{1}'.format(obj_name,F),E+' ',O+1);C=E+' def __init__(self, *argv, **kwargs) -> None:\n';C+=E+' ...\n\n';J.write(C)
144
144
  elif any(A in I for A in[u,t,'closure']):
145
145
  T=V;U=B
146
146
  if O>0:U='self, '
@@ -151,7 +151,7 @@ class Stubber:
151
151
  elif I.startswith("<class '"):
152
152
  G=I[8:-2];C=B
153
153
  if G in(r,p,q,s,'bytearray','bytes'):C=X.format(E,F,H,G)
154
- elif G in(d,c,b):f={d:'{}',c:'[]',b:'()'};C=X.format(E,F,f[G],G)
154
+ elif G in(e,d,c):f={e:'{}',d:'[]',c:'()'};C=X.format(E,F,f[G],G)
155
155
  elif G in('object','set','frozenset','Pin',Y):
156
156
  if G==Y:G='Generator'
157
157
  C='{0}{1}: {2} ## = {4}\n'.format(E,F,G,I,H)
@@ -181,18 +181,18 @@ class Stubber:
181
181
  def report_start(B,filename='modules.json'):
182
182
  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()
183
183
  try:
184
- 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')
184
+ with O(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')
185
185
  except F as I:A.error(w);B._json_name=E;raise I
186
186
  def report_add(B,module_name,stub_file):
187
- if not B._json_name:raise m(x)
187
+ if not B._json_name:raise n(x)
188
188
  try:
189
189
  with O(B._json_name,'a')as C:
190
- if not B._json_first:C.write(e)
190
+ if not B._json_first:C.write(f)
191
191
  else:B._json_first=H
192
192
  D='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',G));C.write(D)
193
193
  except F:A.error(w)
194
194
  def report_end(B):
195
- if not B._json_name:raise m(x)
195
+ if not B._json_name:raise n(x)
196
196
  with O(B._json_name,'a')as C:C.write('\n]}')
197
197
  A.info('Path: {}'.format(B.path))
198
198
  def X(path):
@@ -217,13 +217,16 @@ def Y(s):
217
217
  if not W in s:return B
218
218
  A=s.split(W)[1].split(J)[1];return A
219
219
  def _info():
220
- 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[0],C:B,D:B,L:B,K:sys.platform,U:'UNKNOWN',O:B,F:B,P:B})
220
+ c='ev3-pybricks';Z='pycom';X='pycopy';V='unix';S='win32';R='arch';P='cpu';O='ver';F='mpy';D='build'
221
+ try:H=sys.implementation[0]
222
+ except a:H=sys.implementation.name
223
+ A=g({Q:H,C:B,D:B,O:B,K:sys.platform,U:'UNKNOWN',P:B,F:B,R:B})
221
224
  if A[K].startswith('pyb'):A[K]='stm32'
222
- elif A[K]==R:A[K]='windows'
223
- elif A[K]=='linux':A[K]=S
225
+ elif A[K]==S:A[K]='windows'
226
+ elif A[K]=='linux':A[K]=V
224
227
  try:A[C]=A1(sys.implementation.version)
225
228
  except I:pass
226
- 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
229
+ try:J=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[U]=J;A[P]=J.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
227
230
  except(I,T):pass
228
231
  A[U]=A2()
229
232
  try:
@@ -231,23 +234,23 @@ def _info():
231
234
  A[D]=Y(os.uname()[3])
232
235
  if not A[D]:A[D]=Y(os.uname()[2])
233
236
  elif C in M(sys):A[D]=Y(sys.version)
234
- except(I,T,n):pass
235
- if A[C]==B and sys.platform not in(S,R):
236
- try:b=os.uname();A[C]=b.release
237
- except(T,I,n):pass
238
- for(c,d,e)in[(V,V,'const'),(X,X,'FAT'),(Z,'pybricks.hubs','EV3Brick')]:
239
- try:g=__import__(d,E,E,e);A[Q]=c;del g;break
240
- except(N,l):pass
241
- if A[Q]==Z:A['release']='2.0.0'
242
- if A[Q]==a:
237
+ except(I,T,a):pass
238
+ if A[C]==B and sys.platform not in(V,S):
239
+ try:d=os.uname();A[C]=d.release
240
+ except(T,I,a):pass
241
+ for(e,f,h)in[(X,X,'const'),(Z,Z,'FAT'),(c,'pybricks.hubs','EV3Brick')]:
242
+ try:i=__import__(f,E,E,h);A[Q]=e;del i;break
243
+ except(N,m):pass
244
+ if A[Q]==c:A['release']='2.0.0'
245
+ if A[Q]==b:
243
246
  A[C]
244
247
  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
248
  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
249
+ G=int(A[F]);L=[E,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][G>>10]
250
+ if L:A[R]=L
248
251
  A[F]='v{}.{}'.format(G&255,G>>8&3)
249
252
  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
253
+ A[O]=f"{A[C]}-{A[D]}"if A[D]else f"{A[C]}";return A
251
254
  def A1(version):
252
255
  A=version;B=J.join([str(A)for A in A[:3]])
253
256
  if P(A)>3 and A[3]:B+=V+A[3]
@@ -264,41 +267,41 @@ def get_root():
264
267
  try:C=os.stat(B);break
265
268
  except F:continue
266
269
  return B
267
- def g(filename):
270
+ def h(filename):
268
271
  try:
269
272
  if os.stat(filename)[0]>>14:return R
270
273
  return H
271
274
  except F:return H
272
- def h():S("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
275
+ def i():S("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
273
276
  def read_path():
274
277
  path=B
275
278
  if P(sys.argv)==3:
276
279
  A=sys.argv[1].lower()
277
280
  if A in('--path','-p'):path=sys.argv[2]
278
- else:h()
279
- elif P(sys.argv)==2:h()
281
+ else:i()
282
+ elif P(sys.argv)==2:i()
280
283
  return path
281
- def i():
282
- try:A=bytes('abc',encoding='utf8');B=i.__module__;return H
283
- except(j,I):return R
284
+ def j():
285
+ try:A=bytes('abc',encoding='utf8');B=j.__module__;return H
286
+ except(k,I):return R
284
287
  def main():
285
288
  stubber=Stubber(path=read_path());stubber.clean()
286
289
  def A(stubber):
287
290
  D.collect();stubber.modules=[]
288
291
  for C in A0:
289
292
  B=C+'/modulelist.txt'
290
- if not g(B):continue
293
+ if not h(B):continue
291
294
  with O(B)as E:
292
295
  while R:
293
296
  A=E.readline().strip()
294
297
  if not A:break
295
298
  if P(A)>0 and A[0]!='#':stubber.modules.append(A)
296
299
  D.collect();S('BREAK');break
297
- if not stubber.modules:stubber.modules=[a]
300
+ if not stubber.modules:stubber.modules=[b]
298
301
  D.collect()
299
302
  stubber.modules=[];A(stubber);D.collect();stubber.create_all_stubs()
300
- if __name__=='__main__'or i():
301
- if not g('no_auto_stubber.txt'):
303
+ if __name__=='__main__'or j():
304
+ if not h('no_auto_stubber.txt'):
302
305
  try:D.threshold(4*1024);D.enable()
303
306
  except BaseException:pass
304
307
  main()
Binary file
@@ -10,17 +10,17 @@ r='str'
10
10
  q='float'
11
11
  p='int'
12
12
  o='stubber'
13
- n=TypeError
14
- m=Exception
15
- l=KeyError
16
- k=sorted
17
- j=NotImplementedError
18
- f='pycom'
19
- e=',\n'
20
- d='dict'
21
- c='list'
22
- b='tuple'
23
- a='micropython'
13
+ n=Exception
14
+ m=KeyError
15
+ l=sorted
16
+ k=NotImplementedError
17
+ g='pycom'
18
+ f=',\n'
19
+ e='dict'
20
+ d='list'
21
+ c='tuple'
22
+ b='micropython'
23
+ a=TypeError
24
24
  Z=repr
25
25
  Y=print
26
26
  V='-preview'
@@ -48,9 +48,9 @@ try:from ujson import dumps
48
48
  except:from json import dumps
49
49
  try:from machine import reset
50
50
  except N:pass
51
- try:from collections import OrderedDict as g
52
- except N:from ucollections import OrderedDict as g
53
- __version__='v1.17.5'
51
+ try:from collections import OrderedDict as h
52
+ except N:from ucollections import OrderedDict as h
53
+ __version__='v1.19.0'
54
54
  A0=2
55
55
  A1=2
56
56
  A5=['lib','/lib','/sd/lib','/flash/lib',J]
@@ -72,11 +72,11 @@ class Stubber:
72
72
  def __init__(B,path=D,firmware_id=D):
73
73
  C=firmware_id
74
74
  try:
75
- if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise j('MicroPython 1.13.0 cannot be stubbed')
75
+ if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise k('MicroPython 1.13.0 cannot be stubbed')
76
76
  except I:pass
77
77
  B.info=_info();A.info('Port: {}'.format(B.info[K]));A.info('Board: {}'.format(B.info[S]));F.collect()
78
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)
79
+ elif B.info[O]==b:B._fwid='{family}-v{version}-{port}-{board}'.format(**B.info).rstrip(T)
80
80
  else:B._fwid='{family}-v{version}-{port}'.format(**B.info)
81
81
  B._start_free=F.mem_free()
82
82
  if path:
@@ -94,15 +94,15 @@ class Stubber:
94
94
  D=getattr(H,A)
95
95
  try:E=Z(type(D)).split("'")[1]
96
96
  except P:E=B
97
- if E in{p,q,r,s,b,c,d}:G=1
97
+ if E in{p,q,r,s,c,d,e}:G=1
98
98
  elif E in{t,u}:G=2
99
99
  elif E in'class':G=3
100
100
  else:G=4
101
101
  C.append((A,Z(D),Z(type(D)),D,G))
102
102
  except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
103
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
105
- def add_modules(A,modules):A.modules=k(set(A.modules)|set(modules))
104
+ C=l([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
105
+ def add_modules(A,modules):A.modules=l(set(A.modules)|set(modules))
106
106
  def create_all_stubs(B):
107
107
  A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();F.collect()
108
108
  for C in B.modules:B.create_one_stub(C)
@@ -128,14 +128,14 @@ class Stubber:
128
128
  K.report_add(C,I)
129
129
  if C not in{'os',v,w,'gc'}:
130
130
  try:del M
131
- except(E,l):A.warning('could not del new_module')
131
+ except(E,m):A.warning('could not del new_module')
132
132
  F.collect();return U
133
133
  def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
134
134
  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;D=indent;F.collect()
135
135
  if M in L.problematic:A.warning('SKIPPING problematic module:{}'.format(M));return
136
136
  a,P=L.get_obj_attributes(M)
137
137
  if P:A.error(P)
138
- for(E,H,I,e,g)in a:
138
+ for(E,H,I,b,g)in a:
139
139
  if E in['classmethod','staticmethod','BaseException',N]:continue
140
140
  if E[0].isdigit():A.warning('NameError: invalid name {}'.format(E));continue
141
141
  if I=="<class 'type'>"and R(D)<=A1*4:
@@ -143,7 +143,7 @@ class Stubber:
143
143
  if S:Q=N
144
144
  C='\n{}class {}({}):\n'.format(D,E,Q)
145
145
  if S:C+=D+' ...\n';J.write(C);continue
146
- J.write(C);L.write_object_stub(J,e,'{0}.{1}'.format(obj_name,E),D+' ',O+1);C=D+' def __init__(self, *argv, **kwargs) -> None:\n';C+=D+' ...\n\n';J.write(C)
146
+ J.write(C);L.write_object_stub(J,b,'{0}.{1}'.format(obj_name,E),D+' ',O+1);C=D+' def __init__(self, *argv, **kwargs) -> None:\n';C+=D+' ...\n\n';J.write(C)
147
147
  elif any(A in I for A in[u,t,'closure']):
148
148
  T=V;U=B
149
149
  if O>0:U='self, '
@@ -154,7 +154,7 @@ class Stubber:
154
154
  elif I.startswith("<class '"):
155
155
  G=I[8:-2];C=B
156
156
  if G in(r,p,q,s,'bytearray','bytes'):C=X.format(D,E,H,G)
157
- elif G in(d,c,b):f={d:'{}',c:'[]',b:'()'};C=X.format(D,E,f[G],G)
157
+ elif G in(e,d,c):f={e:'{}',d:'[]',c:'()'};C=X.format(D,E,f[G],G)
158
158
  elif G in('object','set','frozenset','Pin',Y):
159
159
  if G==Y:G='Generator'
160
160
  C='{0}{1}: {2} ## = {4}\n'.format(D,E,G,I,H)
@@ -184,18 +184,18 @@ class Stubber:
184
184
  def report_start(B,filename='modules.json'):
185
185
  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()
186
186
  try:
187
- 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')
187
+ 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')
188
188
  except E as I:A.error(y);B._json_name=D;raise I
189
189
  def report_add(B,module_name,stub_file):
190
- if not B._json_name:raise m(z)
190
+ if not B._json_name:raise n(z)
191
191
  try:
192
192
  with Q(B._json_name,'a')as C:
193
- if not B._json_first:C.write(e)
193
+ if not B._json_first:C.write(f)
194
194
  else:B._json_first=H
195
195
  D='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',G));C.write(D)
196
196
  except E:A.error(y)
197
197
  def report_end(B):
198
- if not B._json_name:raise m(z)
198
+ if not B._json_name:raise n(z)
199
199
  with Q(B._json_name,'a')as C:C.write('\n]}')
200
200
  A.info('Path: {}'.format(B.path))
201
201
  def W(path):
@@ -220,13 +220,16 @@ def X(s):
220
220
  if not V in s:return B
221
221
  A=s.split(V)[1].split(J)[1];return A
222
222
  def _info():
223
- Y='ev3-pybricks';W='pycopy';U='unix';T='win32';R='arch';Q='cpu';L='ver';F='mpy';E='build';A=g({O:sys.implementation[0],C:B,E:B,L:B,K:sys.platform,S:'UNKNOWN',Q:B,F:B,R:B})
223
+ Z='ev3-pybricks';Y='pycopy';W='unix';U='win32';T='arch';R='cpu';Q='ver';F='mpy';E='build'
224
+ try:H=sys.implementation[0]
225
+ except a:H=sys.implementation.name
226
+ A=h({O:H,C:B,E:B,Q:B,K:sys.platform,S:'UNKNOWN',R:B,F:B,T:B})
224
227
  if A[K].startswith('pyb'):A[K]='stm32'
225
- elif A[K]==T:A[K]='windows'
226
- elif A[K]=='linux':A[K]=U
228
+ elif A[K]==U:A[K]='windows'
229
+ elif A[K]=='linux':A[K]=W
227
230
  try:A[C]=A2(sys.implementation.version)
228
231
  except I:pass
229
- 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
232
+ try:J=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[S]=J;A[R]=J.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
230
233
  except(I,P):pass
231
234
  A[S]=A3()
232
235
  try:
@@ -234,23 +237,23 @@ def _info():
234
237
  A[E]=X(os.uname()[3])
235
238
  if not A[E]:A[E]=X(os.uname()[2])
236
239
  elif C in M(sys):A[E]=X(sys.version)
237
- except(I,P,n):pass
238
- if A[C]==B and sys.platform not in(U,T):
239
- try:Z=os.uname();A[C]=Z.release
240
- except(P,I,n):pass
241
- for(b,c,d)in[(W,W,'const'),(f,f,'FAT'),(Y,'pybricks.hubs','EV3Brick')]:
242
- try:e=__import__(c,D,D,d);A[O]=b;del e;break
243
- except(N,l):pass
244
- if A[O]==Y:A['release']='2.0.0'
245
- if A[O]==a:
240
+ except(I,P,a):pass
241
+ if A[C]==B and sys.platform not in(W,U):
242
+ try:c=os.uname();A[C]=c.release
243
+ except(P,I,a):pass
244
+ for(d,e,f)in[(Y,Y,'const'),(g,g,'FAT'),(Z,'pybricks.hubs','EV3Brick')]:
245
+ try:i=__import__(e,D,D,f);A[O]=d;del i;break
246
+ except(N,m):pass
247
+ if A[O]==Z:A['release']='2.0.0'
248
+ if A[O]==b:
246
249
  A[C]
247
250
  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]
248
251
  if F in A and A[F]:
249
- G=int(A[F]);J=[D,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][G>>10]
250
- if J:A[R]=J
252
+ G=int(A[F]);L=[D,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][G>>10]
253
+ if L:A[T]=L
251
254
  A[F]='v{}.{}'.format(G&255,G>>8&3)
252
255
  if A[E]and not A[C].endswith(V):A[C]=A[C]+V
253
- A[L]=f"{A[C]}-{A[E]}"if A[E]else f"{A[C]}";return A
256
+ A[Q]=f"{A[C]}-{A[E]}"if A[E]else f"{A[C]}";return A
254
257
  def A2(version):
255
258
  A=version;B=J.join([str(A)for A in A[:3]])
256
259
  if R(A)>3 and A[3]:B+=T+A[3]
@@ -272,20 +275,20 @@ def A4(filename):
272
275
  if os.stat(filename)[0]>>14:return U
273
276
  return H
274
277
  except E:return H
275
- def h():Y("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
278
+ def i():Y("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
276
279
  def read_path():
277
280
  path=B
278
281
  if R(sys.argv)==3:
279
282
  A=sys.argv[1].lower()
280
283
  if A in('--path','-p'):path=sys.argv[2]
281
- else:h()
282
- elif R(sys.argv)==2:h()
284
+ else:i()
285
+ elif R(sys.argv)==2:i()
283
286
  return path
284
- def i():
285
- try:A=bytes('abc',encoding='utf8');B=i.__module__;return H
286
- except(j,I):return U
287
- 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()
288
- if __name__=='__main__'or i():
287
+ def j():
288
+ try:A=bytes('abc',encoding='utf8');B=j.__module__;return H
289
+ except(k,I):return U
290
+ 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',b,'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',g,'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()
291
+ if __name__=='__main__'or j():
289
292
  if not A4('no_auto_stubber.txt'):
290
293
  try:F.threshold(4*1024);F.enable()
291
294
  except BaseException:pass
Binary file
@@ -16,14 +16,13 @@ from rich.console import Console
16
16
  from rich.table import Table
17
17
  from tenacity import retry, stop_after_attempt, wait_fixed
18
18
 
19
+ from mpflash.mpremoteboard import ERROR, OK, MPRemoteBoard
19
20
  from stubber import utils
20
- from stubber.publish.merge_docstubs import get_board_path, merge_all_docstubs
21
+ from stubber.publish.merge_docstubs import merge_all_docstubs
21
22
  from stubber.publish.pathnames import board_folder_name
22
23
  from stubber.publish.publish import build_multiple
23
24
  from stubber.utils.config import CONFIG
24
25
 
25
- from .mpremoteboard import ERROR, OK, MPRemoteBoard
26
-
27
26
  # TODO : make this a bit nicer
28
27
  HERE = Path(__file__).parent
29
28
  ###############################################################################################
@@ -442,10 +441,15 @@ def print_result_table(all_built: List, console: Console):
442
441
  table = Table(title="Results")
443
442
 
444
443
  table.add_column("Result", style="cyan")
445
- table.add_column("Name", style="cyan")
444
+ table.add_column("Name/Path", style="cyan")
446
445
  table.add_column("Version", style="green")
447
446
  table.add_column("Error", style="red")
448
447
 
449
448
  for result in all_built:
450
- table.add_row(result["result"], result["name"], result["version"], result["error"])
449
+ table.add_row(
450
+ result["result"],
451
+ (result["name"] + "\n" + result["path"]).strip(),
452
+ result["version"],
453
+ result["error"],
454
+ )
451
455
  console.print(table)
@@ -1,24 +1,22 @@
1
+ # type: ignore
1
2
  """
2
3
  This file contains the `def main()` funcion for the db variant of createstubs.py
3
4
  - type_check_only is used to avoid circular imports
4
5
  The partial is enclosed in ###PARTIAL### and ###PARTIALEND### markers
5
6
  """
7
+
6
8
  # sourcery skip: require-parameter-annotation, for-append-to-extend, use-named-expression
7
9
 
8
- from io import TextIOWrapper
9
- from typing import TYPE_CHECKING, List, type_check_only
10
+ from typing import TYPE_CHECKING, List
10
11
 
11
12
  if TYPE_CHECKING:
12
13
  import gc
13
14
  import logging
14
- import sys
15
15
 
16
16
  class logging:
17
- def getLogger(self, name: str) -> "logging":
18
- ...
17
+ def getLogger(self, name: str) -> "logging": ...
19
18
 
20
- def info(self, msg: str) -> None:
21
- ...
19
+ def info(self, msg: str) -> None: ...
22
20
 
23
21
  log = logging()
24
22
 
@@ -28,36 +26,27 @@ if TYPE_CHECKING:
28
26
  modules = []
29
27
  _json_name: str
30
28
 
31
- def __init__(self, path: str = "", firmware_id: str = "") -> None:
32
- ...
29
+ def __init__(self, path: str = "", firmware_id: str = "") -> None: ...
33
30
 
34
- def clean(self) -> None:
35
- ...
31
+ def clean(self) -> None: ...
36
32
 
37
- def create_one_stub(self, modulename: str) -> bool:
38
- ...
33
+ def create_one_stub(self, modulename: str) -> bool: ...
39
34
 
40
- def report_start(self, filename: str = "modules.json"):
41
- ...
35
+ def report_start(self, filename: str = "modules.json"): ...
42
36
 
43
- def report_end(self):
44
- ...
37
+ def report_end(self): ...
45
38
 
46
- def create_all_stubs(self):
47
- ...
39
+ def create_all_stubs(self): ...
48
40
 
49
- def read_path() -> str:
50
- ...
41
+ def read_path() -> str: ...
51
42
 
52
43
  class _gc:
53
- def collect(self) -> None:
54
- ...
44
+ def collect(self) -> None: ...
55
45
 
56
46
  gc: _gc
57
47
  log = logging.getLogger("stubber")
58
48
 
59
- def file_exists(filename: str) -> bool:
60
- ...
49
+ def file_exists(filename: str) -> bool: ...
61
50
 
62
51
  LIBS = [".", "lib"]
63
52
 
@@ -63,12 +63,12 @@ def main():
63
63
  except Exception:
64
64
  fw_id = "lvgl-{0}_{1}_{2}_{3}-{4}".format(8, 1, 0, "dev", sys.platform)
65
65
  finally:
66
- stubber = Stubber(firmware_id=fw_id)
66
+ stubber = Stubber(firmware_id=fw_id) # type: ignore
67
67
  stubber.clean()
68
68
  # modules to stub : only lvgl specifics
69
69
  stubber.modules = ["io", "lodepng", "rtch", "lvgl"] # spell-checker: enable
70
70
 
71
- gc.collect()
71
+ gc.collect() # type: ignore
72
72
 
73
73
  stubber.create_all_stubs()
74
74
  stubber.report()
stubber/codemod/board.py CHANGED
@@ -1,6 +1,7 @@
1
1
  """"
2
2
  Codemods to create the different variants of createstubs.py
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from enum import Enum
@@ -129,7 +130,9 @@ class ReadModulesCodemod(codemod.Codemod):
129
130
 
130
131
  def __init__(self, context: codemod.CodemodContext, reader_node: Optional[cst.Module] = None):
131
132
  super().__init__(context)
132
- self.modules_reader_node = reader_node or cst.parse_module(Partial.MODULES_READER.contents())
133
+ self.modules_reader_node = reader_node or cst.parse_module(
134
+ Partial.MODULES_READER.contents(), # type: ignore
135
+ )
133
136
 
134
137
  def transform_module_impl(self, tree: cst.Module) -> cst.Module:
135
138
  """Replaces static modules list with file-load method."""
@@ -213,7 +216,9 @@ class LVGLCodemod(codemod.Codemod):
213
216
  # return self.modules_transform.transform_module_impl(tree)
214
217
 
215
218
  docstr_transformer = ModuleDocCodemod(self.context, _LVGL_MODULE_DOC)
216
- def_main_tree = cst.parse_module(Partial.LVGL_MAIN.contents())
219
+ def_main_tree = cst.parse_module(
220
+ Partial.LVGL_MAIN.contents(), # type: ignore
221
+ )
217
222
 
218
223
  work_tree = docstr_transformer.transform_module_impl(tree)
219
224
  matches = m.findall(work_tree, _DEF_MAIN_MATCHER, metadata_resolver=self)
@@ -253,7 +258,9 @@ class DBCodemod(codemod.Codemod):
253
258
  def transform_module_impl(self, tree: cst.Module) -> cst.Module:
254
259
  """Generates createstubs.py db variant."""
255
260
  docstr_transformer = ModuleDocCodemod(self.context, _DB_MODULE_DOC)
256
- def_main_tree = cst.parse_module(Partial.DB_MAIN.contents())
261
+ def_main_tree = cst.parse_module(
262
+ Partial.DB_MAIN.contents(), # type: ignore
263
+ )
257
264
 
258
265
  work_tree = docstr_transformer.transform_module_impl(tree)
259
266
  matches = m.findall(work_tree, _DEF_MAIN_MATCHER, metadata_resolver=self)