mirror of
https://github.com/weewx/weewx.git
synced 2026-04-20 17:46:58 -04:00
s/ObservationDefaults/Defaults/g
This commit is contained in:
@@ -286,20 +286,20 @@ def modify_config(config_dict, stn_info, logger, debug=False):
|
||||
config_dict['Station'][p] = stn_info[p]
|
||||
# Update units display with any stn_info overrides
|
||||
if stn_info.get('units') is not None:
|
||||
if 'ObservationDefaults' not in config_dict:
|
||||
config_dict['ObservationDefaults'] = {}
|
||||
if 'Units' not in config_dict['ObservationDefaults']:
|
||||
config_dict['ObservationDefaults']['Units'] = {}
|
||||
if 'Groups' not in config_dict['ObservationDefaults']['Units']:
|
||||
config_dict['ObservationDefaults']['Units']['Groups'] = {}
|
||||
if 'Defaults' not in config_dict:
|
||||
config_dict['Defaults'] = {}
|
||||
if 'Units' not in config_dict['Defaults']:
|
||||
config_dict['Defaults']['Units'] = {}
|
||||
if 'Groups' not in config_dict['Defaults']['Units']:
|
||||
config_dict['Defaults']['Units']['Groups'] = {}
|
||||
if stn_info.get('units') in ['metric', 'metricwx']:
|
||||
if debug:
|
||||
logger.log("Using Metric units for display", level=2)
|
||||
config_dict['ObservationDefaults']['Units']['Groups'].update(metricwx_group)
|
||||
config_dict['Defaults']['Units']['Groups'].update(metricwx_group)
|
||||
elif stn_info.get('units') == 'us':
|
||||
if debug:
|
||||
logger.log("Using US units for display", level=2)
|
||||
config_dict['ObservationDefaults']['Units']['Groups'].update(us_group)
|
||||
config_dict['Defaults']['Units']['Groups'].update(us_group)
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
@@ -992,7 +992,7 @@ def update_to_v39(config_dict):
|
||||
|
||||
- New top-level options log_success and log_failure
|
||||
- New subsections [[SeasonsReport]], [[SmartphoneReport]], and [[MobileReport]]
|
||||
- New section [ObservationDefaults]
|
||||
- New section [Defaults]
|
||||
"""
|
||||
|
||||
major, minor = get_version_info(config_dict)
|
||||
@@ -1071,8 +1071,8 @@ def update_to_v39(config_dict):
|
||||
# Put the comment back in
|
||||
config_dict.comments['StdReport'] = std_report_comment
|
||||
|
||||
if 'ObservationDefaults' not in config_dict:
|
||||
defaults_dict = configobj.ConfigObj(StringIO("""[ObservationDefaults]
|
||||
if 'Defaults' not in config_dict:
|
||||
defaults_dict = configobj.ConfigObj(StringIO("""[Defaults]
|
||||
|
||||
# The following section is for managing the selection and formatting of units.
|
||||
[[Units]]
|
||||
@@ -1261,10 +1261,10 @@ def update_to_v39(config_dict):
|
||||
"""))
|
||||
|
||||
weeutil.config.merge_config(config_dict, defaults_dict)
|
||||
# Put the comment for the [ObservationDefaults] section back in, which the merge process always seems to strip:
|
||||
config_dict.comments['ObservationDefaults'] = major_comment_block + ['# Various default values used by observations', '']
|
||||
# Move the [ObservationDefaults] section to just before the [Engine] section
|
||||
reorder_sections(config_dict, 'ObservationDefaults', 'Engine')
|
||||
# Put the comment for the [Defaults] section back in, which the merge process always seems to strip:
|
||||
config_dict.comments['Defaults'] = major_comment_block + ['# Various default values used by observations', '']
|
||||
# Move the [Defaults] section to just before the [Engine] section
|
||||
reorder_sections(config_dict, 'Defaults', 'Engine')
|
||||
|
||||
config_dict['version'] = '3.9.0'
|
||||
|
||||
@@ -1321,11 +1321,11 @@ def patch_skin_dict(config_dict, skin_dict, report, logger):
|
||||
if section in skin_dict:
|
||||
n_commented += fix_overrides(config_dict['StdReport'][report][section], skin_dict[section])
|
||||
|
||||
# For each section under [ObservationDefaults], delete any scalar in skin.conf
|
||||
# that has the same value as in [ObservationDefaults].
|
||||
for section in config_dict['ObservationDefaults'].sections:
|
||||
# For each section under [Defaults], delete any scalar in skin.conf
|
||||
# that has the same value as in [Defaults].
|
||||
for section in config_dict['Defaults'].sections:
|
||||
if section in skin_dict:
|
||||
n_commented += fix_defaults(config_dict['ObservationDefaults'][section], skin_dict[section])
|
||||
n_commented += fix_defaults(config_dict['Defaults'][section], skin_dict[section])
|
||||
|
||||
logger.log("For report '%s', %d lines were commented out" % (report, n_commented), level=2)
|
||||
|
||||
@@ -1355,7 +1355,7 @@ def fix_overrides(section_dict, skin_dict_section):
|
||||
|
||||
def fix_defaults(defaults_dict, skin_dict_section):
|
||||
"""Delete any values in the skin.conf that are the same as their corresponding value
|
||||
in [ObservationDefaults]"""
|
||||
in [Defaults]"""
|
||||
n_commented = 0
|
||||
for section in defaults_dict.sections:
|
||||
if section in skin_dict_section:
|
||||
@@ -1406,8 +1406,8 @@ def get_station_info(config_dict):
|
||||
# Try to figure out what unit system the user is using. Assume we can't.
|
||||
stn_info['units'] = None
|
||||
try:
|
||||
# First look for a [ObservationDefaults] section.
|
||||
stn_info['units'] = get_unit_info(config_dict['ObservationDefaults'])
|
||||
# First look for a [Defaults] section.
|
||||
stn_info['units'] = get_unit_info(config_dict['Defaults'])
|
||||
except KeyError:
|
||||
pass
|
||||
# If that didn't work, look for an override in the [[StandardReport]] section.
|
||||
|
||||
@@ -433,7 +433,7 @@ version = 3.9.0a5
|
||||
|
||||
# Various default values used by observations
|
||||
|
||||
[ObservationDefaults]
|
||||
[Defaults]
|
||||
|
||||
# The following section is for managing the selection and formatting of units.
|
||||
[[Units]]
|
||||
|
||||
@@ -389,7 +389,7 @@ version = 3.9.0
|
||||
|
||||
# Various default values used by observations
|
||||
|
||||
[ObservationDefaults]
|
||||
[Defaults]
|
||||
|
||||
# The following section is for managing the selection and formatting of units.
|
||||
[[Units]]
|
||||
|
||||
@@ -216,11 +216,11 @@ class StdReportEngine(threading.Thread):
|
||||
def _build_skin_dict(self, report):
|
||||
"""Find and build the skin_dict for the given report"""
|
||||
|
||||
if 'ObservationDefaults' in self.config_dict:
|
||||
# Start with the [ObservationDefaults] section in weewx.conf. Because we will be modifying it,
|
||||
if 'Defaults' in self.config_dict:
|
||||
# Start with the [Defaults] section in weewx.conf. Because we will be modifying it,
|
||||
# we need to make a deep copy. We can do this by applying the .dict() member function,
|
||||
# which returns a copy as a plain old dictionary, then converting that into a ConfigObj
|
||||
skin_dict = configobj.ConfigObj(self.config_dict['ObservationDefaults'].dict())
|
||||
skin_dict = configobj.ConfigObj(self.config_dict['Defaults'].dict())
|
||||
else:
|
||||
skin_dict = configobj.ConfigObj()
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ version = test
|
||||
|
||||
# Various default values used by observations
|
||||
|
||||
[ObservationDefaults]
|
||||
[Defaults]
|
||||
|
||||
# The following section is for managing the selection and formatting of units.
|
||||
[[Units]]
|
||||
|
||||
@@ -8,7 +8,7 @@ New default skin called Seasons.
|
||||
Dropped support of Python 2.5. You must now use either Python 2.6 or 2.7. This is
|
||||
in anticipation of porting to Python 3.
|
||||
|
||||
Introduced a new section [ObservationDefaults] in weewx.conf that holds much of the
|
||||
Introduced a new section [Defaults] in weewx.conf that holds much of the
|
||||
information that used to be in the individual skin.conf files. Once set up correctly,
|
||||
changing a unit system here will change it everywhere. Of course, overrides for
|
||||
individual skins are still allowed. The install program will patch any skin.conf
|
||||
|
||||
@@ -682,7 +682,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
<p>
|
||||
The "<a href="#Observation_defaults">Observation defaults</a>", explained in the next section, are in <span
|
||||
class="code">weewx.conf</span>, in their own high-level section <span
|
||||
class="code">[ObservationDefaults]</span> and, therefore, near the root of the hierarchy. This places them
|
||||
class="code">[Defaults]</span> and, therefore, near the root of the hierarchy. This places them
|
||||
at the lowest priority — they are expressed only if not overridden under <span class="code">[StdReport]</span>
|
||||
or in <span class="code">skin.conf</span>.
|
||||
</p>
|
||||
@@ -726,7 +726,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
<td>Scope</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="code"><a href="#change_defaults">[ObservationDefaults]</a></td>
|
||||
<td class="code"><a href="#change_defaults">[Defaults]</a></td>
|
||||
<td>System wide. Affects <em>all</em> reports.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -742,22 +742,22 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
</p>
|
||||
|
||||
<h3 id="change_defaults">
|
||||
Changing an option in <span class="code">[ObservationDefaults]</span>
|
||||
Changing an option in <span class="code">[Defaults]</span>
|
||||
</h3>
|
||||
<p>
|
||||
With this approach, you change an option under the <span class="code">[ObservationDefaults]</span> section
|
||||
With this approach, you change an option under the <span class="code">[Defaults]</span> section
|
||||
in <span class="code">weewx.conf.</span> Changes here will affect <em>all</em> reports.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example, suppose you wish to use metric units for all your reports, instead of the default US Customary
|
||||
Units. The section under <span class="code">[ObservationDefaults]</span> that controls units is <span
|
||||
Units. The section under <span class="code">[Defaults]</span> that controls units is <span
|
||||
class="code">[[Units]][[[Groups]]]</span>. It looks like this:
|
||||
</p>
|
||||
<pre class="tty">
|
||||
# Default values for reports
|
||||
|
||||
[ObservationDefaults]
|
||||
[Defaults]
|
||||
|
||||
# The following section is for managing the selection and formatting of units.
|
||||
[[Units]]
|
||||
@@ -796,7 +796,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
<pre class="tty">
|
||||
# Default values for reports
|
||||
|
||||
[ObservationDefaults]
|
||||
[Defaults]
|
||||
|
||||
# The following section is for managing the selection and formatting of units.
|
||||
[[Units]]
|
||||
@@ -841,7 +841,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
option, located in section <a href="#Labels_Generic"><span class="code">[Labels][[Generic]]</span></a>, from
|
||||
the default
|
||||
</p>
|
||||
<pre class="tty">[ObservationDefaults]
|
||||
<pre class="tty">[Defaults]
|
||||
|
||||
...
|
||||
|
||||
@@ -855,7 +855,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
outTemp = Outside Temperature
|
||||
...</pre>
|
||||
<p>to:</p>
|
||||
<pre class="tty">[ObservationDefaults]
|
||||
<pre class="tty">[Defaults]
|
||||
|
||||
...
|
||||
|
||||
@@ -872,7 +872,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
<p>
|
||||
With this change, all observations of console temperature, such as in an HTML report, or a plot, will now be
|
||||
labeled <em>"Barn Temperature</em>." Because this is under the <span
|
||||
class="code">[ObservationDefaults]</span> section, this change will apply to <em>all</em> reports.
|
||||
class="code">[Defaults]</span> section, this change will apply to <em>all</em> reports.
|
||||
</p>
|
||||
|
||||
<h3 id="overriding_from_weewx_conf">
|
||||
@@ -887,7 +887,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
Suppose you want two reports, one in Metric,
|
||||
the other in US Customary. The Metric report will go in the regular directory <span class="symcode">HTML_ROOT</span>,
|
||||
but the latter in a subdirectory, <span class="code"><span class="symcode">HTML_ROOT</span>/metric</span>.
|
||||
To accomplish this, the <span class="code">[ObservationDefaults]</span> section in <span class="code">weewx.conf</span>
|
||||
To accomplish this, the <span class="code">[Defaults]</span> section in <span class="code">weewx.conf</span>
|
||||
remains untouched, but the <span class="code">[StdReport]</span> section would read:
|
||||
</p>
|
||||
<pre class="tty">
|
||||
@@ -934,7 +934,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The reason this works is that section <span class="code">[ObservationDefaults]</span> is at the "root" of
|
||||
The reason this works is that section <span class="code">[Defaults]</span> is at the "root" of
|
||||
the option tree, while an option under <span class="code">[StdReport]</span> is one step closer to the
|
||||
leaves, so the latter has a higher priority. If an option was specified in the configuration file <span
|
||||
class="code">skin.conf</span>, it would be even farther out the tree and would have the final say. Indeed,
|
||||
@@ -944,7 +944,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
|
||||
|
||||
<h2 id="Reference_guide_to_Observation_defaults">Reference guide to Observation defaults</h2>
|
||||
|
||||
<p>This section is a reference to all the Observation defaults, normally found in <span class="code">[ObservationDefaults]</span>
|
||||
<p>This section is a reference to all the Observation defaults, normally found in <span class="code">[Defaults]</span>
|
||||
in <span class="code">weewx.conf</span></p>
|
||||
|
||||
<h3 class="config_section">[Units]</h3>
|
||||
@@ -4256,7 +4256,7 @@ class MyStats(SearchList): # 1
|
||||
|
||||
<p>
|
||||
Next, you will need to go through the <a href="#Observation_defaults">Observation defaults</a> in the
|
||||
section <span class="code">[ObservationDefaults]</span> in <span class="code">weewx.conf</span>, translating
|
||||
section <span class="code">[Defaults]</span> in <span class="code">weewx.conf</span>, translating
|
||||
labels and modifying formats to follow local conventions.
|
||||
</p>
|
||||
|
||||
@@ -4264,7 +4264,7 @@ class MyStats(SearchList): # 1
|
||||
In particular, you will probably need to change the following sections:
|
||||
</p>
|
||||
<pre class="tty">
|
||||
[ObservationDefaults]
|
||||
[Defaults]
|
||||
|
||||
# The following section is for managing the selection and formatting of units.
|
||||
[[Units]]
|
||||
|
||||
@@ -206,8 +206,8 @@ sudo apt-get install weewx</pre>
|
||||
|
||||
<h3>Skin defaults</h3>
|
||||
<p class="note">
|
||||
A new <span class="code">[ObservationDefaults]</span> section has been introduced to <span class="code">weewx.conf</span>.
|
||||
To change the unit system, and many other things used by your skins, just change <span class="code">[ObservationDefaults].</span>
|
||||
A new <span class="code">[Defaults]</span> section has been introduced to <span class="code">weewx.conf</span>.
|
||||
To change the unit system, and many other things used by your skins, just change <span class="code">[Defaults].</span>
|
||||
</p>
|
||||
<p>With version 3.9, the way defaults propogate through skins has changed. Before this version, a value
|
||||
specified in a skin's configuration file <span class="code">skin.conf</span> could be "overridden" by a
|
||||
@@ -226,7 +226,7 @@ sudo apt-get install weewx</pre>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>Version 3.9 introduces a <span class="code">[ObservationDefaults]</span> section that applies to <em>all</em>
|
||||
<p>Version 3.9 introduces a <span class="code">[Defaults]</span> section that applies to <em>all</em>
|
||||
skins, unless overridden for individual reports in <span class="code">weewx.conf</span>, or by the report's
|
||||
<span class="code">skin.conf</span>. This means that <span class="code">skin.conf</span> has the final say
|
||||
in what value to use.
|
||||
@@ -239,15 +239,15 @@ sudo apt-get install weewx</pre>
|
||||
class="code">skin.conf</span> to bring them up-to-date. It primarily does four things:
|
||||
</p>
|
||||
<ol>
|
||||
<li>Add a <span class="code">[ObservationDefaults]</span> section to <span class="code">weewx.conf</span>
|
||||
<li>Add a <span class="code">[Defaults]</span> section to <span class="code">weewx.conf</span>
|
||||
</li>
|
||||
<li>For each scalar override in <span class="code">[StdReport]</span>, it will comment out or delete the
|
||||
corresponding scalar in <span class="code">skin.conf</span>. This allows the <span class="code">[StdReport]</span>
|
||||
override to continue to have an affect.
|
||||
</li>
|
||||
<li>For each scalar left over in <span class="code">skin.conf</span>, if its value is the same as in <span
|
||||
class="code">[ObservationDefaults]</span>, it will comment out or delete the scalar from <span
|
||||
class="code">skin.conf</span>. This means that changing a value in <span class="code">[ObservationDefaults]</span>
|
||||
class="code">[Defaults]</span>, it will comment out or delete the scalar from <span
|
||||
class="code">skin.conf</span>. This means that changing a value in <span class="code">[Defaults]</span>
|
||||
will have an affect.
|
||||
</li>
|
||||
<li>As a final step, it adds a scalar, <span class="code">skin_semantics</span>, to <span class="code">skin.conf</span>
|
||||
@@ -302,7 +302,7 @@ sudo apt-get install weewx</pre>
|
||||
group_degree_day = degree_C_day
|
||||
group_speed = meter_per_second
|
||||
</pre>
|
||||
<pre class="tty added"><span class="">[ObservationDefaults]
|
||||
<pre class="tty added"><span class="">[Defaults]
|
||||
[[Units]]
|
||||
[[[Groups]]]
|
||||
group_altitude = foot
|
||||
|
||||
@@ -2120,7 +2120,7 @@ longitude = -77.0366</pre>
|
||||
<p>
|
||||
These are the four reports that actually generate HTML files and plots. They all ship in the standard WeeWX
|
||||
distribution. They all use US Customary units by default, but this can be changed by editing section <a
|
||||
href="#Section_Defaults"><span class="code">[ObservationDefaults]</span></a>.
|
||||
href="#Section_Defaults"><span class="code">[Defaults]</span></a>.
|
||||
</p>
|
||||
<p>They all have the following options in common.</p>
|
||||
|
||||
@@ -2715,7 +2715,7 @@ longitude = -77.0366</pre>
|
||||
Default is <span class="code">INNODB</span>.
|
||||
</p>
|
||||
|
||||
<h2 class="config_section" id="Section_Defaults">[ObservationDefaults]</h2>
|
||||
<h2 class="config_section" id="Section_Defaults">[Defaults]</h2>
|
||||
<p>
|
||||
This section covers a suite of "Observation defaults," which control things such as which unit system should be
|
||||
used in reports, what label to be used for an observation type, and how it should be formatted. Details can
|
||||
|
||||
@@ -397,7 +397,7 @@ version = 3.9.0a5
|
||||
|
||||
# Various default values used by observations
|
||||
|
||||
[ObservationDefaults]
|
||||
[Defaults]
|
||||
|
||||
# The following section is for managing the selection and formatting of units.
|
||||
[[Units]]
|
||||
|
||||
Reference in New Issue
Block a user