Ejemplo n.º 1
0
class Comment:
    content: str
    extension: str
    single: Single
    multi: Multi
    todo: TODO

    def __init__(self, content, extension):
        self.content = content
        self.extension = extension
        self.single = Single(self.content, self.extension)
        self.multi = Multi(self.content, self.extension)
        self.todo = TODO(self.content)

    def singleLines(self):
        singles = self.single.lines()
        multiSingles = self.single.multiSingleLines()
        falsePositives = self.single.falsePositivesLines(
        )  #special case pattern for single false positives
        return str(singles - multiSingles - falsePositives)

    def blockComments(self):
        blocks = self.multi.blocks()
        multiSingleBlocks = int(self.single.multiSingleBlocks())
        return str(blocks + multiSingleBlocks)

    def blockLines(self):
        lines = self.multi.lines()
        multiSingleLines = self.single.multiSingleLines()
        return str(lines + multiSingleLines)

    def commentLines(self):
        return str(int(self.singleLines()) + int(self.blockLines()))

    def TODOLines(self):
        return str(int(self.todo.lines()))
Ejemplo n.º 2
0
 def test_multiLineCommentsWithNewLines(self):
     string = "\'\'\'\nComment\n\'\'\'"
     test = Multi(string,"py")
     output = test.blocks()
     self.assertEqual(1, output)
Ejemplo n.º 3
0
 def test_multiLineComment(self):
     string = "\'\'\'Comment\'\'\'"
     test = Multi(string,"py")
     output = test.blocks()
     self.assertEqual(1, output)