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