Biltong | 5 Mar 10:32 2012

How to use the generic IniFile module?

Hello,

Is it possible to list all lenses that Augeas supports?

I'd like to edit a .ini file without defining a new lens. When I try, I
get an error:

augtool> set /augeas/load/IniFile/lens inifile
augtool> set /augeas/load/IniFile/incl /some/file.ini
augtool> load
error: Lens not found
error: Can not find lens inifile

I can see a inifile.aug in /usr/share/augeas/lenses/dist

What's going on? Thanks.

-- 
  Biltong
  biltong@...

--

-- 
http://www.fastmail.fm - Does exactly what it says on the tin

Dominic Cleal | 5 Mar 11:29 2012
Picon

Re: How to use the generic IniFile module?

On 05/03/12 09:32, Biltong wrote:
> Hello,
> 
> Is it possible to list all lenses that Augeas supports?

Looking in /usr/share/augeas/lenses/dist is probably your best bet.
Most of the modules have a "lns" lens inside, except where they're
designed as building blocks (e.g. util, rx, build and inifile).

There's also the generated documentation, but it doesn't list all
lenses, as documentation coverage isn't complete yet:

http://augeas.net/docs/references/lenses/

> I'd like to edit a .ini file without defining a new lens. When I try, I
> get an error:
> 
> augtool> set /augeas/load/IniFile/lens inifile
> augtool> set /augeas/load/IniFile/incl /some/file.ini
> augtool> load
> error: Lens not found
> error: Can not find lens inifile
> 
> I can see a inifile.aug in /usr/share/augeas/lenses/dist
> 
> What's going on? Thanks.

Two things here:

a) The IniFile module is a set of building blocks and doesn't contain a
(Continue reading)

Biltong | 5 Mar 16:07 2012

Re: How to use the generic IniFile module?

On Mon, Mar 5, 2012, at 10:29 AM, Dominic Cleal wrote:
> On 05/03/12 09:32, Biltong wrote:
> > Hello,
> > 
> > Is it possible to list all lenses that Augeas supports?
> 
> Looking in /usr/share/augeas/lenses/dist is probably your best bet.
> Most of the modules have a "lns" lens inside, except where they're
> designed as building blocks (e.g. util, rx, build and inifile).
> 
> There's also the generated documentation, but it doesn't list all
> lenses, as documentation coverage isn't complete yet:
> 
> http://augeas.net/docs/references/lenses/

Thanks. The ability for augtool to list lenses would still be nice
though. Should I file an RFE?

> > I'd like to edit a .ini file without defining a new lens. When I try, I
> > get an error:
> > 
> > augtool> set /augeas/load/IniFile/lens inifile
> > augtool> set /augeas/load/IniFile/incl /some/file.ini
> > augtool> load
> > error: Lens not found
> > error: Can not find lens inifile
> > 
> > I can see a inifile.aug in /usr/share/augeas/lenses/dist
> > 
> > What's going on? Thanks.
(Continue reading)

Dominic Cleal | 5 Mar 16:15 2012
Picon

Re: How to use the generic IniFile module?

On 05/03/12 15:07, Biltong wrote:
> On Mon, Mar 5, 2012, at 10:29 AM, Dominic Cleal wrote:
>> a) The IniFile module is a set of building blocks and doesn't contain a
>> lens that will let you parse a whole file.  The reason for this is .ini
>> files actually vary somewhat in design, so there's no single generic
>> lens it provides.
>>
>> You'd be better off specifying one of the derived lenses, such as:
>>
>> Puppet.lns - simple .ini file
>> PHP.lns - allows settings outside of sections (under ".anon")
>> MySQL.lns - allows slashes in section names, supports !include etc
>> Dput.lns - allows only certain setting names, allows slashes
>>
>> For a many cases, Puppet.lns is probably suitable.
> 
> Okay. And what's the best way of distributing lenses, if I create new
> ones? Putting them somewhere not in /dist sounds sensible, is that
> right?

Yep, the /dist directory is used by the package.

The /usr/share/augeas/lenses directory will be searched by Augeas first
so add your lenses here, or use the -I argument to augtool to search
another path.

--

-- 
Dominic Cleal
Red Hat Consulting
m: +44 (0)7817 878113
(Continue reading)

Raphaël Pinson | 5 Mar 12:16 2012
Picon

Re: How to use the generic IniFile module?

Hello,

On Mon, Mar 5, 2012 at 10:32 AM, Biltong <biltong@...> wrote:
> Is it possible to list all lenses that Augeas supports?

Yes, in augtool you can use:

augtool> print /augeas//incl

which will list all include paths. Beware that there's also "excl"
nodes for exclusions on wildcards.

>
> I'd like to edit a .ini file without defining a new lens. When I try, I
> get an error:
>
> augtool> set /augeas/load/IniFile/lens inifile
> augtool> set /augeas/load/IniFile/incl /some/file.ini
> augtool> load
> error: Lens not found
> error: Can not find lens inifile
>
> I can see a inifile.aug in /usr/share/augeas/lenses/dist
>
> What's going on? Thanks.

As Dominic already said, inifile.aug is a generic lens used to build
IniFile lenses, since IniFiles are not standard.

Raphaël
(Continue reading)

Biltong | 5 Mar 16:08 2012

Re: How to use the generic IniFile module?

On Mon, Mar 5, 2012, at 12:16 PM, Raphaël Pinson wrote:
> Hello,
> 
> On Mon, Mar 5, 2012 at 10:32 AM, Biltong <biltong@...> wrote:
> > Is it possible to list all lenses that Augeas supports?
> 
> 
> Yes, in augtool you can use:
> 
> augtool> print /augeas//incl

Aha, good to know. Thanks.

> 
> which will list all include paths. Beware that there's also "excl"
> nodes for exclusions on wildcards.
> 
> 
> >
> > I'd like to edit a .ini file without defining a new lens. When I try, I
> > get an error:
> >
> > augtool> set /augeas/load/IniFile/lens inifile
> > augtool> set /augeas/load/IniFile/incl /some/file.ini
> > augtool> load
> > error: Lens not found
> > error: Can not find lens inifile
> >
> > I can see a inifile.aug in /usr/share/augeas/lenses/dist
> >
(Continue reading)

David Lutterkort | 13 Mar 01:05 2012
Picon

Re: How to use the generic IniFile module?

On Mon, 2012-03-05 at 10:32 +0100, Biltong wrote:
> Is it possible to list all lenses that Augeas supports?

You can do this with

  augtool --noload print /augeas/load/*/lens

That will spit out lines of the form

        /augeas/load/Modprobe/lens = " <at> Modprobe"

The ' <at> Modprobe' is shorthand for 'the lens marked for autoload from
module Modprobe'. You can find that module in general
in /usr/share/augeas/lenses/dist/modprobe.aug, and usually it's the lens
called 'lns' in that file.

David


Gmane