Skip to content

Commit 044db70

Browse files
authored
Merge pull request #57 from dkillick/udunits_xml_from_cfg
Use site config to specify UDUNITS2 XML database location
2 parents 94e1838 + 18c7bb6 commit 044db70

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cf_units/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,10 @@ def suppress_errors():
380380
# relative to sys.prefix to support environments such as conda.
381381
_ud_system = _ut_read_xml(None)
382382
if _ud_system is None:
383-
_alt_xml_path = os.path.join(sys.prefix, 'share',
384-
'udunits', 'udunits2.xml')
383+
_alt_xml_path = config.get_option(
384+
'System', 'udunits2_xml_path',
385+
default=os.path.join(sys.prefix, 'share', 'udunits',
386+
'udunits2.xml'))
385387
_ud_system = _ut_read_xml(_alt_xml_path.encode())
386388
if not _ud_system:
387389
_status_msg = 'UNKNOWN'

cf_units/etc/site.cfg.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[System]
22
udunits2_path = /path/to/libudunits2.so
3+
udunits2_xml_path = /path/to/udunits2.xml

0 commit comments

Comments
 (0)