本文整理汇总了Python中trytond.pool.Pool._get_installed_module_directories方法的典型用法代码示例。如果您正苦于以下问题:Python Pool._get_installed_module_directories方法的具体用法?Python Pool._get_installed_module_directories怎么用?Python Pool._get_installed_module_directories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool._get_installed_module_directories方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _clean_nereid
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import _get_installed_module_directories [as 别名]
def _clean_nereid(translation):
"""
Remove the nereid translations if the module is not installed
"""
TranslationSet = Pool().get('ir.translation.set', type='wizard')
installed_modules = TranslationSet._get_installed_module_directories()
# Clean if the module is not installed anymore
for module, directory in installed_modules:
if translation.module == module:
break
else:
return True
# Clean any messages from tests
if 'tests' in translation.name.split('/'):
return True
# Clean if the translation has changed (avoid duplicates)
# (translation has no equivalent in template)
babel_file = os.path.join(directory, translation.name)
if not os.path.exists(babel_file):
return True
found = False
for template, lineno, message in \
TranslationSet._get_babel_messages_from_file(TranslationSet,
babel_file):
if (lineno, message) == (translation.res_id, translation.src):
found = True
break
if not found:
return True
示例2: _clean_nereid
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import _get_installed_module_directories [as 别名]
def _clean_nereid(translation):
"""
Remove the nereid translations if the module is not installed
"""
TranslationSet = Pool().get('ir.translation.set', type='wizard')
installed_modules = TranslationSet._get_installed_module_directories()
# Clean if the module is not installed anymore
for module, directory in installed_modules:
if translation.module == module:
break
else:
return True
示例3: _clean_nereid_template
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import _get_installed_module_directories [as 别名]
def _clean_nereid_template(translation):
"""
Clean the template translations if the module is not installed, or if
the template is not there.
"""
TranslationSet = Pool().get('ir.translation.set', type='wizard')
installed_modules = TranslationSet._get_installed_module_directories()
# Clean if the module is not installed anymore
for module, directory in installed_modules:
if translation.module == module:
break
else:
return True
# Clean if the template directory does not exist
template_dir = os.path.join(directory, 'templates')
if not os.path.isdir(template_dir):
return True
# Clean if the template is not found
loader = FileSystemLoader(template_dir)
if translation.name not in loader.list_templates():
return True
# Clean if the translation has changed (avoid duplicates)
# (translation has no equivalent in template)
found = False
for template, lineno, function, message, comments in \
TranslationSet._get_nereid_template_messages_from_file(
TranslationSet, template_dir, translation.name):
if (template, lineno, message, comments and
'\n'.join(comments) or None) == \
(translation.name, translation.res_id, translation.src,
translation.comments):
found = True
break
if not found:
return True
示例4: _clean_nereid_template
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import _get_installed_module_directories [as 别名]
def _clean_nereid_template(translation):
"""
Clean the template translations if the module is not installed, or if
the template is not there.
"""
TranslationSet = Pool().get('ir.translation.set', type='wizard')
installed_modules = TranslationSet._get_installed_module_directories()
# Clean if the module is not installed anymore
for module, directory in installed_modules:
if translation.module == module:
break
else:
return True
# Clean if the template directory does not exist
template_dir = os.path.join(directory, 'templates')
if not os.path.isdir(template_dir):
return True
# Clean if the template is not found
loader = FileSystemLoader(template_dir)
if translation.name not in loader.list_templates():
return True