MCPcopy Create free account
hub / github.com/Image-Py/imagepy / build_widgets

Function build_widgets

imagepy/core/loader/loader.py:214–240  ·  view source on GitHub ↗
(path, err=False)

Source from the content-addressed store, hash-verified

212 return rst
213
214def build_widgets(path, err=False):
215 root = err in (True, False)
216 if root: sta, err = err, []
217 subtree = []
218 cont = os.listdir(os.path.join(root_dir, path))
219 for i in cont:
220 subp = os.path.join(path,i)
221 if root and os.path.isdir(os.path.join(root_dir, subp)):
222 sub = build_widgets(subp, err)
223 if len(sub)!=0:subtree.append(sub)
224 elif not root:
225 if i[len(i)-7:] in ('_wgt.py', 'wgts.py'):
226 subtree.append(i[:-3])
227 #print('====', subtree)
228 if len(subtree)==0:return []
229 rpath = path.replace('/', '.').replace('\\','.')
230 #rpath = rpath[rpath.index('imagepy.'):]
231 pg = __import__('imagepy.' + rpath,'','',[''])
232 pg.title = os.path.basename(path)
233 if hasattr(pg, 'catlog'):
234 subtree = sort_widgets(pg.catlog, subtree)
235 if not root:
236 subtree = extend_widgets(path, subtree, err)
237 elif sta and len(err)>0:
238 IPy.write('widgets not loaded:')
239 for i in err: IPy.write('>>> %-50s%-20s%s'%i)
240 return (pg, subtree)
241
242def build_document(path):
243 docs = []

Callers

nothing calls this directly

Calls 4

sort_widgetsFunction · 0.85
extend_widgetsFunction · 0.85
appendMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected