From 5cfd2ff8ba38b17c356e48e756cd7057f236aa71 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Sat, 5 Jan 2019 18:15:28 -0800 Subject: [PATCH] s/ObservationDefaults/Defaults/g --- bin/weecfg/__init__.py | 44 +++++++++---------- .../test/expected/weewx20_user_expected.conf | 2 +- .../test/expected/weewx39_expected.conf | 2 +- bin/weewx/reportengine.py | 6 +-- bin/weewx/test/testgen.conf | 2 +- docs/changes.txt | 2 +- docs/customizing.htm | 30 ++++++------- docs/upgrading.htm | 14 +++--- docs/usersguide.htm | 4 +- weewx.conf | 2 +- 10 files changed, 54 insertions(+), 54 deletions(-) diff --git a/bin/weecfg/__init__.py b/bin/weecfg/__init__.py index a4f6e064..5e4412ee 100644 --- a/bin/weecfg/__init__.py +++ b/bin/weecfg/__init__.py @@ -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. diff --git a/bin/weecfg/test/expected/weewx20_user_expected.conf b/bin/weecfg/test/expected/weewx20_user_expected.conf index ab9631b5..9a92c1c4 100644 --- a/bin/weecfg/test/expected/weewx20_user_expected.conf +++ b/bin/weecfg/test/expected/weewx20_user_expected.conf @@ -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]] diff --git a/bin/weecfg/test/expected/weewx39_expected.conf b/bin/weecfg/test/expected/weewx39_expected.conf index 974e6afe..24d1bc9d 100644 --- a/bin/weecfg/test/expected/weewx39_expected.conf +++ b/bin/weecfg/test/expected/weewx39_expected.conf @@ -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]] diff --git a/bin/weewx/reportengine.py b/bin/weewx/reportengine.py index 15f16fad..01f9d232 100644 --- a/bin/weewx/reportengine.py +++ b/bin/weewx/reportengine.py @@ -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() diff --git a/bin/weewx/test/testgen.conf b/bin/weewx/test/testgen.conf index 6951c1a5..a293de77 100644 --- a/bin/weewx/test/testgen.conf +++ b/bin/weewx/test/testgen.conf @@ -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]] diff --git a/docs/changes.txt b/docs/changes.txt index 4989b93a..1b0fa4a1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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 diff --git a/docs/customizing.htm b/docs/customizing.htm index c0ffdd19..adb10512 100644 --- a/docs/customizing.htm +++ b/docs/customizing.htm @@ -682,7 +682,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\

The "Observation defaults", explained in the next section, are in weewx.conf, in their own high-level section [ObservationDefaults] and, therefore, near the root of the hierarchy. This places them + class="code">[Defaults] and, therefore, near the root of the hierarchy. This places them at the lowest priority — they are expressed only if not overridden under [StdReport] or in skin.conf.

@@ -726,7 +726,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\ Scope - [ObservationDefaults] + [Defaults] System wide. Affects all reports. @@ -742,22 +742,22 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\

- Changing an option in [ObservationDefaults] + Changing an option in [Defaults]

- With this approach, you change an option under the [ObservationDefaults] section + With this approach, you change an option under the [Defaults] section in weewx.conf. Changes here will affect all reports.

For example, suppose you wish to use metric units for all your reports, instead of the default US Customary - Units. The section under [ObservationDefaults] that controls units is [Defaults] that controls units is [[Units]][[[Groups]]]. It looks like this:

 #   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 "\
         
 #   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 [Labels][[Generic]], from
             the default
         

-
[ObservationDefaults]
+        
[Defaults]
 
     ...
 
@@ -855,7 +855,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
             outTemp = Outside Temperature
             ...

to:

-
[ObservationDefaults]
+        
[Defaults]
 
     ...
 
@@ -872,7 +872,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
         

With this change, all observations of console temperature, such as in an HTML report, or a plot, will now be labeled "Barn Temperature." Because this is under the [ObservationDefaults] section, this change will apply to all reports. + class="code">[Defaults] section, this change will apply to all reports.

