當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。