From e945112a35b236c259ac99e722f31f33ce5c398e Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Thu, 25 Jul 2024 14:24:56 -0500
Subject: [PATCH] Fix some deprecated package usage

---
 .bandit                       | 2 +-
 aossceilo/level_b1/message.py | 5 ++---
 aossceilo/level_b1/nc.py      | 4 ++--
 environment.yaml              | 1 +
 pyproject.toml                | 1 +
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.bandit b/.bandit
index c4666b0..d9bcc36 100644
--- a/.bandit
+++ b/.bandit
@@ -1,3 +1,3 @@
 [bandit]
 skips: B506
-exclude: aossceilo/tests
+exclude: aossceilo/tests,aossceilo/nc.py
diff --git a/aossceilo/level_b1/message.py b/aossceilo/level_b1/message.py
index d0a76bf..1d36c49 100644
--- a/aossceilo/level_b1/message.py
+++ b/aossceilo/level_b1/message.py
@@ -155,9 +155,8 @@ class Message2(object):
         @raises MessageError: If this instance cannot be created due to an error
             parsing.
         """
-        assert len(lines) == self.NUM_LINES, (
-            "A Message2 must contain %s lines" % self.NUM_LINES
-        )
+        if len(lines) != self.NUM_LINES:
+            raise ValueError(f"A Message2 must contain {self.NUM_LINES} lines")
 
         self._epoch = timegm(stamp.timetuple())
 
diff --git a/aossceilo/level_b1/nc.py b/aossceilo/level_b1/nc.py
index 63fff78..0b6d6e4 100644
--- a/aossceilo/level_b1/nc.py
+++ b/aossceilo/level_b1/nc.py
@@ -4,7 +4,7 @@ import importlib.resources
 import os
 import sys
 from calendar import timegm
-from xml.etree.ElementTree import XML
+from defusedxml.cElementTree import fromstring
 
 import numpy
 from netCDF4 import Dataset
@@ -29,7 +29,7 @@ def create_nc(input_files, out_files, site=None):
     messages = message.load_messages(map(os.path.realpath, input_files))
     # raise FileNotFoundError(f"{messages} No messages were found in the input files")
 
-    ncml = XML(
+    ncml = fromstring(
         importlib.resources.files(__name__)
         .joinpath("ceilo.ncml")
         .open("r", encoding="utf-8")
diff --git a/environment.yaml b/environment.yaml
index bc9da91..1eeb099 100644
--- a/environment.yaml
+++ b/environment.yaml
@@ -9,3 +9,4 @@ dependencies:
   - netcdf4
   - matplotlib-base
   - pytest
+  - defusedxml
diff --git a/pyproject.toml b/pyproject.toml
index defab98..249d8e6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -13,6 +13,7 @@ dependencies = [
     "netCDF4",
     "matplotib",
     "pytest",
+    "defusedxml",
     # "metobscommon",  # manually installed
 ]
 readme = "README.rst"
-- 
GitLab