diff --git a/survey/exporter/tex/survey2tex.py b/survey/exporter/tex/survey2tex.py index 3ef4a5ea..a9430b88 100755 --- a/survey/exporter/tex/survey2tex.py +++ b/survey/exporter/tex/survey2tex.py @@ -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 @@ -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) @@ -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 diff --git a/survey/locale/de/LC_MESSAGES/django.po b/survey/locale/de/LC_MESSAGES/django.po index 0f7e5404..f5d56e0e 100644 --- a/survey/locale/de/LC_MESSAGES/django.po +++ b/survey/locale/de/LC_MESSAGES/django.po @@ -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 \n" @@ -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'" diff --git a/survey/locale/es/LC_MESSAGES/django.po b/survey/locale/es/LC_MESSAGES/django.po index 4049add1..4cf0fed6 100644 --- a/survey/locale/es/LC_MESSAGES/django.po +++ b/survey/locale/es/LC_MESSAGES/django.po @@ -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" @@ -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'" diff --git a/survey/locale/fr/LC_MESSAGES/django.po b/survey/locale/fr/LC_MESSAGES/django.po index 52f6e5e0..2f5d5893 100644 --- a/survey/locale/fr/LC_MESSAGES/django.po +++ b/survey/locale/fr/LC_MESSAGES/django.po @@ -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 \n" @@ -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'" diff --git a/survey/locale/ja/LC_MESSAGES/django.po b/survey/locale/ja/LC_MESSAGES/django.po index 4e0dbdb9..9f5c4f3c 100644 --- a/survey/locale/ja/LC_MESSAGES/django.po +++ b/survey/locale/ja/LC_MESSAGES/django.po @@ -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' '\n" "Language-Team: LANGUAGE \n" @@ -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」の中から選択してください。" diff --git a/survey/locale/ru/LC_MESSAGES/django.po b/survey/locale/ru/LC_MESSAGES/django.po index cd73aa83..2a7722a5 100644 --- a/survey/locale/ru/LC_MESSAGES/django.po +++ b/survey/locale/ru/LC_MESSAGES/django.po @@ -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' '\n" "Language-Team: \n" @@ -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'" diff --git a/survey/locale/zh/LC_MESSAGES/django.po b/survey/locale/zh/LC_MESSAGES/django.po index cefe7776..a8a20e54 100644 --- a/survey/locale/zh/LC_MESSAGES/django.po +++ b/survey/locale/zh/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \n" @@ -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' 中选择。" diff --git a/tex/pgf-pie.sty b/survey/static/survey/sty/pgf-pie.sty similarity index 100% rename from tex/pgf-pie.sty rename to survey/static/survey/sty/pgf-pie.sty diff --git a/tex/pgfplots.sty b/survey/static/survey/sty/pgfplots.sty similarity index 100% rename from tex/pgfplots.sty rename to survey/static/survey/sty/pgfplots.sty