Skip to content
Snippets Groups Projects
Commit fa0d6edf authored by Eva Zangerle's avatar Eva Zangerle
Browse files

removed generator script

parent 6914bd0f
No related branches found
No related tags found
No related merge requests found
.PHONY: clean watch
all: thesis_bachelor_english thesis_bachelor_german thesis_master_english thesis_master_german
thesis_bachelor_english:
python3 generator.py --lang en --type bachelor --title Title --student "Name1, Name2" --supervisor "Supervisor1, Supervisor2" > thesis_bachelor_english.tex
mv thesis_bachelor_english.tex ..
thesis_bachelor_german:
python3 generator.py --lang de --type bachelor --title Title --student "Name1, Name2" --supervisor "Supervisor1, Supervisor2" > thesis_bachelor_german.tex
mv thesis_bachelor_german.tex ..
thesis_master_english:
python3 generator.py --lang en --type master --title Title --student "Name1, Name2" --supervisor "Supervisor1, Supervisor2" > thesis_master_english.tex
mv thesis_master_english.tex ..
thesis_master_german:
python3 generator.py --lang de --type master --title Title --student "Name1, Name2" --supervisor "Supervisor1, Supervisor2" > thesis_master_german.tex
mv thesis_master_german.tex ..
clean:
rm ../*.tex
# DBIS Thesis Template Generator
This script was made to unify german and english thesis template generation
## Usage
Make sure you have the `click` library installed in your env: `pip install click`
Output of `the generator.py` help page
```
Usage: generator.py [OPTIONS]
Options:
--lang [en|de] Language of thesis template
--type [bachelor|master] Select type of thesis
--title TEXT Title of the thesis
--student TEXT Names of contributing students comma separated
--supervisor TEXT Names of supervisor comma separated
-o, --output TEXT Name of outputfile
--help Show this message and exit.
```
The script prompts an input for each option except for the output.
If `output` option is not set, the script prints the template to `stdout`.
### todos
- within the `template.tex`: In the original templates were different locations for
`\pagenumbering{Roman}`. These need to be fixed.
\ No newline at end of file
#!/usr/bin/env python
from typing import Dict
import click
TEMPLATE_START = '{%'
TEMPLATE_END = '%}'
GERMAN = {
'DOCUMENT_CLASS_LANG': ', ngerman',
'DOCUMENT_LANGUAGE': 'ngerman',
'TITLE_PAGE_COMMENT': 'TITELSEITE',
'TITLE_DEPARTEMENT_NAME': 'Institut für Informatik',
'TITLE_GROUP_NAME': 'Datenbanken und Informationssysteme',
'TITLE_FOOTER_MASTER': 'Masterarbeit',
'TITLE_FOOTER_BACHELOR': 'Bachelorarbeit',
'TITLE_SUPERVISED_BY': 'betreut von',
'STATUTORY_DECLARATION_COMMENT': 'Eidesstattliche Erklärung',
'GERMAN_ABSTRACT_COMMENT': 'ZUSAMMENFASSUNG',
'ENGLISH_ABSTRACT_COMMENT': 'ABSTRACT',
'ACKNOWLEDGEMENTS_COMMENT': 'DANKSAGUNG',
'TABLE_OF_CONTENTS_COMMENT': 'INHALTSVERZEICHNIS',
'CHAPTER_COMMENT': 'KAPITEL',
'CHAPTER_1_NAME': 'Einleitung',
'CHAPTER_2_NAME': 'Kapitel 2',
'SECTION_COMMENT': 'ABSCHNITT',
'SECTION_NAME': 'Abschnitt',
'SUB_SECTION_NAME': 'Teilabschnitt',
'APPENDIX_COMMENT': 'ANHANG',
'APPENDIX_TITLE': 'Anhang',
'APPENDIX_SECTION_NAME': 'Anhang Abschnitt',
'BIBLIOGRAPHY_COMMENT': 'LITERATURVERZEICHNIS',
'BIBLIOGRAHPY_TITLE': 'Literaturverzeichnis',
}
ENGLISH = {
'DOCUMENT_CLASS_LANG': '',
'DOCUMENT_LANGUAGE': 'english',
'TITLE_PAGE_COMMENT': 'TITLEPAGE',
'TITLE_DEPARTEMENT_NAME': 'Department of Computer Science',
'TITLE_GROUP_NAME': 'Databases and Information Systems',
'TITLE_FOOTER_MASTER': 'Master Thesis',
'TITLE_FOOTER_BACHELOR': 'Bachelor Thesis',
'TITLE_SUPERVISED_BY': 'supervised by',
'STATUTORY_DECLARATION_COMMENT': 'STATUTORY DECLARATION',
'GERMAN_ABSTRACT_COMMENT': 'german ABSTRACT',
'ENGLISH_ABSTRACT_COMMENT': 'ABSTRACT',
'ACKNOWLEDGEMENTS_COMMENT': 'ACKNOWLEDGEMENTS',
'TABLE_OF_CONTENTS_COMMENT': 'TABLE OF CONTENTS',
'CHAPTER_COMMENT': 'CHAPTER',
'CHAPTER_1_NAME': 'Introduction',
'CHAPTER_2_NAME': 'Chapter 2',
'SECTION_COMMENT': 'SECTION',
'SECTION_NAME': 'Section',
'SUB_SECTION_NAME': 'Subsection',
'APPENDIX_COMMENT': 'APPENDIX',
'APPENDIX_TITLE': 'Appendix',
'APPENDIX_SECTION_NAME': 'Appendix Section',
'BIBLIOGRAPHY_COMMENT': 'BIBLIOGRAPHY',
'BIBLIOGRAHPY_TITLE': 'Bibliography',
}
THESIS_TITLE = 'THESIS_TITLE'
STUDENT_NAME = 'STUDENT_NAME'
STUDENT_NAME_TITLE = 'STUDENT_NAME_TITLE'
SUPERVISOR_NAME = 'SUPERVISORS'
def __load_template() -> str:
with open(f"./templates/template.tex", 'r') as fp:
return ''.join(fp.readlines())
def _load_statutory_declaration(type: str) -> str:
file = 'master_statutory_declaration.tex' if type == 'master' else 'bachelor_statutory_declaration.tex'
with open(f"./templates/{file}", 'r') as fp:
return ''.join(fp.readlines())
def _template_replace(template: str, key: str, value: str) -> str:
return template.replace(f"{TEMPLATE_START} {key} {TEMPLATE_END}", value)
def _insert_translations(template: str, translations: Dict[str, str]) -> str:
_template = template
for key, translation in translations.items():
_template = _template_replace(_template, key, translation)
return _template
def _insert_title_page_content(students: str, template: str, title: str) -> str:
template = _template_replace(template, THESIS_TITLE, title)
template = _template_replace(template, STUDENT_NAME, students)
template = _template_replace(template, STUDENT_NAME_TITLE, ('\\\\').join(students.split(',')))
return template
def _title_footer(type: str, language: str) -> str:
if language == 'en':
return ENGLISH['TITLE_FOOTER_MASTER'] if type == 'master' else ENGLISH['TITLE_FOOTER_BACHELOR']
else:
return GERMAN['TITLE_FOOTER_MASTER'] if type == 'master' else GERMAN['TITLE_FOOTER_BACHELOR']
def _insert_type_specific_content(template: str, type: str, language: str) -> str:
thesis_type = 'MASTER' if type == 'master' else 'BACHELOR'
template = _template_replace(template, 'THESIS_TYPE', thesis_type)
template = _template_replace(template, 'STATUTORY_DECLARATION', _load_statutory_declaration(type))
template = _template_replace(template, 'TITLE_FOOTER', _title_footer(type, language))
return template
def _create_thesis_template(language: str, type: str, title: str, students: str, supervisors: str) -> str:
translations = ENGLISH if language == 'en' else GERMAN
template = _insert_translations(__load_template(), translations)
template = _insert_title_page_content(students, template, title)
template = _insert_type_specific_content(template, type, language)
return _template_replace(template, SUPERVISOR_NAME, supervisors)
@click.command()
@click.option('--lang', default='en', prompt='Language of the Thesis', help='Language of thesis template',
type=click.Choice(['en', 'de']))
@click.option('--type', default='bachelor', prompt='Thesis type', help='Select type of thesis',
type=click.Choice(['bachelor', 'master']))
@click.option('--title', default='title', prompt='Thesis title', help='Title of the thesis')
@click.option('--student', prompt='Name(s) of Student(s) (comma separated)',
help='Names of contributing students comma separated')
@click.option('--supervisor', prompt='Name(s) of Supervisor(s) (comma separated)',
help='Names of supervisor comma separated')
@click.option('-o', '--output', required=False, help='Name of outputfile')
def create_template(lang, type, title, student, supervisor, output=None) -> None:
template = _create_thesis_template(lang, type, title, student, supervisor)
if output is None:
print(_create_thesis_template(lang, type, title, student, supervisor))
else:
with open(output, 'w+') as fp:
fp.writelines(template)
if __name__ == '__main__':
create_template()
Click==7.0
\section*{Eidesstattliche Erklärung}
Ich erkläre hiermit an Eides statt durch meine eigenhändige Unterschrift, dass ich die vorliegende Arbeit selbständig verfasst und keine anderen als die angegebenen Quellen und Hilfsmittel verwendet habe.
Alle Stellen, die wörtlich oder inhaltlich den angegebenen Quellen entnommen wurden, sind als solche kenntlich gemacht.\\
Ich erkläre mich mit der Archivierung der vorliegenden Bachelorarbeit einverstanden.\\[3cm]
\begin{minipage}{0.4\textwidth}
\centering
\rule{\textwidth}{.4pt}\\
Datum
\end{minipage}%
\hfill%
\begin{minipage}{0.4\textwidth}
\centering
\rule{\textwidth}{.4pt}\\
Unterschrift
\end{minipage}
\section*{Eidesstattliche Erklärung}
Ich erkläre hiermit an Eides statt durch meine eigenhändige Unterschrift, dass ich die vorliegende Arbeit selbständig verfasst und keine anderen als die angegebenen Quellen und Hilfsmittel verwendet habe.
Alle Stellen, die wörtlich oder inhaltlich den angegebenen Quellen entnommen wurden, sind als solche kenntlich gemacht.\\
Die vorliegende Arbeit wurde bisher in gleicher oder ähnlicher Form noch nicht als Magister-/Master-/Diplomarbeit/Dissertation eingereicht.\\[3cm]
\begin{minipage}{0.4\textwidth}
\centering
\rule{\textwidth}{.4pt}\\
Datum
\end{minipage}%
\hfill%
\begin{minipage}{0.4\textwidth}
\centering
\rule{\textwidth}{.4pt}\\
Unterschrift
\end{minipage}
\ No newline at end of file
% vim: filetype=tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% {% THESIS_TYPE %} Thesis Template
% Research Group Databases and Information Systems
% University of Innsbruck
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% define document class
\documentclass[11pt,a4paper,titlepage, twoside{% DOCUMENT_CLASS_LANG %}]{report}
% include required packages
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{url}
\usepackage{appendix}
% % use abbrv-bibliography style
\bibliographystyle{abbrv}
% specify margins for two-sided print
\oddsidemargin 3cm
\evensidemargin 1cm
\textwidth 12cm
% define header format
\fancyhead{}
\fancyhead[LE,RO]{\leftmark}
\fancyfoot[LO, RE]{{% STUDENT_NAME %}}
\fancyfoot[RO, LE]{\thepage}
\fancyfoot[CE, CO]{}
\headheight 26pt
\renewcommand{\headrulewidth}{0.3pt}
\renewcommand{\footrulewidth}{0.3pt}
% define style for appendix header
\newcommand{\appendixheader}{ % specify header for appendix
\fancyhf{}
\fancyhead[LE, RO]{APPENDIX \rightmark}
\fancyfoot[LO, RE]{Name 1, Name 2}
\fancyfoot[RO, LE]{\thepage}
}
% code for creating empty pages
% no headers on empty pages before new chapter
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother \clearpage{\pagestyle{empty}\cleardoublepage}
\begin{document}
\parindent 0cm
\selectlanguage{{% DOCUMENT_LANGUAGE %}}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% TITLE_PAGE_COMMENT %}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\begin{titlepage}
\begin{center}
% insert university logo
\includegraphics[height=40mm]{uni_2017} \\[3mm]
\vspace{1cm}
\begin{large}
Universität Innsbruck\\[5mm]
{% TITLE_DEPARTEMENT_NAME %}\\
{% TITLE_GROUP_NAME %}\\[25mm]
\end{large}
\begin{LARGE}{% THESIS_TITLE %}\\ \end{LARGE}
\begin{footnotesize}{% TITLE_FOOTER %}\end{footnotesize}\\[15mm]
{% STUDENT_NAME_TITLE %}\\[30mm]
{% TITLE_SUPERVISED_BY %}\\
{% SUPERVISORS %}\\[10mm]
\begin{footnotesize}Innsbruck, \today \end{footnotesize}
\end{center}
\end{titlepage}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% STATUTORY_DECLARATION_COMMENT %}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\cleardoublepage
\pagenumbering{Roman}
\thispagestyle{empty}
\selectlanguage{ngerman}
{% STATUTORY_DECLARATION %}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% GERMAN_ABSTRACT_COMMENT %}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\cleardoublepage
\thispagestyle{plain}
\selectlanguage{ngerman}
\begin{abstract}
Dies ist die deutsche Zusammenfassung.
\end{abstract}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% ENGLISH_ABSTRACT_COMMENT %}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\cleardoublepage
\selectlanguage{english}
\begin{abstract}
This is the English abstract.
\end{abstract}
\selectlanguage{{% DOCUMENT_LANGUAGE %}}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% ACKNOWLEDGEMENTS_COMMENT %}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%\cleardoublepage
%\thispagestyle{plain}
%\chapter*{Acknowledgements}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% TABLE_OF_CONTENTS_COMMENT %}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\cleardoublepage
\pagestyle{fancy}
\tableofcontents
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% CHAPTER_COMMENT %} 1
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% chapter starts on right side
\cleardoublepage
\chapter{{% CHAPTER_1_NAME %}}
% change numbering to normal format, set page counter to 1
\pagenumbering{arabic}
\setcounter{page}{1}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% CHAPTER_COMMENT %} 2
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\cleardoublepage
\chapter{{% CHAPTER_2_NAME %}}
%-------------------------------------
% {% SECTION_COMMENT %}
%-------------------------------------
\section{{% SECTION_NAME %}}
\subsection{{% SUB_SECTION_NAME %}}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% APPENDIX_COMMENT %} A
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\cleardoublepage
\appendixheader
% reset counter for section numbering
\setcounter{section}{0}
\setcounter{chapter}{0}
% redefine numbering of sections to A.x
\renewcommand{\thesection}{A.\arabic{section}}
\renewcommand{\thechapter}{A}
\chapter*{{% APPENDIX_TITLE %}} % use *-form to suppress numbering
\addcontentsline{toc}{chapter}{{% APPENDIX_TITLE %}}
% reset counter for section numbering
\setcounter{section}{0}
\setcounter{chapter}{0}
% redefine numbering of sections to A.x
\renewcommand{\thesection}{A.\arabic{section}}
\renewcommand{\thechapter}{A}
\section{{% APPENDIX_SECTION_NAME %}}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% {% BIBLIOGRAPHY_COMMENT %}
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\cleardoublepage
\nocite{*}
\bibliography{literature}
\addcontentsline{toc}{chapter}{{% BIBLIOGRAHPY_TITLE %}}
\end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment