From 31fcf1e86a1c70fff370979b70a6b06bfe355465 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Tue, 17 Oct 2017 10:20:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B0=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D0=B5=D0=B3=D0=BE=D1=80=D0=B8=D0=B9=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20world=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/calculate/lib/cl_template.py | 4 ++++ pym/calculate/lib/format/world.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pym/calculate/lib/cl_template.py b/pym/calculate/lib/cl_template.py index 58eef7f..eb35712 100644 --- a/pym/calculate/lib/cl_template.py +++ b/pym/calculate/lib/cl_template.py @@ -1805,6 +1805,10 @@ class TemplateFormat(_error): def set_parent(self, parent): self.parent = parent + @property + def template_name(self): + return self.parent.nameFileTemplate + def getIni(self, key, nameFile=""): return self.parent.functObj.getIni(key, nameFile) diff --git a/pym/calculate/lib/format/world.py b/pym/calculate/lib/format/world.py index 5083699..7f39782 100644 --- a/pym/calculate/lib/format/world.py +++ b/pym/calculate/lib/format/world.py @@ -18,6 +18,7 @@ import sys from calculate.lib.cl_template import TemplateFormat from calculate.lib.utils.text import _u from calculate.lib.cl_lang import setLocalTranslate +from os import path _ = lambda x: x setLocalTranslate('cl_lib3', sys.modules[__name__]) @@ -55,9 +56,16 @@ class world(TemplateFormat): def textToXML(self): """Создание документа из текста self.text """ + category = path.basename(path.dirname(self.template_name)) + + def autocategory(name): + if name and "/" not in name: + prefix, op, name = name.rpartition("!") + return "%s%s%s/%s" % (prefix, op, category, name) + return name try: doc = filter(None, - [x.strip() for x in self.text.split("\n") + [autocategory(x.strip()) for x in self.text.split("\n") if not x.startswith("#")]) except ValueError: doc = False