[augeas-devel] [PATCH 1/1] Added 'setm' function.

David Lutterkort lutter at redhat.com
Tue Mar 16 22:42:01 UTC 2010


Hi Frederik,

On Tue, 2010-03-16 at 23:04 +0100, Frederik Wagner wrote:
> On Tue, Mar 16, 2010 at 10:38 PM, David Lutterkort <lutter at redhat.com> wrote:
> > On Tue, 2010-03-16 at 22:04 +0100, Frederik Wagner wrote:
> >> This function sets multiple elements to a node set.
> >
> > This patch looks fine to me; I am curious though what you thought of
> > adding 'set multiple' functionality to libaugeas itself, and the way the
> > patch I sent works.
> >
> 
> oh, I didn't yet see that one (hanging behind digging through the
> mails:), I just send what I already had.
> 
> We have to be carefull about the features of the 'setm' function now:
> What I send is the possibility to  (e.g.) append multiple values (from
> an array) to a node set, like users to a group. You send an idea for a
> - let's call it - the 'set_all' function. Should we mix that
> functionality?

No - I didn't look at the patch carefully enough. For the 'set from an
array' functionality, it's best to do that in Ruby. We need to make sure
that the names for those two functions does not collide though.

You could add what you did in the existing set method:
      * rename the set in ext/augeas/_augeas.c to set_internal
      * add to lib/augeas.rb
        
        def set(path, *values)
          values.flatten.all { |v| set_internal(path, v) }
        end

With that, you can say 'aug.set(path, "v")' or 'aug.set(path, "v1",
"v2")' or 'aug.set(path, ["v1", "v2"])'

David





More information about the augeas-devel mailing list