Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
html2protoxml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexis Filipozzi
html2protoxml
Commits
78f8b819
Commit
78f8b819
authored
9 years ago
by
Alexis Filipozzi
Browse files
Options
Downloads
Patches
Plain Diff
get text from title and remove useless tag
parent
fc6ff8cb
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.txt
+25
-1
25 additions, 1 deletion
README.txt
formatter.py
+2
-1
2 additions, 1 deletion
formatter.py
html_parser.py
+13
-2
13 additions, 2 deletions
html_parser.py
main.py
+1
-0
1 addition, 0 deletions
main.py
with
41 additions
and
4 deletions
README.txt
+
25
−
1
View file @
78f8b819
...
@@ -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
This diff is collapsed.
Click to expand it.
formatter.py
+
2
−
1
View file @
78f8b819
...
@@ -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
"
...
...
This diff is collapsed.
Click to expand it.
html_parser.py
+
13
−
2
View file @
78f8b819
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
main.py
+
1
−
0
View file @
78f8b819
...
@@ -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__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment