本文整理汇总了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,
#.........这里部分代码省略.........