Browse Source

fixup! [REF] remove use of cloc. use pygount librairy instead

12.0
Sylvain LE GAL 5 years ago
committed by OCA-git-bot
parent
commit
9ebe987db1
  1. 2
      module_analysis/__manifest__.py
  2. 20
      module_analysis/data/ir_config_parameter.xml
  3. 6
      module_analysis/models/ir_module_author.py
  4. 21
      module_analysis/models/ir_module_module.py
  5. 16
      module_analysis/models/ir_module_type.py
  6. 4
      module_analysis/readme/INSTALL.rst
  7. 1
      module_analysis/readme/USAGE.rst
  8. 2
      module_analysis/views/view_ir_module_type.xml

2
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',
],

20
module_analysis/data/ir_config_parameter.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019-Today: GRAP (<http://www.grap.coop/>)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo noupdate="1">
<record id="parameter_exclude_directories" model="ir.config_parameter">
<field name="key">module_analysis.exclude_directories</field>
<field name="value">lib,demo,test,tests,doc,description</field>
</record>
<record id="parameter_exclude_files" model="ir.config_parameter">
<field name="key">module_analysis.exclude_files</field>
<field name="value">__openerp__.py,__manifest__.py</field>
</record>
</odoo>

6
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):

21
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 = []

16
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)

4
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``

1
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

2
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).
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="module_qty"/>
<field name="installed_module_qty"/>
</tree>
</field>
</record>

Loading…
Cancel
Save