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:
parent
abc8fb8947
commit
7eae142a62
1 changed files with 7 additions and 5 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue