diff --git a/swmmanywhere/parameters.py b/swmmanywhere/parameters.py index a85baf86..7747c61f 100644 --- a/swmmanywhere/parameters.py +++ b/swmmanywhere/parameters.py @@ -235,6 +235,42 @@ def _generate_property(self, getattr(self, location), property_name) + def _generate_project(self): + return self._generate_path(self.project_name) + + def _generate_national(self): + return self._generate_property('national', 'project') + + def _generate_national_building(self): + return self._generate_property('building.parquet', + 'national') + def _generate_bbox(self): + return self._generate_property(f'bbox_{self.bbox_number}', + 'project') + def _generate_model(self): + return self._generate_property(f'model_{self.model_number}', + 'bbox') + def _generate_subcatchments(self): + return self._generate_property(f'subcatchments.{self.extension}', + 'model') + def _generate_download(self): + return self._generate_property('download', + 'bbox') + def _generate_river(self): + return self._generate_property('river.json', + 'download') + def _generate_street(self): + return self._generate_property('street.json', + 'download') + def _generate_elevation(self): + return self._generate_property('elevation.tif', 'download') + def _generate_building(self): + return self._generate_property(f'building.{self.extension}', + 'download') + def _generate_precipitation(self): + return self._generate_property(f'precipitation.{self.extension}', + 'download') + def _fetch_address(self, name): """Fetch the address. @@ -248,39 +284,8 @@ def _fetch_address(self, name): Returns: Path: Path to the folder/file. """ - if name == 'project': - return self._generate_path(self.project_name) - elif name == 'national': - return self._generate_property('national', 'project') - elif name == 'national_building': - return self._generate_property('building.parquet', - 'national') - elif name == 'bbox': - return self._generate_property(f'bbox_{self.bbox_number}', - 'project') - elif name == 'model': - return self._generate_property(f'model_{self.model_number}', - 'bbox') - elif name == 'subcatchments': - return self._generate_property(f'subcatchments.{self.extension}', - 'model') - elif name == 'download': - return self._generate_property('download', - 'bbox') - elif name == 'river': - return self._generate_property('river.json', - 'download') - elif name == 'street': - return self._generate_property('street.json', - 'download') - elif name == 'elevation': - return self._generate_property('elevation.tif', 'download') - elif name == 'building': - return self._generate_property(f'building.{self.extension}', - 'download') - elif name == 'precipitation': - return self._generate_property(f'precipitation.{self.extension}', - 'download') - else: - raise AttributeError(f"Attribute {name} not found") - \ No newline at end of file + try: + return getattr(self, f"_generate_{name}")() + except AttributeError: + raise AttributeError( + f"Generate path for '{name}' failed. Attribute not found.") \ No newline at end of file