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


Python gettextutils._函数代码示例

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


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

示例1: to_bytes

def to_bytes(text, default=0):
    """Converts a string into an integer of bytes.

    Looks at the last characters of the text to determine
    what conversion is needed to turn the input text into a byte number.
    Supports "B, K(B), M(B), G(B), and T(B)". (case insensitive)

    :param text: String input for bytes size conversion.
    :param default: Default return value when text is blank.

    """
    match = BYTE_REGEX.search(text)
    if match:
        magnitude = int(match.group(1))
        mult_key_org = match.group(2)
        if not mult_key_org:
            return magnitude
    elif text:
        msg = _('Invalid string format: %s') % text
        raise TypeError(msg)
    else:
        return default
    mult_key = mult_key_org.lower().replace('b', '', 1)
    multiplier = BYTE_MULTIPLIERS.get(mult_key)
    if multiplier is None:
        msg = _('Unknown byte multiplier: %s') % mult_key_org
        raise TypeError(msg)
    return magnitude * multiplier
开发者ID:Cerberus98,项目名称:python-neutronclient,代码行数:28,代码来源:strutils.py

示例2: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         'name', metavar='NAME',
         help=_('Name of security group'))
     parser.add_argument(
         '--description',
         help=_('Description of security group'))
开发者ID:B-Rich,项目名称:python-neutronclient,代码行数:7,代码来源:securitygroup.py

示例3: run

 def run(self, parsed_args):
     self.log.debug('run(%s)', parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _extra_values = parse_args_to_dict(self.values_specs)
     _merge_args(self, parsed_args, _extra_values,
                 self.values_specs)
     body = self.args2body(parsed_args)
     if self.resource in body:
         body[self.resource].update(_extra_values)
     else:
         body[self.resource] = _extra_values
     if not body[self.resource]:
         raise exceptions.CommandError(
             _("Must specify new values to update %s") %
             self.cmd_resource)
     if self.allow_names:
         _id = find_resourceid_by_name_or_id(
             neutron_client, self.resource, parsed_args.id,
             cmd_resource=self.cmd_resource)
     else:
         _id = find_resourceid_by_id(
             neutron_client, self.resource, parsed_args.id,
             self.cmd_resource, self.parent_id)
     obj_updater = getattr(neutron_client,
                           "update_%s" % self.cmd_resource)
     if self.parent_id:
         obj_updater(_id, self.parent_id, body)
     else:
         obj_updater(_id, body)
     print((_('Updated %(resource)s: %(id)s') %
            {'id': parsed_args.id, 'resource': self.resource}),
           file=self.app.stdout)
     return
开发者ID:AsherBond,项目名称:python-quantumclient,代码行数:34,代码来源:__init__.py

示例4: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         '--name',
         help=_('Name of security group.'))
     parser.add_argument(
         '--description',
         help=_('Description of security group.'))
开发者ID:yuvarajan07,项目名称:python-neutronclient,代码行数:7,代码来源:securitygroup.py

示例5: validate_lifetime_dict

def validate_lifetime_dict(lifetime_dict):

    for key, value in lifetime_dict.items():
        if key not in lifetime_keys:
            message = _(
                "Lifetime Dictionary KeyError: "
                "Reason-Invalid unit key : "
                "'%(key)s' not in %(supported_key)s ") % {
                    'key': key, 'supported_key': lifetime_keys}
            raise KeyError(message)
        if key == 'units' and value not in lifetime_units:
            message = _(
                "Lifetime Dictionary ValueError: "
                "Reason-Invalid units : "
                "'%(key_value)s' not in %(supported_units)s ") % {
                    'key_value': key, 'supported_units': lifetime_units}
            raise ValueError(message)
        if key == 'value':
            if int(value) < 60:
                message = _(
                    "Lifetime Dictionary ValueError: "
                    "Reason-Invalid value should be at least 60:"
                    "'%(key_value)s' = %(value)i ") % {
                        'key_value': key, 'value': int(value)}
                raise ValueError(str(message))
            else:
                lifetime_dict['value'] = int(value)
    return
开发者ID:niuzhenguo,项目名称:python-neutronclient,代码行数:28,代码来源:utils.py

示例6: get_parser

 def get_parser(self, prog_name):
     parser = super(DisassociateHealthMonitor, self).get_parser(prog_name)
     parser.add_argument("health_monitor_id", metavar="HEALTH_MONITOR_ID", help=_("Health monitor to associate."))
     parser.add_argument(
         "pool_id", metavar="POOL", help=_("ID of the pool to be associated with the health monitor.")
     )
     return parser
开发者ID:rackerlabs,项目名称:python-neutronclient,代码行数:7,代码来源:healthmonitor.py

示例7: validate_dpd_dict

def validate_dpd_dict(dpd_dict):
    for key, value in dpd_dict.items():
        if key not in dpd_supported_keys:
            message = _(
                "DPD Dictionary KeyError: "
                "Reason-Invalid DPD key : "
                "'%(key)s' not in %(supported_key)s ") % {
                    'key': key, 'supported_key': dpd_supported_keys}
            raise KeyError(message)
        if key == 'action' and value not in dpd_supported_actions:
            message = _(
                "DPD Dictionary ValueError: "
                "Reason-Invalid DPD action : "
                "'%(key_value)s' not in %(supported_action)s ") % {
                    'key_value': value,
                    'supported_action': dpd_supported_actions}
            raise ValueError(message)
        if key in ('interval', 'timeout'):
            if int(value) <= 0:
                message = _(
                    "DPD Dictionary ValueError: "
                    "Reason-Invalid positive integer value: "
                    "'%(key)s' = %(value)i ") % {
                        'key': key, 'value': int(value)}
                raise ValueError(message)
            else:
                dpd_dict[key] = int(value)
    return
开发者ID:niuzhenguo,项目名称:python-neutronclient,代码行数:28,代码来源:utils.py

示例8: get_parser

 def get_parser(self, prog_name):
     parser = super(UpdatePolicyProfileV2, self).get_parser(prog_name)
     parser.add_argument("--add-tenant",
                         help=_("Add tenant to the policy profile"))
     parser.add_argument("--remove-tenant",
                         help=_("Remove tenant from the policy profile"))
     return parser
开发者ID:ralphwort,项目名称:chef-repo,代码行数:7,代码来源:policyprofile.py

示例9: run_subcommand

 def run_subcommand(self, argv):
     subcommand = self.command_manager.find_command(argv)
     cmd_factory, cmd_name, sub_argv = subcommand
     cmd = cmd_factory(self, self.options)
     err = None
     result = 1
     try:
         self.prepare_to_run_command(cmd)
         full_name = cmd_name if self.interactive_mode else " ".join([self.NAME, cmd_name])
         cmd_parser = cmd.get_parser(full_name)
         return run_command(cmd, cmd_parser, sub_argv)
     except Exception as err:
         if self.options.verbose_level == self.DEBUG_LEVEL:
             self.log.exception(unicode(err))
         else:
             self.log.error(unicode(err))
         try:
             self.clean_up(cmd, result, err)
         except Exception as err2:
             if self.options.verbose_level == self.DEBUG_LEVEL:
                 self.log.exception(unicode(err2))
             else:
                 self.log.error(_("Could not clean up: %s"), unicode(err2))
         if self.options.verbose_level == self.DEBUG_LEVEL:
             raise
     else:
         try:
             self.clean_up(cmd, result, None)
         except Exception as err3:
             if self.options.verbose_level == self.DEBUG_LEVEL:
                 self.log.exception(unicode(err3))
             else:
                 self.log.error(_("Could not clean up: %s"), unicode(err3))
     return result
开发者ID:CingHu,项目名称:neutronclient-ustack,代码行数:34,代码来源:shell.py

