Skip to content

Commit

Permalink
Move the sty dependencies in the right directory
Browse files Browse the repository at this point in the history
Permit to generate the pdf whatever the directory we use.
  • Loading branch information
Pierre-Sassoulas committed Feb 9, 2020
1 parent b0cf954 commit 0e8acba
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 18 deletions.
11 changes: 11 additions & 0 deletions survey/exporter/tex/survey2tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime
from pathlib import Path
from pydoc import locate
from shutil import copy

import pytz
from django.utils.text import slugify
Expand All @@ -19,11 +20,14 @@
from survey.models.question import Question

LOGGER = logging.getLogger(__name__)
STATIC = Path(__file__).parent.parent.parent.joinpath("static")


class Survey2Tex(Survey2X):

ANALYSIS_FUNCTION = []
PGF_PIE_STY = Path(STATIC, "survey", "sty", "pgf-pie.sty")
PGF_PLOT_STY = Path(STATIC, "survey", "sty", "pgfplots.sty")

def __init__(self, survey, configuration=None):
Survey2X.__init__(self, survey)
Expand Down Expand Up @@ -105,10 +109,17 @@ def generate(self, path, output=None):
previous_directory = os.getcwd()
dir_name, file_name = os.path.split(path)
os.chdir(dir_name)
sty_dependencies = [self.PGF_PIE_STY, self.PGF_PLOT_STY]
dependencies_to_delete = []
for dep in sty_dependencies:
copy(dep, dir_name)
dependencies_to_delete.append(Path(dir_name, dep.name))
os.system("xelatex {}".format(file_name))
os.system("xelatex {}".format(file_name))
if output is not None:
os.system("mv {}.pdf {}".format(file_name[:-3], output))
for dep in dependencies_to_delete:
dep.unlink()
os.chdir(previous_directory)

@property
Expand Down
6 changes: 3 additions & 3 deletions survey/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-09 17:13+0000\n"
"POT-Creation-Date: 2020-02-09 20:07+0000\n"
"PO-Revision-Date: 2020-01-24 17:05+0000\n"
"Last-Translator: b' <>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -101,11 +101,11 @@ msgstr "in Zusammenhang mit der Frage"
msgid "right"
msgstr "rechts"

#: survey/exporter/tex/survey2tex.py:66
#: survey/exporter/tex/survey2tex.py:72
msgid "We could not render a chart because the type"
msgstr "Wir konnten eine Grafik nicht erstellen, weil der Typ"

#: survey/exporter/tex/survey2tex.py:69
#: survey/exporter/tex/survey2tex.py:75
msgid "is not a standard type nor the path to an importable valid Question2Tex child class. Choose between 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' or 'package.path.MyQuestion2TexCustomClass'"
msgstr "kein Standard Typ und auch kein Pfad zu einer importierbaren Question2Tex child class ist. Wähle zwischen 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' oder 'package.path.MyQuestion2TexCustomClass'"

Expand Down
6 changes: 3 additions & 3 deletions survey/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-09 17:13+0000\n"
"POT-Creation-Date: 2020-02-09 20:07+0000\n"
"PO-Revision-Date: 2018-10-06 20:42+0000\n"
"Last-Translator: Javier Ordóñez <>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -104,11 +104,11 @@ msgstr "en relación con la pregunta"
msgid "right"
msgstr "derecha"

#: survey/exporter/tex/survey2tex.py:66
#: survey/exporter/tex/survey2tex.py:72
msgid "We could not render a chart because the type"
msgstr "no pudimos generar un gráfico porque el tipo"

#: survey/exporter/tex/survey2tex.py:69
#: survey/exporter/tex/survey2tex.py:75
msgid "is not a standard type nor the path to an importable valid Question2Tex child class. Choose between 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' or 'package.path.MyQuestion2TexCustomClass'"
msgstr "no es un tipo estándar ni ruta a una subclase importable válida de Question2Tex. Escoje entre 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' o 'package.path.MyQuestion2TexCustomClass'"

Expand Down
6 changes: 3 additions & 3 deletions survey/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-09 17:13+0000\n"
"POT-Creation-Date: 2020-02-09 20:07+0000\n"
"PO-Revision-Date: 2018-04-01 11:49+0000\n"
"Last-Translator: b' <>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -100,11 +100,11 @@ msgstr "mise en relation avec la question"
msgid "right"
msgstr "à droite"

