当前位置: 首页>>代码示例>>Python>>正文


Python TextDocument.lineText方法代码示例

本文整理汇总了Python中vai.models.TextDocument.TextDocument.lineText方法的典型用法代码示例。如果您正苦于以下问题:Python TextDocument.lineText方法的具体用法?Python TextDocument.lineText怎么用?Python TextDocument.lineText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vai.models.TextDocument.TextDocument的用法示例。


在下文中一共展示了TextDocument.lineText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testDeleteChars

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
    def testDeleteChars(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)

        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], "")
开发者ID:rsdenijs,项目名称:vai,代码行数:28,代码来源:test_TextDocument.py

示例2: testDeleteChars

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [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], '')
开发者ID:gavd89,项目名称:vai,代码行数:27,代码来源:test_TextDocument.py

示例3: testDeleteLine2

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [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())
开发者ID:gavd89,项目名称:vai,代码行数:28,代码来源:test_TextDocument.py

示例4: testLine

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [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))
开发者ID:gavd89,项目名称:vai,代码行数:11,代码来源:test_TextDocument.py

示例5: testReplaceChars

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [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')
开发者ID:gavd89,项目名称:vai,代码行数:12,代码来源:test_TextDocument.py

示例6: testJoinWithNextLine

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
    def testJoinWithNextLine(self):
        doc = TextDocument()
        doc.open(fixtures.get("basic_nonempty_file.txt"))
        doc.joinWithNextLine(1)
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.lineText(1), 'hellohow are you?\n')
        self.assertTrue(doc.isModified())

        doc.joinWithNextLine(1)
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.lineText(1), 'hellohow are you?\n')
开发者ID:gavd89,项目名称:vai,代码行数:13,代码来源:test_TextDocument.py

示例7: testLine

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
    def testLine(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)

        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))
开发者ID:rsdenijs,项目名称:vai,代码行数:13,代码来源:test_TextDocument.py

示例8: testReplaceChars

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
    def testReplaceChars(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)
        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")
开发者ID:rsdenijs,项目名称:vai,代码行数:13,代码来源:test_TextDocument.py

示例9: testJoinWithNextLine

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
    def testJoinWithNextLine(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)
        doc.joinWithNextLine(1)
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.lineText(1), "hellohow are you?\n")

        doc.joinWithNextLine(1)
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.lineText(1), "hellohow are you?\n")
开发者ID:rsdenijs,项目名称:vai,代码行数:13,代码来源:test_TextDocument.py

示例10: testCharMeta

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
 def testCharMeta(self):
     doc = TextDocument()
     with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
         doc.read(f)
     doc.updateCharMeta((1, 1), {"Hello": [1]})
     self.assertEqual(len(doc.charMeta((1, 1))["Hello"]), len(doc.lineText(1)))
     self.assertEqual(doc.charMeta((1, 1))["Hello"], [1, None, None, None, None, None])
开发者ID:rsdenijs,项目名称:vai,代码行数:9,代码来源:test_TextDocument.py

示例11: testBreakLine

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
 def testBreakLine(self):
     doc = TextDocument()
     with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
         doc.read(f)
     doc.breakLine((1, 3))
     self.assertEqual(doc.lineText(1), "he\n")
     self.assertEqual(doc.lineText(2), "llo\n")
开发者ID:rsdenijs,项目名称:vai,代码行数:9,代码来源:test_TextDocument.py

示例12: testInsertFragment

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
    def testInsertFragment(self):
        doc = TextDocument()
        with open(fixtures.get("numbers.txt"), "r") as f:
            doc.read(f)
        doc.createLineMetaInfo("whatever")
        doc.createLineMetaInfo("whatever2")

        fragment = doc.extractFragment(2)
        self.assertNotEqual(fragment.lineText(1), doc.lineText(15))
        doc.insertFragment(15, fragment)
        self.assertEqual(fragment.lineText(1), doc.lineText(15))

        fragment = doc.extractFragment(2, 4)
        self.assertNotEqual(fragment.lineText(1), doc.lineText(10))
        doc.insertFragment(10, fragment)

        self.assertEqual(fragment.lineText(1), doc.lineText(10))
        self.assertEqual(fragment.lineText(2), doc.lineText(11))
        self.assertEqual(fragment.lineText(3), doc.lineText(12))
        self.assertEqual(fragment.lineText(4), doc.lineText(13))
开发者ID:rsdenijs,项目名称:vai,代码行数:22,代码来源:test_TextDocument.py

示例13: testExtractFragment

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
    def testExtractFragment(self):
        doc = TextDocument()
        with open(fixtures.get("bigfile.py"), "r") as f:
            doc.read(f)
        doc.createLineMetaInfo("whatever")
        doc.createLineMetaInfo("whatever2")

        fragment = doc.extractFragment(2)
        self.assertEqual(fragment.numLines(), 1)
        self.assertEqual(fragment.lineText(1), doc.lineText(2))
        self.assertTrue(fragment.hasLineMetaInfo("whatever"))
        self.assertTrue(fragment.hasLineMetaInfo("whatever2"))

        fragment = doc.extractFragment(2, 3)
        self.assertEqual(fragment.numLines(), 3)
        self.assertEqual(fragment.lineText(1), doc.lineText(2))
        self.assertEqual(fragment.lineText(2), doc.lineText(3))
        self.assertEqual(fragment.lineText(3), doc.lineText(4))
        self.assertTrue(fragment.hasLineMetaInfo("whatever"))
        self.assertTrue(fragment.hasLineMetaInfo("whatever2"))
开发者ID:rsdenijs,项目名称:vai,代码行数:22,代码来源:test_TextDocument.py

示例14: testDeleteLine2

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [as 别名]
    def testDeleteLine2(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)

        self.assertEqual(doc.lineText(1), "hello\n")
        self.assertEqual(doc.lineText(2), "how are you?\n")
        self.assertEqual(doc.numLines(), 2)

        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)

        doc.deleteLine(2)
        self.assertEqual(doc.lineText(1), "hello\n")
        self.assertEqual(doc.numLines(), 1)
        self.assertFalse(doc.isEmpty())

        doc.deleteLine(1)
        self.assertEqual(doc.lineText(1), "\n")
        self.assertEqual(doc.numLines(), 1)
        self.assertTrue(doc.isEmpty())
开发者ID:rsdenijs,项目名称:vai,代码行数:25,代码来源:test_TextDocument.py

示例15: testLineMetaInfoMemento

# 需要导入模块: from vai.models.TextDocument import TextDocument [as 别名]
# 或者: from vai.models.TextDocument.TextDocument import lineText [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")
开发者ID:rsdenijs,项目名称:vai,代码行数:25,代码来源:test_TextDocument.py


注:本文中的vai.models.TextDocument.TextDocument.lineText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。