本文整理汇总了Python中meresco.components.json.JsonDict.pretty_print方法的典型用法代码示例。如果您正苦于以下问题:Python JsonDict.pretty_print方法的具体用法?Python JsonDict.pretty_print怎么用?Python JsonDict.pretty_print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meresco.components.json.JsonDict
的用法示例。
在下文中一共展示了JsonDict.pretty_print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _httpConfigAndServices
# 需要导入模块: from meresco.components.json import JsonDict [as 别名]
# 或者: from meresco.components.json.JsonDict import pretty_print [as 别名]
def _httpConfigAndServices(self, apiVersion, arguments, serviceIdentifier=None, prettyPrint=False, **ignored):
result = {}
additionalConfigDict = result
fullServiceInfo = arguments.get('allServiceInfo', ['False'])[0] == 'True'
useVpn = arguments.get('useVpn', ['False'])[0] == 'True'
retrieveAll = arguments.get('__all__', ['False'])[0] == 'True'
keys = self._allKeys() if retrieveAll else self._keysFromArgs(arguments)
for key in _requestedKeys(keys):
try:
if key == 'services':
additionalConfigDict[key] = self.call.listServices(activeOnly=not fullServiceInfo, includeState=fullServiceInfo, convertIpsToVpn=useVpn)
elif key == 'config':
additionalConfigDict[key] = self.call.getConfig()
else:
additionalConfigDict[key] = self.call[key].getConfiguration(allConfiguration=retrieveAll)
except NoneOfTheObserversRespond:
result.setdefault('errors', []).append("Key '%s' not found." % key)
if serviceIdentifier:
this_service = self.call.getService(identifier=serviceIdentifier)
if this_service is not None:
result['this_service'] = this_service
result['this_service']['state'] = self.call.getPrivateStateFor(identifier=serviceIdentifier)
result = JsonDict(api_version=apiVersion, domain=self.call.getDomain(), **result)
if self._softwareVersion is not None:
result['software_version'] = self._softwareVersion
yield okJson
yield result.pretty_print() if prettyPrint else str(result)
示例2: testPrettyPrint
# 需要导入模块: from meresco.components.json import JsonDict [as 别名]
# 或者: from meresco.components.json.JsonDict import pretty_print [as 别名]
def testPrettyPrint(self):
jd = JsonDict({'hello': 'world'})
self.assertEquals('{\n "hello": "world"\n}', jd.pretty_print(indent=5))