Revision: 16230
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 29, 2009 11:29 by laurenceosx
Initial Code
def GetPath(p): def GetHs(itr): return itr.headString().strip().split('\n')[0].strip() def GetBs(itr): return itr.bodyString().strip().split('\n')[0].strip() lst = [] itr = p.copy() level = p.copy().level() while level >= 0: hs = GetHs(itr) bs = GetBs(itr) if hs.startswith('@path'): ThePath = bs lst.append( ThePath ) else: if level > 0: for p in itr.siblings_iter(): hs = GetHs(p) bs = GetBs(p) if hs.startswith('@path'): ThePath = bs lst.append( ThePath ) itr = itr.parent() level = level -1 lst.reverse() s = '\\'.join( lst ) return s # Iterate and fix start = p.copy() current = p.copy() for p in current.self_and_subtree_iter(): hs = p.headString().strip() if hs.startswith('@path'): sPath = GetPath(p) NewHeadString = '@path ' + sPath if hs <> NewHeadString: print 'NewPath->', NewHeadString c.setHeadString(p, NewHeadString) else: print 'PathCheck', hs
Initial URL
Initial Description
Initial Title
Python Leo - Fix Path Nodes Top Down
Initial Tags
python
Initial Language
Python