本文整理匯總了Python中sefaria.model.schema.JaggedArrayNode.append_to方法的典型用法代碼示例。如果您正苦於以下問題:Python JaggedArrayNode.append_to方法的具體用法?Python JaggedArrayNode.append_to怎麽用?Python JaggedArrayNode.append_to使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sefaria.model.schema.JaggedArrayNode
的用法示例。
在下文中一共展示了JaggedArrayNode.append_to方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_default_chain
# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import append_to [as 別名]
def test_default_chain(self):
s = SchemaNode()
s.key = "root"
s.add_title("root", "en", primary=True)
s.add_title("alt root", "en")
s2 = SchemaNode()
s2.key = "default"
s2.default = True
s2.append_to(s)
j = JaggedArrayNode()
j.key = "default"
j.depth = 1
j.default = True
j.sectionNames = ["Foo"]
j.addressTypes = ["Integer"]
j.append_to(s2)
s.validate()
assert s.has_numeric_continuation()
assert s2.has_numeric_continuation()
assert j.has_numeric_continuation()
assert not s.has_titled_continuation()
assert not s2.has_titled_continuation()
assert not j.has_titled_continuation()
示例2: test_validate_children
# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import append_to [as 別名]
def test_validate_children(self):
"""
Does validate fall through to children?
"""
s = SchemaNode()
s.key = "root"
s.add_title("root", "en", primary=True)
j = JaggedArrayNode()
j.add_title("child", "en", primary=True)
j.key = "child"
j.depth = 1
j.sectionNames = ["Foo"]
j.append_to(s)
with pytest.raises(IndexSchemaError):
s.validate()
示例3: test_terms_and_he
# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import append_to [as 別名]
def test_terms_and_he(self):
s = SchemaNode()
s.key = "root"
s.add_title("root", "en", primary=True)
s.add_title(u"שרש", "he", primary=True)
j = JaggedArrayNode()
j.key = "bereshit"
j.depth = 1
j.sectionNames = ["Foo"]
j.addressTypes = ["Integer"]
j.add_shared_term("Bereshit")
j.append_to(s)
j2 = JaggedArrayNode()
j2.key = "noah"
j2.depth = 1
j2.sectionNames = ["Foo"]
j2.addressTypes = ["Integer"]
j2.add_shared_term("Noach")
j2.append_to(s)
s.validate()
td = s.title_dict("he")
assert len(td) == 5
target = {
u'שרש': s,
u'שרש, בראשית': j,
u'שרש, נח': j2,
u'שרש בראשית': j,
u'שרש נח': j2,
}
assert td == target
示例4: test_grandchild_presentation
# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import append_to [as 別名]
def test_grandchild_presentation(self):
s = SchemaNode()
s.key = "root"
s.add_title("root", "en", primary=True)
s.add_title("alt root", "en")
s2 = SchemaNode()
s2.key = "l2"
s2.add_title("Level 2", "en", primary=True)
s2.add_title("Level 2 Alone", "en", presentation="alone")
s2.add_title("Level 2 Both", "en", presentation="both")
s2.append_to(s)
j = JaggedArrayNode()
j.key = "child1"
j.depth = 1
j.sectionNames = ["Foo"]
j.addressTypes = ["Integer"]
j.add_title("Level 3a", "en", primary=True)
j.add_title("Level 3a alone", "en", presentation="alone")
j.add_title("Level 3a both", "en", presentation="both")
j.append_to(s2)
j2 = JaggedArrayNode()
j2.key = "child2"
j2.depth = 1
j2.sectionNames = ["Foo"]
j2.addressTypes = ["Integer"]
j2.add_title("Level 3b", "en", primary=True)
j2.add_title("Level 3b alone", "en", presentation="alone")
j2.add_title("Level 3b both", "en", presentation="both")
j2.append_to(s2)
s.validate()
assert not s.has_numeric_continuation()
assert not s2.has_numeric_continuation()
td = s.title_dict()
assert len(td) == 96
target = {
"root": s,
"alt root": s,
"Level 2 Alone": s2,
"Level 3b alone": j2,
"Level 3a alone": j,
"Level 2 Both": s2,
"Level 3a both": j,
"Level 3b both": j2,
# combined, with comma separator
"root, Level 2 Both": s2,
"root, Level 2": s2,
"alt root, Level 2 Both": s2,
"alt root, Level 2": s2,
"root, Level 2 Both, Level 3a": j,
"root, Level 2, Level 3a": j,
"alt root, Level 2 Both, Level 3a": j,
"alt root, Level 2, Level 3a": j,
"Level 2 Alone, Level 3a": j,
"Level 2 Both, Level 3a": j,
"root, Level 2 Both, Level 3a both": j,
"root, Level 2, Level 3a both": j,
"alt root, Level 2 Both, Level 3a both": j,
"alt root, Level 2, Level 3a both": j,
"Level 2 Alone, Level 3a both": j,
"Level 2 Both, Level 3a both": j,
"root, Level 2 Both, Level 3b": j2,
"root, Level 2, Level 3b": j2,
"alt root, Level 2 Both, Level 3b": j2,
"alt root, Level 2, Level 3b": j2,
"Level 2 Alone, Level 3b": j2,
"Level 2 Both, Level 3b": j2,
"root, Level 2 Both, Level 3b both": j2,
"root, Level 2, Level 3b both": j2,
"alt root, Level 2 Both, Level 3b both": j2,
"alt root, Level 2, Level 3b both": j2,
"Level 2 Alone, Level 3b both": j2,
"Level 2 Both, Level 3b both": j2,
# combined, with space separator
"root Level 2 Both": s2,
"root Level 2": s2,
"alt root Level 2 Both": s2,
"alt root Level 2": s2,
"root Level 2 Both Level 3a": j,
"root Level 2 Level 3a": j,
"alt root Level 2 Both Level 3a": j,
"alt root Level 2 Level 3a": j,
"Level 2 Alone Level 3a": j,
"Level 2 Both Level 3a": j,
"root Level 2 Both Level 3a both": j,
"root Level 2 Level 3a both": j,
#.........這裏部分代碼省略.........