本文整理汇总了Python中watson.common.imports.get_qualified_name函数的典型用法代码示例。如果您正苦于以下问题:Python get_qualified_name函数的具体用法?Python get_qualified_name怎么用?Python get_qualified_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_qualified_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __process_exception
def __process_exception(self, exc_info):
try:
code = exc_info[1].status_code
except:
code = 500
exc = exc_info[1]
message = str(exc)
cause_message = None
try:
exc = exc.__cause__
tb = exc.__traceback__
cause_message = str(exc)
type = get_qualified_name(exc)
except:
tb = exc_info[2]
type = get_qualified_name(exc_info[0])
frames = []
while tb is not None:
frame = tb.tb_frame
line = tb.tb_lineno
co = frame.f_code
file = co.co_filename
function = co.co_name
linecache.checkcache(file)
sourcecode = linecache.getline(file, line, frame.f_globals)
this_frame = {
'line': line,
'file': file,
'function': function,
'code': sourcecode.strip(),
'vars': {}
}
frame_vars = frame.f_locals.items()
for var_name, value in frame_vars:
val = None
try:
val = str(value)
except: # pragma: no cover
try:
val = repr(value) # pragma: no cover
except:
val = None
this_frame['vars'][var_name] = val
frames.append(this_frame)
tb = tb.tb_next
frames.reverse()
del tb
return code, message, cause_message, frames, type
开发者ID:watsonpy,项目名称:watson-framework,代码行数:48,代码来源:exceptions.py
示例2: __repr__
def __repr__(self):
return (
'<{0} template:{1} format:{2}>'.format(
imports.get_qualified_name(self),
self.template,
self.format)
)
开发者ID:enigma,项目名称:watson,代码行数:7,代码来源:views.py
示例3: __repr__
def __repr__(self):
return (
'<{0} routers:{1} routes:{2}>'.format(
get_qualified_name(self),
len(self.routers),
len(self))
)
开发者ID:watsonpy,项目名称:watson-routing,代码行数:7,代码来源:routers.py
示例4: generate_fixtures
def generate_fixtures(self, models, output_to_stdout):
"""Generate fixture data in json format.
Args:
models (string): A comma separated list of models to output
output_to_stdout (boolean): Whether or not to output to the stdout
"""
if models:
models = models.split(',')
for name, options in self.config['connections'].items():
metadata = self._load_metadata(options['metadata'])
for model in metadata._decl_class_registry.values():
model_name = imports.get_qualified_name(model)
if models and model_name not in models:
continue
records = self._get_models_in_session(name, model)
if not records:
continue
records = json.dumps(records, indent=4)
if output_to_stdout:
self.write(records)
else:
model_name, path = fixtures.save(
model, records, self.config['fixtures'])
self.write(
'Created fixture for {} at {}'.format(model_name, path))
开发者ID:watsonpy,项目名称:watson-db,代码行数:26,代码来源:commands.py
示例5: __repr__
def __repr__(self):
return (
'<{0} name:{1} path:{2}>'.format(
get_qualified_name(self),
self.name,
self.path)
)
开发者ID:B-Rich,项目名称:watson-routing,代码行数:7,代码来源:routes.py
示例6: __repr__
def __repr__(self):
return '<{0} name:{1} method:{2} action:{3} fields:{4}>'.format(
get_qualified_name(self),
self.name,
self.method,
self.action,
len(self))
开发者ID:erhuabushuo,项目名称:watson,代码行数:7,代码来源:forms.py
示例7: __repr__
def __repr__(self):
return (
'<{0} name:{1} path:{2} match:{3}>'.format(
get_qualified_name(self),
self.name,
self.path,
self.regex.pattern)
)
开发者ID:strogo,项目名称:watson-framework,代码行数:8,代码来源:routing.py
示例8: get_command
def get_command(self, command_name):
# overrides the runners get_command method
if command_name not in self.runner.commands:
return None
command = self.runner.commands[command_name]
if not isinstance(command, str):
self.container.add(command_name, get_qualified_name(command))
return self.container.get(command_name)
开发者ID:erhuabushuo,项目名称:watson,代码行数:8,代码来源:applications.py
示例9: save
def save(model, items, fixtures_config):
model_name = strings.pluralize(
strings.snakecase(model.__name__))
path = '{}/{}.json'.format(
fixtures_config['path'],
model_name)
with open(path, 'w') as file:
file.write(items)
return imports.get_qualified_name(model), path
开发者ID:watsonpy,项目名称:watson-db,代码行数:9,代码来源:fixtures.py
示例10: wrapper
def wrapper(self, *args, **kwargs):
if not hasattr(self, 'container'):
cache_instance = DEFAULT_CACHE_TYPE()
else:
cache_config = self.container.get('application.config')['cache']
cache_instance = self.container.get(cache_config['type'])
key_name = key if key else get_qualified_name(func)
if key_name not in cache_instance:
cache_instance.set(key_name, func(self, *args, **kwargs), timeout)
return cache_instance[key_name]
开发者ID:erhuabushuo,项目名称:watson,代码行数:10,代码来源:decorators.py
示例11: add
def add(self, name, obj, type_='singleton'):
"""Add an instantiated dependency to the container.
Args:
name (string): The name used to reference the dependency
obj (mixed): The dependency to add
type_ (string): prototype|singleton depending on if it should be
instantiated on each IocContainer.get call.
"""
self._add_to_instantiated(name, obj)
self.add_definition(name,
{'type': type_,
'item': imports.get_qualified_name(obj)})
开发者ID:B-Rich,项目名称:watson-di,代码行数:13,代码来源:container.py
示例12: __setitem__
def __setitem__(self, field, value, replace=False, **options):
if self.mutable:
field = convert_to_http_field(field)
value = [str(value)]
if options:
value.extend(['{0}={1}'.format(key, val) for
key, val in options.items()])
value = '; '.join(value)
if isinstance(self.environ, MultiDict):
self.environ.set(field, value, replace)
else:
self.environ[field] = value
else:
raise TypeError('{0} is not mutable.'.format(get_qualified_name(self)))
开发者ID:bluecottagesoftware,项目名称:watson-http,代码行数:14,代码来源:headers.py
示例13: __process_exception
def __process_exception(self, exc_info):
try:
code = exc_info[1].status_code
except:
code = 500
exc = exc_info[1]
message = str(exc)
cause_message = None
try:
exc = exc.__cause__
tb = exc.__traceback__
cause_message = str(exc)
type = get_qualified_name(exc)
except:
tb = exc_info[2]
type = get_qualified_name(exc_info[0])
frames = []
while tb is not None:
frame = tb.tb_frame
line = tb.tb_lineno
co = frame.f_code
file = co.co_filename
function = co.co_name
linecache.checkcache(file)
sourcecode = linecache.getline(file, line, frame.f_globals)
frames.append({
'line': line,
'file': file,
'function': function,
'code': sourcecode.strip(),
'vars': frame.f_locals.items()
})
tb = tb.tb_next
frames.reverse()
del tb
return code, message, cause_message, frames, type
开发者ID:erhuabushuo,项目名称:watson,代码行数:36,代码来源:exceptions.py
示例14: add
def add(self, callback, priority=1, only_once=False):
"""Adds a new callback to the collection.
Args:
callback (callable): the function to be triggered
priority (int): how important the callback is in relation to others
only_once (bool): the callback should only be fired once and then removed
Raises:
TypeError if non-callable is added.
"""
if not hasattr(callback, '__call__'):
name = get_qualified_name(callback)
raise TypeError('Callback {0} must be callable.'.format(name))
self.append(ListenerDefinition(callback, priority, only_once))
self.require_sort = True
return self
开发者ID:B-Rich,项目名称:watson-events,代码行数:17,代码来源:collections.py
示例15: get_returned_controller_data
def get_returned_controller_data(self, controller, event):
context = event.params['context']
route_match = context['route_match']
try:
execute_params = route_match.params
model_data = controller.execute(**execute_params)
if isinstance(model_data, controllers.ACCEPTABLE_RETURN_TYPES):
model_data = {'content': model_data}
elif isinstance(model_data, Response):
# Short circuited, skip any templating
controller.response = context['response'] = model_data
return model_data, model_data
path = controller.get_execute_method_path(
**route_match.params)
controller_template = os.path.join(*path)
view_template = self.templates.get(controller_template,
controller_template)
format = route_match.params.get('format', 'html')
if isinstance(model_data, Model):
if not model_data.template:
model_data.template = view_template
else:
overridden_template = path[:-1] + [model_data.template]
model_data.template = os.path.join(
*overridden_template)
if not model_data.format:
model_data.format = format
view_model = model_data
else:
view_model = Model(
format=format,
template=view_template,
data=model_data)
context['response'] = controller.response
return controller.response, view_model
except (ApplicationError, NotFoundError, InternalServerError) as exc:
raise # pragma: no cover
except Exception as exc:
raise InternalServerError(
'An error occurred executing controller: {0}'.format(
get_qualified_name(controller))) from exc
开发者ID:watsonpy,项目名称:watson-framework,代码行数:41,代码来源:listeners.py
示例16: _get_models_in_session
def _get_models_in_session(self, name, model):
results = []
if isinstance(model, _ModuleMarker):
return None
inst = inspect(model)
attr_names = [c_attr.key for c_attr in inst.mapper.column_attrs]
for obj in self.sessions[name].query(model):
fields = {}
new_obj = collections.OrderedDict()
new_obj['class'] = imports.get_qualified_name(model)
attr_names = [c_attr.key for c_attr in inst.mapper.column_attrs]
for column in attr_names:
value = getattr(obj, column)
if isinstance(value, enum.Enum):
value = value.value
elif isinstance(value, datetime):
value = str(value)
elif isinstance(value, bytes):
value = value.decode('utf-8')
fields[column] = value
new_obj['fields'] = collections.OrderedDict(
sorted(fields.items(), key=lambda k: k[0]))
results.append(new_obj)
return results
开发者ID:watsonpy,项目名称:watson-db,代码行数:24,代码来源:commands.py
示例17: __delitem__
def __delitem__(self, field):
if self.mutable:
field = convert_to_http_field(field)
del self.environ[field]
else:
raise TypeError('{0} is not mutable.'.format(get_qualified_name(self)))
开发者ID:bluecottagesoftware,项目名称:watson-http,代码行数:6,代码来源:headers.py
示例18: test_qualified_name
def test_qualified_name(self):
assert 'tests.watson.common.test_imports.TestImports' == get_qualified_name(
self)
assert 'tests.watson.common.support.some_func' == get_qualified_name(
some_func)
开发者ID:enigma,项目名称:watson,代码行数:5,代码来源:test_imports.py
示例19: __repr__
def __repr__(self):
return '<{0} name:{1}>'.format(get_qualified_name(self), self.name)
开发者ID:B-Rich,项目名称:watson-form,代码行数:2,代码来源:fields.py
示例20: __repr__
def __repr__(self):
return (
'<{0}: {1} param(s), {2} definition(s)>').format(
imports.get_qualified_name(self), len(self.params),
len(self.definitions)
)
开发者ID:B-Rich,项目名称:watson-di,代码行数:6,代码来源:container.py
注:本文中的watson.common.imports.get_qualified_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论