[generator][python] Supported maps generation without coastlines.

This commit is contained in:
Maksim Andrianov 2019-06-26 13:21:42 +03:00 committed by gmoryes
parent 548d4149e4
commit 08d3fe39d9
5 changed files with 17 additions and 10 deletions

View file

@ -9,7 +9,7 @@ from .maps_generator import (generate_maps, generate_coasts, reset_to_stage,
ALL_STAGES, stage_download_production_external,
stage_descriptions, stage_ugc, stage_popularity,
stage_localads, stage_statistics, stage_srtm,
stages_as_string)
stages_as_string, stage_coastline)
from .utils.collections import unique
logger = logging.getLogger("maps_generator")
@ -85,7 +85,7 @@ def parse_options():
"--coasts",
default=False,
action="store_true",
help="Build WorldCoasts.raw and WorldCoasts.rawgeom files")
help="Build only WorldCoasts.raw and WorldCoasts.rawgeom files")
parser.add_argument(
"--production",
default=False,
@ -199,6 +199,12 @@ def main():
raise SkipError(f"Stages {set(options['skip']) - set(ALL_STAGES)} "
f"not found.")
if not (set(stages_as_string(stage_coastline)) - set(options["skip"])):
countries = [x for x in options["countries"] if x in WORLDS_NAMES]
if countries:
raise SkipError(f"Skipped stage {stages_as_string(stage_coastline)}"
f" and countries {countries} are not compatible.")
env = Env(options)
if env.from_stage:
reset_to_stage(env.from_stage, env)

View file

@ -18,7 +18,7 @@ def stage(func):
stage_formatted = " ".join(func_name.split("_")).capitalize()
logfile = os.path.join(env.log_path, f"{func_name}.log")
log_handler = logging.FileHandler(logfile)
if not env.is_accepted_stage(func_name):
if not env.is_accepted_stage(func):
logger.addHandler(log_handler)
logger.info(f"{stage_formatted} was not accepted.")
return
@ -50,7 +50,7 @@ def country_stage_status(func):
if "logger" in countries_meta[country]:
_logger = countries_meta[country]["logger"]
stage_formatted = " ".join(func_name.split("_")).capitalize()
if not env.is_accepted_stage(func_name):
if not env.is_accepted_stage(func):
_logger.info(f"{stage_formatted} was not accepted.")
return
if "status" not in countries_meta[country]:

View file

@ -149,8 +149,8 @@ class Env:
existing_names.add(name)
return [c for c in self.countries if c in existing_names]
def is_accepted_stage(self, stage_name):
return stage_name not in self._skipped_stages
def is_accepted_stage(self, stage):
return stage.__name__ not in self._skipped_stages
@property
def descriptions_path(self):

View file

@ -83,7 +83,6 @@ def stage_features(env, **kwargs):
dump_cities_boundaries=True,
cities_boundaries_data=env.cities_boundaries_path,
generate_features=True,
emit_coasts=True,
**extra,
**kwargs
)

View file

@ -75,14 +75,16 @@ def stage_preprocess(env, **kwargs):
@stage
def stage_features(env):
extra = {}
if env.is_accepted_stage(stage_descriptions.__name__):
if env.is_accepted_stage(stage_descriptions):
extra["idToWikidata"] = env.id_to_wikidata_path
if env.is_accepted_stage(stage_download_production_external.__name__):
if env.is_accepted_stage(stage_download_production_external):
extra["booking_data"] = env.hotels_path
extra["promo_catalog_cities"] = env.promo_catalog_cities_path
extra["popular_places_data"] = env.popularity_path
extra["brands_data"] = env.food_paths
extra["brands_translations_data"] = env.food_translations_path
if env.is_accepted_stage(stage_coastline):
extra["emit_coasts"]=True
stages.stage_features(env, **extra)
if os.path.exists(env.packed_polygons_path):
@ -219,7 +221,7 @@ def stage_countries_txt(env):
env.countries_synonyms_path,
env.hierarchy_path, env.mwm_path,
env.mwm_version)
if env.is_accepted_stage(stage_download_production_external.__name__):
if env.is_accepted_stage(stage_download_production_external):
countries_json = json.loads(countries)
inject_promo_cities(countries_json, env.promo_catalog_cities_path,
env.mwm_path, env.types_path, env.mwm_path)