From 13c2cbe34fb2ceef775c6a0a14e5bdef4cb8f910 Mon Sep 17 00:00:00 2001 From: acn Date: Mon, 31 Oct 2016 16:40:10 +0100 Subject: [PATCH] =?UTF-8?q?Mehrere=20Verzeichnisse=20f=C3=BCr=20Seiten=20e?= =?UTF-8?q?rm=C3=B6glicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 8 +++++--- rtxPage.py | 18 +++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/config.py b/config.py index 63995a1..dc7b343 100644 --- a/config.py +++ b/config.py @@ -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) diff --git a/rtxPage.py b/rtxPage.py index 44fbd05..74987e5 100644 --- a/rtxPage.py +++ b/rtxPage.py @@ -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: