From 9c0fa1efe32cfdcdfe563396f93070d520a4fa74 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 12 Aug 2022 08:27:18 +0000 Subject: [PATCH] [CHG] core: deprecate get_module_filetree It's pretty much unused and fairly complicated. Also deprecate `listdir` entirely since `get_module_filetree` is the only extant user of the recursive listdir. closes odoo/odoo#98034 Related: odoo/enterprise#30403 Signed-off-by: Xavier Morel (xmo) --- odoo/modules/module.py | 5 +++++ odoo/tools/osutil.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 716ca78b44a..9a2f7fcdbdd 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -217,6 +217,11 @@ def get_module_path(module, downloaded=False, display_warning=True): return False def get_module_filetree(module, dir='.'): + warnings.warn( + "Since 16.0: use os.walk or a recursive glob or something", + DeprecationWarning, + stacklevel=2 + ) path = get_module_path(module) if not path: return False diff --git a/odoo/tools/osutil.py b/odoo/tools/osutil.py index 772b59302f5..2861951ac0f 100644 --- a/odoo/tools/osutil.py +++ b/odoo/tools/osutil.py @@ -6,6 +6,7 @@ Some functions related to the os and os.path module """ import os import re +import warnings import zipfile from os.path import join as opj @@ -56,6 +57,7 @@ def listdir(dir, recursive=False): it follows leaves `dir`... """ assert recursive, "use `os.listdir` or `pathlib.Path.iterdir`" + warnings.warn("Since 16.0, use os.walk or a recursive glob", DeprecationWarning, stacklevel=2) dir = os.path.normpath(dir) res = []