+
+
+ def get_osm_file_list(self) -> Optional[List[Path]]:
+ """ Return the --osm-file argument as a list of Paths or None
+ if no argument was given. The function also checks if the files
+ exist and raises a UsageError if one cannot be found.
+ """
+ if not self.osm_file:
+ return None
+
+ files = [Path(f) for f in self.osm_file]
+ for fname in files:
+ if not fname.is_file():
+ LOG.fatal("OSM file '%s' does not exist.", fname)
+ raise UsageError('Cannot access file.')
+
+ return files
+
+
+ def get_geometry_output(self) -> napi.GeometryFormat:
+ """ Get the requested geometry output format in a API-compatible
+ format.
+ """
+ if not self.polygon_output:
+ return napi.GeometryFormat.NONE
+ if self.polygon_output == 'geojson':
+ return napi.GeometryFormat.GEOJSON
+ if self.polygon_output == 'kml':
+ return napi.GeometryFormat.KML
+ if self.polygon_output == 'svg':
+ return napi.GeometryFormat.SVG
+ if self.polygon_output == 'text':
+ return napi.GeometryFormat.TEXT
+
+ try:
+ return napi.GeometryFormat[self.polygon_output.upper()]
+ except KeyError as exp:
+ raise UsageError(f"Unknown polygon output format '{self.polygon_output}'.") from exp
+
+
+ def get_locales(self, default: Optional[str]) -> napi.Locales:
+ """ Get the locales from the language parameter.
+ """
+ if self.lang:
+ return napi.Locales.from_accept_languages(self.lang)
+ if default:
+ return napi.Locales.from_accept_languages(default)
+
+ return napi.Locales()
+
+
+ def get_layers(self, default: napi.DataLayer) -> Optional[napi.DataLayer]:
+ """ Get the list of selected layers as a DataLayer enum.
+ """
+ if not self.layers:
+ return default
+
+ return reduce(napi.DataLayer.__or__,
+ (napi.DataLayer[s.upper()] for s in self.layers))