[FIX] Export translations: module name from path calculations corrected

lp bug: https://launchpad.net/bugs/519699 fixed

bzr revid: jvo@tinyerp.com-20100512103352-604yu97m9aexm9zr
This commit is contained in:
Jay (Open ERP) 2010-05-12 16:03:52 +05:30
parent 4f5be5aa54
commit 773238132b
1 changed files with 25 additions and 18 deletions

View File

@ -596,23 +596,30 @@ def trans_generate(lang, modules, dbname=None):
push_translation(module, 'model', name, xml_name, encode(trad))
# parse source code for _() calls
def get_module_from_path(path,mod_paths=None):
if not mod_paths:
# First, construct a list of possible paths
def_path = os.path.abspath(os.path.join(tools.config['root_path'], 'addons')) # default addons path (base)
ad_paths= map(lambda m: os.path.abspath(m.strip()),tools.config['addons_path'].split(','))
mod_paths=[def_path]
for adp in ad_paths:
mod_paths.append(adp)
if not adp.startswith('/'):
mod_paths.append(os.path.join(def_path,adp))
elif adp.startswith(def_path):
mod_paths.append(adp[len(def_path)+1:])
for mp in mod_paths:
if path.startswith(mp) and (os.path.dirname(path) != mp):
path = path[len(mp)+1:]
return path.split(os.path.sep)[0]
def get_module_from_path(path, mod_paths=None):
# if not mod_paths:
## First, construct a list of possible paths
# def_path = os.path.abspath(os.path.join(tools.config['root_path'], 'addons')) # default addons path (base)
# ad_paths= map(lambda m: os.path.abspath(m.strip()),tools.config['addons_path'].split(','))
# mod_paths=[def_path]
# for adp in ad_paths:
# mod_paths.append(adp)
# if not adp.startswith('/'):
# mod_paths.append(os.path.join(def_path,adp))
# elif adp.startswith(def_path):
# mod_paths.append(adp[len(def_path)+1:])
# for mp in mod_paths:
# if path.startswith(mp) and (os.path.dirname(path) != mp):
# path = path[len(mp)+1:]
# return path.split(os.path.sep)[0]
path_dir = os.path.dirname(path[1:])
if path_dir:
if os.path.exists(os.path.join(tools.config['addons_path'],path[1:])):
return path.split(os.path.sep)[1]
else:
root_addons = os.path.join(tools.config['root_path'], 'addons')
if os.path.exists(os.path.join(root_addons,path[1:])):
return path.split(os.path.sep)[1]
return 'base' # files that are not in a module are considered as being in 'base' module
modobj = pool.get('ir.module.module')
@ -620,7 +627,7 @@ def trans_generate(lang, modules, dbname=None):
installed_modules = map(lambda m: m['name'], modobj.read(cr, uid, installed_modids, ['name']))
root_path = os.path.join(tools.config['root_path'], 'addons')
if root_path in tools.config['addons_path'] :
path_list = [root_path]
else :