Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Modifying pyploma.py in order to take the year of the event from command line. #446

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added certificates/ECW-stamp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions certificates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# CodeEUCertificates

Instructions:
$ python pyploma.py "Name Surname" Event_ID Year
Empty file removed certificates/__init__.py
Empty file.
27 changes: 14 additions & 13 deletions certificates/resources/template.tex → certificates/certi.tex
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[spanish]{babel}
\usepackage{mathpazo}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[landscape,a4paper]{geometry}
\geometry{verbose,tmargin=0cm,bmargin=0cm,lmargin=3cm,rmargin=3cm}
\geometry{verbose,tmargin=0cm,bmargin=0cm,lmargin=0cm,rmargin=0cm}
\usepackage{fancybox}
\usepackage{calc}
\usepackage{multicol}
Expand All @@ -18,13 +18,13 @@
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,%
keepaspectratio]{images/background.png}%
keepaspectratio]{V14.png}%
\vfill
}}}


\begin{document}
\AddToShipoutPicture{\BackgroundPic}
\[\AddToShipoutPicture{\BackgroundPic}
~
\vspace{1.2cm}
~
Expand All @@ -35,20 +35,19 @@
\begin{center}
\begin{tabular}{lr}
%~\hspace{0.7cm}
\includegraphics[height=3.4cm]{images/codeweek_logo.png}
\includegraphics[height=3.4cm]{images/european_commission_logo.png}
\includegraphics[height=3.4cm]{codeweekeu.png}
\includegraphics[height=3.4cm]{EC.png}
\end{tabular}
\end{center}
\end{table}
\vspace{-0.2cm}
\LARGE{CodeWeek EU organisers are honoured\\
\vspace{1cm}
\fontsize{50}{60}{\textbf{TO CERTIFY}}
}

\vspace{0.4cm}

\Huge{that \textbf{<CERTIFICATE_HOLDER_NAME>
\Huge{that \textbf{%pointname
}}

\vspace{0.4cm}
Expand All @@ -57,7 +56,8 @@

\vspace{0.3cm}

\Huge{\textbf{EUROPE CODE WEEK 2016}}
\Huge{\textbf{EUROPE CODE WEEK \textbf{%pointyear
}}}

\vspace{0.3cm}

Expand All @@ -81,18 +81,19 @@
\begin{center}
\begin{tabular}{lr}
%~\hspace{0.7cm}
\includegraphics[height=2.5cm]{images/signature_and_stamp.png}
\includegraphics[height=2.5cm]{signature2.png}
\end{tabular}
\end{center}
\end{table}
\vspace{-2.2cm}
\begin{center}
\footnotesize{On behalf of Europe Code Week Ambassadors}\\
%\end{tabular}
\footnotesize{On behalf of Europe Code Week Ambassadors}\\
\end{tabular}

%Diploma elaborado con el software libre \texttt{Pyploma}, (c)
%\url{[email protected]} bajo licencia
%GPLv3. Visite: \url{http://code.google.com/p/pyploma}

\end{center}
\end{document}
\]
\end{document}
59 changes: 0 additions & 59 deletions certificates/generator.py

This file was deleted.

46 changes: 46 additions & 0 deletions certificates/pyploma.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# This diploma generator read a list of names to
# fill a LaTeX template with a point for the name.
# Optinally, it can compile the LaTeX files and join them.
# If LaTeX errors are present, then press Enter.

print "Pyploma: Diploma generator for LaTeX and pdf.\n"

import sys
# Invoke terminal
from commands import *
import commands
def run_command(cmd):
getstatusoutput(cmd)

if len(sys.argv) != 4:
print "Usage: python pyploma.py \"Name To be Printed\" Event_ID\"Year"
else:
name = str(sys.argv[1])
filename = str(sys.argv[2])
year = str(sys.argv[3])

salida = open(filename + ".tex","w") # create a LaTeX file for each person in the list

text = open("certi.tex") # open the LaTeX document
text = text.read() # read it
text_list = list(text) # transform it into a list

y_name = text.find("%pointname") #search the point for name inclusion
z_name = len("%pointname")+2
text_list[y_name+z_name:y_name+z_name] = name # insert the name
x_name = text.find("%pointyear") #search the point for year inclusion
n_name = len("%pointyear")+4
text_list[x_name+n_name:x_name+n_name] = year # insert the year

text_final = "".join(text_list) # from list to string

salida.write(text_final) # save changes in the created file
salida.close() # closes the file

run_command(str("pdflatex -interaction=nonstopmode " + filename + ".tex")) # compile LaTeX a pdf (optional)
print name #control

run_command(str("pdftk output*.pdf cat output todos_diplomas.pdf")) # create pdf with all the created diplomas (optional)

print "\nAnd we are done! :-)" #control
Binary file added certificates/signature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.