Skip to content

Commit

Permalink
Removal of cwd from default paths if CSV2BUFR_TEMPLATES set.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-i-berry committed Feb 14, 2024
1 parent c192a86 commit 0cfa0b0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion csv2bufr/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
THISDIR = os.path.dirname(os.path.realpath(__file__))
LOGGER = logging.getLogger(__name__)
SCHEMA = f"{THISDIR}{os.sep}resources{os.sep}schema"
TEMPLATE_DIRS = [Path("./")]
TEMPLATE_DIRS = [] # [Path("./")]

_SUCCESS_ = True

Expand All @@ -47,10 +47,20 @@
LOGGER.error(msg)
raise RuntimeError(msg)

_template_flag = False
# Set user defined location first
if 'CSV2BUFR_TEMPLATES' in os.environ:
TEMPLATE_DIRS.append(Path(os.environ['CSV2BUFR_TEMPLATES']))
else:
TEMPLATE_DIRS.append(Path("./"))
_template_flag = True

# Check if /opt/csv2bur/templates exists and add to search path
if Path("/opt/csv2bufr/templates").exists() and \
"/opt/csv2bufr/templates" not in TEMPLATE_DIRS:
TEMPLATE_DIRS.append(Path("/opt/csv2bufr/templates"))

if _template_flag:
LOGGER.warning(f"""CSV2BUFR_TEMPLATES is not set, default search path(s)
will be used ({TEMPLATE_DIRS}).""")

Expand Down

0 comments on commit 0cfa0b0

Please sign in to comment.