rate-client 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.3
2
+ Name: rate-client
3
+ Version: 0.1.0
4
+ Summary: rate estimator application
5
+ Author: Harison
6
+ Author-email: Harison <harisonokonkwo@gmail.com>
7
+ Requires-Python: >=3.14
8
+ Description-Content-Type: text/markdown
9
+
10
+ ### Description
11
+ This application calculates the fare price of uber
12
+
13
+ ### How to Install
14
+ ```bash
15
+ uv pip install fare-client
16
+ # or
17
+ pip install fare-client
18
+ ```
19
+
20
+ ### CLI Usage
21
+ ```bash
22
+ uber-rate --help
23
+
24
+ uber-rate --base=3.5 --distance=120 --rate=0.09
25
+ ```
@@ -0,0 +1,16 @@
1
+ ### Description
2
+ This application calculates the fare price of uber
3
+
4
+ ### How to Install
5
+ ```bash
6
+ uv pip install fare-client
7
+ # or
8
+ pip install fare-client
9
+ ```
10
+
11
+ ### CLI Usage
12
+ ```bash
13
+ uber-rate --help
14
+
15
+ uber-rate --base=3.5 --distance=120 --rate=0.09
16
+ ```
@@ -0,0 +1,17 @@
1
+ [project]
2
+ name = "rate-client"
3
+ version = "0.1.0"
4
+ description = "rate estimator application"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Harison", email = "harisonokonkwo@gmail.com" }
8
+ ]
9
+ requires-python = ">=3.14"
10
+ dependencies = []
11
+
12
+ [project.scripts]
13
+ lyft-rate = "rate_client.cli:main"
14
+
15
+ [build-system]
16
+ requires = ["uv_build>=0.11.28,<0.12.0"]
17
+ build-backend = "uv_build"
@@ -0,0 +1,2 @@
1
+ def main() -> None:
2
+ print("Hello from rate-client!")
@@ -0,0 +1,32 @@
1
+ # classes, functions, exceptions (try/except), argparse
2
+ import argparse
3
+ from rate_client.error import InvalidDistanceError, InvalidRateError, FareEstimatorError
4
+ from rate_client.fares import FareEstimator
5
+ from rate_client.utils import parser, add_tax
6
+
7
+ # make use of args variable
8
+ args = parser()
9
+
10
+
11
+ def main():
12
+ try:
13
+ print(f"Running application version: {args.version}")
14
+ estimator = FareEstimator(base_fare=args.base)
15
+ fare = estimator.estimate(distance=args.distance, rate=args.rate)
16
+ tax = add_tax(fare)
17
+ total_fare = fare + tax
18
+ print(f"Tax is: ${tax}")
19
+ print(f"Total Uber fare including tax is: ${total_fare:.2f}")
20
+ print("Thanks for riding with us ...")
21
+ except InvalidRateError as ex:
22
+ print(f"Rate error: {ex}")
23
+ except InvalidDistanceError as ex:
24
+ print(f"Distance error: {ex}")
25
+ except FareEstimatorError as ex:
26
+ print(f"General fare error: {ex}")
27
+ except Exception as ex:
28
+ print(f"Unexpected error: {ex}")
29
+
30
+
31
+ if __name__ == '__main__':
32
+ main()
@@ -0,0 +1,11 @@
1
+ # custom error class
2
+ class FareEstimatorError(Exception):
3
+ pass
4
+
5
+
6
+ class InvalidRateError(FareEstimatorError):
7
+ pass
8
+
9
+
10
+ class InvalidDistanceError(FareEstimatorError):
11
+ pass
@@ -0,0 +1,14 @@
1
+ from rate_client.error import InvalidRateError, InvalidDistanceError
2
+
3
+
4
+ class FareEstimator:
5
+ def __init__(self, base_fare: float):
6
+ self.base_fare = base_fare
7
+
8
+ def estimate(self, distance, rate):
9
+ # validate our inputs
10
+ if distance <= 0:
11
+ raise InvalidDistanceError("Distance must be greater than zero.")
12
+ if rate <= 0:
13
+ raise InvalidRateError("Rate must be greater than zero.")
14
+ return self.base_fare + (distance * rate)
@@ -0,0 +1,16 @@
1
+ import argparse
2
+
3
+
4
+ def add_tax(fare, tax=0.10):
5
+ return fare * tax
6
+
7
+
8
+ def parser():
9
+ # make use of argparse
10
+ parser = argparse.ArgumentParser(description="Uber Fare Estimator")
11
+ parser.add_argument("--base", "-b", required=False, default=2.5, type=float, help="base fare")
12
+ parser.add_argument("--distance", "-d", required=False, default=100, type=float, help="distance to travel")
13
+ parser.add_argument("--rate", "-r", required=True, type=float, help="fare rate")
14
+ parser.add_argument("--version", "-V", default="0.0.1", type=str, help="display version of our app")
15
+ args = parser.parse_args()
16
+ return args