-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtarbell_config.py
65 lines (50 loc) · 1.42 KB
/
tarbell_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
import markdown as Markdown
import os
from flask import Blueprint
from jinja2 import Markup
"""
Tarbell project configuration
"""
# Google spreadsheet key
CONTEXT_SOURCE_FILE = "_slides.xlsx"
# Exclude these files from publication
EXCLUDES = ["*.md", "requirements.txt", "slides/*"]
# Create JSON data at ./data.json, disabled by default
# CREATE_JSON = True
# S3 bucket configuration
S3_BUCKETS = {
"production": "recoveredfactory.net/data-workflow",
"staging": "recoveredfactory.net/data-workflow-draft",
}
# Default template variables
DEFAULT_CONTEXT = {
'name': 'data-workflow',
'title': 'Reusable data processing workflows'
}
blueprint = Blueprint('data_workflow', __name__)
def read_file(path, absolute=False):
"""
Read the file at `path`. If `absolute` is True, use absolute path,
otherwise path is assumed to be relative to Tarbell template root dir.
"""
if not absolute:
path = os.path.join(os.path.dirname(__file__), path)
try:
return open(path, 'r').read()
except IOError:
return None
@blueprint.app_context_processor
def context_processor():
"""
Add helper functions to context for all projects.
"""
return {
'read_file': read_file,
}
@blueprint.app_template_filter()
def markdown(value):
"""Run text through markdown process"""
if value:
return Markup(Markdown.markdown(value))
return value