예제 #1
0
def stage_countries_txt(env):
    countries = hierarchy_to_countries(env.old_to_new_path,
                                       env.borders_to_osm_path,
                                       env.countries_synonyms_path,
                                       env.hierarchy_path, env.mwm_path,
                                       env.mwm_version)
    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)
        countries = json.dumps(countries_json, ensure_ascii=True, indent=1)

    with open(env.counties_txt_path, "w") as f:
        f.write(countries)
예제 #2
0
    def apply(self, env: Env):
        countries = hierarchy_to_countries(
            env.paths.old_to_new_path,
            env.paths.borders_to_osm_path,
            env.paths.countries_synonyms_path,
            env.paths.hierarchy_path,
            env.paths.mwm_path,
            env.paths.mwm_version,
        )
        if env.production:
            inject_promo_ids(
                countries,
                env.paths.promo_catalog_cities_path,
                env.paths.promo_catalog_countries_path,
                env.paths.mwm_path,
                env.paths.types_path,
                env.paths.mwm_path,
            )

        with open(env.paths.counties_txt_path, "w") as f:
            json.dump(countries, f, ensure_ascii=True, indent=1)
예제 #3
0
 def apply(self, env: Env):
     countries = hierarchy_to_countries(
         env.paths.old_to_new_path,
         env.paths.borders_to_osm_path,
         env.paths.countries_synonyms_path,
         env.paths.hierarchy_path,
         env.paths.mwm_path,
         env.paths.mwm_version,
     )
     if is_skipped(env, StageDownloadProductionExternal):
         countries_json = json.loads(countries)
         inject_promo_ids(
             countries_json,
             env.paths.promo_catalog_cities_path,
             env.paths.promo_catalog_countries_path,
             env.paths.mwm_path,
             env.paths.types_path,
             env.paths.mwm_path,
         )
         countries = json.dumps(countries_json, ensure_ascii=True, indent=1)
     with open(env.paths.counties_txt_path, "w") as f:
         f.write(countries)