diff --git a/NEWS.rst b/NEWS.rst index 2aaac04452e7e5989bf1233c10f72c1c21be378c_TkVXUy5yc3Q=..1062ce4eb3c356e4d673c0141dffce667b8b1a63_TkVXUy5yc3Q= 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -2,6 +2,11 @@ History ======= +8.0.1 +----- + +Fix nested blacklisting. + 8.0.0 ----- @@ -11,7 +16,7 @@ import_* follow symlinks. -✨ allow nested blacklistin: +✨ 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/odoo_scripts/config.py b/odoo_scripts/config.py index 2aaac04452e7e5989bf1233c10f72c1c21be378c_b2Rvb19zY3JpcHRzL2NvbmZpZy5weQ==..1062ce4eb3c356e4d673c0141dffce667b8b1a63_b2Rvb19zY3JpcHRzL2NvbmZpZy5weQ== 100644 --- a/odoo_scripts/config.py +++ b/odoo_scripts/config.py @@ -32,6 +32,10 @@ """ def __init__( - self, path: str = None, blacklist: str = None, read: str = None + self, + path: str = None, + blacklist: str = None, + read: str = None, + parent_configuration=None, ): self._expanded_configuration = dict() @@ -36,5 +40,6 @@ ): self._expanded_configuration = dict() + self.path = path setup_path = "setup.cfg" if path: setup_path = os.path.join(path, setup_path) @@ -57,7 +62,8 @@ ] = section.get(key) for name, value in expanded_info.items(): + value["parent_configuration"] = self if "path" not in value: _logger.error("Expansion without path for %s", name) raise Exception("Expansion without path for %s" % name) else: @@ -60,8 +66,25 @@ if "path" not in value: _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 relative_path the relative path between this and the + # parent. + # this allows blacklisting odoo-mint/theme when expanding + # mint hr. + if parent_configuration: + # difference between this path and the parents + relative_path = os.path.join( + os.path.relpath( + path, + parent_configuration.path + if parent_configuration.path + else "", + ), + value["path"], + ) + else: + relative_path = value["path"] + if blacklist and re.match(blacklist, relative_path): _logger.info( "Ignoring directory '%s' due to blacklisting", os.path.join(path, value["path"])