本文整理汇总了Python中meresco.components.json.JsonDict.dump方法的典型用法代码示例。如果您正苦于以下问题:Python JsonDict.dump方法的具体用法?Python JsonDict.dump怎么用?Python JsonDict.dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meresco.components.json.JsonDict
的用法示例。
在下文中一共展示了JsonDict.dump方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _configure
# 需要导入模块: from meresco.components.json import JsonDict [as 别名]
# 或者: from meresco.components.json.JsonDict import dump [as 别名]
def _configure(self):
configuration = JsonDict({
"path": {
"data": ensureDir(self.stateDir, 'data'),
"logs": ensureDir(self.stateDir, 'logs'),
"work": ensureDir(self.stateDir, 'work'), # temporary files
"conf": self.configDir,
"plugins": ensureDir(self.stateDir, 'plugins'),
},
"cluster":{
"name": self.name,
},
"http":{
"port": self.port,
},
"transport": {
"tcp": {
"port": self.transportPort
}
}
})
self._configureIndex(configuration)
if self.identifier:
configuration.setdefault("node", dict())['name'] = self.identifier
with open(self.configFile, 'w') as f:
configuration.dump(f, indent=4, sort_keys=True)
示例2: testServiceRegistryOldFormat
# 需要导入模块: from meresco.components.json import JsonDict [as 别名]
# 或者: from meresco.components.json.JsonDict import dump [as 别名]
def testServiceRegistryOldFormat(self):
uuid1 = str(uuid4())
uuid2 = str(uuid4())
with open(join(self.tempdir, 'serviceregistry.json'), 'w') as f:
d = JsonDict({
uuid1: {
"ipAddress": "5.153.228.85",
"readable": True,
"number": 1,
"data": {
"uptime": 366867,
"VERSION": "1.5.12.3"
},
"writable": True,
"lastseen": 1423494771.904539,
"type": "holding",
"infoport": 35609,
},
uuid2: {
"ipAddress": "5.153.228.85",
"readable": True,
"number": 1,
"data": {
"uptime": 366867,
"VERSION": "1.5.12.3"
},
"writable": True,
"lastseen": 1423494771.904539,
"type": "plein",
"infoport": 41609,
}
})
d.dump(f)
registry = ServiceRegistry(
stateDir=self.tempdir,
domainname='zp.example.org',
reactor=CallTrace(),
)
self.assertEquals(set([uuid1, uuid2]), set(registry.listServices(activeOnly=False).keys()))
示例3: testDumpWithFilename
# 需要导入模块: from meresco.components.json import JsonDict [as 别名]
# 或者: from meresco.components.json.JsonDict import dump [as 别名]
def testDumpWithFilename(self):
jd = JsonDict({'hello': 'world'})
tempfile = join(self.tempdir, 'json.json')
jd.dump(tempfile)
self.assertEquals('{"hello": "world"}', open(tempfile).read())
示例4: testDump
# 需要导入模块: from meresco.components.json import JsonDict [as 别名]
# 或者: from meresco.components.json.JsonDict import dump [as 别名]
def testDump(self):
jd = JsonDict({'hello': 'world'})
tempfile = join(self.tempdir, 'json.json')
with open(tempfile, 'w') as f:
jd.dump(f)
self.assertEquals('{"hello": "world"}', open(tempfile).read())