Thanks for the clarification.  I think we can live with the workaround 
(which works fine).

On Wednesday, January 27, 2021 at 2:13:30 PM UTC-8 Tom Keffer wrote:

> It's not a bug, it's a limitation with ConfigObj.
>
> In ConfigObj, all comments belong to the option or section below them. If 
> you don't have anything below, there is no place for ConfigObj to put the 
> comment and it is ignored.
>
> Usually one can find creative ways around the problem. For example, this 
> is the reason why [[Corrections]] has the entry "foo = foo + 0.2".
>
> On Wed, Jan 27, 2021 at 1:44 PM vince <vince...@gmail.com> wrote:
>
>> Tom - think I found a bug in 4.3.0 for this one - the extension installer 
>> gets confused if you flip-flop back and forth in a sub-element between 
>> comments and uncommented items in the install.py script. wee_extension 
>> seems to not put any comments that are in install.py 'below' the last 
>> uncommented item in the config_dict into the resulting weewx.conf file.
>>
>> background -  I was working on some tweaks to Pat's install.py (my forked 
>> version is HERE 
>> <https://github.com/vinceskahan/weewx-belchertown/blob/master/install.py>) 
>> and found this one experimentally by installing/uninstalling my forked 
>> Belchertown.   The intent FWIW is to have a fully populated 
>> [[[Belchertown]]] stanza there with the zillion options present, just 
>> commented out as the default.
>>
>> I found a solid workaround by putting an uncommented unused bogus 
>> var=value line on line 154, but I thought I'd mention it anyway as a 
>> nice-to-have.
>>
>> To show the bug:
>>
>>    - grab my forked skin, comment out line 154 (the workaround) so the 
>>    config_dict Extras elements are all comments
>>    - install the skin.  All the comments in the [[[Belchertown]]] stanza 
>>    make it into weewx ok
>>    - uninstall the skin to revert to clean weewx
>>    - uncomment line 90 in install.py and install the extension.   That 
>>    will be the last line wee_extension puts into weewx.conf. Everything 
>> above 
>>    that line makes it into weewx ok....but nothing 'after' that line will be 
>>    in weewx (that's the bug)
>>    - uninstall the skin to revert to clean weewx
>>
>>
>> The pattern is that nothing under the 'last' uncommented item in the 
>> install.py config_dict makes it into the resulting weewx.conf file.  It 
>> doesn't matter which line has a uncommented key=value pair.   The rest of 
>> the lines 'below' the last uncommented ones get dropped by the extension 
>> installer
>>
>> I think the commit you made to get to today's config is 
>> https://github.com/weewx/weewx/commit/47a55eede790b3da0025e71596d13cd39ebc7e03
>>
>> Obviously an edge case.   If you want me to open a github issue for 
>> getting to it whenever, let me know...
>>
>> On Thursday, December 24, 2020 at 12:15:39 PM UTC-8 vince wrote:
>>
>>> Tom - can we get this into 4.3 please since that's imminent and this one 
>>> affects only comments ?
>>>
>>> On Wednesday, December 23, 2020 at 4:56:37 PM UTC-8 Tom Keffer wrote:
>>>
>>>> Now that I look at the actual code, my approach doesn't always work!  
>>>> It will not preserve comments at the root level. For example:
>>>>
>>>> # This is a comment
>>>> [SectionA]
>>>>   # Comment on option1
>>>>   option1 = foo
>>>>   option2 = bar  # Inline comment about option2
>>>>
>>>> The highlighted comment would not get preserved. The others would.
>>>>
>>>> Fixed in commit 98eef9b 
>>>> <https://github.com/weewx/weewx/commit/98eef9be0f9dddeb942847296ebe592f99051ec3>
>>>>
>>>>
>>>> On Wed, Dec 23, 2020 at 4:04 PM vince <vince...@gmail.com> wrote:
>>>>
>>>>> On Wednesday, December 23, 2020 at 2:48:37 PM UTC-8 Tom Keffer wrote:
>>>>>
>>>>>> I guess I'm not understanding this. If you create a config section 
>>>>>> for the installer, it will be faithfully reproduced as it gets injected 
>>>>>> into weewx.conf, including any comments. 
>>>>>>
>>>>>> As an example, take a look at install.py 
>>>>>> <https://github.com/tkeffer/weewx-nmea-xdr/blob/master/install.py> 
>>>>>> for weewx-nmea-xdr <https://github.com/tkeffer/weewx-nmea-xdr>.
>>>>>>
>>>>>>
>>>>> Perfect.
>>>>> Exactly what I was hoping to do.
>>>>>
>>>>> Neither Belchertown (here 
>>>>> <https://github.com/poblabs/weewx-belchertown/blob/master/install.py>) 
>>>>> nor weewx-mqtt (here 
>>>>> <https://github.com/matthewwall/weewx-mqtt/blob/master/install.py>) 
>>>>> do it that way.
>>>>> Your way is way slicker.
>>>>>  
>>>>>
>>>>>> Or, am I missing something?
>>>>>>
>>>>>>
>>>>> Not in the least.
>>>>>
>>>>> Thanks a bunch !
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "weewx-user" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to weewx-user+...@googlegroups.com.
>>>>>
>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/weewx-user/7abfafed-bdbe-42a3-a41d-22e5ffcfffddn%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/weewx-user/7abfafed-bdbe-42a3-a41d-22e5ffcfffddn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to weewx-user+...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-user/8deb909f-971c-490a-81c1-658814fe0331n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-user/8deb909f-971c-490a-81c1-658814fe0331n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/d0853738-095f-44c2-9119-41cba9c27205n%40googlegroups.com.

Reply via email to