Skip to content

Commit

Permalink
closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpeckham committed Feb 25, 2024
1 parent 43ed3e1 commit a169e14
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/vin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from vin.constants import VIN_LENGTH
from vin.constants import VIN_MODEL_YEAR_CHARACTERS
from vin.constants import VIN_POSITION_WEIGHTS
from vin.database import decode_vin
from vin.database import decode_vin, get_vpic_version


class DecodingError(Exception):
Expand Down Expand Up @@ -588,8 +588,12 @@ def _decode_vin(self) -> None:
self._body_class = vehicle.get("body_class", "")
self._electrification_level = vehicle.get("electrification_level", "")

@classmethod
def version(cls):
return get_vpic_version()

def __repr__(self) -> str:
return f"VIN({self!s})"

def __str__(self) -> str:
return self._vin
return self.description
15 changes: 15 additions & 0 deletions src/vin/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,18 @@ def get_make_from_wmi(wmi: str) -> str:
where
wmi.code == ?;
"""


def get_vpic_version() -> dict:
return dict(query(sql=GET_VPIC_VERSION_SQL)[0])


GET_VPIC_VERSION_SQL = """
select
version,
released,
effective,
url
from
vpic_version;
"""
Binary file modified src/vin/vehicle.db
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from vin import VIN


def test_version():
version = VIN.version()
assert version["version"] == "3.44"
assert version["released"] == "2024-02-17"

0 comments on commit a169e14

Please sign in to comment.