From d8643d508f80de0acb3f1138dd3e6ee067c2885c Mon Sep 17 00:00:00 2001 From: fkantelberg Date: Thu, 25 Jan 2024 08:46:32 +0100 Subject: [PATCH] Make the help a bit clearer. Fix problem if the manifest of a module uses set for assets. Bump version --- patch.diff | 88 ++++++++++++++++++++++++++++++++++++ src/odoo_analyse/__init__.py | 2 +- src/odoo_analyse/__main__.py | 11 +++-- src/odoo_analyse/odoo.py | 9 ++-- src/odoo_analyse/utils.py | 7 +++ 5 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 patch.diff diff --git a/patch.diff b/patch.diff new file mode 100644 index 0000000..b262a0f --- /dev/null +++ b/patch.diff @@ -0,0 +1,88 @@ +diff --git a/src/odoo_analyse/__init__.py b/src/odoo_analyse/__init__.py +index 071b5fc..893b12c 100644 +--- a/src/odoo_analyse/__init__.py ++++ b/src/odoo_analyse/__init__.py +@@ -19,4 +19,4 @@ __all__ = [ + "geometric_mean", + ] + +-VERSION = "1.6.0" ++VERSION = "1.6.1" +diff --git a/src/odoo_analyse/__main__.py b/src/odoo_analyse/__main__.py +index a8ed971..39a3f73 100644 +--- a/src/odoo_analyse/__main__.py ++++ b/src/odoo_analyse/__main__.py +@@ -54,7 +54,7 @@ def parser_load_save(parser): + "--path", + default=[], + action="append", +- help="Specify a path to search for odoo modules", ++ help="Specify a path to search for odoo modules. Multiple use is supported", + ) + parser.add_argument( + "-l", +@@ -121,7 +121,7 @@ def parser_filters(parser): + "--modules", + default="*", + help="Filter out modules which names aren't matching the glob. " +- "Separate multiple filters by comma. Use `-` load load from stdin", ++ "Separate multiple filters by comma. Use `-` to load from stdin", + ) + parser.add_argument( + "--views", +diff --git a/src/odoo_analyse/odoo.py b/src/odoo_analyse/odoo.py +index f9c1c24..aa484eb 100644 +--- a/src/odoo_analyse/odoo.py ++++ b/src/odoo_analyse/odoo.py +@@ -10,6 +10,7 @@ from configparser import ConfigParser + from fnmatch import fnmatch + from functools import reduce + ++from . import utils + from .module import Module + + try: +@@ -331,10 +332,10 @@ class Odoo: + """Output the analyse result as JSON""" + # Write to a file or stdout + if file_path == "-": +- print(json.dumps(data, indent=2)) ++ print(json.dumps(data, indent=2, cls=utils.JSONEncoder)) + else: + with open(file_path, "w+", encoding="utf-8") as fp: +- json.dump(data, fp, indent=2) ++ json.dump(data, fp, indent=2, cls=utils.JSONEncoder) + + def load_path(self, paths, depth=None, **config): + if isinstance(paths, str): +@@ -358,10 +359,10 @@ class Odoo: + def save_json(self, filename): + data = {k: m.to_json() for k, m in self.full.items()} + if filename == "-": +- json.dump(data, sys.stdout) ++ json.dump(data, sys.stdout, cls=utils.JSONEncoder) + else: + with open(filename, "w+", encoding="utf-8") as fp: +- json.dump(data, fp) ++ json.dump(data, fp, cls=utils.JSONEncoder) + + def _find_edges_in_loop(self, graph): # pylint: disable=R0201 + # Eliminate not referenced and not referring modules +diff --git a/src/odoo_analyse/utils.py b/src/odoo_analyse/utils.py +index a52c319..3ff1bd2 100644 +--- a/src/odoo_analyse/utils.py ++++ b/src/odoo_analyse/utils.py +@@ -14,6 +14,13 @@ from json.decoder import JSONDecodeError + _logger = logging.getLogger(__name__) + + ++class JSONEncoder(json.JSONEncoder): ++ def default(self, o): ++ if isinstance(o, (tuple, set)): ++ return list(o) ++ return super().default(o) ++ ++ + def call(cmd, cwd=None): + with subprocess.Popen( + cmd, diff --git a/src/odoo_analyse/__init__.py b/src/odoo_analyse/__init__.py index 071b5fc..893b12c 100644 --- a/src/odoo_analyse/__init__.py +++ b/src/odoo_analyse/__init__.py @@ -19,4 +19,4 @@ "geometric_mean", ] -VERSION = "1.6.0" +VERSION = "1.6.1" diff --git a/src/odoo_analyse/__main__.py b/src/odoo_analyse/__main__.py index a8ed971..55fd61b 100644 --- a/src/odoo_analyse/__main__.py +++ b/src/odoo_analyse/__main__.py @@ -54,7 +54,7 @@ def parser_load_save(parser): "--path", default=[], action="append", - help="Specify a path to search for odoo modules", + help="Specify a path to search for odoo modules. Multiple use is supported", ) parser.add_argument( "-l", @@ -121,7 +121,7 @@ def parser_filters(parser): "--modules", default="*", help="Filter out modules which names aren't matching the glob. " - "Separate multiple filters by comma. Use `-` load load from stdin", + "Separate multiple filters by comma. Use `-` to load from stdin", ) parser.add_argument( "--views", @@ -307,7 +307,12 @@ def parse_args(): parser_load_save(parser.add_argument_group("Loading/Saving")) parser_analyse(parser.add_argument_group("Analyse Options")) - parser_filters(parser.add_argument_group("Filters")) + parser_filters( + parser.add_argument_group( + "Filters", + "Filters are using to hide module for the graphs and analyse output", + ) + ) parser_database(parser.add_argument_group("Database")) parser_module_graph( parser.add_argument_group( diff --git a/src/odoo_analyse/odoo.py b/src/odoo_analyse/odoo.py index f9c1c24..aa484eb 100644 --- a/src/odoo_analyse/odoo.py +++ b/src/odoo_analyse/odoo.py @@ -10,6 +10,7 @@ from fnmatch import fnmatch from functools import reduce +from . import utils from .module import Module try: @@ -331,10 +332,10 @@ def _analyse_out_json(self, data, file_path): # pylint: disable=R0201 """Output the analyse result as JSON""" # Write to a file or stdout if file_path == "-": - print(json.dumps(data, indent=2)) + print(json.dumps(data, indent=2, cls=utils.JSONEncoder)) else: with open(file_path, "w+", encoding="utf-8") as fp: - json.dump(data, fp, indent=2) + json.dump(data, fp, indent=2, cls=utils.JSONEncoder) def load_path(self, paths, depth=None, **config): if isinstance(paths, str): @@ -358,10 +359,10 @@ def load_json(self, filename): def save_json(self, filename): data = {k: m.to_json() for k, m in self.full.items()} if filename == "-": - json.dump(data, sys.stdout) + json.dump(data, sys.stdout, cls=utils.JSONEncoder) else: with open(filename, "w+", encoding="utf-8") as fp: - json.dump(data, fp) + json.dump(data, fp, cls=utils.JSONEncoder) def _find_edges_in_loop(self, graph): # pylint: disable=R0201 # Eliminate not referenced and not referring modules diff --git a/src/odoo_analyse/utils.py b/src/odoo_analyse/utils.py index a52c319..3ff1bd2 100644 --- a/src/odoo_analyse/utils.py +++ b/src/odoo_analyse/utils.py @@ -14,6 +14,13 @@ _logger = logging.getLogger(__name__) +class JSONEncoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, (tuple, set)): + return list(o) + return super().default(o) + + def call(cmd, cwd=None): with subprocess.Popen( cmd,