# HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1622648383 -7200 # Wed Jun 02 17:39:43 2021 +0200 # Node ID 1062ce4eb3c356e4d673c0141dffce667b8b1a63 # Parent 2aaac04452e7e5989bf1233c10f72c1c21be378c 🚑 fix nested blacklisting diff --git a/NEWS.rst b/NEWS.rst --- 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 --- a/odoo_scripts/config.py +++ b/odoo_scripts/config.py @@ -32,9 +32,14 @@ """ 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() + self.path = path setup_path = "setup.cfg" if path: setup_path = os.path.join(path, setup_path) @@ -57,11 +62,29 @@ ] = 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: - 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"])