From 9ebe987db140b97ea4f387d80a1b0353effe37c2 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 8 Jul 2019 21:55:05 +0200 Subject: [PATCH] fixup! [REF] remove use of cloc. use pygount librairy instead --- module_analysis/__manifest__.py | 2 +- module_analysis/data/ir_config_parameter.xml | 20 ++++++++++++++++++ module_analysis/models/ir_module_author.py | 6 +++--- module_analysis/models/ir_module_module.py | 21 ++++++++++++------- module_analysis/models/ir_module_type.py | 16 +++++++------- module_analysis/readme/INSTALL.rst | 4 ++-- module_analysis/readme/USAGE.rst | 1 - module_analysis/views/view_ir_module_type.xml | 2 +- 8 files changed, 50 insertions(+), 22 deletions(-) create mode 100644 module_analysis/data/ir_config_parameter.xml diff --git a/module_analysis/__manifest__.py b/module_analysis/__manifest__.py index 6921bdb3c..fbe44c2e6 100644 --- a/module_analysis/__manifest__.py +++ b/module_analysis/__manifest__.py @@ -22,7 +22,7 @@ 'views/view_ir_module_type.xml', 'views/view_ir_module_type_rule.xml', 'views/view_ir_module_module.xml', - + 'data/ir_config_parameter.xml', 'data/ir_module_type.xml', 'data/ir_module_type_rule.xml', ], diff --git a/module_analysis/data/ir_config_parameter.xml b/module_analysis/data/ir_config_parameter.xml new file mode 100644 index 000000000..337ff4ab4 --- /dev/null +++ b/module_analysis/data/ir_config_parameter.xml @@ -0,0 +1,20 @@ + + + + + + + module_analysis.exclude_directories + lib,demo,test,tests,doc,description + + + + module_analysis.exclude_files + __openerp__.py,__manifest__.py + + + diff --git a/module_analysis/models/ir_module_author.py b/module_analysis/models/ir_module_author.py index 53510d15d..160d098ad 100644 --- a/module_analysis/models/ir_module_author.py +++ b/module_analysis/models/ir_module_author.py @@ -11,7 +11,7 @@ class IrModuleAuthor(models.Model): name = fields.Char(string='Name', required=True) - module_ids = fields.Many2many( + installed_module_ids = fields.Many2many( string='Modules', comodel_name='ir.module.module', relation='ir_module_module_author_rel') @@ -25,10 +25,10 @@ class IrModuleAuthor(models.Model): ] @api.multi - @api.depends('module_ids') + @api.depends('installed_module_ids') def _compute_installed_module_qty(self): for author in self: - author.installed_module_qty = len(author.module_ids) + author.installed_module_qty = len(author.installed_module_ids) @api.model def _get_or_create(self, name): diff --git a/module_analysis/models/ir_module_module.py b/module_analysis/models/ir_module_module.py index ea0a8ee99..779162411 100644 --- a/module_analysis/models/ir_module_module.py +++ b/module_analysis/models/ir_module_module.py @@ -27,13 +27,17 @@ class IrModuleModule(models.Model): module_type_id = fields.Many2one( string='Module Type', comodel_name='ir.module.type', readonly=True) - python_code_qty = fields.Integer(string='Python Lines', readonly=True) + python_code_qty = fields.Integer( + string='Python Code Quantity', readonly=True) - xml_code_qty = fields.Integer(string='XML Lines', readonly=True) + xml_code_qty = fields.Integer( + string='XML Code Quantity', readonly=True) - js_code_qty = fields.Integer(string='JS Lines', readonly=True) + js_code_qty = fields.Integer( + string='JS Code Quantity', readonly=True) - css_code_qty = fields.Integer(string='CSS Lines', readonly=True) + css_code_qty = fields.Integer( + string='CSS Code Quantity', readonly=True) # Overloadable Section @api.model @@ -101,11 +105,14 @@ class IrModuleModule(models.Model): IrModuleTypeRule = self.env['ir.module.type.rule'] rules = IrModuleTypeRule.search([]) - exclude_directories = ['description', 'lib', 'tests'] - exclude_files = ['__openerp__.py', '__manifest__.py'] + cfg = self.env['ir.config_parameter'] + val = cfg.get_param('module_analysis.exclude_directories', '') + exclude_directories = [x.strip() for x in val.split(',') if x.strip()] + val = cfg.get_param('module_analysis.exclude_files', '') + exclude_files = [x.strip() for x in val.split(',') if x.strip()] for module in self: - _logger.info("Analyzing Code for module %s" % (module.name)) + _logger.info("Analyzing Code for module %s ..." % (module.name)) # Update Authors, based on manifest key authors = [] diff --git a/module_analysis/models/ir_module_type.py b/module_analysis/models/ir_module_type.py index aa56f4c41..0a59a3d1b 100644 --- a/module_analysis/models/ir_module_type.py +++ b/module_analysis/models/ir_module_type.py @@ -14,15 +14,17 @@ class IrModuleType(models.Model): sequence = fields.Integer(string='Sequence') - module_ids = fields.One2many( - string='Modules', comodel_name='ir.module.module', + installed_module_ids = fields.One2many( + string='Installed Modules', comodel_name='ir.module.module', inverse_name='module_type_id') - module_qty = fields.Integer( - string='Modules Quantity', compute='_compute_module_qty', store=True) + installed_module_qty = fields.Integer( + string='Modules Quantity', compute='_compute_installed_module_qty', + store=True) @api.multi - @api.depends('module_ids.module_type_id') - def _compute_module_qty(self): + @api.depends('installed_module_ids.module_type_id') + def _compute_installed_module_qty(self): for module_type in self: - module_type.module_qty = len(module_type.module_ids) + module_type.installed_module_qty = len( + module_type.installed_module_ids) diff --git a/module_analysis/readme/INSTALL.rst b/module_analysis/readme/INSTALL.rst index 0064beeb9..15ecd6f37 100644 --- a/module_analysis/readme/INSTALL.rst +++ b/module_analysis/readme/INSTALL.rst @@ -1,3 +1,3 @@ -To use this module, you have to install the application ``cloc`` +To use this module, you have to install the ``pygount`` python librairy. -``sudo apt-get install cloc`` +``pip install pygount`` diff --git a/module_analysis/readme/USAGE.rst b/module_analysis/readme/USAGE.rst index 8667f84c7..a88d6fcfc 100644 --- a/module_analysis/readme/USAGE.rst +++ b/module_analysis/readme/USAGE.rst @@ -4,6 +4,5 @@ Open the stats to analyze the detail of the code installed .. image:: ../static/description/analysis_pivot.png - .. image:: ../static/description/analysis_pie.png diff --git a/module_analysis/views/view_ir_module_type.xml b/module_analysis/views/view_ir_module_type.xml index 311dde6e4..d7b774165 100644 --- a/module_analysis/views/view_ir_module_type.xml +++ b/module_analysis/views/view_ir_module_type.xml @@ -28,7 +28,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - +