Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid KeyError if a product metadata doesn't have a namespace #151

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eoreader/products/sar/rcm_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _set_product_type(self) -> None:
"""Set products type"""
# Get MTD XML file
root, nsmap = self.read_mtd()
namespace = nsmap[None]
namespace = nsmap.get(None, "")

# Open identifier
prod_type = root.findtext(f".//{namespace}productType")
Expand Down Expand Up @@ -263,7 +263,7 @@ def _set_sensor_mode(self) -> None:
"""
# Get metadata
root, nsmap = self.read_mtd()
namespace = nsmap[None]
namespace = nsmap.get(None, "")

# Get sensor mode
# WARNING: this word may differ from the Enum !!! (no docs available)
Expand Down Expand Up @@ -303,7 +303,7 @@ def get_datetime(self, as_datetime: bool = False) -> Union[str, datetime]:
"""
# Get MTD XML file
root, nsmap = self.read_mtd()
namespace = nsmap[None]
namespace = nsmap.get(None, "")

# Open identifier
acq_date = root.findtext(f".//{namespace}rawDataStartTime")
Expand Down Expand Up @@ -426,7 +426,7 @@ def get_orbit_direction(self) -> OrbitDirection:
"""
# Get MTD XML file
root, nsmap = self.read_mtd()
namespace = nsmap[None]
namespace = nsmap.get(None, "")

# Get the orbit direction
try:
Expand Down
8 changes: 4 additions & 4 deletions eoreader/products/sar/rs2_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def _pre_init(self, **kwargs) -> None:

# SNAP can process non-complex archive
root, nsmap = self.read_mtd()
namespace = nsmap[None]
namespace = nsmap.get(None, "")

# Open identifier
prod_type = root.findtext(f".//{namespace}productType")
Expand Down Expand Up @@ -458,7 +458,7 @@ def _set_sensor_mode(self) -> None:
"""
# Get metadata
root, nsmap = self.read_mtd()
namespace = nsmap[None]
namespace = nsmap.get(None, "")

# Get sensor mode
# WARNING: this word may differ from the Enum !!! (no docs available)
Expand Down Expand Up @@ -499,7 +499,7 @@ def get_datetime(self, as_datetime: bool = False) -> Union[str, datetime]:
if self.datetime is None:
# Get MTD XML file
root, nsmap = self.read_mtd()
namespace = nsmap[None]
namespace = nsmap.get(None, "")

# Open identifier
acq_date = root.findtext(f".//{namespace}rawDataStartTime")
Expand Down Expand Up @@ -596,7 +596,7 @@ def get_orbit_direction(self) -> OrbitDirection:
"""
# Get MTD XML file
root, nsmap = self.read_mtd()
namespace = nsmap[None]
namespace = nsmap.get(None, "")

# Get the orbit direction
try:
Expand Down