[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) <xmo@odoo.com>
This commit is contained in:
Xavier Morel
2022-08-23 07:36:24 +02:00
parent adf534f2bf
commit 9c0fa1efe3
2 changed files with 7 additions and 0 deletions
+5
View File
@@ -217,6 +217,11 @@ def get_module_path(module, downloaded=False, display_warning=True):
return False return False
def get_module_filetree(module, dir='.'): 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) path = get_module_path(module)
if not path: if not path:
return False return False
+2
View File
@@ -6,6 +6,7 @@ Some functions related to the os and os.path module
""" """
import os import os
import re import re
import warnings
import zipfile import zipfile
from os.path import join as opj from os.path import join as opj
@@ -56,6 +57,7 @@ def listdir(dir, recursive=False):
it follows leaves `dir`... it follows leaves `dir`...
""" """
assert recursive, "use `os.listdir` or `pathlib.Path.iterdir`" 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) dir = os.path.normpath(dir)
res = [] res = []