-
Notifications
You must be signed in to change notification settings - Fork 5
/
patch.diff
88 lines (81 loc) · 3.02 KB
/
patch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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,