當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。