@@ -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 HTML_ROOT, but the latter in a subdirectory, HTML_ROOT/metric. - To accomplish this, the [ObservationDefaults] section in weewx.conf + To accomplish this, the [Defaults] section in weewx.conf remains untouched, but the [StdReport] section would read:

@@ -934,7 +934,7 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\
         

- The reason this works is that section [ObservationDefaults] is at the "root" of + The reason this works is that section [Defaults] is at the "root" of the option tree, while an option under [StdReport] is one step closer to the leaves, so the latter has a higher priority. If an option was specified in the configuration file skin.conf, 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 "\

Reference guide to Observation defaults

-

This section is a reference to all the Observation defaults, normally found in [ObservationDefaults] +

This section is a reference to all the Observation defaults, normally found in [Defaults] in weewx.conf

[Units]

@@ -4256,7 +4256,7 @@ class MyStats(SearchList): # 1

Next, you will need to go through the Observation defaults in the - section [ObservationDefaults] in weewx.conf, translating + section [Defaults] in weewx.conf, translating labels and modifying formats to follow local conventions.

@@ -4264,7 +4264,7 @@ class MyStats(SearchList): # 1 In particular, you will probably need to change the following sections:

-[ObservationDefaults]
+[Defaults]
 
     # The following section is for managing the selection and formatting of units.
     [[Units]]
diff --git a/docs/upgrading.htm b/docs/upgrading.htm
index b1860a01..0ee387a5 100644
--- a/docs/upgrading.htm
+++ b/docs/upgrading.htm
@@ -206,8 +206,8 @@ sudo apt-get install weewx

Skin defaults

- A new [ObservationDefaults] section has been introduced to weewx.conf. - To change the unit system, and many other things used by your skins, just change [ObservationDefaults]. + A new [Defaults] section has been introduced to weewx.conf. + To change the unit system, and many other things used by your skins, just change [Defaults].

With version 3.9, the way defaults propogate through skins has changed. Before this version, a value specified in a skin's configuration file skin.conf could be "overridden" by a @@ -226,7 +226,7 @@ sudo apt-get install weewx

-

Version 3.9 introduces a [ObservationDefaults] section that applies to all +

Version 3.9 introduces a [Defaults] section that applies to all skins, unless overridden for individual reports in weewx.conf, or by the report's skin.conf. This means that skin.conf has the final say in what value to use. @@ -239,15 +239,15 @@ sudo apt-get install weewx

class="code">skin.conf to bring them up-to-date. It primarily does four things:

    -
  1. Add a [ObservationDefaults] section to weewx.conf +
  2. Add a [Defaults] section to weewx.conf
  3. For each scalar override in [StdReport], it will comment out or delete the corresponding scalar in skin.conf. This allows the [StdReport] override to continue to have an affect.
  4. For each scalar left over in skin.conf, if its value is the same as in [ObservationDefaults], it will comment out or delete the scalar from skin.conf. This means that changing a value in [ObservationDefaults] + class="code">[Defaults], it will comment out or delete the scalar from skin.conf. This means that changing a value in [Defaults] will have an affect.
  5. As a final step, it adds a scalar, skin_semantics, to skin.conf @@ -302,7 +302,7 @@ sudo apt-get install weewx
group_degree_day = degree_C_day group_speed = meter_per_second
-
[ObservationDefaults]
+                
[Defaults]
     [[Units]]
         [[[Groups]]]
             group_altitude = foot
diff --git a/docs/usersguide.htm b/docs/usersguide.htm
index e5a8c052..490856eb 100644
--- a/docs/usersguide.htm
+++ b/docs/usersguide.htm
@@ -2120,7 +2120,7 @@ longitude = -77.0366

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 [ObservationDefaults]. + href="#Section_Defaults">[Defaults].

They all have the following options in common.

@@ -2715,7 +2715,7 @@ longitude = -77.0366
Default is INNODB.

-

[ObservationDefaults]

+

[Defaults]

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 diff --git a/weewx.conf b/weewx.conf index 335d56d9..def54929 100644 --- a/weewx.conf +++ b/weewx.conf @@ -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]]