本文整理汇总了Python中anyblok.blok.BlokManager.get方法的典型用法代码示例。如果您正苦于以下问题:Python BlokManager.get方法的具体用法?Python BlokManager.get怎么用?Python BlokManager.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anyblok.blok.BlokManager
的用法示例。
在下文中一共展示了BlokManager.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_invalid_blok
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def test_get_invalid_blok(self):
try:
BlokManager.load()
BlokManager.get('invalid blok')
self.fail('No exception when get invalid blok')
except BlokManagerException:
pass
示例2: test_load_anyblok
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def test_load_anyblok(self):
BlokManager.load()
if not BlokManager.list():
self.fail('No blok load')
if not BlokManager.has('anyblok-core'):
self.fail("The blok 'anyblok-core' is missing")
BlokManager.get('anyblok-core')
示例3: test_reload
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def test_reload(self):
BlokManager.load()
BlokManager.set('invalid blok', None)
BlokManager.get('invalid blok')
BlokManager.reload()
try:
BlokManager.get('invalid blok')
self.fail("Reload classmethod doesn't reload the bloks")
except BlokManagerException:
pass
示例4: imports
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def imports(self):
""" Imports modules and / or packages listed in the blok path"""
from anyblok.blok import BlokManager
from anyblok.registry import RegistryManager
RegistryManager.init_blok(self.blok)
b = BlokManager.get(self.blok)
b.import_declaration_module()
示例5: get_short_description
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def get_short_description(self):
""" fget of the ``short_description`` Column.Selection
:rtype: the docstring of the blok
"""
blok = BlokManager.get(self.name)
if hasattr(blok, '__doc__'):
return blok.__doc__ or ''
return ''
示例6: get_addons
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def get_addons(request):
res = []
for blok_name in BlokManager.ordered_bloks:
blok = BlokManager.get(blok_name)
if hasattr(blok, 'setting_blok_description'):
addons = blok.setting_blok_description
addons['id'] = blok_name
res.append(addons)
return res
示例7: get_logo
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [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
示例8: get_templates_from
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [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()
示例9: load
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def load(self):
""" Method to load the blok when the registry is completly loaded
"""
name = self.name
blok_cls = BlokManager.get(name)
if blok_cls is None:
logger.warning("load(): class of Blok %r not found, "
"Blok can't be loaded", name)
return
logger.info("Loading Blok %r", name)
blok_cls(self.registry).load()
logger.debug("Succesfully loaded Blok %r", name)
示例10: get_static
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def get_static(static_type):
""" Get in the Blok definition the static data from the client
:param static: entry to read: css, js, ...
:rtype: list of str
"""
res = []
for blok_name in BlokManager.ordered_bloks:
blok = BlokManager.get(blok_name)
if hasattr(blok, static_type):
for static_url in getattr(blok, static_type):
res.append(format_static(blok_name, static_url))
return res
示例11: load
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [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
示例12: get_templates
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [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()
示例13: get_static
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def get_static(cls, static_type):
""" return the list of all static file path
:param static_type: entry in the blok
:rtype: list of the path
"""
res = []
Blok = cls.registry.System.Blok
for blok in Blok.list_by_state('installed'):
b = BlokManager.get(blok)
if hasattr(b, static_type):
for static_url in getattr(b, static_type):
res.append(cls.format_static(blok, static_url))
return res
示例14: load_config_bloks
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [as 别名]
def load_config_bloks(self):
""" loop on each blok, keep the order of the blok to load the
pyramid config. The blok must declare the meth
``pyramid_load_config``::
def pyramid_load_config(config):
config.add_route('hello', '/hello/{name}/')
...
"""
self.commit()
for blok_name in BlokManager.ordered_bloks:
blok = BlokManager.get(blok_name)
if hasattr(blok, 'pyramid_load_config'):
logger.debug('Load configuration from: %r' % blok_name)
blok.pyramid_load_config(self)
self.commit()
示例15: get_long_description
# 需要导入模块: from anyblok.blok import BlokManager [as 别名]
# 或者: from anyblok.blok.BlokManager import get [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