コード例 #1
0
ファイル: LineTextAnalyzer.py プロジェクト: sernst/PyAid
    def __init__(self, src ='', debug =False, blockDefs =None):
        """Creates a new instance of ClassTemplate."""
        RedactionTextAnalyzer.__init__(self, src, debug, blockDefs)

        self._lines        = []
        self._lineCursor   = 0
        self._startIndices = None
        self.refreshStartIndices()
        if debug:
            print('START INDICES:', self._startIndices)

        prev = None
        while True:
            line = LineMetadata(self, prev)
            if prev:
                prev.nextLine = line

            prev = line
            self._lines.append(line)

            if debug:
                print('LINE: ',line.startIndex,line.endIndex,'of',len(self._raw))

            if not line.endIndex < len(self._raw) - 1:
                break
コード例 #2
0
    def __init__(self, src='', debug=False, blockDefs=None):
        """Creates a new instance of ClassTemplate."""
        RedactionTextAnalyzer.__init__(self, src, debug, blockDefs)

        self._lines = []
        self._lineCursor = 0
        self._startIndices = None
        self.refreshStartIndices()
        if debug:
            print('START INDICES:', self._startIndices)

        prev = None
        while True:
            line = LineMetadata(self, prev)
            if prev:
                prev.nextLine = line

            prev = line
            self._lines.append(line)

            if debug:
                print('LINE: ', line.startIndex, line.endIndex, 'of',
                      len(self._raw))

            if not line.endIndex < len(self._raw) - 1:
                break
コード例 #3
0
ファイル: LineTextAnalyzer.py プロジェクト: sernst/PyAid
    def _insertImpl(self, start, end, value):
        add = value.count('\n') - self.source[start:end].count('\n')
        RedactionTextAnalyzer._insertImpl(self, start, end, value)

        if add == 0:
            return

        for l in self._lines:
            if l.contains(start):
                nl = l
                if add > 0:
                    for i in range(0, add):
                        nl = nl.addLineAfter()
                else:
                    for i in range(0, abs(add)):
                        l.removeLineAfter()
                break
コード例 #4
0
    def _insertImpl(self, start, end, value):
        add = value.count('\n') - self.source[start:end].count('\n')
        RedactionTextAnalyzer._insertImpl(self, start, end, value)

        if add == 0:
            return

        for l in self._lines:
            if l.contains(start):
                nl = l
                if add > 0:
                    for i in range(0, add):
                        nl = nl.addLineAfter()
                else:
                    for i in range(0, abs(add)):
                        l.removeLineAfter()
                break
コード例 #5
0
ファイル: LineTextAnalyzer.py プロジェクト: sernst/PyAid
    def changeOffsets(self, index, amount):
        RedactionTextAnalyzer.changeOffsets(self, index, amount)

        for l in self._lines:
            if l.contains(index):
                l.setDirty(True)
                break

        # Updates the lines, adding or removing them as needed.
        lastLine = self._lines[-1]

        # REMOVE LINES
        while lastLine.startIndex == len(self.source):
            lastLine.destroy()
            lastLine = self._lines[-1]

        # ADD LINES
        while lastLine.endIndex < len(self.source):
            l                 = LineMetadata(self, lastLine)
            lastLine.nextLine = l
            lastLine          = l
コード例 #6
0
    def changeOffsets(self, index, amount):
        RedactionTextAnalyzer.changeOffsets(self, index, amount)

        for l in self._lines:
            if l.contains(index):
                l.setDirty(True)
                break

        # Updates the lines, adding or removing them as needed.
        lastLine = self._lines[-1]

        # REMOVE LINES
        while lastLine.startIndex == len(self.source):
            lastLine.destroy()
            lastLine = self._lines[-1]

        # ADD LINES
        while lastLine.endIndex < len(self.source):
            l = LineMetadata(self, lastLine)
            lastLine.nextLine = l
            lastLine = l