diff --git a/.github/workflows/bag_on_linux.yml b/.github/workflows/bag_on_linux.yml index 57ed20c..5d16647 100644 --- a/.github/workflows/bag_on_linux.yml +++ b/.github/workflows/bag_on_linux.yml @@ -23,6 +23,7 @@ jobs: run: | conda config --add channels conda-forge conda install appdirs cartopy gdal matplotlib-base numpy psutil pyproj qt-material + conda install h5py dateutil lxml pip install PySide6 sudo apt-get install -y libegl1 pip install hyo2.abc2 diff --git a/hyo2/bag/__init__.py b/hyo2/bag/__init__.py index c50ea79..28ef5db 100644 --- a/hyo2/bag/__init__.py +++ b/hyo2/bag/__init__.py @@ -4,7 +4,7 @@ """ name = 'BAG' -__version__ = '1.2.3' +__version__ = '1.2.4' __author__ = 'gmasetti@ccom.unh.edu' __license__ = 'LGPLv3 license' __copyright__ = 'Copyright (c) 2024, University of New Hampshire, Center for Coastal and Ocean Mapping' diff --git a/hyo2/bag/bag.py b/hyo2/bag/bag.py index d1eb60a..ddad8b7 100644 --- a/hyo2/bag/bag.py +++ b/hyo2/bag/bag.py @@ -3,7 +3,7 @@ from typing import Tuple import numpy as np -from lxml import etree +from lxml import etree, isoschematron from hyo2.bag.base import is_bag, File from hyo2.bag.helper import BAGError, Helper @@ -353,8 +353,8 @@ def tracking_list_types(self): return self[BAGFile._bag_tracking_list].dtype def has_valid_row_in_tracking_list(self): - rows, cols = self.elevation_shape() - # logger.info('rows: %s, cols: %s' % (rows, cols)) + rows, _ = self.elevation_shape() + # logger.info('rows: %s, cols: %s' % (rows, _)) tl = self.tracking_list() for idx, row in enumerate(tl['row']): @@ -363,7 +363,7 @@ def has_valid_row_in_tracking_list(self): return False return True - + def has_valid_col_in_tracking_list(self): rows, cols = self.elevation_shape() # logger.info('rows: %s, cols: %s' % (rows, cols)) @@ -432,7 +432,7 @@ def substitute_metadata(self, path): is_valid = self.validate_metadata(xml_string) if not is_valid: - logger.info("the passed medatadata file is not valid") + logger.info("the passed metadata file is not valid") return del self[BAGFile._bag_metadata] @@ -441,7 +441,7 @@ def substitute_metadata(self, path): for i, bt in enumerate(xml_string): ds[i] = bytes([bt]) - def validate_metadata(self, xml_string=None): + def validate_metadata(self, xml_string: None | bytes = None) -> bool: """ Validate metadata based on XML Schemas and schematron. """ # clean metadata error list self.meta_errors = list() @@ -454,7 +454,7 @@ def validate_metadata(self, xml_string=None): try: xml_tree = etree.fromstring(xml_string) except etree.Error as e: - logger.warning("unabled to parse XML metadata: %s" % e) + logger.warning("unable to parse XML metadata: %s" % e) self.meta_errors.append(e) return False @@ -463,7 +463,7 @@ def validate_metadata(self, xml_string=None): schema_doc = etree.parse(schema_path) schema = etree.XMLSchema(schema_doc) except etree.Error as e: - logger.warning("unabled to parse XML schema: %s" % e) + logger.warning("unable to parse XML schema: %s" % e) self.meta_errors.append(e) return False @@ -483,22 +483,14 @@ def validate_metadata(self, xml_string=None): schematron_path = os.path.join(Helper.iso19757_3_folder(), 'bag_metadata_profile.sch') schematron_doc = etree.parse(schematron_path) except etree.DocumentInvalid as e: - logger.warning("unabled to parse BAG schematron: %s" % e) - self.meta_errors.append(e) - return False - - try: - from lxml import isoschematron - except IOError as e: - msg = "Unable to load lxml isoschematron files" - logger.warning("%s: %s" % (msg, e)) + logger.warning("unable to parse BAG schematron: %s" % e) self.meta_errors.append(e) return False try: schematron = isoschematron.Schematron(schematron_doc, store_report=True) except etree.DocumentInvalid as e: - logger.warning("unabled to load BAG schematron: %s" % e) + logger.warning("unable to load BAG schematron: %s" % e) self.meta_errors.append(e) return False diff --git a/hyo2/bag/tracklist.py b/hyo2/bag/tracklist.py index 6211cec..8c70365 100644 --- a/hyo2/bag/tracklist.py +++ b/hyo2/bag/tracklist.py @@ -29,7 +29,7 @@ def __init__(self, track_list: np.ndarray, csv_file=None, header=None, comment=N self.header = header if self.header is None: self.header = str() - if type(self.header) is tuple: + if isinstance(self.header, tuple): self.header = ",".join(fld for fld in self.header) self.header += "\n" logger.debug("header: %s" % self.header)