From 64c3dbec35bb9d3400fe251906cd3532d561df98 Mon Sep 17 00:00:00 2001 From: Jasper Date: Tue, 26 Sep 2023 18:21:42 +0200 Subject: [PATCH] Add unit conversion code example --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 5ead32c..20ea09b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ You will no longer need an exspensive API for danish license plate lookups with - [Asynchronous Get](#asynchronous-get) - [Validating License Plates](#validating-license-plates) - [Models to dict/json](#models-to-dictjson) + - [Unit Conversion](#unit-conversion) - [Contributing](#contributing) - [Issue we can't do anything about](#issue-we-cant-do-anything-about) - [License Plates for testing](#license-plates-for-testing) @@ -114,6 +115,21 @@ vehicle.model_dump() dict(vehicle) ``` +### Unit Conversion + +The default units used in this library is metric. A [Converter](/dmr/converter.py) class has been implemented, to make it easier to convert units to imperial and the other way around. + +```python +from dmr import Converter + +range_in_km = 100 + +range_in_miles = Converter.km_to_miles(range_in_km) + +print("Range in miles:", range_in_miles) +# Range in miles: 62.14 +``` + ## Contributing I would be more than happy if those who know how to make pull requests, contribute with code! Sometimes XPaths may not match with the ones on the [danish vehicle registry](https://motorregister.skat.dk/dmr-kerne/koeretoejdetaljer/visKoeretoej 'motorregister.skat.dk'), if that's the case, then you can either make a pull request with XPath fixes or make an issue saying that the XPaths are wrong, then I will fix it. XPaths are kept in [this file](https://github.com/j4asper/dmr.py/blob/main/dmr/utils/xpaths.py).