Skip to content

Commit

Permalink
Make the help a bit clearer. Fix problem if the manifest of a module …
Browse files Browse the repository at this point in the history
…uses set for assets. Bump version
  • Loading branch information
fkantelberg committed Jan 25, 2024
1 parent 17b34da commit d8643d5
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 8 deletions.
88 changes: 88 additions & 0 deletions patch.diff
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 1 addition & 1 deletion src/odoo_analyse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"geometric_mean",
]

VERSION = "1.6.0"
VERSION = "1.6.1"
11 changes: 8 additions & 3 deletions src/odoo_analyse/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 5 additions & 4 deletions src/odoo_analyse/odoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from fnmatch import fnmatch
from functools import reduce

from . import utils
from .module import Module

try:
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/odoo_analyse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d8643d5

Please sign in to comment.