Merge lp:~fabien-morin/unifield-server/fm-us-2339-new into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4237
Proposed branch: lp:~fabien-morin/unifield-server/fm-us-2339-new
Merge into: lp:unifield-server
Diff against target: 243 lines (+83/-46)
7 files modified
bin/addons/msf_profile/i18n/fr_MF.po (+7/-0)
bin/addons/report_webkit/webkit_report.py (+51/-3)
bin/addons/spreadsheet_xml/spreadsheet_xml.py (+1/-1)
bin/addons/sync_client/backup.py (+2/-2)
bin/tools/misc.py (+1/-1)
setup.py (+13/-13)
setup_py2exe_custom.py (+8/-26)
To merge this branch: bzr merge lp:~fabien-morin/unifield-server/fm-us-2339-new
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+317788@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeff Allen (jr.allen) :
4206. By Fabien MORIN

US-2339 [FIX] no need to parse two times the same xml document

4207. By Fabien MORIN

US-2339 [MERGE] with latest trunk

4208. By Fabien MORIN

US-2339 [FIX] revert us-2374 as it breaks the AIO generation

4209. By Fabien MORIN

US-2339 [IMP] avoid crashing by ensuring name and sheet_name cannot be None

4210. By Fabien MORIN

US-2339 [ADD] translation for the Sheet name

4211. By Fabien MORIN

US-2339 [FIX] if xml is modified in any of this two check :
- worksheet name
- malformed data
the modified xml should be returned.
If not modified, return the original xml

4212. By Fabien MORIN

US-2339 [FIX] getiterator is depreciated since long time, use iter instead
[FIX] iter (and getiterator now) cannot be restricted by
receiving a QName object but only (from
http://lxml.de/api/lxml.etree._Element-class.html#iter)
"Can be restricted to find only elements with a specific tag: pass
"{ns}localname" as tag. Either or both of ns and localname can be * for a
wildcard; ns can be empty for no namespace. "localname" is equivalent to
"{}localname" (i.e. no namespace) but "*" is "{*}*" (any or no namespace), not
"{}*".

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
--- bin/addons/msf_profile/i18n/fr_MF.po 2017-02-20 16:10:18 +0000
+++ bin/addons/msf_profile/i18n/fr_MF.po 2017-02-21 15:07:51 +0000
@@ -76441,3 +76441,10 @@
76441#, python-format76441#, python-format
76442msgid "No journal found to book the reversal FX entry."76442msgid "No journal found to book the reversal FX entry."
76443msgstr "Pas de journal trouvé pour enregistrer l'annulation de l'écriture de différence de change."76443msgstr "Pas de journal trouvé pour enregistrer l'annulation de l'écriture de différence de change."
76444
76445#. module: report_webkit
76446#: code:addons/report_webkit/webkit_report.py:435
76447#: code:addons/report_webkit/webkit_report.py:466
76448#, python-format
76449msgid "Sheet 1"
76450msgstr "Feuille 1"
7644476451
=== modified file 'bin/addons/report_webkit/webkit_report.py'
--- bin/addons/report_webkit/webkit_report.py 2017-02-09 13:41:23 +0000
+++ bin/addons/report_webkit/webkit_report.py 2017-02-21 15:07:51 +0000
@@ -423,6 +423,26 @@
423423
424 return result424 return result
425425
426 def sanitizeWorksheetName(self, name):
427 '''
428 according to microsoft documentation :
429 https://msdn.microsoft.com/en-us/library/office/aa140066(v=office.10).aspx#odc_xmlss_ss:worksheet
430 The following caracters are not allowed : /, \, ?, *, [, ]
431 It also seems that microsoft excel do not accept Worksheet name longer
432 than 31 characters.
433 '''
434 if not name:
435 return _('Sheet 1')
436 replacement_char = '-'
437 not_allowed_char_list = ['/', '\\', '?', '*', '[', ']']
438 new_name = name
439 if set(new_name).intersection(not_allowed_char_list):
440 for char in not_allowed_char_list:
441 if char in new_name:
442 new_name = new_name.replace(char, replacement_char)
443
444 return new_name[:31]
445
426 def check_malformed_xml_spreadsheet(self, xml_string, report_name):446 def check_malformed_xml_spreadsheet(self, xml_string, report_name):
427 '''Check that the xml spreadsheet doesn't contain447 '''Check that the xml spreadsheet doesn't contain
428 node <Date ss:Type="DateTime"> with 'False' in the values448 node <Date ss:Type="DateTime"> with 'False' in the values
@@ -431,10 +451,37 @@
431 logger = logging.getLogger('mako_spreadsheet')451 logger = logging.getLogger('mako_spreadsheet')
432 file_dom = etree.fromstring(xml_string)452 file_dom = etree.fromstring(xml_string)
433 namespaces = {453 namespaces = {
454 'o': 'urn:schemas-microsoft-com:office:office',
455 'x': 'urn:schemas-microsoft-com:office:excel',
434 'ss': 'urn:schemas-microsoft-com:office:spreadsheet',456 'ss': 'urn:schemas-microsoft-com:office:spreadsheet',
435 'spreadsheet': 'urn:schemas-microsoft-com:office:spreadsheet'457 'html': 'http://www.w3.org/TR/REC-html40'
436 }458 }
437 data_time_elements = file_dom.xpath('//spreadsheet:Data[@ss:Type="DateTime"]',459
460 spreadsheet_elements = file_dom.xpath('//ss:Worksheet',
461 namespaces=namespaces)
462
463 xml_modified = False
464 sheet_name_dict = {}
465 count = 0
466 for sheet in spreadsheet_elements:
467 sheet_name = sheet.get('{%(ss)s}Name' % namespaces, _('Sheet 1'))
468 new_name = self.sanitizeWorksheetName(sheet_name)
469 if new_name != sheet_name:
470 # if the sheet name already exists, modify it to add
471 # a counter to the name
472 if new_name in sheet_name_dict:
473 sheet_name_dict[new_name] += 1
474 count = sheet_name_dict[new_name]
475 new_name = '%s_%s' % (new_name[:28], count)
476 else:
477 sheet_name_dict[new_name] = 1
478 sheet.attrib['{urn:schemas-microsoft-com:office:spreadsheet}Name'] = new_name
479 xml_modified = True
480 else:
481 if new_name not in sheet_name_dict:
482 sheet_name_dict[new_name] = 1
483
484 data_time_elements = file_dom.xpath('//ss:Data[@ss:Type="DateTime"]',
438 namespaces=namespaces)485 namespaces=namespaces)
439 element_to_remove = []486 element_to_remove = []
440 for element in data_time_elements:487 for element in data_time_elements:
@@ -446,7 +493,8 @@
446 # if a malformed node exists, replace it with an empty String cell493 # if a malformed node exists, replace it with an empty String cell
447 element.attrib['{urn:schemas-microsoft-com:office:spreadsheet}Type'] = 'String'494 element.attrib['{urn:schemas-microsoft-com:office:spreadsheet}Type'] = 'String'
448 element.text = ''495 element.text = ''
449 if element_to_remove:496 xml_modified = True
497 if xml_modified:
450 # return modified xml498 # return modified xml
451 return etree.tostring(file_dom, xml_declaration=True, encoding="utf-8")499 return etree.tostring(file_dom, xml_declaration=True, encoding="utf-8")
452 return xml_string500 return xml_string
453501
=== modified file 'bin/addons/spreadsheet_xml/spreadsheet_xml.py'
--- bin/addons/spreadsheet_xml/spreadsheet_xml.py 2016-08-26 10:10:58 +0000
+++ bin/addons/spreadsheet_xml/spreadsheet_xml.py 2017-02-21 15:07:51 +0000
@@ -137,7 +137,7 @@
137137
138 def getRows(self,worksheet=1):138 def getRows(self,worksheet=1):
139 table = self.xmlobj.xpath('//ss:Worksheet[%d]/ss:Table[1]'%(worksheet, ), **self.xa)139 table = self.xmlobj.xpath('//ss:Worksheet[%d]/ss:Table[1]'%(worksheet, ), **self.xa)
140 return SpreadsheetRow(table[0].getiterator(etree.QName(self.defaultns, 'Row')))140 return SpreadsheetRow(table[0].iter('{%s}Row' % self.defaultns))
141141
142 def enc(self, s):142 def enc(self, s):
143 if isinstance(s, unicode):143 if isinstance(s, unicode):
144144
=== modified file 'bin/addons/sync_client/backup.py'
--- bin/addons/sync_client/backup.py 2017-02-16 15:52:37 +0000
+++ bin/addons/sync_client/backup.py 2017-02-21 15:07:51 +0000
@@ -76,12 +76,12 @@
76 return 'UNKNOWN_VERSION'76 return 'UNKNOWN_VERSION'
7777
78 def _set_pg_psw_env_var(self):78 def _set_pg_psw_env_var(self):
79 if tools.config['db_password'] and not os.environ.get('PGPASSWORD', ''):79 if os.name == 'nt' and not os.environ.get('PGPASSWORD', ''):
80 os.environ['PGPASSWORD'] = tools.config['db_password']80 os.environ['PGPASSWORD'] = tools.config['db_password']
81 self._pg_psw_env_var_is_set = True81 self._pg_psw_env_var_is_set = True
8282
83 def _unset_pg_psw_env_var(self):83 def _unset_pg_psw_env_var(self):
84 if self._pg_psw_env_var_is_set:84 if os.name == 'nt' and self._pg_psw_env_var_is_set:
85 os.environ['PGPASSWORD'] = ''85 os.environ['PGPASSWORD'] = ''
8686
87 def exp_dump_for_state(self, cr, uid, state, context=None, force=False):87 def exp_dump_for_state(self, cr, uid, state, context=None, force=False):
8888
=== modified file 'bin/tools/misc.py'
--- bin/tools/misc.py 2017-02-17 15:44:19 +0000
+++ bin/tools/misc.py 2017-02-21 15:07:51 +0000
@@ -142,7 +142,7 @@
142 return None142 return None
143143
144def _set_env_pg(remove=False):144def _set_env_pg(remove=False):
145 if config['db_password']:145 if os.name == 'nt':
146 if not remove and not os.environ.get('PGPASSWORD', ''):146 if not remove and not os.environ.get('PGPASSWORD', ''):
147 os.environ['PGPASSWORD'] = config['db_password']147 os.environ['PGPASSWORD'] = config['db_password']
148 if remove and os.environ.get('PGPASSWORD'):148 if remove and os.environ.get('PGPASSWORD'):
149149
=== modified file 'setup.py'
--- setup.py 2017-02-16 15:52:37 +0000
+++ setup.py 2017-02-21 15:07:51 +0000
@@ -58,7 +58,7 @@
58 "packages": [58 "packages": [
59 "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",59 "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
60 "lxml.objectify", "decimal", "xml", "xml", "xml.dom",60 "lxml.objectify", "decimal", "xml", "xml", "xml.dom",
61 "encodings", "dateutil", "wizard", "PIL", "pyparsing",61 "encodings", "dateutil", "wizard", "pychart", "PIL", "pyparsing",
62 "pydot", "asyncore","asynchat", "reportlab", "vobject",62 "pydot", "asyncore","asynchat", "reportlab", "vobject",
63 "HTMLParser", "select", "mako", "poplib",63 "HTMLParser", "select", "mako", "poplib",
64 "imaplib", "smtplib", "email", "yaml", "DAV",64 "imaplib", "smtplib", "email", "yaml", "DAV",
@@ -240,18 +240,18 @@
240 },240 },
241 package_dir = find_package_dirs(),241 package_dir = find_package_dirs(),
242 install_requires = [242 install_requires = [
243 'lxml==2.2.4',243 'lxml',
244 'mako==0.2.5',244 'mako',
245 'python-dateutil==2.5.3',245 'python-dateutil',
246 'psycopg2==2.0.13',246 'psycopg2',
247 'pydot==1.0.2',247 'pychart',
248 'pytz==2010b0',248 'pydot',
249 'reportlab==2.4',249 'pytz',
250 'pyyaml==3.12',250 'reportlab',
251 'egenix-mx-base==3.2.9',251 'caldav',
252 'passlib==1.6.5',252 'pyyaml',
253 'bcrypt==3.1.1',253 'pywebdav',
254 'xlwt==1.1.2',254 'feedparser',
255 ],255 ],
256 extras_require={256 extras_require={
257 'SSL' : ['pyopenssl'],257 'SSL' : ['pyopenssl'],
258258
=== modified file 'setup_py2exe_custom.py'
--- setup_py2exe_custom.py 2017-02-16 15:52:37 +0000
+++ setup_py2exe_custom.py 2017-02-21 15:07:51 +0000
@@ -24,25 +24,7 @@
2424
25import os25import os
26import tempfile26import tempfile
27import sys27from py2exe.build_exe import py2exe as build_exe, fancy_split
28
29if sys.platform == 'nt':
30 from py2exe.build_exe import py2exe as build_exe, fancy_split
31else:
32 # fake it for non-Windows, so that setup.py can be run for
33 # installing dependencies.
34 class _be(dict):
35 def __init__(self, arg1,arg2,arg3):
36 pass
37 def __dir__(self):
38 return tuple(self)
39 def __getattribute__(self, name):
40 if name == 'user_options':
41 return []
42 else:
43 raise AttributeError(name)
44 build_exe = _be(1, 2, 3)
45 fancy_split = None
4628
47def fixup_data_pytz_zoneinfo():29def fixup_data_pytz_zoneinfo():
48 r = {}30 r = {}
@@ -54,8 +36,8 @@
54 return r.items()36 return r.items()
5537
56def byte_compile_noop(py_files, optimize=0, force=0,38def byte_compile_noop(py_files, optimize=0, force=0,
57 target_dir=None, verbose=1, dry_run=0,39 target_dir=None, verbose=1, dry_run=0,
58 direct=None):40 direct=None):
5941
60 compiled_files = []42 compiled_files = []
61 from distutils.dir_util import mkpath43 from distutils.dir_util import mkpath
@@ -177,11 +159,11 @@
177 # Run fake compilation - just copy raw .py file into their159 # Run fake compilation - just copy raw .py file into their
178 # destination directory160 # destination directory
179 self.no_compiled_files = byte_compile_noop(py_files,161 self.no_compiled_files = byte_compile_noop(py_files,
180 target_dir=self.collect_dir,162 target_dir=self.collect_dir,
181 optimize=self.optimize,163 optimize=self.optimize,
182 force=0,164 force=0,
183 verbose=self.verbose,165 verbose=self.verbose,
184 dry_run=self.dry_run)166 dry_run=self.dry_run)
185167
186 # Force relocate of specific packages data within collected libs dir168 # Force relocate of specific packages data within collected libs dir
187 def fixup_location(l):169 def fixup_location(l):

Subscribers

People subscribed via source and target branches