LICENCES = {
"MIT": {"commercial": True, "share_source": False},
"Apache-2.0": {"commercial": True, "share_source": False},
"GPL-3.0": {"commercial": True, "share_source": True},
"CC-BY-NC": {"commercial": False, "share_source": False},
}
def check(components, selling, closed_source):
for name, lic in components:
rules = LICENCES.get(lic)
if rules is None:
print(f"{name}: unknown licence - get permission first")
elif selling and not rules["commercial"]:
print(f"{name}: not allowed in a product you sell")
elif closed_source and rules["share_source"]:
print(f"{name}: would require sharing your source")
else:
print(f"{name}: OK - keep the {lic} notice and give credit")
check([("sorter", "MIT"), ("charts", "GPL-3.0"), ("icons", "CC-BY-NC"),
("blog snippet", None)], selling=True, closed_source=True)
A simplified licence checker using a dictionary of rules. Real licences have more conditions, so treat this as a first check, not legal advice.