micropython-stubber 1.24.0__py3-none-any.whl → 1.24.2__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 (39) hide show
  1. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/METADATA +3 -2
  2. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/RECORD +38 -36
  3. mpflash/mpflash/bootloader/activate.py +1 -1
  4. mpflash/mpflash/flash/esp.py +1 -1
  5. mpflash/mpflash/flash/uf2/__init__.py +18 -2
  6. mpflash/mpflash/mpboard_id/add_boards.py +5 -2
  7. mpflash/mpflash/mpboard_id/board_id.py +7 -5
  8. mpflash/mpflash/mpboard_id/board_info.zip +0 -0
  9. mpflash/mpflash/vendor/pico-universal-flash-nuke/LICENSE.txt +21 -0
  10. mpflash/mpflash/vendor/pico-universal-flash-nuke/universal_flash_nuke.uf2 +0 -0
  11. mpflash/mpflash/vendor/readme.md +2 -0
  12. mpflash/poetry.lock +754 -488
  13. mpflash/pyproject.toml +1 -1
  14. stubber/__init__.py +1 -1
  15. stubber/board/createstubs.py +44 -38
  16. stubber/board/createstubs_db.py +17 -12
  17. stubber/board/createstubs_db_min.py +63 -63
  18. stubber/board/createstubs_db_mpy.mpy +0 -0
  19. stubber/board/createstubs_mem.py +17 -12
  20. stubber/board/createstubs_mem_min.py +99 -99
  21. stubber/board/createstubs_mem_mpy.mpy +0 -0
  22. stubber/board/createstubs_min.py +111 -112
  23. stubber/board/createstubs_mpy.mpy +0 -0
  24. stubber/board/modulelist.txt +27 -27
  25. stubber/codemod/enrich.py +4 -6
  26. stubber/codemod/merge_docstub.py +10 -10
  27. stubber/codemod/visitors/type_helpers.py +182 -0
  28. stubber/commands/get_docstubs_cmd.py +5 -6
  29. stubber/cst_transformer.py +2 -1
  30. stubber/merge_config.py +3 -0
  31. stubber/publish/merge_docstubs.py +1 -2
  32. stubber/publish/stubpackage.py +36 -14
  33. stubber/rst/lookup.py +3 -0
  34. stubber/rst/reader.py +8 -13
  35. stubber/tools/manifestfile.py +2 -1
  36. stubber/codemod/visitors/typevars.py +0 -200
  37. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/LICENSE +0 -0
  38. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/WHEEL +0 -0
  39. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/entry_points.txt +0 -0
@@ -9,7 +9,7 @@
9
9
  - cross compilation, using mpy-cross,
10
10
  to avoid the compilation step on the micropython device
11
11
 
