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


Python v2_0.parse_args_to_dict函数代码示例

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


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

示例1: take_action

 def take_action(self, parsed_args):
     client = self.get_client()
     extra_values = v2_0.parse_args_to_dict(self.values_specs)
     if extra_values:
         raise exceptions.CommandError(
             _("Invalid argument(s): --%s") % ', --'.join(extra_values))
     tenant_id = parsed_args.tenant_id or parsed_args.pos_tenant_id
     if parsed_args.dry_run:
         data = client.validate_auto_allocated_topology_requirements(
             tenant_id)
     else:
         data = client.get_auto_allocated_topology(tenant_id)
     if self.resource in data:
         for k, v in data[self.resource].items():
             if isinstance(v, list):
                 value = ""
                 for _item in v:
                     if value:
                         value += "\n"
                     if isinstance(_item, dict):
                         value += jsonutils.dumps(_item)
                     else:
                         value += str(_item)
                 data[self.resource][k] = value
             elif v == "dry-run=pass":
                 return ("dry-run",), ("pass",)
             elif v is None:
                 data[self.resource][k] = ''
         return zip(*sorted(data[self.resource].items()))
     else:
         return None
开发者ID:ChameleonCloud,项目名称:python-neutronclient,代码行数:31,代码来源:auto_allocated_topology.py

示例2: get_data

 def get_data(self, parsed_args):
     self.log.debug('run(%s)', parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _extra_values = neutronV20.parse_args_to_dict(self.values_specs)
     neutronV20._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
     obj_updator = getattr(neutron_client,
                           "update_%s" % self.resource)
     tenant_id = get_tenant_id(parsed_args.tenant_id,
                               neutron_client)
     data = obj_updator(tenant_id, body)
     if self.resource in data:
         for k, v in six.iteritems(data[self.resource]):
             if isinstance(v, list):
                 value = ""
                 for _item in v:
                     if value:
                         value += "\n"
                     if isinstance(_item, dict):
                         value += jsonutils.dumps(_item)
                     else:
                         value += str(_item)
                 data[self.resource][k] = value
             elif v is None:
                 data[self.resource][k] = ''
         return zip(*sorted(six.iteritems(data[self.resource])))
     else:
         return None
开发者ID:annp,项目名称:python-neutronclient,代码行数:34,代码来源:quota.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
     data = {self.resource: parse_args_to_dict(parsed_args)}
     if parsed_args.remove_tenant:
         data[self.resource]['remove_tenant'] = parsed_args.remove_tenant
     neutron_client.update_network_profile(parsed_args.id,
                                           {self.resource: data})
     print((_('Updated %(resource)s: %(id)s') %
            {'id': parsed_args.id, 'resource': self.resource}),
           file=self.app.stdout)
     return
开发者ID:carrierstack,项目名称:python-neutronclient,代码行数:13,代码来源:networkprofile.py

示例4: 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
     data = {self.resource: parse_args_to_dict(parsed_args)}
     if parsed_args.remove_tenant:
         data[self.resource]["remove_tenant"] = parsed_args.remove_tenant
     neutron_client.update_network_profile(parsed_args.id, {self.resource: data})
     print(
         (_("Updated %(resource)s: %(id)s") % {"id": parsed_args.id, "resource": self.resource}),
         file=self.app.stdout,
     )
     return
开发者ID:Gvkrishna,项目名称:python-neutronclient,代码行数:13,代码来源:networkprofile.py

示例5: test_dict_arg_with_attribute_named_type

 def test_dict_arg_with_attribute_named_type(self):
     _specs = ['--tag=t', '--arg1', 'type=dict', 'type=value1,key2=value2']
     arg1 = neutronV20.parse_args_to_dict(_specs)['arg1']
     self.assertEqual('value1', arg1['type'])
     self.assertEqual('value2', arg1['key2'])
开发者ID:vijayendrabvs,项目名称:ssl-python-neutronclient,代码行数:5,代码来源:test_casual_args.py

示例6: test_goodarg_with_minus_number

 def test_goodarg_with_minus_number(self):
     _specs = ['--arg1', 'value1', '-1', '-1.0']
     _mydict = neutronV20.parse_args_to_dict(_specs)
     self.assertEqual(['value1', '-1', '-1.0'],
                      _mydict['arg1'])
开发者ID:vijayendrabvs,项目名称:ssl-python-neutronclient,代码行数:5,代码来源:test_casual_args.py

示例7: test_arg

 def test_arg(self):
     _specs = ['--tag=t', '--arg1', 'value1']
     self.assertEqual('value1',
                      neutronV20.parse_args_to_dict(_specs)['arg1'])
开发者ID:vijayendrabvs,项目名称:ssl-python-neutronclient,代码行数:4,代码来源:test_casual_args.py

示例8: test_bool_false

 def test_bool_false(self):
     _specs = ['--my_bool', 'type=bool', 'false', '--arg1', 'value1']
     _mydict = neutronV20.parse_args_to_dict(_specs)
     self.assertFalse(_mydict['my_bool'])
开发者ID:vijayendrabvs,项目名称:ssl-python-neutronclient,代码行数:4,代码来源:test_casual_args.py

示例9: test_nargs

 def test_nargs(self):
     _specs = ['--tag', 'x', 'y', '--arg1', 'value1']
     _mydict = neutronV20.parse_args_to_dict(_specs)
     self.assertIn('x', _mydict['tag'])
     self.assertIn('y', _mydict['tag'])
开发者ID:vijayendrabvs,项目名称:ssl-python-neutronclient,代码行数:5,代码来源:test_casual_args.py

示例10: test_arg

 def test_arg(self):
     _specs = ["--tag=t", "--arg1", "value1"]
     self.assertEqual("value1", neutronV20.parse_args_to_dict(_specs)["arg1"])
开发者ID:CingHu,项目名称:neutronclient-ustack,代码行数:3,代码来源:test_casual_args.py

示例11: test_default_bool

 def test_default_bool(self):
     _specs = ['--my_bool', '--arg1', 'value1']
     _mydict = neutronV20.parse_args_to_dict(_specs)
     self.assertTrue(_mydict['my_bool'])
开发者ID:vijayendrabvs,项目名称:ssl-python-neutronclient,代码行数:4,代码来源:test_casual_args.py

示例12: test_nargs

 def test_nargs(self):
     _specs = ["--tag", "x", "y", "--arg1", "value1"]
     _mydict = neutronV20.parse_args_to_dict(_specs)
     self.assertTrue("x" in _mydict["tag"])
     self.assertTrue("y" in _mydict["tag"])
开发者ID:CingHu,项目名称:neutronclient-ustack,代码行数:5,代码来源:test_casual_args.py

示例13: test_int_and_str

 def test_int_and_str(self):
     _specs = ['--my-int', 'type=int', '10',
               '--my-str', 'type=str', 'value1']
     _mydict = neutronV20.parse_args_to_dict(_specs)
     self.assertEqual(10, _mydict['my_int'])
     self.assertEqual('value1', _mydict['my_str'])
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:6,代码来源:test_casual_args.py

示例14: test_clear_action

 def test_clear_action(self):
     _specs = ["--anyarg", "action=clear"]
     args = neutronV20.parse_args_to_dict(_specs)
     self.assertEqual(None, args["anyarg"])
开发者ID:CingHu,项目名称:neutronclient-ustack,代码行数:4,代码来源:test_casual_args.py

示例15: test_list_of_dict_arg

 def test_list_of_dict_arg(self):
     _specs = ["--tag=t", "--arg1", "type=dict", "list=true", "key1=value1,key2=value2"]
     arg1 = neutronV20.parse_args_to_dict(_specs)["arg1"]
     self.assertEqual("value1", arg1[0]["key1"])
     self.assertEqual("value2", arg1[0]["key2"])
开发者ID:CingHu,项目名称:neutronclient-ustack,代码行数:5,代码来源:test_casual_args.py


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