Skip to content

Instantly share code, notes, and snippets.

@FelixWolf
Last active October 30, 2022 13:57
Show Gist options
  • Select an option

  • Save FelixWolf/fefefa81df547da2819497f1f7109cb6 to your computer and use it in GitHub Desktop.

Select an option

Save FelixWolf/fefefa81df547da2819497f1f7109cb6 to your computer and use it in GitHub Desktop.
#!/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")
@dani72092
Copy link
Copy Markdown

dani72092 commented Aug 7, 2022

LICENSE_CS_BY_SA = 101

DEP_CS = "Dragon's Eye Productions/Catnip Studios"

It would be useful to be able to sign derivative works appropriately, with some safeguards added. Thinking about the following rules:

  1. An object with the FC-DEP/CS-BY-SA license cannot be relicensed (when called from a command line or something, code will be code).
  2. An object with the FC-DEP/CS-BY-SA license must have "Dragon's Eye Productions/Catnip Studios" as the original author, preserving any existing authors after it and any additional authors after that. The exception being if DEP/CS is listed in any other form as an "additional author", see #3.
  3. "Dragon's Eye Productions/Catnip Studios" should only ever be the original author and should not be listed again. This applies to all authors, in that they should only be listed once and duplicate instances should be removed, prioritizing the earliest instance.

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.

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