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


Python JsonDict.dump方法代码示例

本文整理汇总了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)
开发者ID:seecr,项目名称:meresco-elasticsearch,代码行数:28,代码来源:config.py

示例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()))
开发者ID:seecr,项目名称:meresco-distributed,代码行数:41,代码来源:serviceregistrytest.py

示例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())
开发者ID:seecr,项目名称:meresco-components,代码行数:7,代码来源:jsontest.py

示例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())
开发者ID:seecr,项目名称:meresco-components,代码行数:8,代码来源:jsontest.py


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