Last active
April 2, 2024 19:53
-
-
Save pawamoy/4d573561a59197a97283ba8a31a27ded to your computer and use it in GitHub Desktop.
Print funding URLs of installed Python packages
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
from importlib.metadata import distributions | |
funding_keywords = {"donate", "funding", "tidelift"} | |
def print_funding_urls(): | |
for package in distributions(): | |
funding_urls = [] | |
for line in package.metadata.get_all("Project-URL", []): | |
title, url = line.split(", ", 1) | |
if title.lower() in funding_keywords: | |
funding_urls.append(url) | |
if funding_urls: | |
print(f"{package.metadata['Name']}: {', '.join(funding_urls)}") | |
if __name__ == "__main__": | |
print_funding_urls() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment