From ae6ba71dd0784c5a29ba69b1231340241297cf8a Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Fri, 5 May 2017 20:52:24 +0200 Subject: [PATCH] Fixed the lang miss, not sure this commit is the dreamt solution --- generator/file_parser.py | 8 ++++++-- sites/example_website/Poetry/poetry1.txt | 2 +- test.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/generator/file_parser.py b/generator/file_parser.py index 954d2be..d6804fb 100644 --- a/generator/file_parser.py +++ b/generator/file_parser.py @@ -39,6 +39,8 @@ class WebPage(object): def get_next_line(self,filter_lang="*"): "Get a line of text, with a filter if needed" for line,lang in self.content: + if line.find("rose")>0: + print lang,line,filter_lang,self.match_with_lang(lang,filter_lang) if self.match_with_lang(lang,filter_lang): yield line @@ -49,16 +51,17 @@ class WebPage(object): return 1 return 0 - def get_text(self,filter): + def get_text(self,filter_lang): "Get the whole text matching the filter, note that the * filter will ONLY match if the text is meant for all, not all text" text="" - for line in self.get_next_line(filter): + for line in self.get_next_line(filter_lang): text+=line text+=os.linesep return text def add_variable(self,var,value): """Add the folowing variable and update the necessary constants + Note that it's one of the only ways to add a language to the list_of_lang Takes a variable (with an eventual langague tag) and it's value""" var,lang=create_lang(var) if var in self.reserved: @@ -156,6 +159,7 @@ def parse_file(file_name): print " >",line except: traceback.print_exc() + page.list_of_lang.update(used_langs) # Not sure this fix is actually a good idea, could just force adding langs in variables return page re_config_line=re.compile("(?P.+): (?P.*)") diff --git a/sites/example_website/Poetry/poetry1.txt b/sites/example_website/Poetry/poetry1.txt index 945c25c..7e0f4dc 100644 --- a/sites/example_website/Poetry/poetry1.txt +++ b/sites/example_website/Poetry/poetry1.txt @@ -4,7 +4,7 @@ author_*: Max ---- __en__ -A Rose flew +A rose flew Flower of beauty Why are you so pretty diff --git a/test.py b/test.py index fb5f27e..bde64ca 100644 --- a/test.py +++ b/test.py @@ -173,11 +173,11 @@ class testTree(simple): self.addSucess() self.currentTest="tree:Poetry:content" - if poem1.get_content("fr")=="Une rose qui passe\nQuelle est bien belle\nMais pourquoi donc\nEsceque tu est jolie": self.addSucess() else: self.addFailure("can't load content") + testVky=group(name="vkyWeb_all",terminal=term,verbose=1,align=42) #testConfig=group(name="config",terminal=term,prefix="| ")