Skip to content

Instantly share code, notes, and snippets.

@makkoncept
Created April 12, 2019 20:38
Show Gist options
  • Save makkoncept/9cc294c2fd7bce600e0f8df8b5149d2d to your computer and use it in GitHub Desktop.
Save makkoncept/9cc294c2fd7bce600e0f8df8b5149d2d to your computer and use it in GitHub Desktop.
import os
from lektor.pluginsystem import Plugin
class CheckfilePlugin(Plugin):
name = 'CheckFile'
description = u'Plugin to check if a file is present'
def on_setup_env(self, **extra):
def check_file(filename):
fn = os.path.join(self.env.root_path, filename)
assert os.path.isfile(fn), 'file {} does not exist'.format(fn)
self.env.jinja_env.globals.update(
check_file=check_file
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment