(self)
| 249 | tree.write(self.output_file) |
| 250 | |
| 251 | def convert(self): |
| 252 | with open(self.input_file, 'r') as file: |
| 253 | content = file.read().strip() |
| 254 | if not content: |
| 255 | raise ValueError(f"The file {self.input_file} is empty or not a valid JSON file.") |
| 256 | |
| 257 | mime_type, _ = mimetypes.guess_type(self.input_file) |
| 258 | if mime_type == 'application/geo+json' or mime_type == 'application/json': |
| 259 | self.process_geojson_features(content) |
| 260 | elif mime_type == 'text/csv': |
| 261 | self.process_csv_features(content) |
| 262 | else: |
| 263 | raise ValueError(f"Unsupported file format: {self.input_file}") |
| 264 | |
| 265 | # Write to output file in the desired format, KML or GPX |
| 266 | if self.output_format == 'kml': |
| 267 | self.write_kml() |
| 268 | elif self.output_format == 'gpx': |
| 269 | self.write_gpx() |
| 270 | print("Exported Google Saved Places to " + path.abspath(self.output_file)) |
| 271 | |
| 272 | if __name__ == "__main__": |
| 273 | parser = argparse.ArgumentParser(description="Convert Google Maps saved places to KML or GPX.") |
no test coverage detected