Skip to content

Commit

Permalink
Add unit conversion code example
Browse files Browse the repository at this point in the history
  • Loading branch information
j4asper committed Sep 26, 2023
1 parent 6c6bbc1 commit 64c3dbe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 64c3dbe

Please sign in to comment.