12
- This variant was generated from createstubs.py by micropython-stubber v1.24.0
12
+ This variant was generated from createstubs.py by micropython-stubber v1.24.2
13
13
  """
14
14
 
15
15
  # Copyright (c) 2019-2024 Jos Verlinde
@@ -35,7 +35,8 @@ except ImportError:
35
35
  from ucollections import OrderedDict # type: ignore
36
36
 
37
37
  __version__ = "v1.24.0"
38
- ENOENT = 2
38
+ ENOENT = 2 # on most ports
39
+ ENOMESSAGE = 44 # on pyscript
39
40
  _MAX_CLASS_LEVEL = 2 # Max class nesting
40
41
  LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
41
42
 
@@ -82,7 +83,7 @@ logging.basicConfig(level=logging.INFO)
82
83
  class Stubber:
83
84
  "Generate stubs for modules in firmware"
84
85
 
85
- def __init__(self, path: str = None, firmware_id: str = None): # type: ignore
86
+ def __init__(self, path: str = "", firmware_id: str = ""): # type: ignore
86
87
  try:
87
88
  if os.uname().release == "1.13.0" and os.uname().version < "v1.13-103": # type: ignore
88
89
  raise NotImplementedError("MicroPython 1.13.0 cannot be stubbed")
@@ -241,7 +242,7 @@ class Stubber:
241
242
  info_ = str(self.info).replace("OrderedDict(", "").replace("})", "}")
242
243
  s = '"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(module_name, self._fwid, info_, __version__)
243
244
  fp.write(s)
244
- fp.write("from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n")
245
+ fp.write("from __future__ import annotations\nfrom typing import Any, Final, Generator\nfrom _typeshed import Incomplete\n\n")
245
246
  self.write_object_stub(fp, new_module, module_name, "")
246
247
 
247
248
  self.report_add(module_name, file_name)
@@ -360,12 +361,16 @@ class Stubber:
360
361
  s = "{0}{1}: {3} = {2}\n".format(indent, item_name, ev[t], t)
361
362
  else:
362
363
  # something else
363
- if t in ("object", "set", "frozenset", "Pin", "generator"): # "FileIO"
364
+ if t in ("object", "set", "frozenset", "Pin"): # "FileIO"
364
365
  # https://docs.python.org/3/tutorial/classes.html#item_instance-objects
365
366
  # use these types for the attribute
366
- if t == "generator":
367
- t = "Generator"
368
367
  s = "{0}{1}: {2} ## = {4}\n".format(indent, item_name, t, item_type_txt, item_repr)
368
+ elif t == "generator":
369
+ # either a normal or async Generator function
370
+ t = "Generator"
371
+ s = "{0}def {1}(*args, **kwargs) -> Generator: ## = {4}\n{0} ...\n\n".format(
372
+ indent, item_name, t, item_type_txt, item_repr
373
+ )
369
374
  else:
370
375
  # Requires Python 3.6 syntax, which is OK for the stubs/pyi
371
376
  t = "Incomplete"
@@ -400,9 +405,9 @@ class Stubber:
400
405
  s = s.replace(c, "_")
401
406
  return s
402
407
 
403
- def clean(self, path: str = None): # type: ignore
408
+ def clean(self, path: str = ""): # type: ignore
404
409
  "Remove all files from the stub folder"
405
- if path is None:
410
+ if not path:
406
411
  path = self.path
407
412
  log.info("Clean/remove files in folder: {}".format(path))
408
413
  try:
@@ -483,7 +488,7 @@ def ensure_folder(path: str):
483
488
  _ = os.stat(p)
484
489
  except OSError as e:
485
490
  # folder does not exist
486
- if e.args[0] == ENOENT:
491
+ if e.args[0] in [ENOENT, ENOMESSAGE]:
487
492
  try:
488
493
  log.debug("Create folder {}".format(p))
489
494
  os.mkdir(p)
@@ -712,11 +717,11 @@ def is_micropython() -> bool:
712
717
 
713
718
  # b) https://docs.micropython.org/en/latest/genrst/builtin_types.html#bytes-with-keywords-not-implemented
714
719
  # Micropython: NotImplementedError
715
- b = bytes("abc", encoding="utf8") # type: ignore # lgtm [py/unused-local-variable]
720
+ b = bytes("abc", encoding="utf8") # type: ignore
716
721
 
717
722
  # c) https://docs.micropython.org/en/latest/genrst/core_language.html#function-objects-do-not-have-the-module-attribute
718
723
  # Micropython: AttributeError
719
- c = is_micropython.__module__ # type: ignore # lgtm [py/unused-local-variable]
724
+ c = is_micropython.__module__ # type: ignore
720
725
  return False
721
726
  except (NotImplementedError, AttributeError):
722
727
  return True
@@ -34,12 +34,12 @@ L='port'
34
34
  K='.'
35
35
  I=AttributeError
36
36
  H=False
37
- G='/'
38
- F=OSError
39
- D=None
37
+ G=None
38
+ E='/'
39
+ D=OSError
40
40
  C='version'
41
41
  B=''
42
- import gc as E,os,sys
42
+ import gc as F,os,sys
43
43
  from time import sleep
44
44
  try:from ujson import dumps
45
45
  except:from json import dumps
@@ -49,8 +49,9 @@ try:from collections import OrderedDict as g
49
49
  except N:from ucollections import OrderedDict as g
50
50
  __version__='v1.24.0'
51
51
  y=2
52
- z=2
53
- A0=['lib','/lib','/sd/lib','/flash/lib',K]
52
+ z=44
53
+ A0=2
54
+ A1=['lib','/lib','/sd/lib','/flash/lib',K]
54
55
  class J:
55
56
  DEBUG=10;INFO=20;WARNING=30;ERROR=40;level=INFO;prnt=O
56
57
  @staticmethod
@@ -68,149 +69,148 @@ class J:
68
69
  A=J.getLogger(o)
69
70
  J.basicConfig(level=J.INFO)
70
71
  class Stubber:
71
- def __init__(B,path=D,firmware_id=D):
72
+ def __init__(B,path=B,firmware_id=B):
72
73
  C=firmware_id
73
74
  try:
74
75
  if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise k('MicroPython 1.13.0 cannot be stubbed')
75
76
  except I:pass
76
- B.info=_info();A.info('Port: {}'.format(B.info[L]));A.info('Board: {}'.format(B.info[U]));E.collect()
77
+ B.info=_info();A.info('Port: {}'.format(B.info[L]));A.info('Board: {}'.format(B.info[U]));F.collect()
77
78
  if C:B._fwid=C.lower()
78
79
  elif B.info[S]==b:B._fwid='{family}-v{version}-{port}-{board}'.format(**B.info).rstrip(V)
79
80
  else:B._fwid='{family}-v{version}-{port}'.format(**B.info)
80
- B._start_free=E.mem_free()
81
+ B._start_free=F.mem_free()
81
82
  if path:
82
- if path.endswith(G):path=path[:-1]
83
+ if path.endswith(E):path=path[:-1]
83
84
  else:path=get_root()
84
- B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',G)
85
- try:X(path+G)
86
- except F:A.error('error creating stub folder {}'.format(path))
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
85
+ B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',E)
86
+ try:X(path+E)
87
+ except D: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=G;B._json_first=H
88
89
  def get_obj_attributes(L,item_instance):
89
90
  H=item_instance;C=[];K=[]
90
91
  for A in M(H):
91
92
  if A.startswith('__')and not A in L.modules:continue
92
93
  try:
93
94
  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
98
- elif F in'class':G=3
95
+ try:E=Z(type(D)).split("'")[1]
96
+ except P:E=B
97
+ if E in{p,q,r,s,c,d,e}:G=1
98
+ elif E in{t,u}:G=2
99
+ elif E in'class':G=3
99
100
  else:G=4
100
101
  C.append((A,Z(D),Z(type(D)),D,G))
101
102
  except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
102
103
  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
+ C=l([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
104
105
  def add_modules(A,modules):A.modules=l(set(A.modules)|set(modules))
105
106
  def create_all_stubs(B):
106
- A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();E.collect()
107
+ A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();F.collect()
107
108
  for C in B.modules:B.create_one_stub(C)
108
109
  B.report_end();A.info('Finally done')
109
110
  def create_one_stub(C,module_name):
110
111
  B=module_name
111
112
  if B in C.problematic:A.warning('Skip module: {:<25} : Known problematic'.format(B));return H
112
113
  if B in C.excluded:A.warning('Skip module: {:<25} : Excluded'.format(B));return H
113
- I='{}/{}.pyi'.format(C.path,B.replace(K,G));E.collect();D=H
114
- try:D=C.create_module_stub(B,I)
115
- except F:return H
116
- E.collect();return D
117
- def create_module_stub(J,module_name,file_name=D):
114
+ I='{}/{}.pyi'.format(C.path,B.replace(K,E));F.collect();G=H
115
+ try:G=C.create_module_stub(B,I)
116
+ except D:return H
117
+ F.collect();return G
118
+ def create_module_stub(J,module_name,file_name=G):
118
119
  I=file_name;C=module_name
119
- if I is D:L=C.replace(K,'_')+'.pyi';I=J.path+G+L
120
- else:L=I.split(G)[-1]
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))
120
+ if I is G:L=C.replace(K,'_')+'.pyi';I=J.path+E+L
121
+ else:L=I.split(E)[-1]
122
+ if E in C:C=C.replace(E,K)
123
+ M=G
124
+ try:M=__import__(C,G,G,'*');P=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,P))
124
125
  except N:return H
125
126
  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
+ 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, Final, Generator\nfrom _typeshed import Incomplete\n\n');J.write_object_stub(O,M,C,B)
127
128
  J.report_add(C,I)
128
129
  if C not in{'os','sys','logging','gc'}:
129
130
  try:del M
130
- except(F,m):A.warning('could not del new_module')
131
- E.collect();return T
131
+ except(D,m):A.warning('could not del new_module')
132
+ F.collect();return T
132
133
  def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
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()
134
+ Y=' at ...>';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;F.collect()
134
135
  if M in L.problematic:A.warning('SKIPPING problematic module:{}'.format(M));return
135
- a,P=L.get_obj_attributes(M)
136
+ Z,P=L.get_obj_attributes(M)
136
137
  if P:A.error(P)
137
- for(C,H,I,b,g)in a:
138
+ for(C,H,I,a,f)in Z:
138
139
  if C in['classmethod','staticmethod','BaseException',N]:continue
139
140
  if C[0].isdigit():A.warning('NameError: invalid name {}'.format(C));continue
140
- if I=="<class 'type'>"and R(F)<=z*4:
141
+ if I=="<class 'type'>"and R(E)<=A0*4:
141
142
  Q=B;S=C.endswith(N)or C.endswith('Error')or C in['KeyboardInterrupt','StopIteration','SystemExit']
142
143
  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)
144
+ D='\n{}class {}({}):\n'.format(E,C,Q)
145
+ if S:D+=E+' ...\n';J.write(D);continue
146
+ J.write(D);L.write_object_stub(J,a,'{0}.{1}'.format(obj_name,C),E+' ',O+1);D=E+' def __init__(self, *argv, **kwargs) -> None:\n';D+=E+' ...\n\n';J.write(D)
146
147
  elif any(A in I for A in[u,t,'closure']):
147
148
  T=V;U=B
148
149
  if O>0:U='self, '
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)
150
+ if W in I or W in H:D='{}@classmethod\n'.format(E)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(E,C,T)
151
+ else:D='{}def {}({}*args, **kwargs) -> {}:\n'.format(E,C,U,T)
152
+ D+=E+' ...\n\n';J.write(D)
152
153
  elif I=="<class 'module'>":0
153
154
  elif I.startswith("<class '"):
154
155
  G=I[8:-2];D=B
155
156
  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)
159
- elif G in('object','set','frozenset','Pin',Y):
160
- if G==Y:G='Generator'
161
- D='{0}{1}: {2} ## = {4}\n'.format(F,C,G,I,H)
157
+ if C.upper()==C:D='{0}{1}: Final[{3}] = {2}\n'.format(E,C,H,G)
158
+ else:D=X.format(E,C,H,G)
159
+ elif G in(e,d,c):b={e:'{}',d:'[]',c:'()'};D=X.format(E,C,b[G],G)
160
+ elif G in('object','set','frozenset','Pin'):D='{0}{1}: {2} ## = {4}\n'.format(E,C,G,I,H)
161
+ elif G=='generator':G='Generator';D='{0}def {1}(*args, **kwargs) -> Generator: ## = {4}\n{0} ...\n\n'.format(E,C,G,I,H)
162
162
  else:
163
163
  G=V
164
- if K in H:H=H.split(K)[0]+Z
165
- if K in H:H=H.split(K)[0]+Z
166
- D='{0}{1}: {2} ## {3} = {4}\n'.format(F,C,G,I,H)
164
+ if K in H:H=H.split(K)[0]+Y
165
+ if K in H:H=H.split(K)[0]+Y
166
+ D='{0}{1}: {2} ## {3} = {4}\n'.format(E,C,G,I,H)
167
167
  J.write(D)
168
- else:J.write("# all other, type = '{0}'\n".format(I));J.write(F+C+' # type: Incomplete\n')
168
+ else:J.write("# all other, type = '{0}'\n".format(I));J.write(E+C+' # type: Incomplete\n')
169
169
  @property
170
170
  def flat_fwid(self):
171
171
  A=self._fwid;B=' .()/\\:$'
172
172
  for C in B:A=A.replace(C,'_')
173
173
  return A
174
- def clean(C,path=D):
175
- if path is D:path=C.path
174
+ def clean(C,path=B):
175
+ if not path:path=C.path
176
176
  A.info('Clean/remove files in folder: {}'.format(path))
177
177
  try:os.stat(path);E=os.listdir(path)
178
- except(F,I):return
179
- for G in E:
180
- B=v.format(path,G)
178
+ except(D,I):return
179
+ for F in E:
180
+ B=v.format(path,F)
181
181
  try:os.remove(B)
182
- except F:
182
+ except D:
183
183
  try:C.clean(B);os.rmdir(B)
184
- except F:pass
184
+ except D:pass
185
185
  def report_start(B,filename='modules.json'):
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()
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));F.collect()
187
187
  try:
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
188
+ with Q(B._json_name,'w')as E:E.write('{');E.write(dumps({H:B.info})[1:-1]);E.write(f);E.write(dumps({o:{C:__version__},'stubtype':H})[1:-1]);E.write(f);E.write('"modules" :[\n')
189
+ except D as I:A.error(w);B._json_name=G;raise I
190
190
  def report_add(B,module_name,stub_file):
191
191
  if not B._json_name:raise n(x)
192
192
  try:
193
193
  with Q(B._json_name,'a')as C:
194
194
  if not B._json_first:C.write(f)
195
195
  else:B._json_first=H
196
- D='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',G));C.write(D)
197
- except F:A.error(w)
196
+ F='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',E));C.write(F)
197
+ except D:A.error(w)
198
198
  def report_end(B):
199
199
  if not B._json_name:raise n(x)
200
200
  with Q(B._json_name,'a')as C:C.write('\n]}')
201
201
  A.info('Path: {}'.format(B.path))
202
202
  def X(path):
203
- B=D=0
203
+ B=F=0
204
204
  while B!=-1:
205
- B=path.find(G,D)
205
+ B=path.find(E,F)
206
206
  if B!=-1:
207
207
  C=path[0]if B==0 else path[:B]
208
208
  try:I=os.stat(C)
209
- except F as E:
210
- if E.args[0]==y:
209
+ except D as G:
210
+ if G.args[0]in[y,z]:
211
211
  try:A.debug('Create folder {}'.format(C));os.mkdir(C)
212
- except F as H:A.error('failed to create folder {}'.format(C));raise H
213
- D=B+1
212
+ except D as H:A.error('failed to create folder {}'.format(C));raise H
213
+ F=B+1
214
214
  def Y(s):
215
215
  C=' on '
216
216
  if not s:return B
@@ -221,63 +221,63 @@ def Y(s):
221
221
  if not W in s:return B
222
222
  A=s.split(W)[1].split(K)[1];return A
223
223
  def _info():
224
- c='ev3-pybricks';Z='pycom';X='pycopy';V='unix';T='win32';R='arch';Q='cpu';O='ver';F='mpy';E='build'
224
+ c='ev3-pybricks';Z='pycom';X='pycopy';V='unix';T='win32';R='arch';Q='cpu';O='ver';E='mpy';D='build'
225
225
  try:J=sys.implementation[0]
226
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})
227
+ A=g({S:J,C:B,D:B,O:B,L:sys.platform,U:'UNKNOWN',Q:B,E:B,R:B})
228
228
  if A[L].startswith('pyb'):A[L]='stm32'
229
229
  elif A[L]==T:A[L]='windows'
230
230
  elif A[L]=='linux':A[L]=V
231
- try:A[C]=A1(sys.implementation.version)
231
+ try:A[C]=A2(sys.implementation.version)
232
232
  except I:pass
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
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[E]=sys.implementation._mpy if'_mpy'in M(sys.implementation)else sys.implementation.mpy if E in M(sys.implementation)else B
234
234
  except(I,P):pass
235
- A[U]=A2()
235
+ A[U]=A3()
236
236
  try:
237
237
  if'uname'in M(os):
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)
238
+ A[D]=Y(os.uname()[3])
239
+ if not A[D]:A[D]=Y(os.uname()[2])
240
+ elif C in M(sys):A[D]=Y(sys.version)
241
241
  except(I,P,a):pass
242
242
  if A[C]==B and sys.platform not in(V,T):
243
243
  try:d=os.uname();A[C]=d.release
244
244
  except(P,I,a):pass
245
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
246
+ try:i=__import__(f,G,G,h);A[S]=e;del i;break
247
247
  except(N,m):pass
248
248
  if A[S]==c:A['release']='2.0.0'
249
249
  if A[S]==b:
250
250
  A[C]
251
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]
252
- if F in A and A[F]:
253
- G=int(A[F])
254
- try:H=[D,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin','rv32imc'][G>>10]
252
+ if E in A and A[E]:
253
+ F=int(A[E])
254
+ try:H=[G,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin','rv32imc'][F>>10]
255
255
  except P:H='unknown'
256
256
  if H:A[R]=H
257
- A[F]='v{}.{}'.format(G&255,G>>8&3)
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):
257
+ A[E]='v{}.{}'.format(F&255,F>>8&3)
258
+ if A[D]and not A[C].endswith(W):A[C]=A[C]+W
259
+ A[O]=f"{A[C]}-{A[D]}"if A[D]else f"{A[C]}";return A
260
+ def A2(version):
261
261
  A=version;B=K.join([str(A)for A in A[:3]])
262
262
  if R(A)>3 and A[3]:B+=V+A[3]
263
263
  return B
264
- def A2():
264
+ def A3():
265
265
  try:from boardname import BOARDNAME as C;A.info('Found BOARDNAME: {}'.format(C))
266
266
  except N:A.warning('BOARDNAME not found');C=B
267
267
  return C
268
268
  def get_root():
269
269
  try:A=os.getcwd()
270
- except(F,I):A=K
270
+ except(D,I):A=K
271
271
  B=A
272
- for B in['/remote','/sd','/flash',G,A,K]:
272
+ for B in['/remote','/sd','/flash',E,A,K]:
273
273
  try:C=os.stat(B);break
274
- except F:continue
274
+ except D:continue
275
275
  return B
276
276
  def h(filename):
277
277
  try:
278
278
  if os.stat(filename)[0]>>14:return T
279
279
  return H
280
- except F:return H
280
+ except D:return H
281
281
  def i():O("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
282
282
  def read_path():
283
283
  path=B
@@ -293,8 +293,8 @@ def j():
293
293
  def main():
294
294
  stubber=Stubber(path=read_path());stubber.clean()
295
295
  def A(stubber):
296
- E.collect();stubber.modules=[]
297
- for C in A0:
296
+ F.collect();stubber.modules=[]
297
+ for C in A1:
298
298
  B=C+'/modulelist.txt'
299
299
  if not h(B):continue
300
300
  with Q(B)as D:
@@ -302,13 +302,13 @@ def main():
302
302
  A=D.readline().strip()
303
303
  if not A:break
304
304
  if R(A)>0 and A[0]!='#':stubber.modules.append(A)
305
- E.collect();O('BREAK');break
305
+ F.collect();O('BREAK');break
306
306
  if not stubber.modules:stubber.modules=[b]
307
- E.collect()
308
- stubber.modules=[];A(stubber);E.collect();stubber.create_all_stubs()
307
+ F.collect()
308
+ stubber.modules=[];A(stubber);F.collect();stubber.create_all_stubs()
309
309
  if __name__=='__main__'or j():
310
310
  if not h('no_auto_stubber.txt'):
311
311
  O(f"createstubs.py: {__version__}")
312
- try:E.threshold(4096);E.enable()
312
+ try:F.threshold(4096);F.enable()
313
313
  except BaseException:pass
314
314
  main()
Binary file