Skip to content

Instantly share code, notes, and snippets.

@shotastage
Created July 22, 2020 05:38
Show Gist options
  • Save shotastage/2e0e01295620e02a01c62af6dfd00293 to your computer and use it in GitHub Desktop.
Save shotastage/2e0e01295620e02a01c62af6dfd00293 to your computer and use it in GitHub Desktop.
#!/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)
Copy link

ghost commented Mar 3, 2023

Yes

Copy link

ghost commented Mar 3, 2023

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment