(self, lines)
return result
Wrap long Fortran lines

           Argument:
             lines  --  a list of lines (without \\n character)

           A comment line is split at white space. Code lines are split with a more
           complex rule to give nice results.
Wrap long Fortran lines
Wrap long Fortran lines
def _wrap_fortran(self, lines):
        """Wrap long Fortran lines

           Argument:
             lines  --  a list of lines (without \\n character)

           A comment line is split at white space. Code lines are split with a more
           complex rule to give nice results.
        """
        # routine to find split point in a code line
        my_alnum = set("_+-." + string.digits + string.ascii_letters)
        my_white = set(" \t()")

        def split_pos_code(line, endpos):
            if len(line) <= endpos:
                return len(line)
            pos = endpos
            split = lambda pos: \
                (line[pos] in my_alnum and line[pos - 1] not in my_alnum) or \
                (line[pos] not in my_alnum and line[pos - 1] in my_alnum) or \
                (line[pos] in my_white and line[pos - 1] not in my_white) or \
                (line[pos] not in my_white and line[pos - 1] in my_white)
            while not split(pos):
                pos -= 1
                if pos == 0:
                    return endpos
            return pos
        # split line by line and add the splitted lines to result
        result = []
        if self._settings['source_format'] == 'free':
            trailing = ' &'
        else:
            trailing = ''
        for line in lines:
            if line.startswith(self._lead_comment):
                # comment line
                if len(line) > 72:
                    pos = line.rfind(" ", 6, 72)
                    if pos == -1:
                        pos = 72
                    hunk = line[:pos]
                    line = line[pos:].lstrip()
                    result.append(hunk)
                    while len(line) > 0:
                        pos = line.rfind(" ", 0, 66)
                        if pos == -1 or len(line) < 66:
                            pos = 66
                        hunk = line[:pos]
                        line = line[pos:].lstrip()
                        result.append("%s%s" % (self._lead_comment, hunk))
                else:
                    result.append(line)
            elif line.startswith(self._lead_code):
                # code line
                pos = split_pos_code(line, 72)
                hunk = line[:pos].rstrip()
                line = line[pos:].lstrip()
                if line:
                    hunk += trailing
                result.append(hunk)
                while len(line) > 0:
                    pos = split_pos_code(line, 65)
                    hunk = line[:pos].rstrip()
                    line = line[pos:].lstrip()
                    if line:
                        hunk += trailing
                    result.append("%s%s" % (self._lead_cont, hunk))
            else:
                result.append(line)
        return result
def _wrap_fortran ( self , lines ) : # routine to find split point in a code line my_alnum = set ( "_+-." + string . digits + string . ascii_letters ) my_white = set ( " \t()" ) def split_pos_code ( line , endpos ) : if len ( line ) <= endpos : return len ( line ) pos = endpos split = lambda pos : ( line [ pos ] in my_alnum and line [ pos - 1 ] not in my_alnum ) or ( line [ pos ] not in my_alnum and line [ pos - 1 ] in my_alnum ) or ( line [ pos ] in my_white and line [ pos - 1 ] not in my_white ) or ( line [ pos ] not in my_white and line [ pos - 1 ] in my_white ) while not split ( pos ) : pos -= 1 if pos == 0 : return endpos return pos # split line by line and add the splitted lines to result result = [ ] if self . _settings [ 'source_format' ] == 'free' : trailing = ' &' else : trailing = '' for line in lines : if line . startswith ( self . _lead_comment ) : # comment line if len ( line ) > 72 : pos = line . rfind ( " " , 6 , 72 ) if pos == - 1 : pos = 72 hunk = line [ : pos ] line = line [ pos : ] . lstrip ( ) result . append ( hunk ) while len ( line ) > 0 : pos = line . rfind ( " " , 0 , 66 ) if pos == - 1 or len ( line ) < 66 : pos = 66 hunk = line [ : pos ] line = line [ pos : ] . lstrip ( ) result . append ( "%s%s" % ( self . _lead_comment , hunk ) ) else : result . append ( line ) elif line . startswith ( self . _lead_code ) : # code line pos = split_pos_code ( line , 72 ) hunk = line [ : pos ] . rstrip ( ) line = line [ pos : ] . lstrip ( ) if line : hunk += trailing result . append ( hunk ) while len ( line ) > 0 : pos = split_pos_code ( line , 65 ) hunk = line [ : pos ] . rstrip ( ) line = line [ pos : ] . lstrip ( ) if line : hunk += trailing result . append ( "%s%s" % ( self . _lead_cont , hunk ) ) else : result . append ( line ) return result