diff options
| author | Olivier Dony <odo@openerp.com> | 2012-09-03 15:05:36 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2012-09-03 15:05:36 +0200 |
| commit | 869564ce28c976765d76ae2a33e2dbb3c8f69534 (patch) | |
| tree | 3e6ea5b31e53455870320c5c83c35de524dd2be8 /openerp/modules/module.py | |
| parent | f29be675e2b63a85c0e2d1032fb448dc9714b6a4 (diff) | |
| parent | 9769884ca5fd897aac95174d751d65bcefd936b3 (diff) | |
[MERGE] file_open: give precedence to directory before zip, courtesy of Florent Xicluna
lp bug: https://launchpad.net/bugs/928376 fixed
lp bug: https://launchpad.net/bugs/928507 fixed
bzr revid: odo@openerp.com-20120903130536-5sqwp9tnhk1ntee3
Diffstat (limited to 'openerp/modules/module.py')
| -rw-r--r-- | openerp/modules/module.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/openerp/modules/module.py b/openerp/modules/module.py index b1d4de31bce..7e2c97125bb 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -283,25 +283,28 @@ def get_module_as_zip(modulename, b64enc=True, src=True): def get_module_resource(module, *args): """Return the full path of a resource of the given module. - @param module: the module - @param args: the resource path components + :param module: module name + :param list(str) args: resource path components within module - @return: absolute path to the resource + :rtype: str + :return: absolute path to the resource TODO name it get_resource_path TODO make it available inside on osv object (self.get_resource_path) """ - a = get_module_path(module) - if not a: return False - resource_path = opj(a, *args) - if zipfile.is_zipfile( a +'.zip') : - zip = zipfile.ZipFile( a + ".zip") + mod_path = get_module_path(module) + if not mod_path: return False + resource_path = opj(mod_path, *args) + if os.path.isdir(mod_path): + # the module is a directory - ignore zip behavior + if os.path.exists(resource_path): + return resource_path + elif zipfile.is_zipfile(mod_path + '.zip'): + zip = zipfile.ZipFile( mod_path + ".zip") files = ['/'.join(f.split('/')[1:]) for f in zip.namelist()] resource_path = '/'.join(args) if resource_path in files: - return opj(a, resource_path) - elif os.path.exists(resource_path): - return resource_path + return opj(mod_path, resource_path) return False def get_module_icon(module): |
