bebraw
9/13/2012 - 3:55 PM

Tiny licensifier script

Tiny licensifier script

#!/usr/bin/env python
import os

def walk(path, extensions, cb):
    path = os.path.abspath(path)

    for f in os.listdir(path):
        fp = os.path.join(path, f)
        p, ext = os.path.splitext(f)

        if ext[1:] in extensions:
            cb(f)

        if os.path.isdir(fp):
            walk(fp, extensions, cb) 

if __name__ == '__main__':
    def cb(path):
        print 'Writing ' + path
        with open(path, 'w') as f:
            pass  # TODO: prepend license block here

    walk('./src', ['c', 'h'], cb)