Skip to content
Snippets Groups Projects
Commit 0ba848df authored by Martin Trigaux's avatar Martin Trigaux
Browse files

[FIX] module: use file_path


The method get_resource_path is redundant with file_path but without
all the checks.
The method will be deprecated in master but make it use file_path in
stable.

closes odoo/odoo#136206

X-original-commit: 64ab4a69
Signed-off-by: default avatarMartin Trigaux (mat) <mat@odoo.com>
parent d344966a
Branches
Tags
No related merge requests found
......@@ -18,6 +18,8 @@ import odoo
import odoo.tools as tools
import odoo.release as release
from odoo.tools import pycompat
from odoo.tools.misc import file_path
MANIFEST_NAMES = ('__manifest__.py', '__openerp__.py')
README = ['README.rst', 'README.md', 'README.txt']
......@@ -228,6 +230,8 @@ def get_module_path(module, downloaded=False, display_warning=True):
path if nothing else is found.
"""
if re.search(r"[\/\\]", module):
return False
for adp in odoo.addons.__path__:
files = [opj(adp, module, manifest) for manifest in MANIFEST_NAMES] +\
[opj(adp, module + '.zip')]
......@@ -281,19 +285,19 @@ def get_resource_path(module, *args):
:rtype: str
:return: absolute path to the resource
TODO make it available inside on osv object (self.get_resource_path)
"""
mod_path = get_module_path(module)
if not mod_path:
resource_path = opj(module, *args)
try:
return file_path(resource_path)
except (FileNotFoundError, ValueError):
return False
return check_resource_path(mod_path, *args)
def check_resource_path(mod_path, *args):
resource_path = opj(mod_path, *args)
if os.path.exists(resource_path):
return resource_path
return False
try:
return file_path(resource_path)
except (FileNotFoundError, ValueError):
return False
# backwards compatibility
get_module_resource = get_resource_path
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment