From e4e98b4f7483507a0a7bb8f8a7300a2152907940 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Sun, 8 Feb 2026 12:07:58 +0900 Subject: [PATCH] Switch to uv from .venv --- .python-version | 1 + README.md | 35 ++++---------- bin/utils/long_lat.py | 12 +++-- pyproject.toml | 61 ++++++++++++++++++++++-- requirements.txt | 8 ---- uv.lock | 106 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 183 insertions(+), 40 deletions(-) create mode 100644 .python-version delete mode 100644 requirements.txt create mode 100644 uv.lock diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..6324d40 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.14 diff --git a/README.md b/README.md index 108690b..5d14f01 100644 --- a/README.md +++ b/README.md @@ -7,30 +7,7 @@ This script will update any of the Country Code, Country, State, City and Locati ## Development Setup ```sh -python3 -m venv .venv -source .venv/bin/activate -.venv/bin/python -m pip install -U pip setuptools wheel -pip freeze > requirements.txt -``` - -```sh -pip install -r requirements.txt -``` - -Then install the requests and python-xmp-toolkit modules from below - -## Installing and setting up - -The script uses the following external non defauly python libraries - -* xmp toolkit -* requests - -install both with the pip3 command - -```sh -pip install requests -pip install python-xmp-toolkit +uv sync ``` XMP Toolkit also needs the [Exempi Library](http://libopenraw.freedesktop.org/wiki/Exempi). This one can be install via brew or macports directly. @@ -38,7 +15,8 @@ See more information for [Python XMP Tool kit](http://python-xmp-toolkit.readthe ## Command line arguments -reverse_geolocate.py [-h] -i +```sh +uv run bin/reverse_geolocate.py [-h] -i [XMP SOURCE FOLDER [XMP SOURCE FOLDER ...]] [-x [EXCLUDE XMP SOURCE FOLDER [EXCLUDE XMP SOURCE FOLDER ...]]] [-l LIGHTROOM FOLDER] [-s] @@ -46,6 +24,13 @@ reverse_geolocate.py [-h] -i [-d [FUZZY DISTANCE]] [-g GOOGLE API KEY] [-o] [-e EMIL ADDRESS] [-w] [-r] [-u] [-a] [-c] [-n] [-v] [--debug] [--test] +``` + +to run it from a differnt path + +```sh +uv run --project run /reverse-geolocate.py +``` ### Arguments diff --git a/bin/utils/long_lat.py b/bin/utils/long_lat.py index e4282d5..40f5c37 100644 --- a/bin/utils/long_lat.py +++ b/bin/utils/long_lat.py @@ -6,7 +6,11 @@ import re from math import radians, sin, cos, atan2, sqrt -def convert_lat_long_to_dms(lat_long, is_latitude=False, is_longitude=False): +def convert_lat_long_to_dms( + lat_long: float, + is_latitude: bool = False, + is_longitude: bool = False +) -> str: """ convert the LR format of N.N to the Exif GPS format @@ -30,7 +34,7 @@ def convert_lat_long_to_dms(lat_long, is_latitude=False, is_longitude=False): return f"{degree},{minutes}{direction}" -def convert_lat_to_dms(lat_long): +def convert_lat_to_dms(lat_long: float) -> str: """ wrapper functions for Long/Lat calls: latitude @@ -44,7 +48,7 @@ def convert_lat_to_dms(lat_long): # wrapper for Long/Lat call: longitute -def convert_long_to_dms(lat_long): +def convert_long_to_dms(lat_long: float) -> str: """ wrapper for Long/Lat call: longitute @@ -57,7 +61,7 @@ def convert_long_to_dms(lat_long): return convert_lat_long_to_dms(lat_long, is_longitude=True) -def long_lat_reg(longitude, latitude): +def long_lat_reg(longitude: str, latitude: str) -> dict[str, float] : """ converts the XMP/EXIF formatted GPS Long/Lat coordinates from the , to the normal float diff --git a/pyproject.toml b/pyproject.toml index afeb3c1..3d06649 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,68 @@ +[project] +name = "reverse-geolocate" +version = "0.1.0" +description = "Reverse Geolcate script" +readme = "README.md" +requires-python = ">=3.14" +dependencies = [ + "python-xmp-toolkit>=2.1.0", + "requests>=2.32.5", +] + +# MARK: Python linting +[tool.pyright] +typeCheckingMode = "strict" +reportMissingImports = "information" +reportMissingTypeStubs = "information" +reportUnknownMemberType = "information" [tool.ruff] line-length = 120 [tool.black] # set 10 short for better formatting line-length = 110 # to avoid " ... " " ... " string sets -experimental-string-processing = true +# experimental-string-processing = true +preview = true +enable-unstable-feature = ["string_processing"] [tool.pylint.format] max-line-length = 120 -[tool.pylint.TYPECHECK] -generated-members="utils.*" +[tool.pylint.miscellaneous] +notes = ["FIXME", "TODO"] +notes-rgx = '(FIXME|TODO)(\((TTD-|#)\[0-9]+\))' [tool.flake8] max-line-length = 120 +ignore = [ + "E741", # ignore ambigious variable name + "W504" # Line break occurred after a binary operator [wrong triggered by "or" in if] +] +[tool.pylint.MASTER] +# this is for the tests/etc folders +init-hook='import sys; sys.path.append("src/")' + +# MARK: Testing +[tool.pytest.ini_options] +testpaths = [ + "tests", +] + +[tool.coverage.run] +omit = [ + "*/tests/*", + "*/test_*.py", + "*/__init__.py" +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "def __str__", + "raise AssertionError", + "raise NotImplementedError", + "if __name__ == .__main__.:" +] +exclude_also = [ + "def __.*__\\(", + "def __.*\\(", + "def _.*\\(", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 34ab806..0000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -certifi==2023.11.17 -charset-normalizer==3.3.2 -idna==3.6 -install==1.3.5 -python-xmp-toolkit==2.0.1 -pytz==2023.3.post1 -requests==2.31.0 -urllib3==2.1.0 diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..1990e76 --- /dev/null +++ b/uv.lock @@ -0,0 +1,106 @@ +version = 1 +revision = 3 +requires-python = ">=3.14" + +[[package]] +name = "certifi" +version = "2026.1.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e0/2d/a891ca51311197f6ad14a7ef42e2399f36cf2f9bd44752b3dc4eab60fdc5/certifi-2026.1.4.tar.gz", hash = "sha256:ac726dd470482006e014ad384921ed6438c457018f4b3d204aea4281258b2120", size = 154268, upload-time = "2026-01-04T02:42:41.825Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl", hash = "sha256:9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c", size = 152900, upload-time = "2026-01-04T02:42:40.15Z" }, +] + +[[package]] +name = "charset-normalizer" +version = "3.4.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/13/69/33ddede1939fdd074bce5434295f38fae7136463422fe4fd3e0e89b98062/charset_normalizer-3.4.4.tar.gz", hash = "sha256:94537985111c35f28720e43603b8e7b43a6ecfb2ce1d3058bbe955b73404e21a", size = 129418, upload-time = "2025-10-14T04:42:32.879Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/35/7051599bd493e62411d6ede36fd5af83a38f37c4767b92884df7301db25d/charset_normalizer-3.4.4-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:da3326d9e65ef63a817ecbcc0df6e94463713b754fe293eaa03da99befb9a5bd", size = 207746, upload-time = "2025-10-14T04:41:33.773Z" }, + { url = "https://files.pythonhosted.org/packages/10/9a/97c8d48ef10d6cd4fcead2415523221624bf58bcf68a802721a6bc807c8f/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8af65f14dc14a79b924524b1e7fffe304517b2bff5a58bf64f30b98bbc5079eb", size = 147889, upload-time = "2025-10-14T04:41:34.897Z" }, + { url = "https://files.pythonhosted.org/packages/10/bf/979224a919a1b606c82bd2c5fa49b5c6d5727aa47b4312bb27b1734f53cd/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:74664978bb272435107de04e36db5a9735e78232b85b77d45cfb38f758efd33e", size = 143641, upload-time = "2025-10-14T04:41:36.116Z" }, + { url = "https://files.pythonhosted.org/packages/ba/33/0ad65587441fc730dc7bd90e9716b30b4702dc7b617e6ba4997dc8651495/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:752944c7ffbfdd10c074dc58ec2d5a8a4cd9493b314d367c14d24c17684ddd14", size = 160779, upload-time = "2025-10-14T04:41:37.229Z" }, + { url = "https://files.pythonhosted.org/packages/67/ed/331d6b249259ee71ddea93f6f2f0a56cfebd46938bde6fcc6f7b9a3d0e09/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d1f13550535ad8cff21b8d757a3257963e951d96e20ec82ab44bc64aeb62a191", size = 159035, upload-time = "2025-10-14T04:41:38.368Z" }, + { url = "https://files.pythonhosted.org/packages/67/ff/f6b948ca32e4f2a4576aa129d8bed61f2e0543bf9f5f2b7fc3758ed005c9/charset_normalizer-3.4.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ecaae4149d99b1c9e7b88bb03e3221956f68fd6d50be2ef061b2381b61d20838", size = 152542, upload-time = "2025-10-14T04:41:39.862Z" }, + { url = "https://files.pythonhosted.org/packages/16/85/276033dcbcc369eb176594de22728541a925b2632f9716428c851b149e83/charset_normalizer-3.4.4-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:cb6254dc36b47a990e59e1068afacdcd02958bdcce30bb50cc1700a8b9d624a6", size = 149524, upload-time = "2025-10-14T04:41:41.319Z" }, + { url = "https://files.pythonhosted.org/packages/9e/f2/6a2a1f722b6aba37050e626530a46a68f74e63683947a8acff92569f979a/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c8ae8a0f02f57a6e61203a31428fa1d677cbe50c93622b4149d5c0f319c1d19e", size = 150395, upload-time = "2025-10-14T04:41:42.539Z" }, + { url = "https://files.pythonhosted.org/packages/60/bb/2186cb2f2bbaea6338cad15ce23a67f9b0672929744381e28b0592676824/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:47cc91b2f4dd2833fddaedd2893006b0106129d4b94fdb6af1f4ce5a9965577c", size = 143680, upload-time = "2025-10-14T04:41:43.661Z" }, + { url = "https://files.pythonhosted.org/packages/7d/a5/bf6f13b772fbb2a90360eb620d52ed8f796f3c5caee8398c3b2eb7b1c60d/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:82004af6c302b5d3ab2cfc4cc5f29db16123b1a8417f2e25f9066f91d4411090", size = 162045, upload-time = "2025-10-14T04:41:44.821Z" }, + { url = "https://files.pythonhosted.org/packages/df/c5/d1be898bf0dc3ef9030c3825e5d3b83f2c528d207d246cbabe245966808d/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:2b7d8f6c26245217bd2ad053761201e9f9680f8ce52f0fcd8d0755aeae5b2152", size = 149687, upload-time = "2025-10-14T04:41:46.442Z" }, + { url = "https://files.pythonhosted.org/packages/a5/42/90c1f7b9341eef50c8a1cb3f098ac43b0508413f33affd762855f67a410e/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:799a7a5e4fb2d5898c60b640fd4981d6a25f1c11790935a44ce38c54e985f828", size = 160014, upload-time = "2025-10-14T04:41:47.631Z" }, + { url = "https://files.pythonhosted.org/packages/76/be/4d3ee471e8145d12795ab655ece37baed0929462a86e72372fd25859047c/charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:99ae2cffebb06e6c22bdc25801d7b30f503cc87dbd283479e7b606f70aff57ec", size = 154044, upload-time = "2025-10-14T04:41:48.81Z" }, + { url = "https://files.pythonhosted.org/packages/b0/6f/8f7af07237c34a1defe7defc565a9bc1807762f672c0fde711a4b22bf9c0/charset_normalizer-3.4.4-cp314-cp314-win32.whl", hash = "sha256:f9d332f8c2a2fcbffe1378594431458ddbef721c1769d78e2cbc06280d8155f9", size = 99940, upload-time = "2025-10-14T04:41:49.946Z" }, + { url = "https://files.pythonhosted.org/packages/4b/51/8ade005e5ca5b0d80fb4aff72a3775b325bdc3d27408c8113811a7cbe640/charset_normalizer-3.4.4-cp314-cp314-win_amd64.whl", hash = "sha256:8a6562c3700cce886c5be75ade4a5db4214fda19fede41d9792d100288d8f94c", size = 107104, upload-time = "2025-10-14T04:41:51.051Z" }, + { url = "https://files.pythonhosted.org/packages/da/5f/6b8f83a55bb8278772c5ae54a577f3099025f9ade59d0136ac24a0df4bde/charset_normalizer-3.4.4-cp314-cp314-win_arm64.whl", hash = "sha256:de00632ca48df9daf77a2c65a484531649261ec9f25489917f09e455cb09ddb2", size = 100743, upload-time = "2025-10-14T04:41:52.122Z" }, + { url = "https://files.pythonhosted.org/packages/0a/4c/925909008ed5a988ccbb72dcc897407e5d6d3bd72410d69e051fc0c14647/charset_normalizer-3.4.4-py3-none-any.whl", hash = "sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f", size = 53402, upload-time = "2025-10-14T04:42:31.76Z" }, +] + +[[package]] +name = "idna" +version = "3.11" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" }, +] + +[[package]] +name = "python-xmp-toolkit" +version = "2.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytz" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/39/54/c0b3621568031346ce3306beef18c6cabbd10467cdf17fd257d1a7eb3783/python_xmp_toolkit-2.1.0.tar.gz", hash = "sha256:ca0aa2c60d418dd2558767db59953ab5954fb5b87dc0b50cecd60566b0b4e2da", size = 3570012, upload-time = "2025-11-26T20:34:32.795Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/00/12/a1e57376289c8a949e079b011c8a1272da12317825a5669fa4488af98260/python_xmp_toolkit-2.1.0-py2.py3-none-any.whl", hash = "sha256:62b51dbbf04009030cb0f0871f1ff7e1e30a2ef8d159daf62c3079290f75a0ed", size = 30257, upload-time = "2025-11-26T20:34:30.644Z" }, +] + +[[package]] +name = "pytz" +version = "2025.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f8/bf/abbd3cdfb8fbc7fb3d4d38d320f2441b1e7cbe29be4f23797b4a2b5d8aac/pytz-2025.2.tar.gz", hash = "sha256:360b9e3dbb49a209c21ad61809c7fb453643e048b38924c765813546746e81c3", size = 320884, upload-time = "2025-03-25T02:25:00.538Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/c4/34e93fe5f5429d7570ec1fa436f1986fb1f00c3e0f43a589fe2bbcd22c3f/pytz-2025.2-py2.py3-none-any.whl", hash = "sha256:5ddf76296dd8c44c26eb8f4b6f35488f3ccbf6fbbd7adee0b7262d43f0ec2f00", size = 509225, upload-time = "2025-03-25T02:24:58.468Z" }, +] + +[[package]] +name = "requests" +version = "2.32.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "charset-normalizer" }, + { name = "idna" }, + { name = "urllib3" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c9/74/b3ff8e6c8446842c3f5c837e9c3dfcfe2018ea6ecef224c710c85ef728f4/requests-2.32.5.tar.gz", hash = "sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf", size = 134517, upload-time = "2025-08-18T20:46:02.573Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/db/4254e3eabe8020b458f1a747140d32277ec7a271daf1d235b70dc0b4e6e3/requests-2.32.5-py3-none-any.whl", hash = "sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6", size = 64738, upload-time = "2025-08-18T20:46:00.542Z" }, +] + +[[package]] +name = "reverse-geolocate" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "python-xmp-toolkit" }, + { name = "requests" }, +] + +[package.metadata] +requires-dist = [ + { name = "python-xmp-toolkit", specifier = ">=2.1.0" }, + { name = "requests", specifier = ">=2.32.5" }, +] + +[[package]] +name = "urllib3" +version = "2.6.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c7/24/5f1b3bdffd70275f6661c76461e25f024d5a38a46f04aaca912426a2b1d3/urllib3-2.6.3.tar.gz", hash = "sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed", size = 435556, upload-time = "2026-01-07T16:24:43.925Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/39/08/aaaad47bc4e9dc8c725e68f9d04865dbcb2052843ff09c97b08904852d84/urllib3-2.6.3-py3-none-any.whl", hash = "sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4", size = 131584, upload-time = "2026-01-07T16:24:42.685Z" }, +]