本文整理匯總了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))