Created
January 21, 2012 02:16
-
-
Save stephenmcd/1650811 to your computer and use it in GitHub Desktop.
Convert 3-clause BSD licenses to 2-clause in a directory of projects, commit and push to BitBucket and GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
cwd = os.path.abspath(os.getcwd()) | |
for project in os.listdir("."): | |
path = os.path.join(cwd, project) | |
if not os.path.isdir(path): | |
continue | |
os.chdir(path) | |
try: | |
with open("LICENSE", "r") as f: | |
license = f.read() | |
except: | |
continue | |
skip = False | |
lines = [] | |
for line in license.split("\n"): | |
if line.strip().startswith("3"): | |
skip = True | |
elif skip and line.startswith("THIS"): | |
skip = False | |
if not skip: | |
lines.append(line) | |
with open("LICENSE", "w") as f: | |
f.writelines("\n".join(lines)) | |
os.system('hg commit -m "Changed LICENSE from 3-clause to 2-clause BSD."') | |
os.system('hg push && hg push github') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment