micropython-stubber 1.14.1__py3-none-any.whl → 1.15.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 (50) hide show
  1. micropython_stubber-1.15.1.dist-info/METADATA +244 -0
  2. {micropython_stubber-1.14.1.dist-info → micropython_stubber-1.15.1.dist-info}/RECORD +49 -46
  3. stubber/__init__.py +1 -1
  4. stubber/basicgit.py +27 -14
  5. stubber/board/createstubs.py +34 -36
  6. stubber/board/createstubs_db.py +35 -35
  7. stubber/board/createstubs_db_min.py +195 -193
  8. stubber/board/createstubs_db_mpy.mpy +0 -0
  9. stubber/board/createstubs_info.py +73 -42
  10. stubber/board/createstubs_lvgl.py +35 -35
  11. stubber/board/createstubs_lvgl_min.py +88 -87
  12. stubber/board/createstubs_lvgl_mpy.mpy +0 -0
  13. stubber/board/createstubs_mem.py +44 -40
  14. stubber/board/createstubs_mem_min.py +179 -174
  15. stubber/board/createstubs_mem_mpy.mpy +0 -0
  16. stubber/board/createstubs_min.py +75 -74
  17. stubber/board/createstubs_mpy.mpy +0 -0
  18. stubber/board/info.py +183 -0
  19. stubber/codemod/enrich.py +28 -16
  20. stubber/commands/build_cmd.py +3 -3
  21. stubber/commands/get_core_cmd.py +17 -5
  22. stubber/commands/get_docstubs_cmd.py +23 -8
  23. stubber/commands/get_frozen_cmd.py +62 -9
  24. stubber/commands/get_lobo_cmd.py +13 -3
  25. stubber/commands/merge_cmd.py +7 -4
  26. stubber/commands/publish_cmd.py +5 -4
  27. stubber/commands/stub_cmd.py +2 -1
  28. stubber/commands/variants_cmd.py +0 -1
  29. stubber/freeze/common.py +2 -2
  30. stubber/freeze/freeze_folder.py +1 -1
  31. stubber/freeze/get_frozen.py +1 -1
  32. stubber/minify.py +43 -28
  33. stubber/publish/bump.py +1 -1
  34. stubber/publish/candidates.py +61 -17
  35. stubber/publish/defaults.py +44 -0
  36. stubber/publish/merge_docstubs.py +19 -56
  37. stubber/publish/package.py +44 -37
  38. stubber/publish/pathnames.py +51 -0
  39. stubber/publish/publish.py +5 -4
  40. stubber/publish/stubpacker.py +55 -33
  41. stubber/rst/lookup.py +7 -16
  42. stubber/rst/reader.py +39 -8
  43. stubber/stubs_from_docs.py +5 -8
  44. stubber/utils/post.py +34 -40
  45. stubber/utils/repos.py +32 -17
  46. stubber/utils/stubmaker.py +22 -14
  47. micropython_stubber-1.14.1.dist-info/METADATA +0 -217
  48. {micropython_stubber-1.14.1.dist-info → micropython_stubber-1.15.1.dist-info}/LICENSE +0 -0
  49. {micropython_stubber-1.14.1.dist-info → micropython_stubber-1.15.1.dist-info}/WHEEL +0 -0
  50. {micropython_stubber-1.14.1.dist-info → micropython_stubber-1.15.1.dist-info}/entry_points.txt +0 -0
@@ -1,19 +1,21 @@
1
- t='{}/{}'
2
- s='method'
3
- r='function'
4
- q='bool'
5
- p='str'
6
- o='float'
7
- n='int'
8
- m='port'
9
- l=NameError
10
- k=sorted
11
- j=NotImplementedError
1
+ v='{}/{}'
2
+ u='method'
3
+ t='function'
4
+ s='bool'
5
+ r='str'
6
+ q='float'
7
+ p='int'
8
+ o='port'
9
+ n=NameError
10
+ m=sorted
11
+ l=NotImplementedError
12
12
  A=',\n'
13
- a='dict'
14
- Z='list'
15
- Y='tuple'
16
- X='micropython'
13
+ c='dict'
14
+ b='list'
15
+ a='tuple'
16
+ Z='micropython'
17
+ Y='stubber'
18
+ X=str
17
19
  W=repr
18
20
  U='_'
19
21
  T=KeyError
@@ -26,253 +28,256 @@ N='family'
26
28
  M=len
27
29
  L='.'
28
30
  K='board'
29
- J=print
30
- I=AttributeError
31
- H=False
32
- G='/'
33
- F=None
31
+ J=AttributeError
32
+ I=False
33
+ H='/'
34
+ G=print
34
35
  E='version'
35
- D=OSError
36
- B=''
37
- import gc as C,os,sys
38
- from ujson import dumps as b
36
+ D=None
37
+ F=OSError
38
+ C=''
39
+ import gc as B,os,sys
40
+ from ujson import dumps as d
39
41
  try:from machine import reset
40
42
  except P:pass
41
- try:from collections import OrderedDict as c
42
- except P:from ucollections import OrderedDict as c
43
- __version__='v1.14.1'
44
- u=2
45
- v=2
46
- d=[L,'/lib','/sd/lib','/flash/lib','lib']
43
+ try:from collections import OrderedDict as e
44
+ except P:from ucollections import OrderedDict as e
45
+ __version__='v1.15.1'
46
+ w=2
47
+ x=2
48
+ f=[L,'/lib','/sd/lib','/flash/lib','lib']
47
49
  from time import sleep
48
50
  class Stubber:
49
- def __init__(A,path=F,firmware_id=F):
50
- B=firmware_id
51
+ def __init__(A,path=D,firmware_id=D):
52
+ C=firmware_id
51
53
  try:
52
- if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise j('MicroPython 1.13.0 cannot be stubbed')
53
- except I:pass
54
- A._report=[];A.info=_info();J('Port: {}'.format(A.info[m]));J('Board: {}'.format(A.info[K]));C.collect()
55
- if B:A._fwid=B.lower()
56
- elif A.info[N]==X:A._fwid='{family}-{ver}-{port}-{board}'.format(**A.info)
54
+ if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise l('MicroPython 1.13.0 cannot be stubbed')
55
+ except J:pass
56
+ A.log=D;A.log=logging.getLogger(Y);A._report=[];A.info=_info();G('Port: {}'.format(A.info[o]));G('Board: {}'.format(A.info[K]));B.collect()
57
+ if C:A._fwid=C.lower()
58
+ elif A.info[N]==Z:A._fwid='{family}-{ver}-{port}-{board}'.format(**A.info)
57
59
  else:A._fwid='{family}-{ver}-{port}'.format(**A.info)
58
- A._start_free=C.mem_free()
60
+ A._start_free=B.mem_free()
59
61
  if path:
60
- if path.endswith(G):path=path[:-1]
62
+ if path.endswith(H):path=path[:-1]
61
63
  else:path=get_root()
62
- A.path='{}/stubs/{}'.format(path,A.flat_fwid).replace('//',G)
63
- try:e(path+G)
64
- except D:J('error creating stub folder {}'.format(path))
64
+ A.path='{}/stubs/{}'.format(path,A.flat_fwid).replace('//',H)
65
+ try:g(path+H)
66
+ except F:G('error creating stub folder {}'.format(path))
65
67
  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=[]
66
68
  def get_obj_attributes(L,item_instance):
67
- H=item_instance;D=[];J=[]
69
+ H=item_instance;D=[];I=[]
68
70
  for A in Q(H):
69
71
  if A.startswith(U)and not A in L.modules:continue
70
72
  try:
71
73
  E=getattr(H,A)
72
74
  try:F=W(type(E)).split("'")[1]
73
- except R:F=B
74
- if F in{n,o,p,q,Y,Z,a}:G=1
75
- elif F in{r,s}:G=2
75
+ except R:F=C
76
+ if F in{p,q,r,s,a,b,c}:G=1
77
+ elif F in{t,u}:G=2
76
78
  elif F in'class':G=3
77
79
  else:G=4
78
80
  D.append((A,W(E),W(type(E)),E,G))
79
- except I as K:J.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,K))
81
+ except J as K:I.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,K))
80
82
  except MemoryError as K:sleep(1);reset()
81
- D=k([A for A in D if not A[0].startswith('__')],key=lambda x:x[4]);C.collect();return D,J
82
- def add_modules(A,modules):A.modules=k(set(A.modules)|set(modules))
83
+ D=m([A for A in D if not A[0].startswith('__')],key=lambda x:x[4]);B.collect();return D,I
84
+ def add_modules(A,modules):A.modules=m(set(A.modules)|set(modules))
83
85
  def create_all_stubs(A):
84
- C.collect()
85
- for B in A.modules:A.create_one_stub(B)
86
+ B.collect()
87
+ for C in A.modules:A.create_one_stub(C)
86
88
  def create_one_stub(A,module_name):
87
- B=module_name
88
- if B in A.problematic:return H
89
- if B in A.excluded:return H
90
- F='{}/{}.py'.format(A.path,B.replace(L,G));C.collect();E=H
91
- try:E=A.create_module_stub(B,F)
92
- except D:return H
93
- C.collect();return E
94
- def create_module_stub(I,module_name,file_name=F):
89
+ C=module_name
90
+ if C in A.problematic:return I
91
+ if C in A.excluded:return I
92
+ E='{}/{}.py'.format(A.path,C.replace(L,H));B.collect();D=I
93
+ try:D=A.create_module_stub(C,E)
94
+ except F:return I
95
+ B.collect();return D
96
+ def create_module_stub(J,module_name,file_name=D):
95
97
  E=file_name;A=module_name
96
- if E is F:K=A.replace(L,U)+'.py';E=I.path+G+K
97
- else:K=E.split(G)[-1]
98
- if G in A:A=A.replace(G,L)
99
- M=F
100
- try:M=__import__(A,F,F,'*');Q=C.mem_free();J('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(A,K,Q))
101
- except P:return H
102
- e(E)
103
- with S(E,'w')as N:R=str(I.info).replace('OrderedDict(',B).replace('})','}');V='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(A,I._fwid,R,__version__);N.write(V);N.write('from typing import Any\nfrom _typeshed import Incomplete\n\n');I.write_object_stub(N,M,A,B)
104
- I._report.append('{{"module": "{}", "file": "{}"}}'.format(A,E.replace('\\',G)))
98
+ if E is D:K=A.replace(L,U)+'.py';E=J.path+H+K
99
+ else:K=E.split(H)[-1]
100
+ if H in A:A=A.replace(H,L)
101
+ M=D
102
+ try:M=__import__(A,D,D,'*');Q=B.mem_free();G('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(A,K,Q))
103
+ except P:return I
104
+ g(E)
105
+ with S(E,'w')as N:R=X(J.info).replace('OrderedDict(',C).replace('})','}');V='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(A,J._fwid,R,__version__);N.write(V);N.write('from typing import Any\nfrom _typeshed import Incomplete\n\n');J.write_object_stub(N,M,A,C)
106
+ J._report.append('{{"module": "{}", "file": "{}"}}'.format(A,E.replace('\\',H)))
105
107
  if A not in{'os','sys','logging','gc'}:
106
108
  try:del M
107
- except (D,T):pass
109
+ except (F,T):pass
108
110
  try:del sys.modules[A]
109
111
  except T:pass
110
- C.collect();return O
112
+ B.collect();return O
111
113
  def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
112
- d='{0}{1} = {2} # type: {3}\n';c='bound_method';b='Incomplete';Q=in_class;P=object_expr;O='Exception';H=fp;E=indent;C.collect()
114
+ d='{0}{1} = {2} # type: {3}\n';Z='bound_method';Y='Incomplete';Q=in_class;P=object_expr;O='Exception';I=fp;D=indent;B.collect()
113
115
  if P in L.problematic:return
114
116
  R,N=L.get_obj_attributes(P)
115
- if N:J(N)
116
- for (F,K,G,S,f) in R:
117
- if F in['classmethod','staticmethod','BaseException',O]:continue
118
- if F[0].isdigit():continue
119
- if G=="<class 'type'>"and M(E)<=v*4:
120
- U=B;V=F.endswith(O)or F.endswith('Error')or F in['KeyboardInterrupt','StopIteration','SystemExit']
117
+ if N:G(N)
118
+ for (E,K,H,S,f) in R:
119
+ if E in['classmethod','staticmethod','BaseException',O]:continue
120
+ if E[0].isdigit():continue
121
+ if H=="<class 'type'>"and M(D)<=x*4:
122
+ U=C;V=E.endswith(O)or E.endswith('Error')or E in['KeyboardInterrupt','StopIteration','SystemExit']
121
123
  if V:U=O
122
- A='\n{}class {}({}):\n'.format(E,F,U)
123
- if V:A+=E+' ...\n';H.write(A);return
124
- H.write(A);L.write_object_stub(H,S,'{0}.{1}'.format(obj_name,F),E+' ',Q+1);A=E+' def __init__(self, *argv, **kwargs) -> None:\n';A+=E+' ...\n\n';H.write(A)
125
- elif any((A in G for A in[s,r,'closure'])):
126
- W=b;X=B
124
+ A='\n{}class {}({}):\n'.format(D,E,U)
125
+ if V:A+=D+' ...\n';I.write(A);return
126
+ I.write(A);L.write_object_stub(I,S,'{0}.{1}'.format(obj_name,E),D+' ',Q+1);A=D+' def __init__(self, *argv, **kwargs) -> None:\n';A+=D+' ...\n\n';I.write(A)
127
+ elif any((A in H for A in[u,t,'closure'])):
128
+ W=Y;X=C
127
129
  if Q>0:X='self, '
128
- if c in G or c in K:A='{}@classmethod\n'.format(E)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(E,F,W)
129
- else:A='{}def {}({}*args, **kwargs) -> {}:\n'.format(E,F,X,W)
130
- A+=E+' ...\n\n';H.write(A)
131
- elif G=="<class 'module'>":0
132
- elif G.startswith("<class '"):
133
- I=G[8:-2];A=B
134
- if I in[p,n,o,q,'bytearray','bytes']:A=d.format(E,F,K,I)
135
- elif I in[a,Z,Y]:e={a:'{}',Z:'[]',Y:'()'};A=d.format(E,F,e[I],I)
130
+ if Z in H or Z in K:A='{}@classmethod\n'.format(D)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(D,E,W)
131
+ else:A='{}def {}({}*args, **kwargs) -> {}:\n'.format(D,E,X,W)
132
+ A+=D+' ...\n\n';I.write(A)
133
+ elif H=="<class 'module'>":0
134
+ elif H.startswith("<class '"):
135
+ J=H[8:-2];A=C
136
+ if J in[r,p,q,s,'bytearray','bytes']:A=d.format(D,E,K,J)
137
+ elif J in[c,b,a]:e={c:'{}',b:'[]',a:'()'};A=d.format(D,E,e[J],J)
136
138
  else:
137
- if I not in['object','set','frozenset']:I=b
138
- A='{0}{1} : {2} ## {3} = {4}\n'.format(E,F,I,G,K)
139
- H.write(A)
140
- else:H.write("# all other, type = '{0}'\n".format(G));H.write(E+F+' # type: Incomplete\n')
139
+ if J not in['object','set','frozenset']:J=Y
140
+ A='{0}{1} : {2} ## {3} = {4}\n'.format(D,E,J,H,K)
141
+ I.write(A)
142
+ else:I.write("# all other, type = '{0}'\n".format(H));I.write(D+E+' # type: Incomplete\n')
141
143
  del R;del N
142
- try:del F,K,G,S
143
- except (D,T,l):pass
144
+ try:del E,K,H,S
145
+ except (F,T,n):pass
144
146
  @property
145
147
  def flat_fwid(self):
146
148
  A=self._fwid;B=' .()/\\:$'
147
149
  for C in B:A=A.replace(C,U)
148
150
  return A
149
- def clean(B,path=F):
150
- if path is F:path=B.path
151
- J('Clean/remove files in folder: {}'.format(path))
151
+ def clean(B,path=D):
152
+ if path is D:path=B.path
153
+ G('Clean/remove files in folder: {}'.format(path))
152
154
  try:os.stat(path);C=os.listdir(path)
153
- except (D,I):return
155
+ except (F,J):return
154
156
  for E in C:
155
- A=t.format(path,E)
157
+ A=v.format(path,E)
156
158
  try:os.remove(A)
157
- except D:
159
+ except F:
158
160
  try:B.clean(A);os.rmdir(A)
159
- except D:pass
161
+ except F:pass
160
162
  def report(A,filename='modules.json'):
161
- J('Created stubs for {} modules on board {}\nPath: {}'.format(M(A._report),A._fwid,A.path));F=t.format(A.path,filename);C.collect()
163
+ G('Created stubs for {} modules on board {}\nPath: {}'.format(M(A._report),A._fwid,A.path));E=v.format(A.path,filename);B.collect()
162
164
  try:
163
- with S(F,'w')as B:
164
- A.write_json_header(B);E=O
165
- for G in A._report:A.write_json_node(B,G,E);E=H
166
- A.write_json_end(B)
167
- I=A._start_free-C.mem_free()
168
- except D:J('Failed to create the report.')
169
- def write_json_header(C,f):B='firmware';f.write('{');f.write(b({B:C.info})[1:-1]);f.write(A);f.write(b({'stubber':{E:__version__},'stubtype':B})[1:-1]);f.write(A);f.write('"modules" :[\n')
165
+ with S(E,'w')as C:
166
+ A.write_json_header(C);D=O
167
+ for H in A._report:A.write_json_node(C,H,D);D=I
168
+ A.write_json_end(C)
169
+ J=A._start_free-B.mem_free()
170
+ except F:G('Failed to create the report.')
171
+ def write_json_header(C,f):B='firmware';f.write('{');f.write(d({B:C.info})[1:-1]);f.write(A);f.write(d({Y:{E:__version__},'stubtype':B})[1:-1]);f.write(A);f.write('"modules" :[\n')
170
172
  def write_json_node(B,f,n,first):
171
173
  if not first:f.write(A)
172
174
  f.write(n)
173
175
  def write_json_end(A,f):f.write('\n]}')
174
- def e(path):
176
+ def g(path):
175
177
  A=C=0
176
178
  while A!=-1:
177
- A=path.find(G,C)
179
+ A=path.find(H,C)
178
180
  if A!=-1:
179
181
  B=path[0]if A==0 else path[:A]
180
- try:H=os.stat(B)
181
- except D as E:
182
- if E.args[0]==u:
182
+ try:I=os.stat(B)
183
+ except F as D:
184
+ if D.args[0]==w:
183
185
  try:os.mkdir(B)
184
- except D as F:J('failed to create folder {}'.format(B));raise F
186
+ except F as E:G('failed to create folder {}'.format(B));raise E
185
187
  C=A+1
186
188
  def V(s):
187
189
  A=' on '
188
- if not s:return B
190
+ if not s:return C
189
191
  if A in s:s=s.split(A,1)[0]
190
- return s.split('-')[1]if'-'in s else B
192
+ return s.split('-')[1]if'-'in s else C
191
193
  def _info():
192
- j='ev3-pybricks';i='pycom';h='pycopy';e='GENERIC';b='arch';a='cpu';Z='ver';S='with';G='mpy';D='build';A=c({N:sys.implementation.name,E:B,D:B,Z:B,m:'stm32'if sys.platform.startswith('pyb')else sys.platform,K:e,a:B,G:B,b:B})
193
- try:A[E]=L.join([str(A)for A in sys.implementation.version])
194
- except I:pass
195
- try:W=sys.implementation._machine if'_machine'in Q(sys.implementation)else os.uname().machine;A[K]=W.strip();A[a]=W.split(S)[1].strip();A[G]=sys.implementation._mpy if'_mpy'in Q(sys.implementation)else sys.implementation.mpy if G in Q(sys.implementation)else B
196
- except (I,R):pass
197
- C.collect()
198
- for J in [A+'/board_info.csv'for A in d]:
199
- if g(J):
194
+ k='ev3-pybricks';j='pycom';g='pycopy';d='GENERIC';c='arch';b='cpu';a='ver';S='with';G='mpy';F='build';A=e({N:sys.implementation.name,E:C,F:C,a:C,o:'stm32'if sys.platform.startswith('pyb')else sys.platform,K:d,b:C,G:C,c:C})
195
+ try:A[E]=L.join([X(A)for A in sys.implementation.version])
196
+ except J:pass
197
+ try:W=sys.implementation._machine if'_machine'in Q(sys.implementation)else os.uname().machine;A[K]=W.strip();A[b]=W.split(S)[1].strip();A[G]=sys.implementation._mpy if'_mpy'in Q(sys.implementation)else sys.implementation.mpy if G in Q(sys.implementation)else C
198
+ except (J,R):pass
199
+ B.collect()
200
+ for I in [A+'/board_info.csv'for A in f]:
201
+ if i(I):
200
202
  H=A[K].strip()
201
- if f(A,H,J):break
203
+ if h(A,H,I):break
202
204
  if S in H:
203
205
  H=H.split(S)[0].strip()
204
- if f(A,H,J):break
205
- A[K]=e
206
- A[K]=A[K].replace(' ',U);C.collect()
206
+ if h(A,H,I):break
207
+ A[K]=d
208
+ A[K]=A[K].replace(' ',U);B.collect()
207
209
  try:
208
- A[D]=V(os.uname()[3])
209
- if not A[D]:A[D]=V(os.uname()[2])
210
- if not A[D]and';'in sys.version:A[D]=V(sys.version.split(';')[1])
211
- except (I,R):pass
212
- if A[D]and M(A[D])>5:A[D]=B
213
- if A[E]==B and sys.platform not in('unix','win32'):
214
- try:k=os.uname();A[E]=k.release
215
- except (R,I,TypeError):pass
216
- for (l,n,o) in [(h,h,'const'),(i,i,'FAT'),(j,'pybricks.hubs','EV3Brick')]:
217
- try:p=__import__(n,F,F,o);A[N]=l;del p;break
210
+ A[F]=V(os.uname()[3])
211
+ if not A[F]:A[F]=V(os.uname()[2])
212
+ if not A[F]and';'in sys.version:A[F]=V(sys.version.split(';')[1])
213
+ except (J,R):pass
214
+ if A[F]and M(A[F])>5:A[F]=C
215
+ if A[E]==C and sys.platform not in('unix','win32'):
216
+ try:l=os.uname();A[E]=l.release
217
+ except (R,J,TypeError):pass
218
+ for (m,n,p) in [(g,g,'const'),(j,j,'FAT'),(k,'pybricks.hubs','EV3Brick')]:
219
+ try:q=__import__(n,D,D,p);A[N]=m;del q;break
218
220
  except (P,T):pass
219
- if A[N]==j:A['release']='2.0.0'
220
- if A[N]==X:
221
+ if A[N]==k:A['release']='2.0.0'
222
+ if A[N]==Z:
221
223
  if A[E]and A[E].endswith('.0')and A[E]>='1.10.0'and A[E]<='1.19.9':A[E]=A[E][:-2]
222
224
  if G in A and A[G]:
223
- O=int(A[G]);Y=[F,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][O>>10]
224
- if Y:A[b]=Y
225
+ O=int(A[G]);Y=[D,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][O>>10]
226
+ if Y:A[c]=Y
225
227
  A[G]='v{}.{}'.format(O&255,O>>8&3)
226
- A[Z]=f"v{A[E]}-{A[D]}"if A[D]else f"v{A[E]}";return A
227
- def f(info,board_descr,filename):
228
+ A[a]=f"v{A[E]}-{A[F]}"if A[F]else f"v{A[E]}";return A
229
+ def h(info,board_descr,filename):
228
230
  with S(filename,'r')as B:
229
231
  while 1:
230
232
  A=B.readline()
231
233
  if not A:break
232
234
  C,D=A.split(',')[0].strip(),A.split(',')[1].strip()
233
235
  if C==board_descr:info[K]=D;return O
234
- return H
236
+ return I
235
237
  def get_root():
236
238
  try:A=os.getcwd()
237
- except (D,I):A=L
239
+ except (F,J):A=L
238
240
  B=A
239
- for B in [A,'/sd','/flash',G,L]:
241
+ for B in [A,'/sd','/flash',H,L]:
240
242
  try:C=os.stat(B);break
241
- except D:continue
243
+ except F:continue
242
244
  return B
243
- def g(filename):
245
+ def i(filename):
244
246
  try:
245
247
  if os.stat(filename)[0]>>14:return O
246
- return H
247
- except D:return H
248
- def h():sys.exit(1)
248
+ return I
249
+ except F:return I
250
+ def j():sys.exit(1)
249
251
  def read_path():
250
- path=B
252
+ path=C
251
253
  if M(sys.argv)==3:
252
254
  A=sys.argv[1].lower()
253
255
  if A in('--path','-p'):path=sys.argv[2]
254
- else:h()
255
- elif M(sys.argv)==2:h()
256
+ else:j()
257
+ elif M(sys.argv)==2:j()
256
258
  return path
257
- def i():
258
- try:A=bytes('abc',encoding='utf8');B=i.__module__;return H
259
- except (j,I):return O
259
+ def k():
260
+ try:A=bytes('abc',encoding='utf8');B=k.__module__;return I
261
+ except (l,J):return O
260
262
  def main():
261
- stubber=Stubber(path=read_path());stubber.clean();stubber.modules=[]
262
- for B in d:
263
+ E='/modulelist.txt';stubber=Stubber(path=read_path());stubber.clean();stubber.modules=[]
264
+ for C in f:
263
265
  try:
264
- with S(B+'/modulelist.txt')as E:
265
- for A in E.read().split('\n'):
266
+ F=B.mem_free()
267
+ with S(C+E)as D:
268
+ G('Debug: List of modules: '+C+E);A=D.readline()
269
+ while A:
266
270
  A=A.strip()
267
271
  if M(A)>0 and A[0]!='#':stubber.modules.append(A)
268
- C.collect();break
269
- except D:pass
270
- if not stubber.modules:stubber.modules=[X];_log.warn('Could not find modulelist.txt, using default modules')
271
- C.collect();stubber.create_all_stubs();stubber.report()
272
- if __name__=='__main__'or i():
273
- try:logging.basicConfig(level=logging.INFO)
274
- except l:pass
275
- if not g('no_auto_stubber.txt'):
276
- try:C.threshold(4*1024);C.enable()
272
+ A=D.readline()
273
+ B.collect();G('Debug: Used memory to load modulelist.txt: '+X(F-B.mem_free())+' bytes');break
274
+ except Exception:pass
275
+ if not stubber.modules:stubber.modules=[Z]
276
+ B.collect();stubber.create_all_stubs();stubber.report()
277
+ if __name__=='__main__'or k():
278
+ try:y=logging.getLogger(Y);logging.basicConfig(level=logging.INFO)
279
+ except n:pass
280
+ if not i('no_auto_stubber.txt'):
281
+ try:B.threshold(4*1024);B.enable()
277
282
  except BaseException:pass
278
283
  main()
Binary file