forked from AlexanderWillner/Core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfillTemplate.py
executable file
·137 lines (116 loc) · 6.75 KB
/
fillTemplate.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script to generate a scientific paper boiler plate."""
# compatibility for Python 2.x
from __future__ import print_function
__author__ = "Alexander Willner"
__copyright__ = "Copyright 2019, Alexander Willner"
__credits__ = ["Alexander Willner"]
__license__ = "Apache 2.0"
__version__ = "0.0.1"
__maintainer__ = "Alexander Willner"
__email__ = "[email protected]"
__status__ = "Development"
import argparse
import re
import fileinput
CONST_TITLE="What is the core summary of the paper?"
CONST_CONTEXT="What is problem area, why is it interesting?"
CONST_PROBLEM="What is problem we specifically consider, why is it hard? (e.g., why do naive approaches fail?)"
CONST_WORK="Survey past relevant work. Why hasn’t it been solved before? Or, what’s wrong with previous proposed solutions?"
CONST_APPROACH="What are the key components of this approach and how does it differ to related work?"
CONST_EVAL="What are the expected/generated results and how will/have we validate(d) them?"
CONST_RESULT="The expected/generated scientific surplus value?"
CONST_OUTLOOK="How could this work be extended?"
def main(args):
""" to be enhanced """
if args.title is not None:
print("Title: ",args.title)
title = re.compile("(\\\\newcommand{\\\\metaTitle}{).*(})")
for line in fileinput.input(['template.meta.tex'], inplace=True):
print(title.sub("\\1" + str(args.title) + "\\2", line), end = '')
print("First Name: ",args.firstname)
print("Last Name: ",args.lastname)
author = re.compile("(\\\\newcommand{\\\\metaAuthorFirst}{).*(})")
for line in fileinput.input(['template.meta.tex'], inplace=True):
print(author.sub("\\1" + str(args.firstname) + " " + str(args.lastname) + "\\2", line), end = '')
print("Mail: ",args.mail)
mail = re.compile("(\\\\newcommand{\\\\metaMailFirst}{).*(})")
for line in fileinput.input(['template.meta.tex'], inplace=True):
print(mail.sub("\\1" + str(args.mail) + "\\2", line), end = '')
print("Institution: ",args.institution)
print("Country: ",args.country)
print("City: ",args.city)
print("Zip: ",args.zip)
instS = str(args.institution) + ", " + str(args.city) + ", " + str(args.country)
inst = re.compile("(\\\\newcommand{\\\\metaInstFirst}{).*(})")
for line in fileinput.input(['template.meta.tex'], inplace=True):
print(inst.sub("\\1" + instS + "\\2", line), end = '')
#todo: refactor and always check for None
if args.context is not None:
print("Context: ",args.context)
context = re.compile(".*(%%context)")
for line in fileinput.input(['src/00_abstract.tex'], inplace=True):
print(context.sub(str(args.context) + " \\1", line), end = '')
for line in fileinput.input(['src/01_introduction.tex'], inplace=True):
print(context.sub("\\\\todotext{1 paragraph: " + str(args.context) + "} \\1", line), end = '')
print("Problem: ",args.problem)
problem = re.compile(".*(%%problem)")
for line in fileinput.input(['src/00_abstract.tex'], inplace=True):
print(problem.sub(str(args.problem) + " \\1", line), end = '')
for line in fileinput.input(['src/01_introduction.tex'], inplace=True):
print(problem.sub("\\\\todotext{1 paragraph: " + str(args.problem) + "} \\1", line), end = '')
print("Work: ",args.work)
work = re.compile(".*(%%work)")
for line in fileinput.input(['src/00_abstract.tex'], inplace=True):
print(work.sub(str(args.work) + " \\1", line), end = '')
for line in fileinput.input(['src/01_introduction.tex'], inplace=True):
print(work.sub("\\\\todotext{1 paragraph: " + str(args.work) + "} \\1", line), end = '')
print("Approach: ",args.approach)
approach = re.compile(".*(%%approach)")
for line in fileinput.input(['src/00_abstract.tex'], inplace=True):
print(approach.sub(str(args.approach) + " \\1", line), end = '')
for line in fileinput.input(['src/01_introduction.tex'], inplace=True):
print(approach.sub("\\\\todotext{1 paragraph: " + str(args.approach) + "} \\1", line), end = '')
print("Evaluation: ",args.evaluation)
evaluation = re.compile(".*(%%evaluation)")
for line in fileinput.input(['src/00_abstract.tex'], inplace=True):
print(evaluation.sub(str(args.evaluation) + " \\1", line), end = '')
for line in fileinput.input(['src/01_introduction.tex'], inplace=True):
print(evaluation.sub("\\\\todotext{1 paragraph: " + str(args.evaluation) + "} \\1", line), end = '')
print("Result: ",args.result)
result = re.compile(".*(%%result)")
for line in fileinput.input(['src/00_abstract.tex'], inplace=True):
print(result.sub(str(args.result) + " \\1", line), end = '')
for line in fileinput.input(['src/01_introduction.tex'], inplace=True):
print(result.sub("\\\\todotext{1 paragraph: " + str(args.result) + "} \\1", line), end = '')
print("Outlook: ",args.outlook)
outlook = re.compile(".*(%%outlook)")
for line in fileinput.input(['src/00_abstract.tex'], inplace=True):
print(outlook.sub(str(args.outlook) + " \\1", line), end = '')
for line in fileinput.input(['src/01_introduction.tex'], inplace=True):
print(outlook.sub("\\\\todotext{1 paragraph: " + str(args.outlook) + "} \\1", line), end = '')
if __name__ == "__main__":
PARSER = argparse.ArgumentParser()
PARSER.add_argument(
"-v",
"--version",
action="version",
version="%(prog)s (version {version})".format(version=__version__))
PARSER.add_argument("-f", "--firstname", action="store", dest="firstname")
PARSER.add_argument("-l", "--lastname", action="store", dest="lastname")
PARSER.add_argument("-m", "--mail", action="store", dest="mail")
PARSER.add_argument("-i", "--institution", action="store", dest="institution")
PARSER.add_argument("--country", action="store", dest="country")
PARSER.add_argument("--city", action="store", dest="city")
PARSER.add_argument("--zip", action="store", dest="zip")
PARSER.add_argument("-t", "--title", action="store", dest="title", help=CONST_TITLE)
PARSER.add_argument("-c", "--context", action="store", dest="context", help=CONST_CONTEXT)
PARSER.add_argument("-p", "--problem", action="store", dest="problem", help=CONST_PROBLEM)
PARSER.add_argument("-w", "--work", action="store", dest="work", help=CONST_WORK)
PARSER.add_argument("-a", "--approach", action="store", dest="approach", help=CONST_APPROACH)
PARSER.add_argument("-r", "--result", action="store", dest="result", help=CONST_RESULT)
PARSER.add_argument("-e", "--evaluation", action="store", dest="evaluation", help=CONST_EVAL)
PARSER.add_argument("-o", "--outlook", action="store", dest="outlook", help=CONST_OUTLOOK)
MYARGS = PARSER.parse_args()
main(MYARGS)