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


Python TextDocument.numLines方法代碼示例

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


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

示例1: testDeleteLine2

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

示例2: testJoinWithNextLine

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

示例3: testJoinWithNextLine

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

示例4: testInsertLine

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

示例5: testInitEmpty

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import numLines [as 別名]
    def testInitEmpty(self):
        doc = TextDocument()

        self.assertTrue(doc.isEmpty())
        self.assertEqual(doc.filename(), None)
        self.assertFalse(doc.isModified())
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.documentText(), '\n')
開發者ID:gavd89,項目名稱:vai,代碼行數:10,代碼來源:test_TextDocument.py

示例6: testInitFromNonEmptyFile

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import numLines [as 別名]
    def testInitFromNonEmptyFile(self):
        doc = TextDocument()
        with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
            doc.read(f)

        self.assertFalse(doc.isEmpty())
        self.assertEqual(doc.numLines(), 2)
        self.assertEqual(doc.documentText(), "hello\nhow are you?\n")
開發者ID:rsdenijs,項目名稱:vai,代碼行數:10,代碼來源:test_TextDocument.py

示例7: testInitFromEmptyFile

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import numLines [as 別名]
    def testInitFromEmptyFile(self):
        doc = TextDocument()
        with open(fixtures.get("empty_file.txt"), "r") as f:
            doc.read(f)

        self.assertTrue(doc.isEmpty())
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.documentText(), "\n")
開發者ID:rsdenijs,項目名稱:vai,代碼行數:10,代碼來源:test_TextDocument.py

示例8: testInitFromNonEmptyFile

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

示例9: testInitFromEmptyFile

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

示例10: testDeleteLine2

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

示例11: testInsertLines

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import numLines [as 別名]
 def testInsertLines(self):
     doc = TextDocument()
     doc.open(fixtures.get("basic_nonempty_file.txt"))
     doc.insertLines(2, ['foo', 'bar'])
     self.assertEqual(doc.numLines(), 4)
開發者ID:gavd89,項目名稱:vai,代碼行數:7,代碼來源:test_TextDocument.py

示例12: testInitEmpty

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import numLines [as 別名]
    def testInitEmpty(self):
        doc = TextDocument()

        self.assertTrue(doc.isEmpty())
        self.assertEqual(doc.numLines(), 1)
        self.assertEqual(doc.documentText(), "\n")
開發者ID:rsdenijs,項目名稱:vai,代碼行數:8,代碼來源:test_TextDocument.py

示例13: testInsertLines

# 需要導入模塊: from vai.models.TextDocument import TextDocument [as 別名]
# 或者: from vai.models.TextDocument.TextDocument import numLines [as 別名]
 def testInsertLines(self):
     doc = TextDocument()
     with open(fixtures.get("basic_nonempty_file.txt"), "r") as f:
         doc.read(f)
     doc.insertLines(2, ["foo", "bar"])
     self.assertEqual(doc.numLines(), 4)
開發者ID:rsdenijs,項目名稱:vai,代碼行數:8,代碼來源:test_TextDocument.py


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