rate-client 0.1.0__py3-none-any.whl
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.
- rate_client/__init__.py +2 -0
- rate_client/cli.py +32 -0
- rate_client/error.py +11 -0
- rate_client/fares.py +14 -0
- rate_client/utils.py +16 -0
- rate_client-0.1.0.dist-info/METADATA +25 -0
- rate_client-0.1.0.dist-info/RECORD +9 -0
- rate_client-0.1.0.dist-info/WHEEL +4 -0
- rate_client-0.1.0.dist-info/entry_points.txt +3 -0
rate_client/__init__.py
ADDED
rate_client/cli.py
ADDED
|
@@ -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()
|
rate_client/error.py
ADDED
rate_client/fares.py
ADDED
|
@@ -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)
|
rate_client/utils.py
ADDED
|
@@ -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
|
|
@@ -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,9 @@
|
|
|
1
|
+
rate_client/__init__.py,sha256=KzJLFD1vjuUgdK1rqnfKidhF1IRsG3nmnSMsOw3e2QY,57
|
|
2
|
+
rate_client/cli.py,sha256=GStZ0KG0gsi30ZosVZ1w5oFzzSgE_A_pOQfd8LGKZcM,1087
|
|
3
|
+
rate_client/error.py,sha256=7_etpLg5aBfclxCKzu-DqN6cFhs5rub612GUl8gpqAk,190
|
|
4
|
+
rate_client/fares.py,sha256=vyW38cIcVu0VsruaXwSuqKoySfT9P4VbnEzNZXb2Lak,498
|
|
5
|
+
rate_client/utils.py,sha256=SVl1BuETN7iLAOtkF4XVf06eMq7P5F49zOP5v7bIzXI,646
|
|
6
|
+
rate_client-0.1.0.dist-info/WHEEL,sha256=CoDSoyhtC_eO_tlxRYzsTraPv1fPJRXFx91k6ISeAvA,81
|
|
7
|
+
rate_client-0.1.0.dist-info/entry_points.txt,sha256=99g_dEL_wQyFYRDpDiAoIeQCmN2sUc9rw91gnTAb2EQ,52
|
|
8
|
+
rate_client-0.1.0.dist-info/METADATA,sha256=SbLeVpzTfruH89f4K9IrYyRnb0RXu0rKGGWop7FK7DA,483
|
|
9
|
+
rate_client-0.1.0.dist-info/RECORD,,
|