#: survey/exporter/tex/survey2tex.py:66
#: survey/exporter/tex/survey2tex.py:72
msgid "We could not render a chart because the type"
msgstr "Nous n'avons pas pu générer un graphique car le type"

#: survey/exporter/tex/survey2tex.py:69
#: survey/exporter/tex/survey2tex.py:75
msgid "is not a standard type nor the path to an importable valid Question2Tex child class. Choose between 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' or 'package.path.MyQuestion2TexCustomClass'"
msgstr "n'est pas un type standard, ni le chemin d'une classe fille de Question2Tex importable. Choisissez entre 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' ou 'package.chemin.MaClasseQuestion2TexPerso'"

Expand Down
6 changes: 3 additions & 3 deletions survey/locale/ja/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-09 17:13+0000\n"
"POT-Creation-Date: 2020-02-09 20:07+0000\n"
"PO-Revision-Date: 2018-04-09 00:52+0000\n"
"Last-Translator: b' <[email protected]>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -100,11 +100,11 @@ msgstr "質問に関連して"
msgid "right"
msgstr "右"

#: survey/exporter/tex/survey2tex.py:66
#: survey/exporter/tex/survey2tex.py:72
msgid "We could not render a chart because the type"
msgstr "チャートを描画できません。何故ならタイプ"

#: survey/exporter/tex/survey2tex.py:69
#: survey/exporter/tex/survey2tex.py:75
msgid "is not a standard type nor the path to an importable valid Question2Tex child class. Choose between 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' or 'package.path.MyQuestion2TexCustomClass'"
msgstr "は標準タイプでもインポート可能で有効なQuestion2Tex子クラスへのパスでもありません。 「raw」、「sankey」、「pie」、「cloud」、 「square」、「polar」または「package.path.MyQuestion2TexCustomClass」の中から選択してください。"

Expand Down
6 changes: 3 additions & 3 deletions survey/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-09 17:13+0000\n"
"POT-Creation-Date: 2020-02-09 20:07+0000\n"
"PO-Revision-Date: 2019-03-10 22:53+0230\n"
"Last-Translator: b' <[email protected]>'\n"
"Language-Team: \n"
Expand Down Expand Up @@ -104,11 +104,11 @@ msgstr "в связи с вопросом"
msgid "right"
msgstr "правильно"

#: survey/exporter/tex/survey2tex.py:66
#: survey/exporter/tex/survey2tex.py:72
msgid "We could not render a chart because the type"
msgstr "Мы не смогли отобразить диаграмму, потому что тип"

#: survey/exporter/tex/survey2tex.py:69
#: survey/exporter/tex/survey2tex.py:75
msgid "is not a standard type nor the path to an importable valid Question2Tex child class. Choose between 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' or 'package.path.MyQuestion2TexCustomClass'"
msgstr "не является стандартным типом или путем к импортируемому допустимому текстовому дочернему классу Question2Tex. Выбрать между 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' o 'package.path.MyQuestion2TexCustomClass'"

Expand Down
6 changes: 3 additions & 3 deletions survey/locale/zh/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-09 17:13+0000\n"
"POT-Creation-Date: 2020-02-09 20:07+0000\n"
"PO-Revision-Date: 2018-04-09 00:52+0000\n"
"Last-Translator: Zhu Sheng Li <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -100,11 +100,11 @@ msgstr "和此问题相关"
msgid "right"
msgstr "右"

#: survey/exporter/tex/survey2tex.py:66
#: survey/exporter/tex/survey2tex.py:72
msgid "We could not render a chart because the type"
msgstr "我们无法生成图表,因为类型"

#: survey/exporter/tex/survey2tex.py:69
#: survey/exporter/tex/survey2tex.py:75
msgid "is not a standard type nor the path to an importable valid Question2Tex child class. Choose between 'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' or 'package.path.MyQuestion2TexCustomClass'"
msgstr "既不是标准类型,也不是可导入的有效 Question2Tex 子类的路径。请在'raw', 'sankey', 'pie', 'cloud', 'square', 'polar' 或 'package.path.MyQuestion2TexCustomClass' 中选择。"

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 0e8acba

Please sign in to comment.