Skip to content

Commit

Permalink
black, isort
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon authored and asierneiradev committed Nov 25, 2022
1 parent 4349694 commit e70bafd
Show file tree
Hide file tree
Showing 17 changed files with 458 additions and 488 deletions.
1 change: 0 additions & 1 deletion component/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from . import core

from . import components
Expand Down
34 changes: 15 additions & 19 deletions component/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

{'name': 'Components',
'summary': 'Add capabilities to register and use decoupled components,'
' as an alternative to model classes',
'version': '13.0.1.0.0',
'author': 'Camptocamp,'
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/connector',
'license': 'LGPL-3',
'category': 'Generic Modules',
'depends': ['base',
],
'external_dependencies': {
'python': ['cachetools'],
},
'installable': False,
'development_status': 'Stable',
'maintainers': ['guewen'],
}
{
"name": "Components",
"summary": "Add capabilities to register and use decoupled components,"
" as an alternative to model classes",
"version": "13.0.1.0.0",
"author": "Camptocamp," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector",
"license": "LGPL-3",
"category": "Generic Modules",
"depends": ["base"],
"external_dependencies": {"python": ["cachetools"]},
"installable": False,
"development_status": "Stable",
"maintainers": ["guewen"],
}
35 changes: 13 additions & 22 deletions component/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
"""
import odoo
from odoo import models
from .core import (
_component_databases,
ComponentRegistry,
DEFAULT_CACHE_SIZE,
)

from .core import DEFAULT_CACHE_SIZE, ComponentRegistry, _component_databases


class ComponentBuilder(models.AbstractModel):
Expand All @@ -37,8 +34,9 @@ class ComponentBuilder(models.AbstractModel):
order.
"""
_name = 'component.builder'
_description = 'Component Builder'

_name = "component.builder"
_description = "Component Builder"

_components_registry_cache_size = DEFAULT_CACHE_SIZE

Expand All @@ -58,34 +56,27 @@ def _init_global_registry(self):
_component_databases[self.env.cr.dbname] = components_registry
return components_registry

def build_registry(self, components_registry, states=None,
exclude_addons=None):
def build_registry(self, components_registry, states=None, exclude_addons=None):
if not states:
states = ('installed', 'to upgrade')
states = ("installed", "to upgrade")
# lookup all the installed (or about to be) addons and generate
# the graph, so we can load the components following the order
# of the addons' dependencies
graph = odoo.modules.graph.Graph()
graph.add_module(self.env.cr, 'base')
graph.add_module(self.env.cr, "base")

query = (
"SELECT name "
"FROM ir_module_module "
"WHERE state IN %s "
)
query = "SELECT name " "FROM ir_module_module " "WHERE state IN %s "
params = [tuple(states)]
if exclude_addons:
query += " AND name NOT IN %s "
params.append(tuple(exclude_addons))
self.env.cr.execute(query, params)

module_list = [name for (name,) in self.env.cr.fetchall()
if name not in graph]
module_list = [name for (name,) in self.env.cr.fetchall() if name not in graph]
graph.add_modules(self.env.cr, module_list)

for module in graph:
self.load_components(module.name,
components_registry=components_registry)
self.load_components(module.name, components_registry=components_registry)

def load_components(self, module, components_registry=None):
""" Build every component known by MetaComponent for an odoo module
Expand All @@ -100,6 +91,6 @@ def load_components(self, module, components_registry=None):
:type registry: :py:class:`~.core.ComponentRegistry`
"""
components_registry = (
components_registry or
_component_databases[self.env.cr.dbname])
components_registry or _component_databases[self.env.cr.dbname]
)
components_registry.load_components(module)
1 change: 0 additions & 1 deletion component/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import base
4 changes: 2 additions & 2 deletions component/components/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

Expand All @@ -12,4 +11,5 @@ class BaseComponent(AbstractComponent):
All your base are belong to us
"""
_name = 'base'

_name = "base"
Loading

0 comments on commit e70bafd

Please sign in to comment.