diff -r 7dc357cbaa40 -r 5c5cff842d57 gmyth-stream/server/0.2/lib/utils.py --- a/gmyth-stream/server/0.2/lib/utils.py Thu Apr 19 22:38:46 2007 +0100 +++ b/gmyth-stream/server/0.2/lib/utils.py Wed Apr 25 15:53:19 2007 +0100 @@ -15,10 +15,10 @@ log = logging.getLogger("gms.utils") -__all__ = ("which", "load_plugins", "PluginSet") +__all__ = ("which", "load_plugins", "PluginSet", "getHTML") def which(app): - """function to implement which(1) unix command""" + """Function to implement which(1) unix command""" pl = os.environ["PATH"].split(os.pathsep) for p in pl: path = os.path.join(p, app) @@ -121,6 +121,7 @@ def load_plugins(directory, basetype): + """Function to load plugins from a given directory""" tn = basetype.__name__ log.debug("Loading plugins from %s, type=%s" % (directory, tn)) @@ -146,3 +147,15 @@ return plugins # load_plugins() + +def getHTML(html_file, params={}): + """This function parses a file 'html_file.html' with the given + parameters and returns a formated web-page""" + try: + filename = os.path.join(sys.path[0], "html", html_file + ".html") + html = open(filename).read() % params + return html + except Exception, e: + return "HTML format error. Wrong keys: %s" % e + +# getHTML