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