From 39ec91620b3102c6aa9765af1f554f213e05148b Mon Sep 17 00:00:00 2001 From: Kumi Date: Tue, 28 Mar 2023 10:39:48 +0000 Subject: [PATCH] Make it installable Fix missing LICENSE content --- LICENSE | 19 ++++++++++++++ pyproject.toml | 26 ++++++++++++++++++++ src/trackingmore/__init__.py | 0 src/trackingmore/classes/__init__.py | 0 {classes => src/trackingmore/classes}/api.py | 0 tracker.py => src/trackingmore/tracker.py | 17 +++++++++---- 6 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 pyproject.toml create mode 100644 src/trackingmore/__init__.py create mode 100644 src/trackingmore/classes/__init__.py rename {classes => src/trackingmore/classes}/api.py (100%) rename tracker.py => src/trackingmore/tracker.py (80%) diff --git a/LICENSE b/LICENSE index e69de29..29ea8ca 100644 --- a/LICENSE +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2023 Kumi Mitterer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b81ccc2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "trackingmore" +version = "0.1.0" +authors = [ + { name="Kumi Mitterer", email="trackingmore-api-tool@kumi.email" }, +] +description = "API wrapper for the TrackingMore API (v3)" +readme = "README.md" +license = { file="LICENSE" } +requires-python = ">=3.8" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://kumig.it/kumitterer/trackingmore-api-tool" +"Bug Tracker" = "https://kumig.it/kumitterer/trackingmore-api-tool/issues" + +[project.scripts] +trackingmore = "trackingmore.tracker:main" diff --git a/src/trackingmore/__init__.py b/src/trackingmore/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/trackingmore/classes/__init__.py b/src/trackingmore/classes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/classes/api.py b/src/trackingmore/classes/api.py similarity index 100% rename from classes/api.py rename to src/trackingmore/classes/api.py diff --git a/tracker.py b/src/trackingmore/tracker.py similarity index 80% rename from tracker.py rename to src/trackingmore/tracker.py index 8a3132e..c3d550d 100644 --- a/tracker.py +++ b/src/trackingmore/tracker.py @@ -1,12 +1,9 @@ -from classes.api import TrackingMore +from trackingmore.classes.api import TrackingMore from configparser import ConfigParser from argparse import ArgumentParser -if __name__ == "__main__": - config = ConfigParser() - config.read('settings.ini') - +def main(): parser = ArgumentParser() parser.add_argument('tracking_number', nargs="?", help='Tracking number to track') @@ -14,9 +11,13 @@ if __name__ == "__main__": parser.add_argument('--detect-carrier', '-d', action='store_true', help='Detect and output carrier from tracking number') parser.add_argument('--list-carriers', '-l', action='store_true', help='List carriers') parser.add_argument('--key', '-k', help='TrackingMore API Key (overrides config)') + parser.add_argument('--config-file', '-f', help='Config file (default: settings.ini in working directory)', default='settings.ini') args = parser.parse_args() + config = ConfigParser() + config.read(args.config_file) + if (args.tracking_number or args.carrier) and args.list_carriers: print("Cannot specify both tracking number and --list-carriers/-l") exit(1) @@ -36,3 +37,9 @@ if __name__ == "__main__": else: print(api.track_shipment(args.tracking_number, args.carrier)) + + else: + print("No tracking number specified - use --help for usage") + +if __name__ == '__main__': + main() \ No newline at end of file