diff options
| author | xmo-odoo <xmo@odoo.com> | 2017-05-10 09:39:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-10 09:39:55 +0200 |
| commit | fffaf735f58f1ac57781c095eb552de6d1fcdc47 (patch) | |
| tree | 88ab0ab65430d871862a836524e0ecc890d1674d /odoo/tools/translate.py | |
| parent | 10eee18a047d35305dc46282e610e88936d81ffc (diff) | |
[FIX] P3: list -> iterable builtins (#16811)
In Python 3:
* various builtins and dict methods were changed to return
view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
removed altogether
This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).
Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.
issue #8530
Diffstat (limited to 'odoo/tools/translate.py')
| -rw-r--r-- | odoo/tools/translate.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py index dcdb95d0955..b2996af6ae3 100644 --- a/odoo/tools/translate.py +++ b/odoo/tools/translate.py @@ -255,7 +255,7 @@ def translate_xml_node(node, callback, method, parser=None): append_content(result, translate_content(todo) if todo_has_text else todo) # translate the required attributes - for name, value in result.items(): + for name, value in pycompat.items(result.attrib): if name in TRANSLATED_ATTRS: result.set(name, translate_text(value) or value) @@ -660,7 +660,7 @@ def trans_export(lang, modules, buffer, format, cr): row.setdefault('tnrs', []).append((type, name, res_id)) row.setdefault('comments', set()).update(comments) - for src, row in sorted(grouped_rows.items()): + for src, row in sorted(pycompat.items(grouped_rows)): if not lang: # translation template, so no translation value row['translation'] = '' @@ -674,7 +674,7 @@ def trans_export(lang, modules, buffer, format, cr): module = row[0] rows_by_module.setdefault(module, []).append(row) tmpdir = tempfile.mkdtemp() - for mod, modrows in rows_by_module.items(): + for mod, modrows in pycompat.items(rows_by_module): tmpmoddir = join(tmpdir, mod, 'i18n') os.makedirs(tmpmoddir) pofilename = (lang if lang else mod) + ".po" + ('t' if not lang else '') @@ -1073,7 +1073,7 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True, dic = dict.fromkeys(('type', 'name', 'res_id', 'src', 'value', 'comments', 'imd_model', 'imd_name', 'module')) dic['lang'] = lang - dic.update(zip(fields, row)) + dic.update(pycompat.izip(fields, row)) # discard the target from the POT targets. src = dic['src'] @@ -1111,7 +1111,7 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True, # Then process the entries implied by the POT file (which is more # correct w.r.t. the targets) if some of them remain. pot_rows = [] - for src, target in pot_targets.iteritems(): + for src, target in pycompat.items(pot_targets): if target.value: for type, name, res_id in target.targets: pot_rows.append((type, name, res_id, src, target.value, target.comments)) |
