def updatePackageHierarchy(self,menu,dir_id=None,currpath=None,pkgId=None,pagesOnly=None): currpath = currpath or [] tblpage = self.db.table('adm.menu_page') allpackages = self.db.application.packages.keys() for node in menu: attr = node.attr tbl = attr.pop('table',None) filepath = attr.pop('file',None) label = attr.pop('label',None) label = label.replace('!!','') if label else node.label tags = attr.pop('tags',None) if tbl or filepath: page_rec = dict(metadata=stringDict(attr) if attr else None) if tbl: page_rec['pkg'] = tbl.split('.')[0] page_rec['tbl'] = tbl elif filepath: filepath = currpath+filepath.strip('/').split('/') if not filepath[0] in allpackages: filepath.insert(0,pkgId) page_rec['pkg'] = filepath[0] page_rec['filepath'] ='/%s' %'/'.join(filepath) if not tblpage.checkDuplicate(**page_rec): label = label page_rec['label'] = label tblpage.insert(page_rec) if not pagesOnly: self.insert(dict(page_id=page_rec['id'],tags=tags,label=label,parent_id=dir_id)) elif isinstance(node.value,Bag): basepath = attr.get('basepath') if not pagesOnly: new_dir_rec = dict(label=label,tags=tags,parent_id=dir_id) dir_rec = self.record(ignoreMissing=True,**new_dir_rec).output('dict') or new_dir_rec if not dir_rec.get('id'): self.insert(dir_rec) self.updatePackageHierarchy(node.value,dir_id = dir_rec['id'] ,currpath=currpath+basepath.strip('/').split('/') if basepath else currpath,pkgId=pkgId,pagesOnly=pagesOnly)
def test_stringDict(): """docstring for test_stringDict""" assert gnrstring.stringDict({ 'height': 22, 'width': 33 }) == 'width=33,height=22'
def test_stringDict(): """docstring for test_stringDict""" assert gnrstring.stringDict({'height': 22, 'width': 33}) == 'width=33,height=22'
def test_stringDict(): """docstring for test_stringDict""" d = {'height': '22', 'width': '33'} assert gnrstring.asDict(gnrstring.stringDict(d)) == d