def _paths_from_ls(recs):
 ret = {}
 last_nm = ''
 level = 0
 path = []
 ret = []
 for ln in recs.splitlines():
  (nm, val) = ln.rstrip().split(' = ')
  barename = nm.lstrip()
  this_level = (len(nm) - len(barename))
  if (this_level == 0):
   ret.append(barename)
   level = 0
   path = []
  elif (this_level == level):
   ret.append(('%s/%s' % ('/'.join(path), barename)))
  elif (this_level > level):
   path.append(last_nm)
   ret.append(('%s/%s' % ('/'.join(path), barename)))
   level = this_level
  elif (this_level < level):
   path = path[:this_level]
   ret.append(('%s/%s' % ('/'.join(path), barename)))
   level = this_level
  last_nm = barename
 return ret

def _paths_from_ls ( recs ) : ret = { } last_nm = '' level = 0 path = [ ] ret = [ ] for ln in recs . splitlines ( ) : ( nm , val ) = ln . rstrip ( ) . split ( ' = ' ) barename = nm . lstrip ( ) this_level = ( len ( nm ) - len ( barename ) ) if ( this_level == 0 ) : ret . append ( barename ) level = 0 path = [ ] elif ( this_level == level ) : ret . append ( ( '%s/%s' % ( '/' . join ( path ) , barename ) ) ) elif ( this_level > level ) : path . append ( last_nm ) ret . append ( ( '%s/%s' % ( '/' . join ( path ) , barename ) ) ) level = this_level elif ( this_level < level ) : path = path [ : this_level ] ret . append ( ( '%s/%s' % ( '/' . join ( path ) , barename ) ) ) level = this_level last_nm = barename return ret
the xenstore-ls command returns a listing that isnt terribly useful .