本文整理汇总了Python中vai.models.TextDocument.TextDocument.newLine方法的典型用法代码示例。如果您正苦于以下问题:Python TextDocument.newLine方法的具体用法?Python TextDocument.newLine怎么用?Python TextDocument.newLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vai.models.TextDocument.TextDocument
的用法示例。
在下文中一共展示了TextDocument.newLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testChangeLineNumber
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import newLine [as 别名]
def testChangeLineNumber(self):
doc = TextDocument()
doc.createLineMetaInfo("whatever")
doc.createLineMetaInfo("whatever2")
meta_info1 = doc.lineMetaInfo("whatever")
meta_info2 = doc.lineMetaInfo("whatever2")
meta_info1.setData("hello", 1)
meta_info2.setData("byebye", 1)
doc.newLineAfter(1)
self.assertEqual(meta_info1.numLines(), 2)
self.assertEqual(meta_info2.numLines(), 2)
self.assertEqual(meta_info1.data(1,2), ["hello", None])
self.assertEqual(meta_info2.data(1,2), ["byebye", None])
doc.newLine(1)
self.assertEqual(meta_info1.numLines(), 3)
self.assertEqual(meta_info2.numLines(), 3)
self.assertEqual(meta_info1.data(1,3), [None, "hello", None])
self.assertEqual(meta_info2.data(1,3), [None, "byebye", None])
doc.deleteLine(2)
self.assertEqual(meta_info1.numLines(), 2)
self.assertEqual(meta_info2.numLines(), 2)
self.assertEqual(meta_info1.data(1,2), [None, None])
self.assertEqual(meta_info2.data(1,2), [None, None])
self.assertEqual(meta_info1.data(1,1), [None])
self.assertEqual(meta_info2.data(1,1), [None])
self.assertEqual(meta_info1.data(1), None)
self.assertEqual(meta_info2.data(1), None)
示例2: testLineMetaInfoMemento
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import newLine [as 别名]
def testLineMetaInfoMemento(self):
doc = TextDocument()
doc.createLineMetaInfo("whatever")
doc.createLineMetaInfo("whatever2")
meta_info1 = doc.lineMetaInfo("whatever")
meta_info2 = doc.lineMetaInfo("whatever2")
doc.newLineAfter(1)
doc.newLine(1)
meta_info1.setData("hello", 1)
meta_info2.setData("byebye", 1)
memento = doc.lineMemento(1)
doc.deleteLine(1)
self.assertEqual(doc.lineMetaInfo("whatever").data(1), None)
self.assertEqual(doc.lineMetaInfo("whatever2").data(1), None)
doc.insertFromMemento(1, memento)
self.assertEqual(doc.lineText(1), "\n")
self.assertEqual(doc.lineMetaInfo("whatever").data(1), "hello")
self.assertEqual(doc.lineMetaInfo("whatever2").data(1), "byebye")
示例3: testNewLine
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import newLine [as 别名]
def testNewLine(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
doc.newLine(1)
示例4: testNewLine
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import newLine [as 别名]
def testNewLine(self):
doc = TextDocument()
with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
doc.read(f)
doc.newLine(1)