本文整理汇总了Python中vai.models.TextDocument.TextDocument.open方法的典型用法代码示例。如果您正苦于以下问题:Python TextDocument.open方法的具体用法?Python TextDocument.open怎么用?Python TextDocument.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vai.models.TextDocument.TextDocument
的用法示例。
在下文中一共展示了TextDocument.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testDeleteLine2
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testDeleteLine2(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
self.assertEqual(doc.lineText(1), 'hello\n')
self.assertEqual(doc.lineText(2), 'how are you?\n')
self.assertEqual(doc.numLines(), 2)
self.assertFalse(doc.isModified())
self.assertRaises(IndexError, lambda : doc.deleteLine(5))
self.assertEqual(doc.lineText(1), 'hello\n')
self.assertEqual(doc.lineText(2), 'how are you?\n')
self.assertEqual(doc.numLines(), 2)
self.assertFalse(doc.isModified())
doc.deleteLine(2)
self.assertEqual(doc.lineText(1), 'hello\n')
self.assertEqual(doc.numLines(), 1)
self.assertFalse(doc.isEmpty())
self.assertTrue(doc.isModified())
doc.deleteLine(1)
self.assertEqual(doc.lineText(1), '\n')
self.assertEqual(doc.numLines(), 1)
self.assertTrue(doc.isEmpty())
self.assertTrue(doc.isModified())
示例2: testDeleteChars
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testDeleteChars(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
self.assertRaises(ValueError, lambda : doc.deleteChars((1,3), -1))
d = doc.deleteChars( (1,3), 1)
self.assertEqual(doc.lineText(1), 'helo\n')
self.assertEqual(d[0], 'l')
d = doc.deleteChars( (1,2), 100)
self.assertEqual(doc.lineText(1), 'h\n')
self.assertEqual(d[0], 'elo')
d = doc.deleteChars( (1,2), 100)
self.assertEqual(doc.lineText(1), 'h\n')
self.assertEqual(d[0], '')
d = doc.deleteChars( (1,1), 100)
self.assertEqual(doc.lineText(1), '\n')
self.assertEqual(d[0], 'h')
d = doc.deleteChars( (1,1), 100)
self.assertEqual(doc.lineText(1), '\n')
self.assertEqual(d[0], '')
示例3: testUpdateCharMeta
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testUpdateCharMeta(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
doc.updateCharMeta( (1, 3), { "foo" : ["a", "a"],
"bar" : ['b', None, 'b'],
}
)
示例4: testDeleteDocumentMeta
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testDeleteDocumentMeta(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
doc.updateDocumentMeta({"Hello": 5})
self.assertEqual(doc.documentMeta()["Hello"], 5)
doc.deleteDocumentMeta("Hello")
self.assertNotIn("Hello", doc.documentMeta())
示例5: testJoinWithNextLine2
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testJoinWithNextLine2(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
doc.joinWithNextLine(2)
self.assertEqual(doc.lineText(1), 'hello\n')
self.assertEqual(doc.lineText(2), 'how are you?\n')
self.assertEqual(doc.numLines(), 2)
self.assertFalse(doc.isModified())
示例6: testUpdateLineMeta
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testUpdateLineMeta(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
doc.updateLineMeta(1, {"hello": 5})
self.assertEqual(type(doc.lineMeta(1)), dict)
self.assertEqual(doc.lineMeta(1)["hello"], 5)
self.assertRaises(IndexError, lambda : doc.updateLineMeta(20, {}))
示例7: testLastModified
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testLastModified(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
last_modified = doc.lastModified()
self.assertEqual(doc.lastModified(), last_modified)
time.sleep(0.1)
doc.insertLine(1,"")
self.assertNotEqual(doc.lastModified(), last_modified)
示例8: testInitFromEmptyFile
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testInitFromEmptyFile(self):
doc = TextDocument()
doc.open(fixtures.get("empty_file.txt"))
self.assertTrue(doc.isEmpty())
self.assertEqual(doc.filename(), fixtures.get("empty_file.txt"))
self.assertFalse(doc.isModified())
self.assertEqual(doc.numLines(), 1)
self.assertEqual(doc.documentText(), '\n')
示例9: testInitFromNonEmptyFile
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testInitFromNonEmptyFile(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
self.assertFalse(doc.isEmpty())
self.assertEqual(doc.filename(), fixtures.get("basic_nonempty_file.txt"))
self.assertFalse(doc.isModified())
self.assertEqual(doc.numLines(), 2)
self.assertEqual(doc.documentText(), 'hello\nhow are you?\n')
示例10: testLine
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testLine(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
self.assertEqual(doc.lineText(1), 'hello\n')
self.assertEqual(doc.lineText(2), 'how are you?\n')
self.assertRaises(IndexError, lambda : doc.lineText(-1))
self.assertRaises(IndexError, lambda : doc.lineText(0))
self.assertRaises(IndexError, lambda : doc.lineText(5))
示例11: testLineLength
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testLineLength(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
self.assertEqual(doc.lineLength(1), 6)
self.assertEqual(doc.lineLength(2), 13)
doc = TextDocument()
doc.open(fixtures.get("empty_file.txt"))
self.assertEqual(doc.lineLength(1), 1)
示例12: testDeleteLineMeta
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testDeleteLineMeta(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
doc.updateLineMeta(1, {"hello": 5})
self.assertEqual(doc.lineMeta(1)["hello"], 5)
doc.deleteLineMeta(1, ["hello"])
self.assertNotIn("hello", doc.lineMeta(1))
self.assertRaises(IndexError, lambda : doc.deleteLineMeta(20, "hello"))
示例13: testReplaceChars
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testReplaceChars(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
doc.replaceChars( (1,3), 1, "hello")
self.assertEqual(doc.lineText(1), 'hehellolo\n')
doc.replaceChars( (1,1), 1, "c")
self.assertEqual(doc.lineText(1), 'cehellolo\n')
示例14: testInsertLine
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testInsertLine(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
self.assertEqual(doc.numLines(), 2)
doc.insertLine(1,"babau")
self.assertEqual(doc.numLines(), 3)
self.assertRaises(IndexError, lambda : doc.insertLine(6,"say what again"))
doc.insertLine(4,"say what again")
self.assertEqual(doc.numLines(), 4)
示例15: testSaveAs
# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import open [as 别名]
def testSaveAs(self):
doc = TextDocument()
doc.open(fixtures.get("basic_nonempty_file.txt"))
doc.saveAs("foo")