Created
June 6, 2017 14:23
-
-
Save m4rc1e/82f42fae7121f45aeb8d8a7c83f6d614 to your computer and use it in GitHub Desktop.
Check the OFL.txt files in the gf repo are good
This file contains 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
""" | |
For each OFL.txt file, if there is not a double linebreak after the firt | |
line, add it. | |
e.g: | |
Before: | |
Copyright 2017 The Manuala Project Authors (http:www.gitrepo.com) | |
This is the license file. description | |
After: | |
Copyright 2017 The Manuala Project Authors (http:www.gitrepo.com) | |
This is the license file. description | |
""" | |
import os | |
import sys | |
import re | |
def main(ofl_path): | |
for path, r, files in os.walk(ofl_path): | |
for file in files: | |
if file == 'OFL.txt': | |
ofl_path = os.path.join(path, file) | |
with open(ofl_path, 'r') as ofl_doc: | |
ofl_text = ofl_doc.read() | |
# if '\r\n' in ofl_text: | |
# ofl_text = ofl_text.replace('\r\n', '\n') | |
# with open(ofl_path, 'w') as ofl_doc_w: | |
# ofl_doc_w.write(ofl_text) | |
pattern = re.search(r'[\n|\r][\r|\n]This Font Software is licensed', ofl_text) | |
if not pattern: | |
print ofl_path | |
if __name__ == '__main__': | |
if len(sys.argv) != 2: | |
print 'Please add path to google/fonts/ofl' | |
else: | |
main(sys.argv[-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment