Not a big deal - I was mainly asking to see if more than a few sometimes 
thought this was an itch worth scratching.

In my case I was trying to script ala-carte bill-of-materials based builds 
using ansible.  The basic problem that weewx lets a third party developer 
put anything they want into any location within the namespace.  So there 
might be multiple 'debug = 0' or 'log_success = true/false' items in 
weewx.conf and it is not possible using ansible nor puppet nor any other 
tool I've found to let you automate setting '*just THAT one*' to a desired 
value.

Maybe there isn't a good solution for something so extensible.   I was just 
asking if others have thoughts....

On Thursday, February 26, 2026 at 6:32:54 AM UTC-8 Greg Troxel wrote:

> Vince Skahan <[email protected]> writes:
>
> > Would some kind of utility to permit simple edits of 'any' item in 
> > weewx.conf be of any value to think about ?
> >
> > Something like "weectl edit config" or the like (for discussion 
> purposes) ?
> >
> > # edit weewx.conf
> > weectl edit config --set "[StdRestful][[MQTT]]" --key "log_success" 
> --value 
> > "true"
>
> Perhaps, but this is something that really should be implemented in
> configobj first -- is that already there?
>
> Can configobj read a file into some pythonic data structure, let you
> change it, and then write it, and have that result in no changes (or
> formatting regularization that is stable), in particular preserving
> comments? Is the implementation just parsing the headings and
> assigning a variable, after read and before write?
>
> (I presonally would prefer
> --set /StdRestful/MQTT/log_success=true
> but I realize that's turning windows ini back into unix paths and
> everybody else wouldn't like that!)
>
> > I know simply telling them 'edit the file dude' of course works, but it 
> > might be helpful for scriptability if there was a way to automate 
> > add/edit/comment/uncomment things programmatically. The use of configobj 
> > makes this really hard to do without some wrapper utility being cooked 
> up.
> >
> > I did think about some alternate ways:
> >
> > - convert the .conf in configobj format to JSON or YAML
> > - edit thataway
> > - convert it back to configobj format
> >
> > But that would be ugly at best and likely would lose any comments from 
> the 
> > .conf file.
>
> configobj talks about round trip:
>
> ConfigObj is a simple but powerful config file reader and writer: an
> ini file round tripper. Its main feature is that it is very easy to
> use, with a straightforward programmer’s interface and a simple syntax
> for config files.
>
> * All comments in the file are preserved
>
> * The order of keys/sections is preserved
>
> so in theory this should work.
>
> It should be easy enough to test with
>
> read weewx.conf to python data structure
> write that to weewx.conf.roundtrip
>
> and diff.
>
>
>
> I remember problems with earlier config updates (maybe 4 years ago)
> where the generated config would have some odd whitespace that was
> different from the standard config file. But I think that's no longer
> the case.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/weewx-development/5dce3454-eeb1-4e32-bf5c-b6151e09c565n%40googlegroups.com.

Reply via email to