How to use the publ.utils.find_file function in Publ

To help you get started, we’ve selected a few Publ examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PlaidWeb / Publ / tests / test_utils.py View on Github external
def test_find_file():
    """ tests for the file finder """
    assert utils.find_file("anything", []) is None

    assert utils.find_file("anything", ["tests/templates"]) is None
    assert utils.find_file("auth", ["tests/templates"]) is None

    assert utils.find_file("index.html",
                           ("tests/templates")
                           ) == "tests/templates/index.html"
    assert utils.find_file("index.html",
                           ("tests/templates", "tests/templates/auth")
                           ) == "tests/templates/index.html"
    assert utils.find_file("index.html",
                           ("tests/templates/auth", "tests/templates")
                           ) == "tests/templates/auth/index.html"
github PlaidWeb / Publ / tests / test_utils.py View on Github external
def test_find_file():
    """ tests for the file finder """
    assert utils.find_file("anything", []) is None

    assert utils.find_file("anything", ["tests/templates"]) is None
    assert utils.find_file("auth", ["tests/templates"]) is None

    assert utils.find_file("index.html",
                           ("tests/templates")
                           ) == "tests/templates/index.html"
    assert utils.find_file("index.html",
                           ("tests/templates", "tests/templates/auth")
                           ) == "tests/templates/index.html"
    assert utils.find_file("index.html",
                           ("tests/templates/auth", "tests/templates")
                           ) == "tests/templates/auth/index.html"
github PlaidWeb / Publ / tests / test_utils.py View on Github external
def test_find_file():
    """ tests for the file finder """
    assert utils.find_file("anything", []) is None

    assert utils.find_file("anything", ["tests/templates"]) is None
    assert utils.find_file("auth", ["tests/templates"]) is None

    assert utils.find_file("index.html",
                           ("tests/templates")
                           ) == "tests/templates/index.html"
    assert utils.find_file("index.html",
                           ("tests/templates", "tests/templates/auth")
                           ) == "tests/templates/index.html"
    assert utils.find_file("index.html",
                           ("tests/templates/auth", "tests/templates")
                           ) == "tests/templates/auth/index.html"
github PlaidWeb / Publ / tests / test_utils.py View on Github external
def test_find_file():
    """ tests for the file finder """
    assert utils.find_file("anything", []) is None

    assert utils.find_file("anything", ["tests/templates"]) is None
    assert utils.find_file("auth", ["tests/templates"]) is None

    assert utils.find_file("index.html",
                           ("tests/templates")
                           ) == "tests/templates/index.html"
    assert utils.find_file("index.html",
                           ("tests/templates", "tests/templates/auth")
                           ) == "tests/templates/index.html"
    assert utils.find_file("index.html",
                           ("tests/templates/auth", "tests/templates")
                           ) == "tests/templates/auth/index.html"
github PlaidWeb / Publ / publ / image.py View on Github external
path -- the image's filename
    search_path -- a search path for the image (string or list of strings)
    """

    if path.startswith('@'):
        return StaticImage(path[1:], search_path)

    if path.startswith('//') or '://' in path:
        return RemoteImage(path, search_path)

    if os.path.isabs(path):
        file_path = utils.find_file(os.path.relpath(
            path, '/'), config.content_folder)
    else:
        file_path = utils.find_file(path, search_path)
    if not file_path:
        return ImageNotFound(path, search_path)

    record = _get_asset(file_path)
    if record.is_asset:
        return FileAsset(record, search_path)
    return LocalImage(record, search_path)
github PlaidWeb / Publ / publ / image.py View on Github external
""" Get an Image object. If the path is given as absolute, it will be
    relative to the content directory; otherwise it will be relative to the
    search path.

    path -- the image's filename
    search_path -- a search path for the image (string or list of strings)
    """

    if path.startswith('@'):
        return StaticImage(path[1:], search_path)

    if path.startswith('//') or '://' in path:
        return RemoteImage(path, search_path)

    if os.path.isabs(path):
        file_path = utils.find_file(os.path.relpath(
            path, '/'), config.content_folder)
    else:
        file_path = utils.find_file(path, search_path)
    if not file_path:
        return ImageNotFound(path, search_path)

    record = _get_asset(file_path)
    if record.is_asset:
        return FileAsset(record, search_path)
    return LocalImage(record, search_path)
github PlaidWeb / Publ / publ / image / __init__.py View on Github external
def _get_image(path: str, search_path: typing.Tuple[str, ...]) -> Image:
    if path.startswith('@'):
        return StaticImage(path[1:], search_path)

    if path.startswith('//') or '://' in path:
        return RemoteImage(path, search_path)

    if os.path.isabs(path):
        file_path = utils.find_file(os.path.relpath(
            path, '/'), config.content_folder)
    else:
        file_path = utils.find_file(path, search_path)
    if not file_path:
        return ImageNotFound(path, search_path)

    record = _get_asset(file_path)
    if record.is_asset:
        return FileAsset(record, search_path)
    return LocalImage(record, search_path)
github PlaidWeb / Publ / publ / image / __init__.py View on Github external
def _get_image(path: str, search_path: typing.Tuple[str, ...]) -> Image:
    if path.startswith('@'):
        return StaticImage(path[1:], search_path)

    if path.startswith('//') or '://' in path:
        return RemoteImage(path, search_path)

    if os.path.isabs(path):
        file_path = utils.find_file(os.path.relpath(
            path, '/'), config.content_folder)
    else:
        file_path = utils.find_file(path, search_path)
    if not file_path:
        return ImageNotFound(path, search_path)

    record = _get_asset(file_path)
    if record.is_asset:
        return FileAsset(record, search_path)
    return LocalImage(record, search_path)