Created
July 22, 2020 05:38
-
-
Save shotastage/2e0e01295620e02a01c62af6dfd00293 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import os | |
import glob | |
import shutil | |
def clean_recent(): | |
flist = glob.glob("./AppMain/Assets/Resources/Licenses/*") | |
for f in flist: | |
os.remove(f) | |
def generate_source_file(framelist): | |
src = """import Foundation | |
enum OpenSourceLibraries { | |
static let libraries: [String] = [ | |
""" | |
for frame in framelist: | |
src += " \"" + frame + "\",\n" | |
src += """ | |
] | |
} | |
""" | |
path_w = "./AppMain/OSS.generated.swift" | |
with open(path_w, mode='w') as f: | |
f.write(src) | |
if __name__ == "__main__": | |
print("Searching Carthage built frameworks...") | |
clean_recent() | |
framelist = os.listdir("./Carthage/Checkouts/") | |
licensed_frames = framelist | |
for i, frame in enumerate(framelist): | |
print("Processing for " + frame + " ...") | |
if os.path.isfile("./Carthage/Checkouts/" + frame + "/LICENSE"): | |
shutil.copyfile("./Carthage/Checkouts/" + frame + "/LICENSE", "./AppMain/Assets/Resources/Licenses/" + frame + ".license") | |
continue | |
if os.path.isfile("./Carthage/Checkouts/" + frame + "/LICENSE.txt"): | |
shutil.copyfile("./Carthage/Checkouts/" + frame + "/LICENSE.txt", "./AppMain/Assets/Resources/Licenses/" + frame + ".license") | |
continue | |
if os.path.isfile("./Carthage/Checkouts/" + frame + "/LICENSE.md"): | |
shutil.copyfile("./Carthage/Checkouts/" + frame + "/LICENSE.md", "./AppMain/Assets/Resources/Licenses/" + frame + ".license") | |
continue | |
licensed_frames.pop(i) | |
generate_source_file(licensed_frames) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes