本文整理汇总了Python中anyblok.blok.BlokManager.getPath方法的典型用法代码示例。如果您正苦于以下问题:Python BlokManager.getPath方法的具体用法?Python BlokManager.getPath怎么用?Python BlokManager.getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anyblok.blok.BlokManager
的用法示例。
在下文中一共展示了BlokManager.getPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_registry
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def load_registry(self):
if self.enabled and self.registryLoaded is False:
# Load the registry here not in configuration,
# because the configuration are not load in order of score
self.registryLoaded = True
BlokManager.load()
load_init_function_from_entry_points(unittest=True)
Configuration.load_config_for_test()
Configuration.parse_options(self.AnyBlokOptions, ('bloks',))
db_name = Configuration.get('db_name')
if not db_name:
raise Exception("No database defined to run Test")
registry = RegistryManager.get(db_name)
if registry:
installed_bloks = registry.System.Blok.list_by_state(
"installed")
selected_bloks = Configuration.get('selected_bloks')
if not selected_bloks:
selected_bloks = installed_bloks
unwanted_bloks = Configuration.get('unwanted_bloks')
if unwanted_bloks is None:
unwanted_bloks = []
self.bloks_path = [BlokManager.getPath(x)
for x in BlokManager.ordered_bloks]
self.authoried_bloks_test_files = [
path for blok in installed_bloks
if blok in selected_bloks and blok not in unwanted_bloks
for path in [join(BlokManager.getPath(blok), 'tests')]
if exists(path)]
registry.close() # free the registry to force create it again
示例2: run_exit
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def run_exit(application, configuration_groups, **kwargs):
"""Run nose unit test for the registry
:param application: name of the application
:param configuration_groups: list configuration groupe to load
:param \**kwargs: ArgumentParser named arguments
"""
format_configuration(configuration_groups, 'unittest')
registry = anyblok.start(application,
configuration_groups=configuration_groups,
useseparator=True, unittest=True, **kwargs)
defaultTest = []
if registry:
installed_bloks = registry.System.Blok.list_by_state("installed")
selected_bloks = Configuration.get('selected_bloks')
if not selected_bloks:
selected_bloks = installed_bloks
unwanted_bloks = Configuration.get('unwanted_bloks') or []
defaultTest = [path
for blok in installed_bloks
if blok in selected_bloks and blok not in unwanted_bloks
for path in [join(BlokManager.getPath(blok), 'tests')]
if exists(path)]
registry.close() # free the registry to force create it again
sys.exit(main(defaultTest=defaultTest))
示例3: anyblok_nose
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def anyblok_nose():
"""Run nose unit test for the registry
"""
warnings.simplefilter('default')
registry = anyblok.start('nose', useseparator=True, unittest=True)
defaultTest = []
if registry:
installed_bloks = registry.System.Blok.list_by_state("installed")
selected_bloks = return_list(
Configuration.get('selected_bloks')) or installed_bloks
unwanted_bloks = return_list(
Configuration.get('unwanted_bloks')) or []
defaultTest = []
for blok in installed_bloks:
if blok not in selected_bloks or blok in unwanted_bloks:
continue
startpath = BlokManager.getPath(blok)
for root, dirs, _ in walk(startpath):
if 'tests' in dirs:
defaultTest.append(join(root, 'tests'))
registry.close() # free the registry to force create it again
sys.exit(main(defaultTest=defaultTest))
示例4: current_blok
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def current_blok():
filename = inspect.stack()[1][1]
for blok in BlokManager.ordered_bloks:
if filename.startswith(BlokManager.getPath(blok)):
return blok
raise AnyBlokPyramidException("You are not in a Blok")
示例5: get_templates_from
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def get_templates_from(attr):
tmpl = Template(forclient=True)
for blok_name in BlokManager.ordered_bloks:
blok = BlokManager.get(blok_name)
if hasattr(blok, attr):
bpath = BlokManager.getPath(blok_name)
for template in getattr(blok, attr):
with open(join(bpath, template), 'r') as fp:
tmpl.load_file(fp)
tmpl.compile()
return tmpl.get_all_template()
示例6: get_logo
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def get_logo(self):
"""fget of ``logo`` return the path in the blok of the logo
:rtype: absolute path or None if unexiste logo
"""
blok = BlokManager.get(self.name)
blok_path = BlokManager.getPath(blok.name)
file_path = join(blok_path, blok.logo)
if isfile(file_path):
return file_path
return None
示例7: load
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def load(self):
from os.path import join
tmpl = Template()
Blok = self.registry.System.Blok
for blok in Blok.list_by_state('installed'):
b = BlokManager.get(blok)
if hasattr(b, 'views'):
bpath = BlokManager.getPath(blok)
for template in b.views:
with open(join(bpath, template), 'r') as fp:
tmpl.load_file(fp)
tmpl.compile()
self.registry.erpblok_views = tmpl
示例8: get_templates
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def get_templates(cls):
""" Return the list of the web client template to load """
from os.path import join
tmpl = Template(forclient=True)
Blok = cls.registry.System.Blok
for blok in Blok.list_by_state('installed'):
b = BlokManager.get(blok)
if hasattr(b, 'client_templates'):
bpath = BlokManager.getPath(blok)
for template in b.client_templates:
with open(join(bpath, template), 'r') as fp:
tmpl.load_file(fp)
tmpl.compile()
return tmpl.get_all_template()
示例9: static_paths
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def static_paths(config):
"""Pyramid includeme, add the static path of the blok
:param config: Pyramid configurator instance
"""
for blok, cls in BlokManager.bloks.items():
if hasattr(cls, 'static_paths'):
paths = cls.static_paths
if isinstance(paths, str):
paths = [paths]
else:
paths = ['static']
blok_path = BlokManager.getPath(blok)
for p in paths:
config.add_static_view(join(blok, p), join(blok_path, p))
示例10: get_long_description
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import getPath [as 别名]
def get_long_description(self):
""" fget of the ``long_description`` Column.Selection
:rtype: the readme file of the blok
"""
blok = BlokManager.get(self.name)
path = BlokManager.getPath(self.name)
readme = getattr(blok, 'readme', 'README.rst')
if readme == '__doc__':
return blok.__doc__
file_path = join(path, readme)
description = ''
if isfile(file_path):
with open(file_path, 'r') as fp:
description = fp.read()
return description