forked from organicmaps/organicmaps
[python] Added stage_external_resources.
This commit is contained in:
parent
b075f5f771
commit
6431847809
2 changed files with 29 additions and 1 deletions
|
@ -141,6 +141,10 @@ class Env:
|
|||
def is_accepted_stage(self, stage_name):
|
||||
return stage_name not in self._skipped_stages
|
||||
|
||||
@property
|
||||
def external_resources_path(self):
|
||||
return os.path.join(self.mwm_path, "external_resources.txt")
|
||||
|
||||
@property
|
||||
def id_to_wikidata_path(self):
|
||||
return os.path.join(self.intermediate_path, "id_to_wikidata.csv")
|
||||
|
|
|
@ -227,6 +227,28 @@ def stage_countries_txt(env):
|
|||
f.write(countries)
|
||||
|
||||
|
||||
@stage
|
||||
def stage_external_resources(env):
|
||||
resources = [os.path.join(file, env.user_resource_path)
|
||||
for file in os.listdir(env.user_resource_path)
|
||||
if file.endswith(".ttf")]
|
||||
for ttf_file in resources:
|
||||
shutil.copy2(ttf_file, env.intermediate_path)
|
||||
|
||||
shutil.copy2(os.path.join(env.user_resource_path, "WorldCoasts_obsolete.mwm"),
|
||||
env.mwm_path)
|
||||
|
||||
for file in os.listdir(env.mwm_path):
|
||||
if file.startswith(WORLD_NAME) and file.endswith(".mwm"):
|
||||
resources.append(os.path.join(env.mwm_path, file))
|
||||
|
||||
resources.sort()
|
||||
with open(env.external_resources_path, "w") as f:
|
||||
for resource in resources:
|
||||
fd = os.open(resource, os.O_RDONLY)
|
||||
f.write(f"{os.path.basename(resource)} {os.fstat(fd).st_size}")
|
||||
|
||||
|
||||
@stage
|
||||
def stage_cleanup(env):
|
||||
osm2ft_path = os.path.join(env.out_path, "osm2ft")
|
||||
|
@ -250,7 +272,8 @@ STAGES = [s.__name__ for s in
|
|||
(stage_download_external, stage_download_production_external,
|
||||
stage_download_and_convert_planet, stage_update_planet,
|
||||
stage_coastline, stage_preprocess, stage_features, stage_mwm,
|
||||
stage_descriptions, stage_countries_txt, stage_cleanup)]
|
||||
stage_descriptions, stage_countries_txt, stage_external_resources,
|
||||
stage_cleanup)]
|
||||
|
||||
ALL_STAGES = STAGES + COUNTRIES_STAGES
|
||||
|
||||
|
@ -308,6 +331,7 @@ def generate_maps(env):
|
|||
stage_mwm(env)
|
||||
stage_descriptions(env)
|
||||
stage_countries_txt(env)
|
||||
stage_external_resources(env)
|
||||
stage_cleanup(env)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue