diff --git a/bin/weewx/gettext.py b/bin/weewx/gettext.py index 74f28788..9ad11e99 100644 --- a/bin/weewx/gettext.py +++ b/bin/weewx/gettext.py @@ -48,44 +48,27 @@ """ from weewx.cheetahgenerator import SearchList -from weewx.units import ValueTuple,ValueHelper -import configobj -import weeutil.weeutil -import weeutil.config -import os -import os.path +#from weewx.units import ValueTuple,ValueHelper +#import configobj +#import weeutil.weeutil +#import weeutil.config +#import os +#import os.path -try: - # Test for new-style weewx v4 logging by trying to import weeutil.logger - import weeutil.logger - import logging +# Test for new-style weewx v4 logging by trying to import weeutil.logger +import weeutil.logger +import logging - log = logging.getLogger(__name__) +log = logging.getLogger(__name__) - def logdbg(msg): - log.debug(msg) +def logdbg(msg): + log.debug(msg) - def loginf(msg): - log.info(msg) +def loginf(msg): + log.info(msg) - def logerr(msg): - log.error(msg) - -except ImportError: - # Old-style weewx logging - import syslog - - def logmsg(level, msg): - syslog.syslog(level, 'gettext: %s' % msg) - - def logdbg(msg): - logmsg(syslog.LOG_DEBUG, msg) - - def loginf(msg): - logmsg(syslog.LOG_INFO, msg) - - def logerr(msg): - logmsg(syslog.LOG_ERR, msg) +def logerr(msg): + log.error(msg) class Gettext(SearchList): @@ -94,6 +77,8 @@ class Gettext(SearchList): """Create an instance of the class""" super(Gettext,self).__init__(generator) + # get the set language code + # (needed for things like self.lang = self.generator.skin_dict.get('lang','undefined') _idx = self.lang.rfind('/') if _idx>=0: @@ -102,16 +87,17 @@ class Gettext(SearchList): if _idx>=0: self.lang = self.lang[:_idx] + # check if skin_dict contains a section [Labels][[Generic]] + # get it, if it is there, otherwise use an empty dict self.labels_dict={} if 'Labels' in self.generator.skin_dict: if 'Generic' in self.generator.skin_dict['Labels']: self.labels_dict = self.generator.skin_dict['Labels']['Generic'] - d=self.generator.skin_dict - if 'Texts' in d: - self.text_dict = d['Texts'] - elif 'Templates' in d: - self.text_dict = d['Templates'] + # check if skin_dict contains a section [Texts] + # get if it is there, otherwise use an empty dict + if 'Texts' in self.generator.skin_dict: + self.text_dict = self.generator.skin_dict['Texts'] else: self.text_dict = {} if not isinstance(self.text_dict,dict): diff --git a/bin/weewx/reportengine.py b/bin/weewx/reportengine.py index f5f5d4ae..9e6c0a0e 100644 --- a/bin/weewx/reportengine.py +++ b/bin/weewx/reportengine.py @@ -309,34 +309,28 @@ class StdReportEngine(threading.Thread): lang_config_path, report, e) raise - # The key 'target_unit' or 'unit_system' defines the target unit + # The key 'unit_system' defines the target unit # system to be used with the report. The value can be 'US', # 'METRIC', 'METRICWX', or 'METRICDE' # Check if a target unit system is defined. - if 'target_unit' in self.config_dict['StdReport'][report]: - # 'target_unit' is set in weewx.conf - target_unit = self.config_dict['StdReport'][report]['target_unit'] - elif 'unit_system' in self.config_dict['StdReport'][report]: + if 'unit_system' in self.config_dict['StdReport'][report]: # 'unit_system' is set in weewx.conf - target_unit = self.config_dict['StdReport'][report]['unit_system'] - elif 'target_unit' in skin_dict: - # 'target_unit' is set in skin.conf - target_unit = skin_dict['target_unit'] + unit_system = self.config_dict['StdReport'][report]['unit_system'] elif 'unit_system' in skin_dict: # 'unit_system' is set in skin.conf - target_unit = skin_dict['unit_system'] + unit_system = skin_dict['unit_system'] else: # No unit system defined. Use defaults. - target_unit = None - log.debug("target unit system for report '%s': %s" % (report,target_unit)) + unit_system = None + log.debug("unit system for report '%s': %s" % (report,unit_system)) - # If a target unit system is defined get the appropriate dict + # If a unit system is defined get the appropriate dict # out of units.py. - if target_unit: + if unit_system: try: - merge_dict = weewx.units.std_groups[weewx.units.unit_constants[target_unit]] + merge_dict = weewx.units.std_groups[weewx.units.unit_constants[unit_system]] except (KeyError,IndexError): merge_dict = {} @@ -346,7 +340,7 @@ class StdReportEngine(threading.Thread): weeutil.config.merge_config(skin_dict, merge_dict) if self.first_run: log.info("Using unit system %s for report '%s'" % - (target_unit, report)) + (unit_system, report)) except (SyntaxError,TypeError,IOError) as e: log.error("error merging target unit system for report '%s'" % report) pass diff --git a/docs/customizing.htm b/docs/customizing.htm index 2f6e65bc..8eef5266 100644 --- a/docs/customizing.htm +++ b/docs/customizing.htm @@ -443,7 +443,8 @@ Version: 4.6

Each report has a skin associated with it. For most reports, the relationship with the skin is an - obvious one: it contains the templates, any auxiliary files such as background GIFs or CSS style sheets, and + obvious one: it contains the templates, any auxiliary files such as background + GIFs or CSS style sheets, files with localization data, and a skin configuration file, skin.conf. If you will, the skin controls the look and feel of the report. Note that more than one report can use the same skin. For example, you might want to run a report that uses US Customary units, then run another report against the same skin, but @@ -1206,12 +1207,12 @@ db_manager.getSql("SELECT SUM(rain) FROM %s "\ [[SeasonsUSReport]] skin = Seasons - target_unit = US + unit_system = US enable = true [[SeasonsMetricReport]] skin = Seasons - target_unit = METRIC + unit_system = METRIC enable = true HTML_ROOT = public_html/metric

diff --git a/docs/usersguide.htm b/docs/usersguide.htm index 410a7101..b99c512e 100644 --- a/docs/usersguide.htm +++ b/docs/usersguide.htm @@ -2264,7 +2264,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 setting the option target_unit/unit_system or by editing section [StdReport][[Defaults]]. @@ -2297,8 +2297,7 @@ longitude = -77.0366 the file according to the list in ISO 639-1.

-

target_unit
- unit_system

+

unit_system

Which unit system to use with the skin. That can be US,