acn/rtx
acn
/
rtx
1
0
Fork 0

Mehrere Verzeichnisse für Seiten ermöglicht

This commit is contained in:
acn 2016-10-31 16:40:10 +01:00
parent 1968449c69
commit 13c2cbe34f
2 changed files with 14 additions and 12 deletions

View File

@ -6,9 +6,11 @@ Configuration file
import logging
## general settings:
PAGES="pages/"
DEMOPAGES="demopages/"
## define the location of rtx pages
## rtx searches all directories and serves the page from the first one (lowest index)
PAGES[0]="pages/"
PAGES[1]="presentation/"
PAGES[2]="demopages/"
## logging settings:
# loglevel values: DEBUG (all messages) > INFO > WARNING > ERROR > CRITICAL (only cricital messages)

View File

@ -35,12 +35,10 @@ class rtxPage:
@staticmethod
def exists(page):
""" checks if the page (i.e. the file) exists """
if os.path.isfile(config.PAGES + page):
for path in config.PAGES:
if os.path.isfile(path + page):
return True
elif os.path.isfile(config.DEMOPAGES + page):
return True
else:
return False
return False
def get_page(self):
""" returns the page if loaded
@ -78,11 +76,13 @@ class rtxPage:
returns False if the page cannot be found
returns True if the page has been loaded
"""
if os.path.isfile(config.PAGES + page):
filename = config.PAGES + page
elif os.path.isfile(config.DEMOPAGES + page):
filename = config.DEMOPAGES + page
for path in config.PAGES:
if os.path.isfile(path + page):
filename = path + page
""" page has been found, now exit the for loop """
break
else:
""" page does not exist anywhere, so exit the function """
return False
with open(filename, "rb") as f: