本文整理汇总了Python中couchdb.Server.stats方法的典型用法代码示例。如果您正苦于以下问题:Python Server.stats方法的具体用法?Python Server.stats怎么用?Python Server.stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchdb.Server
的用法示例。
在下文中一共展示了Server.stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getpaths
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import stats [as 别名]
def getpaths( data, paths):
'extract from dict by multiple key-paths: [ [ str|list, str|list, ...] ] '
r = {}
for p in paths:
r.update( getpath( data, p))
return r
def getpath( data, path):
'extract from dict by key-path: [ str|list, str|list, ...] ; each level is single key or multiple keys/OR'
if not path: return data
r = {}
i = path[0]
for e in (i if isinstance( i, (list,tuple)) else [ i ]):
r[e] = getpath( data.get(e), path[1:] )
return r
if __name__ == '__main__':
import sys
sys.path.pop(0) #XXX HACK avoid cur dir .. because struct.py
from couchdb import Server
server = Server( sys.argv[1])
data = server.stats()
paths = [
[ 'couchdb', 'database_writes', 'current' ], #this misses db-create/delete. even with couchdb/open_databases
[ 'httpd_request_methods', 'COPY DELETE POST PUT'.split(), 'current' ],
]
print( getpaths( data, paths))
# vim:ts=4:sw=4:expandtab