當前位置: 首頁>>代碼示例>>Python>>正文


Python TextDocument.createLineMetaInfo方法代碼示例

本文整理匯總了Python中vai.models.TextDocument.TextDocument.createLineMetaInfo方法的典型用法代碼示例。如果您正苦於以下問題:Python TextDocument.createLineMetaInfo方法的具體用法?Python TextDocument.createLineMetaInfo怎麽用?Python TextDocument.createLineMetaInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vai.models.TextDocument.TextDocument的用法示例。


在下文中一共展示了TextDocument.createLineMetaInfo方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testSetDataForLines

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import createLineMetaInfo [as 別名]
    def testSetDataForLines(self):
        doc = TextDocument()
        doc.createLineMetaInfo("whatever")
        doc.insertLine(1, "hello")
        doc.insertLine(1, "hello")
        doc.insertLine(1, "hello")
        meta_info = doc.lineMetaInfo("whatever")

        meta_info.setDataForLines({2: "damn"})

        self.assertEqual(meta_info.data(), [None, "damn", None, None])
開發者ID:pipter,項目名稱:vai,代碼行數:13,代碼來源:test_LineMetaInfo.py

示例2: testBasic

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import createLineMetaInfo [as 別名]
    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,代碼行數:14,代碼來源:test_LineMetaInfo.py

示例3: testReplaceFromMemento

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import createLineMetaInfo [as 別名]
    def testReplaceFromMemento(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)
        doc.createLineMetaInfo("whatever")
        initial_text = doc.documentText()
        meta_info1 = doc.lineMetaInfo("whatever")
        meta_info1.setData("hello", 1)

        memento = doc.lineMemento(1)
        doc.insertChars((1, 1), "gnakgnak")
        meta_info1.setData("byebye", 1)
        doc.replaceFromMemento(1, memento)

        self.assertEqual(doc.documentText(), initial_text)
        self.assertEqual(meta_info1.data(1), "hello")
開發者ID:rsdenijs,項目名稱:vai,代碼行數:18,代碼來源:test_TextDocument.py

示例4: testInsertFragment

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import createLineMetaInfo [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

示例5: testExtractFragment

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import createLineMetaInfo [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

示例6: testChangeLineNumber

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import createLineMetaInfo [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)
開發者ID:UtahDave,項目名稱:vai,代碼行數:41,代碼來源:test_LineMetaInfo.py

示例7: testLineMetaInfoMemento

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import createLineMetaInfo [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

示例8: testSameObject

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import createLineMetaInfo [as 別名]
 def testSameObject(self):
     doc = TextDocument()
     doc.createLineMetaInfo("whatever")
     doc.createLineMetaInfo("whatever2")
     self.assertEqual(doc.lineMetaInfo("whatever"), doc.lineMetaInfo("whatever"))
     self.assertNotEqual(doc.lineMetaInfo("whatever"), doc.lineMetaInfo("whatever2"))
開發者ID:pipter,項目名稱:vai,代碼行數:8,代碼來源:test_LineMetaInfo.py


注:本文中的vai.models.TextDocument.TextDocument.createLineMetaInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。