# HG changeset patch
# User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr>
# Date 1622627369 -7200
#      Wed Jun 02 11:49:29 2021 +0200
# Node ID 92776f972d58613adb40b6d48eec9c1de47fcedd
# Parent  9fec47b0c5b26333bb33681c7a5f96cc39093340
✨ allow nested blacklisting
For example, allow ignoring odoo-mint/theme when expanding odoo-mint-hr.
🔨 Change list_modules command to output in the console when used.

diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,7 +2,7 @@
 History
 =======
 
-7.0.6
+8.0.0
 -----
 
 flake8 and isort are not run by default when running docker_dev_start.
@@ -11,6 +11,11 @@
 
 import_* follow symlinks.
 
+✨ allow nested blacklistin:
+For example, allow ignoring odoo-mint/theme when expanding odoo-mint-hr.
+
+🔨 Change list_modules command to output in the console when used.
+
 7.0.5
 -----
 
diff --git a/odoo_scripts/config.py b/odoo_scripts/config.py
--- a/odoo_scripts/config.py
+++ b/odoo_scripts/config.py
@@ -61,7 +61,23 @@
                 _logger.error("Expansion without path for %s", name)
                 raise Exception("Expansion without path for %s" % name)
             else:
-                if blacklist and re.match(blacklist, value["path"]):
+                # put in re_path everything but the first path element
+                # this allows blacklisting odoo-mint/theme when expanding
+                # mint hr.
+                if path:
+                    d = os.path.split(path)
+                    p = ""
+                    while d:
+                        d, tail = d
+                        if d:
+                            p = os.path.join(tail, p)
+                            d = os.path.split(d)
+                    re_path = (
+                        os.path.join(p, value["path"]) if p else value["path"]
+                    )
+                else:
+                    re_path = value["path"]
+                if blacklist and re.match(blacklist, re_path):
                     _logger.info(
                         "Ignoring directory '%s' due to blacklisting",
                         os.path.join(path, value["path"])
@@ -71,6 +87,14 @@
                 else:
                     if path:
                         value["path"] = os.path.join(path, value["path"])
+                    if blacklist:
+                        if "blacklist" in value:
+                            # combine the two regexp
+                            value["blacklist"] = "{}|{}".format(
+                                value["blacklist"], blacklist
+                            )
+                        else:
+                            value["blacklist"] = blacklist
                     # read expanded configurations
                     self._expanded_configuration[name] = Configuration(**value)
 
diff --git a/odoo_scripts/list_modules.py b/odoo_scripts/list_modules.py
--- a/odoo_scripts/list_modules.py
+++ b/odoo_scripts/list_modules.py
@@ -54,12 +54,16 @@
     parser = basic_parser(program_license, program_version_message)
     nmspc = parser.parse_args()
     apply(nmspc)
-    list_modules()
+    list_modules(None)
 
 
 def list_modules(filename: str = MODULES_LIST_FILE):
-    with open(filename, "w") as f:
-        f.write(",".join(Config().module_list))
+    output = ",".join(Config().module_list)
+    if filename:
+        with open(filename, "w") as f:
+            f.write(output)
+    else:
+        print(output)
 
 
 if __name__ == "__main__":