本文整理汇总了Python中venusian.attach函数的典型用法代码示例。如果您正苦于以下问题:Python attach函数的具体用法?Python attach怎么用?Python attach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了attach函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __call__
def __call__(self, wrapped):
def callback(scanner, name, ob):
if ob.classification_id not in CLASSIFICATIONS:
CLASSIFICATIONS[ob.classification_id] = ob
venusian.attach(wrapped, callback)
return wrapped
开发者ID:ecreall,项目名称:lagendacommun,代码行数:7,代码来源:classification.py
示例2: decorator
def decorator(wrapped):
def callback(scanner, name, ob):
scanner.registry.add(name, ob, internals, pass_msg)
venusian.attach(wrapped, callback)
return wrapped
开发者ID:jrabbit,项目名称:pyborg-1up,代码行数:7,代码来源:irc.py
示例3: method
def method(method_class):
"""Decorator to use to mark an API method.
When invoking L{Registry.scan} the classes marked with this decorator
will be added to the registry.
@param method_class: The L{Method} class to register.
"""
def callback(scanner, name, method_class):
if method_class.actions is not None:
actions = method_class.actions
else:
actions = [name]
if method_class.versions is not None:
versions = method_class.versions
else:
versions = [None]
for action in actions:
for version in versions:
scanner.registry.add(method_class,
action=action,
version=version)
from venusian import attach
attach(method_class, callback, category="method")
return method_class
开发者ID:ArtRichards,项目名称:txaws,代码行数:29,代码来源:method.py
示例4: __new__
def __new__(mcl, name, bases, d):
testing_config = d.get('testing_config')
d['registry'] = Registry(name, bases, testing_config,
d.get('variables', []))
result = super(AppMeta, mcl).__new__(mcl, name, bases, d)
venusian.attach(result, callback)
return result
开发者ID:io41,项目名称:morepath,代码行数:7,代码来源:app.py
示例5: _add_argument
def _add_argument(function, *args, **kwargs):
"""Add arguments to a function.
This adds a :mod:`venusian` callback to the given function in the
``serverstf:arguments`` category that, when scanned, will attempt to
add the given command line argument to the corresponding subcommand.
:param function: the function to add the callback to. This function must
be decorated by :func:`subcommand`.
:param args: passed to :meth:`argparse.ArgumentParser.add_argument`.
:param kwargs: passed to :meth:`argparse.ArgumentParser.add_argument`.
:return: the given ``function``.
"""
def callback(scanner, name, obj): # pylint: disable=unused-argument,missing-docstring
subcommands = getattr(obj, _SUBCOMMANDS, None)
if not subcommands:
raise CLIError("Can't set CLI arugments for "
"{} as it is not a subcommand".format(obj))
for command in subcommands:
command.arguments.append((args, kwargs))
# Depth 2 is required so that we can use this from within decorators.
venusian.attach(function, callback,
category=__package__ + ":arguments", depth=2)
return function
开发者ID:Holiverh,项目名称:serverstf,代码行数:27,代码来源:cli.py
示例6: decorate
def decorate(factory):
def callback(scanner, factory_name, factory):
scanner.config.action(('location', name), set_location,
args=(scanner.config, name, factory),
order=PHASE2_CONFIG)
venusian.attach(factory, callback, category='pyramid')
return factory
开发者ID:zhouyu,项目名称:encoded,代码行数:7,代码来源:contentbase.py
示例7: __call__
def __call__(self, wrapped):
decorator = self
def callback(scanner, name, obj): #pylint: disable-msg=W0613
if hasattr(scanner, 'plugin_registry'):
scanner.plugin_registry.add('administration_link', decorator.link_text, PluginRegistryItem(decorator))
venusian.attach(wrapped, callback, category='pvs.plugins')
return wrapped
开发者ID:anonymoose,项目名称:pvscore,代码行数:7,代码来源:plugin.py
示例8: decorate
def decorate(checker):
def callback(scanner, factory_name, factory):
scanner.config.add_audit_checker(
checker, item_type, condition, frame)
venusian.attach(checker, callback, category='auditor')
return checker
开发者ID:ClinGen,项目名称:clincoded,代码行数:7,代码来源:auditor.py
示例9: __call__
def __call__(self, wrapped):
def callback(scanner, name, ob):
ob.name = self.name
ob.islocal = self.islocal
ob.superiors = list(ob.superiors)
ob.superiors.extend(self.superiors)
ob.superiors = list(set(ob.superiors))
def get_allsuperiors(role_ob):
superiors = list(role_ob.superiors)
for sup in role_ob.superiors:
superiors.extend(get_allsuperiors(sup))
return list(set(superiors))
ob.all_superiors = list(ob.all_superiors)
ob.all_superiors.extend(get_allsuperiors(ob))
ob.all_superiors = list(set(ob.all_superiors))
for role in ob.all_superiors:
role.lowers = list(set(getattr(role, 'lowers', [])))
role.lowers.append(ob)
role.lowers = list(set(role.lowers))
for role in getattr(ob, 'lowers', self.lowers):
role.superiors = list(role.superiors)
role.superiors.append(ob)
role.superiors = list(set(role.superiors))
role.all_superiors = list(role.all_superiors)
role.all_superiors.append(ob)
role.all_superiors.extend(ob.all_superiors)
role.all_superiors = list(set(role.all_superiors))
DACE_ROLES[ob.name] = ob
venusian.attach(wrapped, callback)
return wrapped
开发者ID:ecreall,项目名称:dace,代码行数:35,代码来源:role.py
示例10: attach
def attach(self, action, cfg=None, depth=1):
action.info = self
if action.hash is None:
action.hash = self.hash
data = getattr(self.module, ATTACH_ATTR, None)
if data is None:
data = AttachData()
setattr(self.module, ATTACH_ATTR, data)
if cfg is None and action.hash in data:
raise TypeError(
"Directive registered twice: %s" % (action.discriminator,))
data[action.hash] = action
def callback(context, name, ob):
config = context.config.with_package(self.module)
config.info = action.info
config.action(
action.discriminator, self._runaction, (action, config),
introspectables=action.introspectables,
order=action.order)
venusian.attach(data, callback, category='ptah', depth=depth+1)
if cfg is not None:
cfg.action(
action.discriminator,
self._runaction, (action, cfg),
introspectables=action.introspectables, order=action.order)
开发者ID:webmaven,项目名称:ptah,代码行数:31,代码来源:config.py
示例11: __call__
def __call__(self, wrapped):
def callback(scanner, name, ob):
ob.component_id = self.component_id
ob.loading_component = self.loading_component
ob.on_demand = self.on_demand
ob.delegate = self.delegate
old_call = ob.update
def update(self):
if not self.params('load_view') or (self.on_demand and self.params('on_demand') != 'load'):
component = self.loading_component(
self.context, self.request,
component_id=self.component_id)
component.wrapper_template = ob.wrapper_template
component.title = ob.title
component.viewid = ob.viewid
component.view_icon = getattr(ob, 'view_icon', '')
component.counter_id = getattr(ob, 'counter_id', '')
component.css_class = ob.css_class + ' async-component-container'
component.container_css_class = ob.container_css_class + \
' async-component'
component.isactive = getattr(ob, 'isactive', False)
return component.update()
return old_call(self)
ob.update = update
ON_LOAD_VIEWS[self.component_id] = ob
venusian.attach(wrapped, callback, category='site_widget')
return wrapped
开发者ID:ecreall,项目名称:nova-ideo,代码行数:31,代码来源:core.py
示例12: decorator
def decorator(wrapped):
def callback(scanner, name, obj):
for scheme in schemes:
scanner.config.registry.registerUtility(
obj, IStorageFactory, scheme)
venusian.attach(wrapped, callback)
return wrapped
开发者ID:koslab,项目名称:pysiphae,代码行数:7,代码来源:decorators.py
示例13: __call__
def __call__(self, wrapped):
def callback(scanner, name, ob):
setattr(wrapped, '__meta__',
{'tablename': None,
'alias': 't{}'.format(self._counter),
'database': self.database,
'collation': self.collation,
'columns': None, # column name in the database
'attributes': None, # map col name to attribute name
# Populate on column descriptors
'primary_key': {},
'pkv': None,
'foreign_keys': {},
})
self.__class__._counter += 1
if not self.name:
self.name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2',
wrapped.__name__)
self.name = re.sub('([a-z0-9])([A-Z])', r'\1_\2',
self.name).lower()
wrapped.__meta__['tablename'] = self.name
meta.register(self.database, self.name, wrapped)
venusian.attach(wrapped, callback, category='aiorm')
return wrapped
开发者ID:mardiros,项目名称:aiorm,代码行数:30,代码来源:decorators.py
示例14: wrapper
def wrapper(wrapped):
def callback(scanner, name, obj):
celery_app = scanner.config.registry.celery_app
celery_app.task(**kwargs)(obj)
venusian.attach(wrapped, callback)
return wrapped
开发者ID:Connexions,项目名称:cnx-publishing,代码行数:8,代码来源:tasks.py
示例15: conf_deco
def conf_deco(func):
def callback(venusian_scanner, *_):
"""This gets called by venusian at scan time."""
self.register(venusian_scanner, key, func)
venusian.attach(func, callback, category=self.category)
return func
开发者ID:pbs,项目名称:flowy,代码行数:8,代码来源:config.py
示例16: plugin
def plugin(wrapped):
"""register a class as plugin"""
def callback(context, name, ob):
bot = context.bot
bot.get_plugin(ob)
assert isinstance(wrapped, type)
venusian.attach(wrapped, callback, category='irc3')
return wrapped
开发者ID:adevore,项目名称:irc3,代码行数:8,代码来源:dec.py
示例17: subcommand
def subcommand(wrapped):
"""This decorator makes a function becomes a subcommand
"""
def callback(scanner, name, ob):
scanner.subcommands[ob.name] = ob
venusian.attach(wrapped, callback, category='subcommands')
return wrapped
开发者ID:victorlin,项目名称:hovercraft,代码行数:8,代码来源:__init__.py
示例18: _wrapped
def _wrapped(cls):
def callback(scanner, obj_name, obj):
registry = scanner.config.registry
registry["filters"].append((name, obj))
venusian.attach(cls, callback)
return cls
开发者ID:pxfs,项目名称:fanboi2,代码行数:8,代码来源:__init__.py
示例19: doc_type
def doc_type(cls):
def callback(scanner, _name, item):
types_ = scanner.config.registry.setdefault("search.doc_types", set())
types_.add(item)
venusian.attach(cls, callback)
return cls
开发者ID:tony,项目名称:warehouse,代码行数:8,代码来源:search.py
示例20: dec
def dec(mapper):
def callback(scanner, name, ob):
config = scanner.config
todict_adapter = mapper_adapter(ob)
config.set_todict(cls, todict_adapter, name=register_name)
venusian.attach(mapper, callback,
category='pyramid')
return mapper
开发者ID:rebeccaframework,项目名称:rebecca.todict_bpmappers,代码行数:8,代码来源:__init__.py
注:本文中的venusian.attach函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论