当前位置: 首页>>代码示例>>Python>>正文


Python gettextutils._函数代码示例

本文整理汇总了Python中vnfsvc.openstack.common.gettextutils._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_paste_app

def load_paste_app(app_name):
    """Builds and returns a WSGI app from a paste config file.

    :param app_name: Name of the application to load
    :raises ConfigFilesNotFoundError when config file cannot be located
    :raises RuntimeError when application cannot be loaded from config file
    """

    config_path = cfg.CONF.find_file(cfg.CONF.api_paste_config)
    if not config_path:
        raise cfg.ConfigFilesNotFoundError(
            config_files=[cfg.CONF.api_paste_config])
    config_path = os.path.abspath(config_path)
    LOG.info(_("Config paste file: %s"), config_path)

    try:
        app = deploy.loadapp("config:%s" % config_path, name=app_name)
    except (LookupError, ImportError):
        msg = (_("Unable to load %(app_name)s from "
                 "configuration file %(config_path)s.") %
               {'app_name': app_name,
                'config_path': config_path})
        LOG.exception(msg)
        raise RuntimeError(msg)
    return app
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:25,代码来源:config.py

示例2: _verify_dict_keys

def _verify_dict_keys(expected_keys, target_dict, strict=True):
    """Allows to verify keys in a dictionary.

    :param expected_keys: A list of keys expected to be present.
    :param target_dict: The dictionary which should be verified.
    :param strict: Specifies whether additional keys are allowed to be present.
    :return: True, if keys in the dictionary correspond to the specification.
    """
    if not isinstance(target_dict, dict):
        msg = (_("Invalid input. '%(target_dict)s' must be a dictionary "
                 "with keys: %(expected_keys)s") %
               {'target_dict': target_dict, 'expected_keys': expected_keys})
        return msg

    expected_keys = set(expected_keys)
    provided_keys = set(target_dict.keys())

    predicate = expected_keys.__eq__ if strict else expected_keys.issubset

    if not predicate(provided_keys):
        msg = (_("Validation of dictionary's keys failed."
                 "Expected keys: %(expected_keys)s "
                 "Provided keys: %(provided_keys)s") %
               {'expected_keys': expected_keys,
                'provided_keys': provided_keys})
        return msg
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:26,代码来源:attributes.py

示例3: _parse_check

def _parse_check(rule):
    """
    Parse a single base check rule into an appropriate Check object.
    """

    # Handle the special checks
    if rule == '!':
        return FalseCheck()
    elif rule == '@':
        return TrueCheck()

    try:
        kind, match = rule.split(':', 1)
    except Exception:
        LOG.exception(_("Failed to understand rule %(rule)s") % locals())
        # If the rule is invalid, we'll fail closed
        return FalseCheck()

    # Find what implements the check
    if kind in _checks:
        return _checks[kind](kind, match)
    elif None in _checks:
        return _checks[None](kind, match)
    else:
        LOG.error(_("No handler for matches of kind %s") % kind)
        return FalseCheck()
开发者ID:hemanthnakkina,项目名称:vnfmanager,代码行数:26,代码来源:policy.py

示例4: _validate_range

def _validate_range(data, valid_values=None):
    """Check that integer value is within a range provided.

    Test is inclusive. Allows either limit to be ignored, to allow
    checking ranges where only the lower or upper limit matter.
    It is expected that the limits provided are valid integers or
    the value None.
    """

    min_value = valid_values[0]
    max_value = valid_values[1]
    try:
        data = int(data)
    except (ValueError, TypeError):
        msg = _("'%s' is not an integer") % data
        LOG.debug(msg)
        return msg
    if min_value is not UNLIMITED and data < min_value:
        msg = _("'%(data)s' is too small - must be at least "
                "'%(limit)d'") % {'data': data, 'limit': min_value}
        LOG.debug(msg)
        return msg
    if max_value is not UNLIMITED and data > max_value:
        msg = _("'%(data)s' is too large - must be no larger than "
                "'%(limit)d'") % {'data': data, 'limit': max_value}
        LOG.debug(msg)
        return msg
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:27,代码来源:attributes.py

示例5: inner

 def inner(*args, **kwargs):
     try:
         with lock(name, lock_file_prefix, external, lock_path):
             LOG.debug(_('Got semaphore / lock "%(function)s"'),
                       {'function': f.__name__})
             return f(*args, **kwargs)
     finally:
         LOG.debug(_('Semaphore / lock released "%(function)s"'),
                   {'function': f.__name__})
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:9,代码来源:lockutils.py

示例6: send_ack

 def send_ack(self, context, vnfd, vdu, instance, status, nsd_id):
     if status == 'COMPLETE':
         self.plugin.build_acknowledge_list(context, vnfd, vdu, instance,
                                            status, nsd_id)
         LOG.debug(_('ACK received from VNFManager: '
                     'Configuration complete for VNF %s'), instance)
     else:
         self.plugin.build_acknowledge_list(context,vnfd, vdu, instance,
                                            status, nsd_id)
         LOG.debug(_('ACK received from VNFManager: '
                     'Confguration failed for VNF %s'), instance)
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:11,代码来源:plugin.py

示例7: validate_head_file

def validate_head_file(config):
    script = alembic_script.ScriptDirectory.from_config(config)
    if len(script.get_heads()) > 1:
        alembic_util.err(_('Timeline branches unable to generate timeline'))

    head_path = os.path.join(script.versions, HEAD_FILENAME)
    if (os.path.isfile(head_path) and
        open(head_path).read().strip() == script.get_current_head()):
        return
    else:
        alembic_util.err(_('HEAD file does not match migration timeline head'))
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:11,代码来源:cli.py

示例8: _validate_string

def _validate_string(data, max_len=None):
    if not isinstance(data, basestring):
        msg = _("'%s' is not a valid string") % data
        LOG.debug(msg)
        return msg

    if max_len is not None and len(data) > max_len:
        msg = (_("'%(data)s' exceeds maximum length of %(max_len)s") %
               {'data': data, 'max_len': max_len})
        LOG.debug(msg)
        return msg
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:11,代码来源:attributes.py

示例9: _validate_non_negative

def _validate_non_negative(data, valid_values=None):
    try:
        data = int(data)
    except (ValueError, TypeError):
        msg = _("'%s' is not an integer") % data
        LOG.debug(msg)
        return msg

    if data < 0:
        msg = _("'%s' should be non-negative") % data
        LOG.debug(msg)
        return msg
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:12,代码来源:attributes.py

示例10: _run_wsgi

def _run_wsgi(app_name):
    app = config.load_paste_app(app_name)
    if not app:
        LOG.error(_('No known API applications configured.'))
        return
    server = wsgi.Server("vnfsvc")
    server.start(app, cfg.CONF.bind_port, cfg.CONF.bind_host)
    # Dump all option values here after all options are parsed
    cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
    LOG.info(_("VNF service started, listening on %(host)s:%(port)s"),
             {'host': cfg.CONF.bind_host,
              'port': cfg.CONF.bind_port})
    return server
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:13,代码来源:service.py

示例11: _get_plugin_instance

 def _get_plugin_instance(self, namespace, plugin_provider):
     try:
         # Try to resolve plugin by name
         mgr = driver.DriverManager(namespace, plugin_provider)
         plugin_class = mgr.driver
     except RuntimeError as e1:
         # fallback to class name
         try:
             plugin_class = importutils.import_class(plugin_provider)
         except ImportError as e2:
             LOG.exception(_("Error loading plugin by name, %s"), e1)
             LOG.exception(_("Error loading plugin by class, %s"), e2)
             raise ImportError(_("Plugin not found."))
     return plugin_class()
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:14,代码来源:manager.py

示例12: read

 def read(self, i=None):
     result = self.data.read(i)
     self.bytes_read += len(result)
     if self.bytes_read > self.limit:
         msg = _("Request is too large.")
         raise webob.exc.HTTPRequestEntityTooLarge(explanation=msg)
     return result
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:7,代码来源:sizelimit.py

示例13: _populate_tenant_id

    def _populate_tenant_id(context, res_dict, is_create):

        if (('tenant_id' in res_dict and
             res_dict['tenant_id'] != context.tenant_id and
             not context.is_admin)):
            msg = _("Specifying 'tenant_id' other than authenticated "
                    "tenant in request requires admin privileges")
            raise webob.exc.HTTPBadRequest(msg)

        if is_create and 'tenant_id' not in res_dict:
            if context.tenant_id:
                res_dict['tenant_id'] = context.tenant_id
            else:
                msg = _("Running without keystone AuthN requires "
                        " that tenant_id is specified")
                raise webob.exc.HTTPBadRequest(msg)
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:16,代码来源:base.py

示例14: _validate_uuid_list

def _validate_uuid_list(data, valid_values=None):
    if not isinstance(data, list):
        msg = _("'%s' is not a list") % data
        LOG.debug(msg)
        return msg

    for item in data:
        msg = _validate_uuid(item)
        if msg:
            LOG.debug(msg)
            return msg

    if len(set(data)) != len(data):
        msg = _("Duplicate items in the list: '%s'") % ', '.join(data)
        LOG.debug(msg)
        return msg
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:16,代码来源:attributes.py

示例15: _to_xml_node

 def _to_xml_node(self, parent, metadata, nodename, data, used_prefixes):
     """Recursive method to convert data members to XML nodes."""
     result = etree.SubElement(parent, nodename)
     if ":" in nodename:
         used_prefixes.append(nodename.split(":", 1)[0])
     if isinstance(data, list):
         if not data:
             result.set(
                 constants.TYPE_ATTR,
                 constants.TYPE_LIST)
             return result
         singular = metadata.get('plurals', {}).get(nodename, None)
         if singular is None:
             if nodename.endswith('s'):
                 singular = nodename[:-1]
             else:
                 singular = 'item'
         for item in data:
             self._to_xml_node(result, metadata, singular, item,
                               used_prefixes)
     elif isinstance(data, dict):
         if not data:
             result.set(
                 constants.TYPE_ATTR,
                 constants.TYPE_DICT)
             return result
         attrs = metadata.get('attributes', {}).get(nodename, {})
         for k, v in data.items():
             if k in attrs:
                 result.set(k, str(v))
             else:
                 self._to_xml_node(result, metadata, k, v,
                                   used_prefixes)
     elif data is None:
         result.set(constants.XSI_ATTR, 'true')
     else:
         if isinstance(data, bool):
             result.set(
                 constants.TYPE_ATTR,
                 constants.TYPE_BOOL)
         elif isinstance(data, int):
             result.set(
                 constants.TYPE_ATTR,
                 constants.TYPE_INT)
         elif isinstance(data, long):
             result.set(
                 constants.TYPE_ATTR,
                 constants.TYPE_LONG)
         elif isinstance(data, float):
             result.set(
                 constants.TYPE_ATTR,
                 constants.TYPE_FLOAT)
         LOG.debug(_("Data %(data)s type is %(type)s"),
                   {'data': data,
                    'type': type(data)})
         if isinstance(data, str):
             result.text = unicode(data, 'utf-8')
         else:
             result.text = unicode(data)
     return result
开发者ID:hemanthnakkina,项目名称:vnfsvc,代码行数:60,代码来源:wsgi.py


注:本文中的vnfsvc.openstack.common.gettextutils._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。