summaryrefslogtreecommitdiff
path: root/odoo/modules/graph.py
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2017-08-18 18:43:46 +0200
committerOlivier Dony <odo@openerp.com>2017-08-20 23:25:54 +0200
commit695716efb0f79f9a0e716952b1dcd433d866371a (patch)
tree1b582a3469d12fc716d6252b4f239f0cd40da9e4 /odoo/modules/graph.py
parent589c0d7e2c3a44adc5d26aac8af08c0d06b97d5a (diff)
[FIX] P3: remove pycompat.{keys,items,values} helpers
Now that we're closer to switching to P3 for good, these helpers have outlived their usefulness, and mostly add noise. All remaining dict.iter*() or dict.view*() must be converted to the normal keys(), values() or items() calls. Whenever the result is likely to be used for more than the scope of a loop, or when the dict needs to be modified during iteration, the calls must be wrapped in a ``list()``, to protect the new P3 semantics. Those cases are very exceptional. Also removed some dead code or improved the API to remove unnecessary conversions.
Diffstat (limited to 'odoo/modules/graph.py')
-rw-r--r--odoo/modules/graph.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/odoo/modules/graph.py b/odoo/modules/graph.py
index 731b6f6557a..0f2e329fab9 100644
--- a/odoo/modules/graph.py
+++ b/odoo/modules/graph.py
@@ -8,7 +8,6 @@ import logging
import odoo
import odoo.tools as tools
-from odoo.tools import pycompat
_logger = logging.getLogger(__name__)
@@ -36,7 +35,7 @@ class Graph(dict):
return
# update the graph with values from the database (if exist)
## First, we set the default values for each package in graph
- additional_data = {key: {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'installed_version': None} for key in pycompat.keys(self)}
+ additional_data = {key: {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'installed_version': None} for key in self.keys()}
## Then we get the values from the database
cr.execute('SELECT name, id, state, demo AS dbdemo, latest_version AS installed_version'
' FROM ir_module_module'
@@ -46,8 +45,8 @@ class Graph(dict):
## and we update the default values with values from the database
additional_data.update((x['name'], x) for x in cr.dictfetchall())
- for package in pycompat.values(self):
- for k, v in pycompat.items(additional_data[package.name]):
+ for package in self.values():
+ for k, v in additional_data[package.name].items():
setattr(package, k, v)
def add_module(self, cr, module, force=None):
@@ -102,9 +101,9 @@ class Graph(dict):
def __iter__(self):
level = 0
- done = set(pycompat.keys(self))
+ done = set(self.keys())
while done:
- level_modules = sorted((name, module) for name, module in pycompat.items(self) if module.depth==level)
+ level_modules = sorted((name, module) for name, module in self.items() if module.depth==level)
for name, module in level_modules:
done.remove(name)
yield module