Skip to content

Commit

Permalink
fixed error in GitHub action for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed May 4, 2024
1 parent 610d449 commit 64bdcee
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bag_on_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hyo2/bag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

name = 'BAG'
__version__ = '1.2.3'
__version__ = '1.2.4'
__author__ = '[email protected]'
__license__ = 'LGPLv3 license'
__copyright__ = 'Copyright (c) 2024, University of New Hampshire, Center for Coastal and Ocean Mapping'
28 changes: 10 additions & 18 deletions hyo2/bag/bag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']):
Expand All @@ -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))
Expand Down Expand Up @@ -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]
Expand All @@ -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()
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion hyo2/bag/tracklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 64bdcee

Please sign in to comment.