1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

use regular expressions to break apart filename

This commit is contained in:
George Hunt 2019-05-17 21:53:57 -07:00
parent abc8fb8947
commit 7eae142a62

View file

@ -54,7 +54,6 @@ def main():
# For installed regions, check that a menu def exists, and it's on home page
for fname in installed_maps:
region = extract_region_from_filename(fname)
print('checking for %s region'%region)
if region == 'maplist': # it is the splash page, display only if no others
menu_ref = 'en-map_test'
item = { "perma_ref" : "en-map_test" }
@ -128,6 +127,7 @@ def write_vector_map_idx(installed_maps):
region = extract_region_from_filename(fname)
if map == 'maplist': continue # not a real region
map_dict = map_catalog['regions'].get(region,'')
print('check for %s in %s'%(region,map_dict))
if map_dict == '': continue
# Create the idx file in format required bo js-menu system
@ -192,11 +192,13 @@ def fetch_menu_json_value(key):
return data.get(key,'')
def extract_region_from_filename(fname):
nibble = re.search(r"^.._osm_..._(.*)_[0-9]{4}",fname)
if not nibble:
# find the index of the date
nibble = re.search(r"\d{4}-\d{2}-\d{2}",fname)
if nibble:
fname = fname[:nibble.start()-1]
return fname
else:
return("maplist")
resp = nibble.group(1)
return(resp)
if __name__ == '__main__':
if console_installed: