Merge lp:~unifield-team/unifield-server/us-1664 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4055
Proposed branch: lp:~unifield-team/unifield-server/us-1664
Merge into: lp:unifield-server
Diff against target: 93 lines (+50/-4)
3 files modified
bin/addons/msf_doc_import/wizard/wizard_po_simulation_screen.py (+26/-4)
bin/addons/msf_profile/i18n/fr_MF.po (+17/-0)
bin/tools/import_po.dtd (+7/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-1664
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+310551@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/msf_doc_import/wizard/wizard_po_simulation_screen.py'
2--- bin/addons/msf_doc_import/wizard/wizard_po_simulation_screen.py 2016-08-23 12:54:03 +0000
3+++ bin/addons/msf_doc_import/wizard/wizard_po_simulation_screen.py 2016-11-10 16:13:50 +0000
4@@ -25,14 +25,19 @@
5 import base64
6 import time
7 import xml.etree.ElementTree as ET
8+from lxml import etree
9+from lxml.etree import XMLSyntaxError
10 import logging
11+import os
12
13 from mx import DateTime
14
15+
16 # Server imports
17 from osv import osv
18 from osv import fields
19 from tools.translate import _
20+import tools
21
22 # Addons imports
23 from msf_order_date import TRANSPORT_TYPE
24@@ -343,10 +348,27 @@
25 if not excel_file.getWorksheets():
26 raise osv.except_osv(_('Error'), _('The given file is not a valid Excel 2003 Spreadsheet file !'))
27 else:
28- xml_file = base64.decodestring(wiz.file_to_import)
29- root = ET.fromstring(xml_file)
30- if root.tag != 'data':
31- raise osv.except_osv(_('Error'), _('The given file is not a valid XML file !'))
32+ try:
33+ xml_file = base64.decodestring(wiz.file_to_import)
34+ dtd_path = os.path.join(tools.config['root_path'], 'tools/import_po.dtd')
35+ dtd = etree.DTD(dtd_path)
36+ tree = etree.fromstring(xml_file)
37+ except XMLSyntaxError as ex:
38+ raise osv.except_osv(_('Error'), _('The given file is not a valid XML file !\nTechnical details:\n%s') % str(ex))
39+
40+ if not dtd.validate(tree):
41+ # build error message:
42+ error_msg = ""
43+ for line_obj in dtd.error_log.filter_from_errors():
44+ line = str(line_obj)
45+ err_line = line.split(':')[1]
46+ err_str = line.split(':')[-1]
47+ err_type = line.split(':')[5]
48+ if err_type != 'DTD_UNKNOWN_ELEM':
49+ continue
50+ error_msg += "Line %s: The tag '%s' is not supported\n" % (err_line, err_str.split()[-1])
51+
52+ raise osv.except_osv(_('Error'), _("The given XML file is not structured as expected in the DTD:\n %s") % error_msg)
53
54 self.write(cr, uid, ids, {'state': 'simu_progress'}, context=context)
55 cr.commit()
56
57=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
58--- bin/addons/msf_profile/i18n/fr_MF.po 2016-10-25 09:13:52 +0000
59+++ bin/addons/msf_profile/i18n/fr_MF.po 2016-11-10 16:13:50 +0000
60@@ -74689,3 +74689,20 @@
61 msgid "You can't search on this object without using at least one exact search term (precede your search with the character '=')."
62 msgstr "Vous ne pouvez pas exécuter de recherche sur cet objet sans utiliser au moins une recherche exacte (ajoutez le caractère = devant votre filtre)."
63
64+#. module: msf_doc_import
65+#: code:addons/msf_doc_import/wizard/wizard_po_simulation_screen.py:357
66+#, python-format
67+msgid "The given file is not a valid XML file !\n"
68+"Technical details:\n"
69+"%s"
70+msgstr "Le fichier XML n'est pas valide.\n"
71+"Détails techniques:\n"
72+"%s"
73+
74+#. module: msf_doc_import
75+#: code:addons/msf_doc_import/wizard/wizard_po_simulation_screen.py:371
76+#, python-format
77+msgid "The given XML file is not structured as expected in the DTD:\n"
78+" %s"
79+msgstr "La structure du fichier XML ne respecte pas la déclaration DTD:\n"
80+" %s"
81\ No newline at end of file
82
83=== added file 'bin/tools/import_po.dtd'
84--- bin/tools/import_po.dtd 1970-01-01 00:00:00 +0000
85+++ bin/tools/import_po.dtd 2016-11-10 16:13:50 +0000
86@@ -0,0 +1,7 @@
87+<!ELEMENT data (record+)>
88+<!ELEMENT record (field+)>
89+<!ELEMENT field ANY>
90+<!ATTLIST record key CDATA #IMPLIED>
91+<!ATTLIST record model CDATA #IMPLIED>
92+<!ATTLIST field name CDATA #REQUIRED>
93+<!ATTLIST field key CDATA #IMPLIED>

Subscribers

People subscribed via source and target branches

to all changes: