-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_template.py
More file actions
96 lines (72 loc) · 2.73 KB
/
config_template.py
File metadata and controls
96 lines (72 loc) · 2.73 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Sets up the local environment of the user for the script main.py
Sets up the local environment of the user for the script main.py
As it is a template, please copy it first to a file named
"config.py"!
After copy, it is strongly recommended to setup all necessary parameters in
the init() function, before running the script main.py for the first time.
"""
import datetime
import locale
import json
import os
# ---------------------------
def init():
parameters = {}
# evaluate the absolut path to this script file
# DO NOT CHANGE!
aPath = os.path.realpath(__file__)
aPath = os.path.dirname(aPath)
aPath = os.path.normpath(aPath)
# expect the path to this script is the path to the project root
# DO NOT CHANGE!
parameters['projectRootDir'] = aPath
# DO NOT CHANGE!
parameters['contentDir'] = os.path.join(parameters['projectRootDir'], "content")
# DO NOT CHANGE!
parameters['webDir'] = os.path.join(parameters['projectRootDir'], "_www")
# DO NOT CHANGE!
locale.setlocale(locale.LC_ALL, '')
# DO NOT CHANGE!
parameters['generatorStarted'] = datetime.datetime.now()
# DO NOT CHANGE!
parameters['currentYear'] = parameters['generatorStarted'].strftime('%Y')
# DO NOT CHANGE!
parameters['generated'] = parameters['generatorStarted'].strftime('%Y%m%d %H%M%S')
# DO NOT CHANGE!
parameters['generatedHumanReadable'] = parameters['generatorStarted'].strftime('%d.%m.%Y %H:%M:%S')
# DO NOT CHANGE!
parameters['pageTemplate'] = ""
# DO NOT CHANGE!
parameters['pageList'] = []
# CHANGE THIS!
# Project Title
parameters['title'] = ""
# CHANGE THIS!
# File Name of document to deploy
parameters['documentName'] = ""
# CHANGE THIS!
# TOC (table of contents) header string fot HTML and PDF generation
toc_string_list = [
"**Inhaltsverzeichnis**",
#"**Table Of Contents**",
"",
"[TOC]",
""
]
# DO NOT CHANGE!
parameters['tocString'] = "\n".join(toc_string_list)
# CHANGE THIS!
# Load sequence of Markdown documents to load from an external JSON file,
# named 'documentSequence.json'
# DO NOT CHANGE!
# Just put the file names into the list items as Strings, but without any
# file name extensions (.md)
documentSequencePath = os.path.join(parameters['projectRootDir'], "documentSequence.json")
with open(documentSequencePath, "r") as f:
parameters['documentSequence'] = json.load(f)
if not parameters['documentSequence']:
raise RuntimeError("FATAL: List of documents in 'documentSequence' should not be empty!")
print("DEBUG: init()")
return parameters