From fcdebe59240ea817b7b144c87ebb72e89a3937ad Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 21 Oct 2010 11:58:17 +0200 Subject: [PATCH] [FIX] naming in get_resource_path, raise errors when invoked stupidly rather than just return False bzr revid: xmo@openerp.com-20101021095817-fm0qr3fzsamj4giw --- bin/addons/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 67d5c4406e2..43453d5dc5c 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -270,16 +270,17 @@ def get_module_resource(module, *args): @return: absolute path to the resource """ a = get_module_path(module) - res = a and opj(a, *args) or False + if not a: raise ValueError('Could not find path for module %s'%module) + resource_path = opj(a, *args) if zipfile.is_zipfile( a +'.zip') : zip = zipfile.ZipFile( a + ".zip") files = ['/'.join(f.split('/')[1:]) for f in zip.namelist()] - res = '/'.join(args) - if res in files: - return opj(a, res) - elif os.path.exists(res): - return res - return False + resource_path = '/'.join(args) + if resource_path in files: + return opj(a, resource_path) + elif os.path.exists(resource_path): + return resource_path + raise IOError('Could not find resource %s'%resource_path)