Skip to content

Commit

Permalink
Merge pull request #57 from dkillick/udunits_xml_from_cfg
Browse files Browse the repository at this point in the history
Use site config to specify UDUNITS2 XML database location
  • Loading branch information
bjlittle authored Jun 22, 2016
2 parents 94e1838 + 18c7bb6 commit 044db70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cf_units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,10 @@ def suppress_errors():
# relative to sys.prefix to support environments such as conda.
_ud_system = _ut_read_xml(None)
if _ud_system is None:
_alt_xml_path = os.path.join(sys.prefix, 'share',
'udunits', 'udunits2.xml')
_alt_xml_path = config.get_option(
'System', 'udunits2_xml_path',
default=os.path.join(sys.prefix, 'share', 'udunits',
'udunits2.xml'))
_ud_system = _ut_read_xml(_alt_xml_path.encode())
if not _ud_system:
_status_msg = 'UNKNOWN'
Expand Down
1 change: 1 addition & 0 deletions cf_units/etc/site.cfg.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[System]
udunits2_path = /path/to/libudunits2.so
udunits2_xml_path = /path/to/udunits2.xml

0 comments on commit 044db70

Please sign in to comment.