示例10: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         "loadbalancer_id", metavar="LOADBALANCER", help=_("ID of the load balancer the listener belong to.")
     )
     parser.add_argument(
         "protocol",
         metavar="PROTOCOL",
         choices=["TCP", "HTTP", "HTTPS", "TERMINATED_HTTPS"],
         help=_("Protocol for the listener."),
     )
     parser.add_argument("protocol_port", metavar="PROTOCOL_PORT", help=_("Protocol port for the listener."))
     parser.add_argument(
         "--connection-limit", metavar="CONNETION_LIMIT", help=_("The connection limit for the listener.")
     )
     parser.add_argument("--default-pool-id", metavar="POOL", help=_("The default pool ID to use."))
     parser.add_argument(
         "--default-tls-container-id",
         metavar="DEFAULT_TLS_CONTAINER_ID",
         help=_("The default tls container ID to use."),
     )
     parser.add_argument(
         "--sni_container_ids", metavar="SNI_TLS_CONTAINER_IDs", help=_("The sni tls container IDs to use.")
     )
     parser.add_argument(
         "--admin-state-down", dest="admin_state", action="store_false", help=_("Set admin state up to false.")
     )
     parser.add_argument("--keep-alive", dest="keep_alive", action="store_true", help=_("Set keep alive flag."))
     parser.add_argument("--name", required=False, help=_("Name of the listener."))
     parser.add_argument("--description", help=_("Description of the listener."))
开发者ID:CingHu,项目名称:neutronclient-ustack,代码行数:29,代码来源:listener.py

示例11: updatable_args2body

def updatable_args2body(parsed_args, body):
    if parsed_args.gateway and parsed_args.no_gateway:
        raise exceptions.CommandError(_("--gateway option and "
                                      "--no-gateway option can "
                                      "not be used same time"))
    if parsed_args.disable_dhcp and parsed_args.enable_dhcp:
        raise exceptions.CommandError(_("--enable-dhcp and --disable-dhcp can "
                                      "not be used in the same command."))

    if parsed_args.no_gateway:
        body['subnet'].update({'gateway_ip': None})
    if parsed_args.gateway:
        body['subnet'].update({'gateway_ip': parsed_args.gateway})
    if parsed_args.name:
        body['subnet'].update({'name': parsed_args.name})
    if parsed_args.disable_dhcp:
        body['subnet'].update({'enable_dhcp': False})
    if parsed_args.enable_dhcp:
        body['subnet'].update({'enable_dhcp': True})
    if parsed_args.allocation_pools:
        body['subnet']['allocation_pools'] = parsed_args.allocation_pools
    if parsed_args.host_routes:
        body['subnet']['host_routes'] = parsed_args.host_routes
    if parsed_args.dns_nameservers:
        body['subnet']['dns_nameservers'] = parsed_args.dns_nameservers
开发者ID:carrierstack,项目名称:python-neutronclient,代码行数:25,代码来源:subnet.py

示例12: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         'l7policy_id', metavar='L7POLICY',
         help=_('ID of the l7policy that this l7rule belongs to.'))
     parser.add_argument(
         '--key',
         required=False,
         help=_('Key of the l7rule.'))
开发者ID:CingHu,项目名称:neutronclient-ustack,代码行数:8,代码来源:l7rule.py

示例13: get_parser

 def get_parser(self, prog_name):
     parser = super(RemoveNetworkFromDhcpAgent, self).get_parser(prog_name)
     parser.add_argument(
         'dhcp_agent',
         help=_('ID of the DHCP agent.'))
     parser.add_argument(
         'network',
         help=_('Network to remove.'))
     return parser
开发者ID:AsherBond,项目名称:python-quantumclient,代码行数:9,代码来源:agentscheduler.py

示例14: get_parser

 def get_parser(self, prog_name):
     parser = super(DisassociateHealthMonitor, self).get_parser(prog_name)
     parser.add_argument(
         'health_monitor_id', metavar='HEALTH_MONITOR_ID',
         help=_('Health monitor to associate.'))
     parser.add_argument(
         'pool_id', metavar='POOL',
         help=_('ID of the pool to be associated with the health monitor.'))
     return parser
开发者ID:carrierstack,项目名称:python-neutronclient,代码行数:9,代码来源:healthmonitor.py

示例15: add_known_arguments

 def add_known_arguments(self, parser):
     parser.add_argument(
         "--admin-state-down", dest="admin_state", action="store_false", help=_("Set admin state up to false.")
     )
     parser.add_argument("--admin_state_down", dest="admin_state", action="store_false", help=argparse.SUPPRESS)
     parser.add_argument(
         "--shared", action="store_true", help=_("Set the network as shared."), default=argparse.SUPPRESS
     )
     parser.add_argument("name", metavar="NAME", help=_("Name of network to create."))
开发者ID:yanheven,项目名称:OpenStackInAction,代码行数:9,代码来源:network.py


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