Mehrere Verzeichnisse für Seiten ermöglicht
This commit is contained in:
parent
1968449c69
commit
13c2cbe34f
@ -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)
|
||||
|
16
rtxPage.py
16
rtxPage.py
@ -35,11 +35,9 @@ 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
|
||||
|
||||
def get_page(self):
|
||||
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user