本文整理汇总了Python中treedict.TreeDict.getClosestKey方法的典型用法代码示例。如果您正苦于以下问题:Python TreeDict.getClosestKey方法的具体用法?Python TreeDict.getClosestKey怎么用?Python TreeDict.getClosestKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treedict.TreeDict
的用法示例。
在下文中一共展示了TreeDict.getClosestKey方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMatch_06
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_06(self):
p = TreeDict()
p.a.b = 1
p.a.a.b = 1
p.a.a.a.c = 1
self.assert_(p.getClosestKey('a.ab') == 'a.a.b')
self.assert_(p.getClosestKey('a.ab',1) == ['a.a.b'])
示例2: testMatch_16_first
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_16_first(self):
p = TreeDict()
p.asdfdjdjd.eiudkdkdk = 1
p.basdfdjdjd.eiudkddk = 1
p.a.b = None
self.assert_(p.getClosestKey('asdfdjdjd', 2) ==
['asdfdjdjd.eiudkdkdk', 'basdfdjdjd.eiudkddk'], p.getClosestKey('asdfdjdjd', 2))
示例3: testMatch_08
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_08(self):
p = TreeDict()
p.ab = 1
p.a.b = 1
p.a.ab = 1
p.a.a.b = 1
p.a.a.bc = 1
p.a.a.a.c = 1
self.assert_(p.getClosestKey('', 4) == ['ab', 'a.b', 'a.ab', 'a.a.b'])
示例4: testMatch_03
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_03(self):
p = TreeDict()
p.set(a=1, b=1, c=1, d=1,e=1,f=1)
self.assert_(p.getClosestKey('cc') == 'c')
self.assert_(p.getClosestKey('cc', 1) == ['c'])
示例5: testMatch_02
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_02(self):
p = TreeDict()
p.aa = 1
p.bb = 1
self.assert_(p.getClosestKey('a') == 'aa')
self.assert_(p.getClosestKey('a',1) == ['aa'])
示例6: testMatch_13_empty
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_13_empty(self):
p = TreeDict()
self.assert_(p.getClosestKey('') is None)
self.assert_(p.getClosestKey('', 1) == [])
self.assert_(p.getClosestKey('', 10000) == [])
示例7: testMatch_15_last
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_15_last(self):
p = TreeDict()
p.asdfdjdjd.eiudkdkdk = 1
p.basdfdjdjd.eiudkddk = 1
self.assert_(p.getClosestKey('asdfjd.eiudkdkdk') == 'asdfdjdjd.eiudkdkdk')
示例8: testMatch_12_empty
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_12_empty(self):
p = TreeDict()
self.assert_(p.getClosestKey('123221321321') is None)
self.assert_(p.getClosestKey('123221321321', 1) == [])
self.assert_(p.getClosestKey('123221321321', 10000) == [])
示例9: testMatch_11
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_11(self):
p = TreeDict()
p.a.b = 1
p.a.a.b = 1
p.a.a.a.c = 1
self.assert_(p.getClosestKey('', 200000) == ['a.b', 'a.a.b', 'a.a.a.c'])
示例10: testMatch_10
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_10(self):
p = TreeDict()
p.set(gambol = 2, bumble = 3, borkborkbork=None)
self.assert_(p.getClosestKey('gumbo', 2) == ['gambol', 'bumble'])
示例11: testMatch_09
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
def testMatch_09(self):
p = TreeDict()
p.set(gambol = 2, bumble = 3)
self.assert_(p.getClosestKey('gumbo') == 'gambol')
self.assert_(p.getClosestKey('gumbo', 1) == ['gambol'])
示例12: TreeDict
# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
t = TreeDict(x = 1)
t.get("x")
t.get("y")
t.get("y", [])
########################################
# getClosestKey
t = TreeDict()
t.alpha.x1 = 1
t.alpha.y1 = 1
t.alpha.zzz = 1
t.beta.x = 1
t.gamma.beta = 1
"alpah.x" in t
t.getClosestKey("alpah.x")
t.getClosestKey("alpah.x", 1)
t.getClosestKey("alpah.x", 3)
########################################
# hash
from treedict import TreeDict
t = TreeDict()
t.set('br.x', 1, 'br.c.y', 2, x = 1, y = 2)
t.hash()
t.hash('br')
t.br.hash()
t.br.hash(add_name = True)
t.hash('x')
t.hash(keys = ['x', 'y'])