Exemplo n.º 1
0
def ccomm(filename):
    c_src = open(filename).read()
    cmt = cStyleComment.scanString(c_src)
    for comment,s,e in cmt:
        for line in comment[0].splitlines():
            if line[4:7]!='===':
                print(line)
        print()
Exemplo n.º 2
0
    
        # only accept .h .hpp .c .cpp .tpp .tut 
        r=re.compile('.*(\.h|\.hpp|\.c|\.cpp|\.tpp|\.tut)$')
        if r.match (filepath):
            if (verbose == True):
                print filepath
        else:
            continue

        # read whole file
        with open(filepath) as f:
            data = f.read()

        try:
            # grep block-comments
            (match, start, end) = cStyleComment.scanString(data).next()
       
            # copy for later use
            cmt = match[0]
            
            # check whether we have a brief and a copyright
            if (re.match(r'(?is)(.*)\\file(.*)', cmt)):
                # do some replacement

                # grep the old brief, author, and date
                if (verbose == True):
                    match = re.search(r'(?is).*([ \t]*\*[ \t]*\\file[ \t].*?\n)', cmt)
                    if match:
                        rawbrief = match.group(1)

                newHeader = re.sub(r'(?is)([ \t]*\*[ \t]*\\file[ \t].*?\n)', '', cmt)
Exemplo n.º 3
0
        else:
            continue

        # as far as i see:
        # -header is never beyond the very first c-style/block-comment match
        #       so it is enough to look at the first occurence of a c-style-comment
        # -there are // headers, but none of them contain a shark-copyright-notice,
        #       except ./include/shark/Models/RecurrentStructure.h

        # read whole file
        with open(filepath) as f:
            data = f.read()

        try:
            # grep block-comments
            (match, start, end) = cStyleComment.scanString(data).next()

            # copy for later use
            cmt = match[0]

            # check whether we have a brief and a copyright
            if (re.match(r'(?is).*Copyright.*', cmt) or re.match(
                    r'(?is).*GNU General Public License as published.*', cmt)):
                # do some replacement

                # grep the old brief, author, and date
                rawbrief = "-"
                match = re.search(r'(?is)\\brief\s*(.*?)(\\a|\\d|<BR>)', cmt)
                if match:
                    rawbrief = match.group(1)
                    # remove comment things