[augeas-devel] augeas target configuration files

David Lutterkort dlutter at redhat.com
Fri Apr 25 17:18:41 UTC 2008


On Fri, 2008-04-25 at 19:10 +0200, Harald Hoyer wrote:
> Harald Hoyer wrote:
> > Can we define a list of config files, which augeas does/will/should 
> > support?
> > 
> 
> so far:
> 
> def recurmatch(aug, path):
>      matches = aug.match(path + "/*")
>      subvals = []
>      for i in matches:
>          val_list = recurmatch(aug, i)
>          if type(val_list) is tuple:
>              subvals.append(val_list)
>          elif type(val_list) is list:
>              subvals.extend(val_list)
>      else:
>          if path != "/":
>              val = aug.get(path)
>              if val:
>                  return (path, val)
>      return subvals
> 
> a = augeas.augeas()
> path = "/"
> matches = recurmatch(a, path)
> for (p, attr) in matches:
>      print "%s = %s" % (p, attr)

That gives you a list of all entries in the tree, which (under /files)
are all files that Augeas knows about _and_ are present on your system
(e.g. you wouldn't see that it can handle Apt's sources.list)

You can get that list also by recursing through /augeas/files and
looking for entries that end in 'path' .. that will always be
'/files/FSPATH' where FSPATH is the path in the file system for the file
that is mapped at '/files/FSPATH'

The real list of files Augeas can handle is in internal data structures
(specifically in transform values defined by the modules) If that
information seems valuable, I could expose it in the /augeas hierarchy,
too

David





More information about the augeas-devel mailing list