コード例 #1
0
def luminosTemplates(url):
    path = url.path()[1:]

    if path:
        path = "templates" + os.sep.join(path.split("/"))
        return "text/html", utils.readResourceFile(path, binary=False)
    else:
        raise UrlInvalidError("No file specified")
コード例 #2
0
def luminosCss(url):
    path = url.path()

    if path:
        path = "css" + os.sep.join(path.split("/"))
        return "text/css", utils.readResourceFile(path, binary=False)
    else:
        raise UrlInvalidError("No file specified")
コード例 #3
0
def luminosJavascript(url):
    """Handler for luminos://javascript.

    Return content of file given as query parameter.
    """
    path = url.path()[1:]
    if path:
        path = "javascript" + os.sep.join(path.split("/"))
        return "text/javascript", utils.readResourceFile(path, binary=False)
    else:
        raise UrlInvalidError("No file specified")
コード例 #4
0
 def test_readfile_binary(self, testfile):
     """Read a test file in binary mode."""
     content = utils.readResourceFile('testfile', binary=True)
     assert content.splitlines()[0] == b"Hello World!"
コード例 #5
0
 def test_readfile(self, testfile):
     """Read a test file."""
     content = utils.readResourceFile('testfile')
     assert content.splitlines()[0] == "Hello World!"