Skip to content
Snippets Groups Projects
Commit 78f8b819 authored by Alexis Filipozzi's avatar Alexis Filipozzi
Browse files

get text from title and remove useless tag

parent fc6ff8cb
No related branches found
No related tags found
No related merge requests found
...@@ -8,3 +8,27 @@ Pour installer lxml il faut installer paquets : ...@@ -8,3 +8,27 @@ Pour installer lxml il faut installer paquets :
- libxml2-dev - libxml2-dev
- python2.7-dev - python2.7-dev
- libxslt1-dev - libxslt1-dev
Il faudra fournir un fichier de style guide-style.protoxml à la racine du dossier traduit, par exemple :
<?xml version="1.0" encoding="UTF-8"?>
<package name="com.daysofwonder.dowml">
<message class="DOWMLStyle">
<text_attributes>
<size>22</size>
<font>TimesNewRomanPSMT</font>
<alignment>NEAR</alignment>
<vertical_alignment>CENTER</vertical_alignment>
</text_attributes>
<layout>
<!--<size relative_width="1" relative_height="1"/>-->
<secondary_alignment>CENTER</secondary_alignment>
<weight>1</weight>
</layout>
</message>
</package>
\ No newline at end of file
...@@ -55,7 +55,8 @@ class Formatter: ...@@ -55,7 +55,8 @@ class Formatter:
self.format_body() self.format_body()
def format_extra(self): def format_extra(self):
assert(self._data._title) if not self._data._title:
self._data._title = ""
title = etree.Element("property") title = etree.Element("property")
title.attrib["key"] = "Title" title.attrib["key"] = "Title"
......
...@@ -34,8 +34,19 @@ class Parser: ...@@ -34,8 +34,19 @@ class Parser:
def parse_title(self): def parse_title(self):
title = self._soup.h1 title = self._soup.h1
if title: title_string = self.get_string_from_content(title)
self._data._title = title.string self._data._title = title_string
def get_string_from_content(self, content):
result = ""
for c in content:
name = c.name
if not name:
result += c.string
else:
result += self.get_string_from_content(c)
return result
def parse_content(self, content, lvl = 0): def parse_content(self, content, lvl = 0):
try: try:
......
...@@ -55,6 +55,7 @@ def parse_format_and_write_file(filename, dest, level): ...@@ -55,6 +55,7 @@ def parse_format_and_write_file(filename, dest, level):
formatter.write_to_file(dest) formatter.write_to_file(dest)
except Exception as e: except Exception as e:
print "Error with file while fomatting: " + str(filename) print "Error with file while fomatting: " + str(filename)
print "Error message: " + str(e)
if __name__=="__main__": if __name__=="__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment