-def expected_template_module_pair(volume_path):
- """Returns the path to the expected base or incremental module for a given volume"""
- base_dir, filename = os.path.split(volume_path)
- return os.path.join(base_dir, filename.replace("_volume", ""))
+class VolumePairModule:
+ def __init__(self, volume_path):
+ self.volume_path = volume_path
+
+ @property
+ def path_options(self):
+ expected_path, _ = self.volume_path.rsplit("_volume", maxsplit=1)
+ return (expected_path + ".yaml", expected_path + ".yml")
+
+ @property
+ def exists(self):
+ return any(os.path.exists(option) for option in self.path_options)
+
+ def get_module_path(self):
+ """
+ Return the path of the volume module's pair if it exists,
+ otherwise None
+ """
+ for option in self.path_options:
+ if os.path.exists(option):
+ return option
+ return None