From ea012ca95b1c88ebccdd9e83078bbb63691907c5 Mon Sep 17 00:00:00 2001 From: KeshavAnandCode Date: Tue, 19 May 2026 15:06:16 +0000 Subject: [PATCH] fixed version and author duplication --- .gitignore | 44 ++++++++++++++++++++++++++++++++++ src/foreignthon_es/__init__.py | 28 +++++++++++++++++++++- src/foreignthon_es/es.json | 4 +--- 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f973e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# Python +__pycache__/ +*.py[cod] +*.pyo +*.pyd +.Python +*.egg-info/ +*.egg +dist/ +build/ +wheels/ +sdist/ + +# Virtual envs +.venv/ +venv/ +env/ + +# Testing +.pytest_cache/ +.coverage +htmlcov/ + +# Ruff / linting +.ruff_cache/ + +# Mypy +.mypy_cache/ + +# Editors +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# ForeignThon compiled output +*.compiled.py + +# Temporary Tests +tmp/** diff --git a/src/foreignthon_es/__init__.py b/src/foreignthon_es/__init__.py index 2afb9d8..90e6017 100644 --- a/src/foreignthon_es/__init__.py +++ b/src/foreignthon_es/__init__.py @@ -1,4 +1,30 @@ from importlib.resources import files +from importlib.metadata import version, metadata, PackageNotFoundError + +try: + package_name = (__package__ or "").replace("_", "-") + __version__ = version(package_name) + + pkg_metadata = metadata(package_name) + + # 1. Grab names from BOTH possible fields (Author and Author-email) + raw_authors = pkg_metadata.get_all("Author") or [] + raw_emails = pkg_metadata.get_all("Author-email") or [] + + # 2. Combine them into one single, clean list of unique names + # This strips out the extra email brackets so you just get the clean names + combined = [] + for item in (raw_authors + raw_emails): + # Extracts just the name if it looks like "Name " + clean_name = item.split("<")[0].strip() + if clean_name and clean_name not in combined: + combined.append(clean_name) + + __authors__ = combined + +except PackageNotFoundError: + __version__ = "0.0.0" + __authors__ = [] def get_pack_path(): - return files(__name__) / "es.json" + return files(__name__) / "es.json" \ No newline at end of file diff --git a/src/foreignthon_es/es.json b/src/foreignthon_es/es.json index 79ae6f3..098db87 100644 --- a/src/foreignthon_es/es.json +++ b/src/foreignthon_es/es.json @@ -2,9 +2,7 @@ "meta": { "name": "Spanish", "native_name": "EspaƱol", - "code": "es", - "version": "0.1.0", - "authors": [] + "code": "es" }, "keywords": { "si": "if",