本文整理汇总了Python中mixcoatl.utils.camelize函数的典型用法代码示例。如果您正苦于以下问题:Python camelize函数的具体用法?Python camelize怎么用?Python camelize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了camelize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_waiting_for_job
def test_waiting_for_job(self):
"""test Job.wait_for(<id>) works"""
with open(self.json_file) as f:
running_data = json.load(f)
with open(self.json_file) as f:
finished_data = json.load(f)
running_data[self.cls.COLLECTION_NAME][:] = [d for d in running_data[self.cls.COLLECTION_NAME] if
d[camelize(self.cls.PRIMARY_KEY)] == 4]
finished_data[self.cls.COLLECTION_NAME][:] = [d for d in finished_data[self.cls.COLLECTION_NAME] if
d[camelize(self.cls.PRIMARY_KEY)] == 4]
finished_data[self.cls.COLLECTION_NAME][0]['status'] = 'COMPLETE'
finished_data[self.cls.COLLECTION_NAME][0]['message'] = '12345'
HTTPretty.register_uri(HTTPretty.GET,
self.es_url+'/'+str(4),
responses = [
#HTTPretty.Response(body=json.dumps(running_data), status=200, content_type='application/json')
HTTPretty.Response(body=json.dumps(finished_data), status=200, content_type='application/json')
])
def validate(x):
assert isinstance(x, self.cls)
assert x.status == 'COMPLETE'
assert x.message == '12345'
y = self.cls.wait_for(4, callback=validate)
z = self.cls.wait_for(4)
assert z is True
示例2: all
def all(cls, **kwargs):
"""List all volumes
:param account_id: Restrict to volumes owned by `account_id`
:type account_id: int.
:param datacenter_id: Restrict to volumes based in `datacenter_id`
:type datacenter_id: int.
:param region_id: Restrict to volumes in `region_id`
:type region_id: int.
:param keys_only: Return :attr:`snapshot_id` or :class:`Snapshot`
:type keys_only: bool.
:param detail: Level of detail to return - `basic` or `extended`
:type detail: str.
:returns: `list` of :attr:`volume_id` or :class:`Volume`
:raises: :class:`VolumeException`
"""
params = {}
r = Resource(cls.PATH)
r.request_details = 'none'
if 'detail' in kwargs:
request_details = kwargs['detail']
else:
request_details = 'extended'
if 'keys_only' in kwargs:
keys_only = kwargs['keys_only']
else:
keys_only = False
if 'datacenter_id' in kwargs:
params['dataCenterId'] = kwargs['datacenter_id']
if 'region_id' in kwargs:
params['regionId'] = kwargs['region_id']
if 'account_id' in kwargs:
params['accountId'] = kwargs['account_id']
x = r.get(params=params)
if r.last_error is None:
keys = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
if keys_only is True:
volumes = keys
else:
volumes = []
for i in x[cls.COLLECTION_NAME]:
key = i[camelize(cls.PRIMARY_KEY)]
volume = cls(key)
volume.request_details = request_details
volume.load()
volumes.append(volume)
return volumes
else:
raise VolumeException(r.last_error)
示例3: test_has_one
def test_has_one(self):
"""test Snapshot(<id>) returns a valid resource"""
pk = 23237460
with open(self.json_file) as f:
data = json.load(f)
data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
d[camelize(self.cls.PRIMARY_KEY)] == pk]
HTTPretty.register_uri(HTTPretty.GET,
self.es_url+'/'+str(pk),
body=json.dumps(data),
status=200,
content_type="application/json")
s = self.cls(pk)
assert s.snapshot_id == 23237460
assert s.available is True
assert s.label is None
assert s.budget == 10287
assert s.created_timestamp == '2012-11-20T01:31:53.000+0000'
assert s.status == 'ACTIVE'
assert s.region['region_id'] == 19556
assert s.customer['customer_id'] == 12345
assert s.encrypted is False
assert s.description == 'snap-b0810e80'
assert s.sharable is True
assert s.name == 'snap-b0810e80'
assert s.volume['volume_id'] == 209179
assert s.provider_id == 'snap-b0810e80'
assert s.cloud['cloud_id'] == 1
assert s.owning_account['account_id'] == 16000
assert s.removable is True
assert s.size_in_gb -- 8
示例4: all
def all(cls, endpoint=None, **kwargs):
r = Resource(cls.PATH,endpoint=endpoint)
params = {}
if 'detail' in kwargs:
r.request_details = kwargs['detail']
else:
r.request_details = 'basic'
if 'keys_only' in kwargs:
keys_only = kwargs['keys_only']
else:
keys_only = False
if 'params' in kwargs:
params = kwargs['params']
x = r.get(params=params)
if r.last_error is None:
if keys_only is True:
results = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
else:
results = [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[cls.COLLECTION_NAME]]
return results
else:
raise RelationalDatabaseException(r.last_error)
示例5: all
def all(cls, keys_only=False, endpoint=None, **kwargs):
"""Get all visible billing codes
.. note::
The keys used to make the original request determine result visibility
:param keys_only: Only return :attr:`billing_code_id` instead of :class:`BillingCode` objects
:type keys_only: bool.
:param detail: The level of detail to return - `basic` or `extended`
:type detail: str.
:returns: `list` - of :class:`BillingCode` or :attr:`billing_code_id`
:raises: :class:`BillingCodeException`
"""
r = Resource(cls.PATH, endpoint=endpoint)
params = {}
if 'details' in kwargs:
r.request_details = kwargs['details']
else:
r.request_details = 'basic'
x = r.get()
if r.last_error is None:
if keys_only is True:
return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
else:
return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
else:
raise BillingCodeException(r.last_error)
示例6: all
def all(cls, server_id, keys_only=False, **kwargs):
"""Get all analytics for `server_id`
:param server_id: The server represented in the analytics
:type server_id: int.
:param data_only: Return only the datapoints
:type data_only: bool.
:param interval: The interval in minutes for the requested data points
:type interval: int.
:param period_start: The start time in UNIX milliseconds for the first datapoint
:param period_start: int.
:param period_end: The end time in UNIX milliseconds for the last datapoint
:param period_end: int.
:returns: :class:`ServerAnalytics` or `list` of :attr:`data_points`
"""
r = Resource(cls.PATH)
params = {}
if 'detail' in kwargs:
r.request_details = kwargs['detail']
else:
r.request_details = 'basic'
if 'server_id' in kwargs:
params['server_id'] = kwargs['server_id']
x = r.get(params=params)
if r.last_error is None:
if keys_only is True:
return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
else:
return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[cls.COLLECTION_NAME]]
else:
raise ServerAnalyticsException(r.last_error)
示例7: all
def all(cls, region_id, endpoint=None, **kwargs):
"""Get a list of all known storage objects.
>>> StorageObject.all(region_id=100)
[{'storage_object_id':1,...},{'storage_object_id':2,...}]
:returns: list -- a list of :class:`StorageObject`
:raises: StorageObjectException
"""
r = Resource(cls.PATH, endpoint=endpoint)
params = {'regionId': region_id}
if 'detail' in kwargs:
r.request_details = kwargs['detail']
else:
r.request_details = 'basic'
if 'keys_only' in kwargs:
keys_only = kwargs['keys_only']
else:
keys_only = False
x = r.get(params=params)
if r.last_error is None:
if keys_only is True:
results = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
else:
results = [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
return results
else:
raise StorageObjectException(r.last_error)
示例8: test_has_one
def test_has_one(self):
'''test LaunchConfiguration(<id>) returns a valid resource'''
pk = 16415
with open(self.json_file) as f:
data = json.load(f)
data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
d[camelize(self.cls.PRIMARY_KEY)] == pk]
HTTPretty.register_uri(HTTPretty.GET,
self.es_url + '/' + str(pk),
body=json.dumps(data),
status=200,
content_type="application/json")
s = self.cls(pk)
assert s.launch_configuration_id == 16415
assert s.primary_product['product_id'] == 'm1.medium'
assert s.secondary_product['product_id'] == 'm1.medium'
assert s.primary_machine_image['machine_image_id'] == 281731
assert s.secondary_machine_image['machine_image_id'] == 281731
assert s.server_name_template == '{group}-{role}-{count}-{timestamp}'
assert s.firewalls[0]['firewall_id'] == 116387
assert s.array_volume_capacity == 0
assert s.array_volume_count == 0
assert s.customer['customer_id'] == 12345
assert s.region['region_id'] == 19344
示例9: test_has_one
def test_has_one(self):
'''test Tier(<id>) returns a valid resource'''
pk = 10429
with open(self.json_file) as f:
data = json.load(f)
data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
d[camelize(self.cls.PRIMARY_KEY)] == pk]
HTTPretty.register_uri(HTTPretty.GET,
self.es_url + '/' + str(pk),
body=json.dumps(data),
status=200,
content_type="application/json")
s = self.cls(pk)
assert s.tier_id == pk
assert s.breach_increment == 1
assert s.breach_period_in_minutes == 5
assert s.cooldown_period_in_minutes == 5
assert s.deployment['deployment_id'] == 13607
assert s.description == 'This is what we call a tier.'
assert s.last_breach_change_timestamp == '2012-12-18T18:42:06.160+0000'
assert s.lower_cpu_threshold == 25
assert s.lower_ram_threshold == 25
assert s.maximum_servers == 1
assert s.minimum_servers == 1
assert s.name == 'Sample Tier'
assert s.removable is False
assert s.scaling_rules == 'BASIC'
assert s.status == 'BREACH_LOWER'
assert s.upper_cpu_threshold == 75
assert s.upper_ram_threshold == 75
示例10: all
def all(cls, region_id, endpoint=None, **kwargs):
"""Return all server products
:param region_id: The region id to search in
:type region_id: int.
:param keys_only: Return :attr:`product_id` or :class:`ServerProduct`
:type keys_only: bool.
:param detail: Level of detail to return - `basic` or `extended`
:type detail: str.
:returns: `list` of :attr:`product_id` or :class:`ServerProduct`
:raises: :class:`ServerProductException`
"""
r = Resource(cls.PATH, endpoint=endpoint)
r.request_details = 'basic'
params = {'regionId': region_id}
if 'keys_only' in kwargs:
keys_only = kwargs['keys_only']
else:
keys_only = False
x = r.get(params=params)
if r.last_error is None:
if keys_only is True:
return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
else:
return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
else:
raise ServerProductException(r.last_error)
示例11: test_has_one
def test_has_one(self):
'''test ConfigurationManagementAccount(<id>) returns a valid resource'''
pk = 3610
with open(self.json_file) as f:
data = json.load(f)
data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
d[camelize(self.cls.PRIMARY_KEY)] == pk]
HTTPretty.register_uri(HTTPretty.GET,
self.es_url + '/' + str(pk),
body=json.dumps(data),
status=200,
content_type="application/json")
s = self.cls(pk)
assert s.cm_account_id == pk
assert s.account_number == ''
assert s.budget is -1
assert s.cm_service['cm_service_id'] == 3710
assert s.created_timestamp == '2013-01-06T06:50:29.326+0000'
assert s.customer['customer_id'] == 12345
assert s.description == 'a chef cm account'
assert s.guid == '/customer/12345/cmAccount/3610'
assert s.label == 'iconlightbulb'
assert s.removable is True
assert s.status == 'ACTIVE'
assert s.last_modified_timestamp == '2013-01-06T06:50:29.326+0000'
示例12: all
def all(cls, keys_only=False, **kwargs):
"""Return all users
.. note::
The keys used to make the request determine results visibility
:param keys_only: Return :attr:`user_id` instead of :class:`User`
:type keys_only: bool.
:param detail: str. The level of detail to return - `basic` or `extended`
:type detail: str.
:returns: `list` of :class:`User` or :attr:`user_id`
:raises: :class:`UserException`
"""
r = Resource(cls.PATH)
if 'detail' in kwargs:
r.request_details = kwargs['detail']
else:
r.request_details = 'basic'
x = r.get()
if r.last_error is None:
if keys_only is True:
return [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
else:
return [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[cls.COLLECTION_NAME]]
else:
raise UserException(r.last_error)
示例13: all
def all(cls, region_id, engine, **kwargs):
"""Get a list of all known relational_databases
>>> RelationalDatabaseProduct.all(region_id=100, engine='MYSQL51')
[{'product_id':1,...},{'product_id':2,...}]
:returns: list -- a list of :class:`RelationalDatabaseProduct`
:raises: RelationalDatabaseProductException
"""
r = Resource(cls.PATH)
r.request_details = 'basic'
params = {'regionId': region_id, 'engine': engine}
if 'detail' in kwargs:
r.request_details = kwargs['detail']
else:
r.request_details = 'basic'
if 'keys_only' in kwargs:
keys_only = kwargs['keys_only']
else:
keys_only = False
x = r.get(params=params)
if r.last_error is None:
if keys_only is True:
results = [i[camelize(cls.PRIMARY_KEY)] for i in x[cls.COLLECTION_NAME]]
else:
results = [type(cls.__name__, (object,), i) for i in uncamel_keys(x)[uncamel(cls.COLLECTION_NAME)]]
return results
else:
raise RelationalDatabaseProductException(r.last_error)
示例14: test_has_one
def test_has_one(self):
'''test Volume(<id>) returns a valid resource'''
pk = 211309
with open(self.json_file) as f:
data = json.load(f)
data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
d[camelize(self.cls.PRIMARY_KEY)] == pk]
HTTPretty.register_uri(HTTPretty.GET,
self.es_url + '/' + str(pk),
body=json.dumps(data),
status=200,
content_type="application/json")
s = self.cls(pk)
s.load()
assert s.volume_id == pk
assert s.available is True
assert s.budget == 10287
assert s.cloud['cloud_id'] == 1
assert s.creation_timestamp == '1970-01-01T00:00:00.000+0000'
assert s.customer['customer_id'] == 12345
assert s.data_center['data_center_id'] == 64716
assert s.description == 'vol-4816d27b'
assert s.device_id == '/dev/sda1'
assert s.encrypted is False
assert s.name == 'vol-4816d27b'
assert s.owning_account['account_id'] == 16000
assert s.owning_groups[0]['group_id'] == 9465
assert s.provider_id == 'vol-4816d27b'
assert s.owning_user['user_id'] == 54321
assert s.region['region_id'] == 19556
assert s.removable is False
assert s.server['server_id'] == 322765
assert s.size_in_gb == 8
assert s.size_string == '8GB'
assert s.status == 'ACTIVE'
示例15: test_has_one
def test_has_one(self):
'''test LoadBalancer(<id>) returns a valid resource'''
pk = 12516
with open(self.json_file) as f:
data = json.load(f)
data[self.cls.COLLECTION_NAME][:] = [d for d in data[self.cls.COLLECTION_NAME] if
d[camelize(self.cls.PRIMARY_KEY)] == pk]
HTTPretty.register_uri(HTTPretty.GET,
self.es_url + '/' + str(pk),
body=json.dumps(data),
status=200,
content_type="application/json")
s = self.cls(pk)
s.load()
assert s.load_balancer_id == pk
assert s.address == 'wordpress-lb.us-west-2.elb.amazonaws.com'
assert s.budget == 10287
assert s.cloud['cloud_id'] == 1
assert s.cname_based is True
assert s.customer['customer_id'] == 12345
assert s.description == 'Cloud Load Balancer for wordpress demo deployment'
assert s.owning_account['account_id'] == 16000
assert s.owning_groups[0]['group_id'] == 9465
assert s.owning_user['user_id'] == 54321
assert s.provider_id == 'wordpress-deployment'
assert s.region['region_id'] == 19344
assert s.status == 'ACTIVE'