Commit 523041ad authored by Filippo Leonardi's avatar Filippo Leonardi

Revert "Merge branch 'F_branch' into 'master'"

This reverts commit 916658be
parent 916658be
......@@ -63,24 +63,11 @@
% Define appearance of C++ code
\lstdefinestyle{CPP}{
language=C++,
%mathescape=true,
mathescape=false,
alsoletter={\\,/,*},
frame=lb,
xleftmargin=4.2pt,
numbers=left,
keywordstyle=\color{blue}\bfseries,
stringstyle=\color{red}\textit,
commentstyle=\color{green}\ttfamily,
morecomment=[l][\color{magenta}]{\#}
keywords={if, while, for, else, switch, std, cout}
morekeywords={\\brief,\\return,\\param, Dune, Eigen, MatrixXd, VectorXd, assert, Zero, define, \\\#},
morekeywords={\\brief,\\return,\\param, Dune, Eigen, MatrixXd, VectorXd, assert, Zero},
literate={\\f}{}0,
basicstyle={\ttfamily \small },
tabsize=4,
breaklines=true,
numberstyle=\color{gray},
prebreak=\mbox{\tiny$\searrow$},
postbreak=\mbox{{\color{gray}$\cdots$}},
}
\lstdefinestyle{MATLAB}{
......@@ -110,6 +97,7 @@
xleftmargin=4.2pt,
}
\lstset{literate={\\f}{}0}
\newcommand{\f}{} % Escape C++ doxygen LaTeX commands of the form \f$ fancy math \f$
......
#!/usr/bin/env python
<<<<<<< latex_creator.py
import re, os, sys, subprocess, time
import re, os, sys, subprocess
from subprocess import Popen, PIPE, STDOUT
from collections import defaultdict
......@@ -273,7 +272,6 @@ def create_tex(dirname, original_files=[], template_dir="", verbose=False):
# print('symlink detected')
pass
# Informations about file named fname
ftype = get_ftype(fname)
md5s = md5sum(fname)
is_duplicate = md5s in hashsums
......@@ -282,16 +280,13 @@ def create_tex(dirname, original_files=[], template_dir="", verbose=False):
is_modified = md5s not in original_files
is_invalid = [lf(fname) for lf in invalid_filenames]
omitted_flag = True in is_invalid
timestamp = time.ctime(os.path.getmtime(fname))
# Dictionary of statistics
files_filtered.append({'fname': fname,
'template-dir': template_dir,
'ftype': ftype,
'md5s': md5s,
'is_modified': is_modified,
'is_duplicate': is_duplicate,
'timestamp' : timestamp,
'omitted': omitted_flag})
allfiles += files_filtered
# create tex
......@@ -319,8 +314,7 @@ def create_tex(dirname, original_files=[], template_dir="", verbose=False):
if not section_tex_str == '':
if section_label == '_____etc':
# Etc. is bugging me
texstr += '\n \\clearpage \\section{Modified files} \n'
texstr += '\n \\clearpage \\section{Etc} \n'
else:
texstr += '\n \\clearpage \\section{' + section_label.replace(
"_", "-") + '} \n'
......@@ -361,57 +355,49 @@ def main(dirname, ip, identifier, original_files=[], lecture_title='', template_
my_header = my_header.replace('LECTURETITLE', lecture_title)
out = [r'\begin{table}[h!] \centering']
out.append(r'\renewcommand{\arraystretch}{1.2}')
ncols = 4;
# Create a header for type of file
def get_category_string(category):
# Escape nightmare
return r'\hline\multicolumn{{{}}}{{|l|}}{{\textbf{{{}}}}}\\\hline'.format(ncols, category)
# Given item, returns row of table representing item
template_str = r'\verb`{:s}`& {:s} & {:s} & \verb`{:s}` \\'
def get_formatted_item_string(item):
return template_str.format(item['fname'],
short_names[item['ftype']],
item['timestamp'],
item['md5s'])
out.append(r'\begin{tabular}{' + '|l'*ncols + '|}')
out.append(r'\begin{tabular}{|l|l|l|}')
out.append(r'\hline\multicolumn{3}{|l|}{\textbf{Modified}}\\\hline')
template_str = r'\verb`{:s}`& {:s} & \verb`{:s}` \\'
# modified
out.append(get_category_string("Modified"))
modified_files = filter(
lambda x: (x['is_modified'] is True and x['is_duplicate'] is False
and x['omitted'] is False and not x['ftype'] == 'symbolic link'),
files)
for item in modified_files:
out.append(get_formatted_item_string(item))
out.append(
template_str.format(item['fname'], short_names[item['ftype']],
item['md5s']))
# duplicate
out.append(get_category_string("Modified (duplicates)"))
out.append(
r'\hline\multicolumn{3}{|l|}{\textbf{Modified (duplicates)}}\\\hline')
for item in filter(
lambda x: (x['is_modified'] is True and x['omitted'] is False
and x['is_duplicate'] is True and not x['ftype'] == 'symbolic link'),
files):
out.append(get_formatted_item_string(item))
out.append(
template_str.format(item['fname'], short_names[item['ftype']],
item['md5s']))
# not modified
out.append(get_category_string("Unmodified"))
out.append(r'\hline\multicolumn{3}{|l|}{\textbf{Unmodified}}\\\hline')
for item in filter(
lambda x: (x['is_modified'] is False and x['omitted'] is False
and not x['ftype'] == 'symbolic link'),
files):
out.append(get_formatted_item_string(item))
out.append(
template_str.format(item['fname'], short_names[item['ftype']],
item['md5s']))
# ignored
out.append(get_category_string("Ignored"))
out.append(r'\hline\multicolumn{3}{|l|}{\textbf{Ignored}}\\\hline')
for item in filter(
lambda x: (x['omitted'] is True and not x['ftype'] == 'symbolic link'),
files):
out.append(get_formatted_item_string(item))
out.append(
template_str.format(item['fname'], short_names[item['ftype']],
item['md5s']))
out.append(r'\hline')
out.append(r'\end{tabular}')
out.append(r'\end{table}')
......
......@@ -7,9 +7,6 @@ import latex_creator
exam_user_file='.exam-setup-user'
def read_info_file(infofile):
"""
Read end variables from results folder (username and realname)
"""
with open(infofile) as f:
for line in f.readlines():
match = re.search('export LOGINNAME="(.+?)"', line)
......@@ -23,9 +20,6 @@ def read_info_file(infofile):
def get_name_table():
"""
Computer ip - names table
"""
name_table = {}
for dirname in os.listdir(args.results):
......@@ -39,9 +33,6 @@ def get_name_table():
def get_file_hashes(hashfile):
"""
Read all hashes from the hash file
"""
with open(hashfile) as f:
hashes = [l[:32] for l in f.readlines()]
return hashes
......
#!/usr/bin/env python
import copy, sys
from PyPDF2 import PdfFileWriter, PdfFileReader
import glob, os
output = PdfFileWriter()
output_page_number = 0
alignment = 4 # to align on even pages
for filename in glob.glob("*.pdf"):
# This code is executed for every file in turn
print(filename)
input = PdfFileReader(open(filename, "rb"))
for p in [input.getPage(i) for i in range(0,input.getNumPages())]:
# This code is executed for every input page in turn
output.addPage(p)
output_page_number += 1
while output_page_number % alignment != 0:
output.addBlankPage()
output_page_number += 1
output_stream = open("file.pdf", "wb")
output.write(output_stream)
......@@ -41,12 +41,6 @@ if [[ ! $? -eq 0 ]]; then
echo "Cannot find parallel command. Make sure you have gnu parallel installed. Exiting."
exit 1
fi
if [[ ! -e ~/.fonts/Inconsolata.otf ]]; then
echo "Installing fonts..."
mkdir -p ~/.fonts/ && cp ./Inconsolata.otf ~/.fonts/
sudo mk
fi
if (( $+myoptions[--help] )) ; then
show_help $0
......@@ -141,8 +135,6 @@ if (( $+myoptions[-t] )) ; then
fi
fi
log="xelatex_compile_$(date +"%s").log"
# compile
if (( $+myoptions[-c] )) ; then
if [[ ! -e $HOME/.fonts/Inconsolata-Regular.ttf ]]; then
......@@ -150,7 +142,6 @@ if (( $+myoptions[-c] )) ; then
mkdir -p $HOME/.fonts && cp ${source_dir}/Inconsolata-{Bold,Regular}.ttf $HOME/.fonts/
fi
echo "\n>>> Compiling PDFs in $results ... \n"
touch $log
(
cd $results
# get all subfolders containing the EXAM_SETUP_USER file
......@@ -167,9 +158,9 @@ if (( $+myoptions[-c] )) ; then
(echo "*WARNING* $texfile does not exist." 1>&2)
fi
done)
echo $files | parallel --bar --will-cite xelatex '-interaction nonstopmode -halt-on-error' >> $log
echo $files | parallel --bar --will-cite xelatex '-interaction nonstopmode -halt-on-error' >> $log
echo $files | parallel --bar --will-cite xelatex '-interaction nonstopmode -halt-on-error' > /dev/null
echo $files | parallel --bar --will-cite xelatex '-interaction nonstopmode -halt-on-error' > /dev/null
# check if pdf was created
for ldir in ${(f)results_dir}; do
tail=${ldir:t}
texfile=${ldir}/${tail}.tex
......@@ -177,14 +168,12 @@ if (( $+myoptions[-c] )) ; then
if [[ ! -f "$pdfpath.pdf" ]]; then
(echo "*WARNING* no PDF created for $ldir" 1>&2)
fi
counter=$((counter+1))
done
)
echo "Compiling done, xelatex log written to \"$log\"."
fi
# concatenate PDFs
if (( $+myoptions[-s] )) ; then
(cd $results && pdfunite [0-9]*pdf results.pdf)
fi
\ No newline at end of file
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment