diff --git a/benjen.py b/benjen.py index 1df91ec..64914fe 100755 --- a/benjen.py +++ b/benjen.py @@ -10,16 +10,20 @@ def load_all(dir): return [file(fn, 'r').read().decode('utf-8') for fn in glob(dir + '/*')] class Benjen(object): - def __init__(self): - self.lookup = TemplateLookup(directories=['templates']) + def __init__(self, entries_dir=None): + if entries_dir is not None: + self.path_prefix = entries_dir + '/' + else: + self.path_prefix = '' + self.lookup = TemplateLookup(directories=[self.path_prefix + 'templates']) - self.config = yaml.load(file('config.yaml')) + self.config = yaml.load(file(self.path_prefix + 'config.yaml')) self.out = self.config['path'] if self.out[-1] != '/': self.out += '/' shutil.rmtree(self.out, ignore_errors=True) - shutil.copytree('static', self.out) + shutil.copytree(self.path_prefix + 'static', self.out) self.load_entries() @@ -31,7 +35,7 @@ def render(self, name, **kwargs): title_sub = partial(re.compile(r'[^a-zA-Z0-9_\-]').sub, '_') def load_entries(self): - raw = load_all('entries') + raw = load_all(self.path_prefix + 'entries') self.entries = [] for entry in raw: