Last active
October 30, 2022 13:57
-
-
Save FelixWolf/fefefa81df547da2819497f1f7109cb6 to your computer and use it in GitHub Desktop.
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 python3 | |
| from libfurc import fox5 | |
| LICENSE_FC_BY_SA = 0 | |
| LICENSE_FC0 = 1 | |
| LICENSE_FC_BY_NC_SA = 2 | |
| LICENSE_FC_ND_NC_SA = 3 | |
| LICENSE_FC_PRIVATE_SA = 4 | |
| LICENSE_FC_BY_X_SA = 5 | |
| LICENSE_DEP = 101 | |
| DEP_CS = "Dragon's Eye Productions/Catnip Studios" | |
| def getSafeLicense(fro, to): | |
| #If license is compatible to be overwritten | |
| if fro in [LICENSE_FC0, None]: | |
| return to | |
| #Else, return the compatible license | |
| return fro | |
| def reAttribute(fox, | |
| license = None, author = None, | |
| overwriteLicense = False, | |
| overwriteAuthor = False, | |
| overwriteLicenseForce = False | |
| ): | |
| #If author is a string, convert it to a list | |
| if type(author) == str: | |
| author = [author] | |
| for obj in fox.body: | |
| #If license is set but the object has no license, or overwriteLicense is set | |
| if license != None and (obj["License"] == None or overwriteLicense == True): | |
| obj["License"] = getSafeLicense(obj["License"], license) | |
| #If author is set | |
| if author != None: | |
| #And authors is none or empty | |
| if obj["Authors"] == None or len(obj["Authors"]) == 0 or overwriteAuthor == True: | |
| obj["Authors"] = author | |
| #Else, append the author | |
| else: | |
| obj["Authors"] = obj["Authors"] + author | |
| #If the license is DEP, ensure the DEP CS is in the Authors | |
| if license == LICENSE_DEP: | |
| #Only if it isn't in the authors table | |
| if obj["Authors"] == None: | |
| obj["Authors"] = [DEP_CS] | |
| else: | |
| obj["Authors"].append(DEP_CS) | |
| fox = fox5.load("somepatch.fox") | |
| reAttribute(fox, LICENSE_FC_BY_SA, ["Vargskelethor", "Fecal Funny Co."]) | |
| fox5.dump(fox, "somepatch.fox") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be useful to be able to sign derivative works appropriately, with some safeguards added. Thinking about the following rules:
It also seems like the License and Author attributes are actually within obj["Properties"], not at the root. Maybe I'm missing something or calling it incorrectly.