Env provides a generation environment. It sets up instruments and paths, that are used for a maps generation. It stores state of the maps generation.
| 357 | |
| 358 | |
| 359 | class Env: |
| 360 | """ |
| 361 | Env provides a generation environment. It sets up instruments and paths, |
| 362 | that are used for a maps generation. It stores state of the maps generation. |
| 363 | """ |
| 364 | |
| 365 | def __init__( |
| 366 | self, |
| 367 | countries: Optional[List[AnyStr]] = None, |
| 368 | production: bool = False, |
| 369 | build_name: Optional[AnyStr] = None, |
| 370 | build_suffix: AnyStr = "", |
| 371 | skipped_stages: Optional[Set[Type[Stage]]] = None, |
| 372 | force_download_files: bool = False, |
| 373 | ): |
| 374 | self.setup_logging() |
| 375 | |
| 376 | logger.info("Start setup ...") |
| 377 | os.environ["TMPDIR"] = PathProvider.tmp_dir() |
| 378 | for k, v in self.setup_osm_tools().items(): |
| 379 | setattr(self, k, v) |
| 380 | |
| 381 | self.production = production |
| 382 | self.force_download_files = force_download_files |
| 383 | self.countries = countries |
| 384 | self.skipped_stages = set() if skipped_stages is None else skipped_stages |
| 385 | if self.countries is None: |
| 386 | self.countries = get_all_countries_list(PathProvider.borders_path()) |
| 387 | |
| 388 | self.node_storage = settings.NODE_STORAGE |
| 389 | |
| 390 | version_format = "%Y_%m_%d__%H_%M_%S" |
| 391 | suffix_div = "-" |
| 392 | self.dt = None |
| 393 | if build_name is None: |
| 394 | self.dt = datetime.datetime.now() |
| 395 | build_name = self.dt.strftime(version_format) |
| 396 | if build_suffix: |
| 397 | build_name = f"{build_name}{suffix_div}{build_suffix}" |
| 398 | else: |
| 399 | s = build_name.split(suffix_div, maxsplit=1) |
| 400 | if len(s) == 1: |
| 401 | s.append("") |
| 402 | |
| 403 | date_str, build_suffix = s |
| 404 | self.dt = datetime.datetime.strptime(date_str, version_format) |
| 405 | |
| 406 | self.build_suffix = build_suffix |
| 407 | self.mwm_version = self.dt.strftime("%y%m%d") |
| 408 | self.planet_version = self.dt.strftime("%s") |
| 409 | self.build_path = os.path.join(settings.MAIN_OUT_PATH, build_name) |
| 410 | self.build_name = build_name |
| 411 | |
| 412 | self.gen_tool = self.setup_generator_tool() |
| 413 | if WORLD_NAME in self.countries: |
| 414 | self.world_roads_builder_tool = self.setup_world_roads_builder_tool() |
| 415 | self.diff_tool = self.setup_mwm_diff_tool() |
| 416 |
no outgoing calls
no test coverage detected