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


Python TextDocument.TextDocument类代码示例

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


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

示例1: testUpdateCharMeta

 def testUpdateCharMeta(self):
     doc = TextDocument()
     doc.open(fixtures.get("basic_nonempty_file.txt"))
     doc.updateCharMeta( (1, 3), { "foo" : ["a", "a"],
                                   "bar" : ['b', None, 'b'],
                                 }
                       )
开发者ID:gavd89,项目名称:vai,代码行数:7,代码来源:test_TextDocument.py

示例2: testSaveUnnamed

    def testSaveUnnamed(self):
        doc = TextDocument()
        self.assertRaises(TextDocument.MissingFilenameException, lambda: doc.save())

        path = fixtures.tempFile("testSaveUnnamed")
        doc.saveAs(path)
        self.assertTrue(os.path.exists(path))
        self.assertEqual(doc.filename(), path)
开发者ID:gavd89,项目名称:vai,代码行数:8,代码来源:test_TextDocument.py

示例3: testDeleteLineMeta

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

示例4: testDeleteDocumentMeta

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

示例5: testBasic

    def testBasic(self):
        doc = TextDocument()
        doc.createLineMetaInfo("whatever")
        meta_info = doc.lineMetaInfo("whatever")

        self.assertEqual(meta_info.document, doc)
        self.assertEqual(meta_info.meta_type, "whatever")
        self.assertEqual(meta_info.numLines(), 1)
        self.assertEqual(meta_info.data(1), None)

        meta_info.setData("hello",1)
        self.assertEqual(meta_info.data(1), "hello")
开发者ID:pipter,项目名称:vai,代码行数:12,代码来源:test_LineMetaInfo.py

示例6: testDocumentMeta

    def testDocumentMeta(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)
        doc.createDocumentMetaInfo("Hello")
        self.assertEqual(doc.documentMetaInfo("Hello").data(), None)

        doc.createDocumentMetaInfo("Hello2", 2)
        self.assertEqual(doc.documentMetaInfo("Hello2").data(), 2)
开发者ID:rsdenijs,项目名称:vai,代码行数:9,代码来源:test_TextDocument.py

示例7: testReplaceChars

    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,代码行数:10,代码来源:test_TextDocument.py

示例8: testCharMeta

 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,代码行数:7,代码来源:test_TextDocument.py

示例9: testReplaceChars

    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,代码行数:11,代码来源:test_TextDocument.py

示例10: testJoinWithNextLine2

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

示例11: testUpdateLineMeta

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

示例12: testLastModified

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

示例13: testLineLength

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

示例14: testInitFromNonEmptyFile

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

示例15: testInitFromEmptyFile

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


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