Skip to content

Commit

Permalink
Fix for new german headers
Browse files Browse the repository at this point in the history
  • Loading branch information
PTST committed Nov 21, 2024
1 parent 317ba02 commit 0a4976a
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 246 deletions.
36 changes: 18 additions & 18 deletions LibreView/LibreView.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from typing import Dict, List
from uuid import UUID
from LibreView.models import Connection
from LibreView.utils import API


class LibreView:
client: API

connections_dict: Dict[UUID, Connection]

def __init__(self, username: str, password: str):
self.client = API(username, password)

def get_connections(self) -> List[Connection]:
cons = self.client.get_connections()
self.connections_dict = {x.id: x for x in cons}
return cons
from typing import Dict, List, Optional
from uuid import UUID
from LibreView.models import Connection
from LibreView.utils import API


class LibreView:
client: API

connections_dict: Dict[UUID, Connection]

def __init__(self, username: str, password: str, region: Optional[str] = None):
self.client = API(username, password, region)

def get_connections(self) -> List[Connection]:
cons = self.client.get_connections()
self.connections_dict = {x.id: x for x in cons}
return cons
44 changes: 22 additions & 22 deletions LibreView/models/Connection.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from dataclasses import dataclass
from uuid import UUID
from dataclass_wizard import JSONWizard

# from LibreView.models import Sensor, GlucoseMeasurement
from LibreView.models.GlucoseMeasurement import GlucoseMeasurement
from LibreView.models.Sensor import Sensor


@dataclass
class Connection(JSONWizard):
id: UUID
patient_id: UUID
country: str
status: int
first_name: str
last_name: str
target_low: int
target_high: int
uom: int
sensor: Sensor
glucose_measurement: GlucoseMeasurement
from dataclasses import dataclass
from uuid import UUID
from dataclass_wizard import JSONWizard

# from LibreView.models import Sensor, GlucoseMeasurement
from LibreView.models.GlucoseMeasurement import GlucoseMeasurement
from LibreView.models.Sensor import Sensor


@dataclass
class Connection(JSONWizard):
id: UUID
patient_id: UUID
country: str
status: int
first_name: str
last_name: str
target_low: int
target_high: int
uom: int
sensor: Sensor
glucose_measurement: GlucoseMeasurement
24 changes: 12 additions & 12 deletions LibreView/models/Device.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from dataclasses import dataclass
from uuid import UUID
from dataclass_wizard import JSONWizard


@dataclass
class Device(JSONWizard):
id: UUID
nickname: str
sn: UUID
type: int
upload_date: int
from dataclasses import dataclass
from uuid import UUID
from dataclass_wizard import JSONWizard


@dataclass
class Device(JSONWizard):
id: UUID
nickname: str
sn: UUID
type: int
upload_date: int
64 changes: 32 additions & 32 deletions LibreView/models/GlucoseMeasurement.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
from dataclasses import dataclass
from datetime import datetime
from dataclass_wizard import JSONWizard, json_field


@dataclass
class GlucoseMeasurement(JSONWizard):
type: int
value_in_mg_per_dl: int
trend_arrow: int
measurement_color: int
glucose_units: int
value: float
is_high: bool
is_low: bool
_factory_timestamp: str = json_field("FactoryTimestamp") # type: ignore
_timestamp: str = json_field("Timestamp") # type: ignore
trend_message: str | None = None

@property
def factory_timestamp(self) -> datetime:
return self.parse_dt(self._factory_timestamp)

@property
def timestamp(self) -> datetime:
return self.parse_dt(self._timestamp)

def parse_dt(self, val: str) -> datetime:
splitted = val.split("/")
splitted[0] = splitted[0].zfill(2)
splitted[1] = splitted[1].zfill(2)
return datetime.strptime("/".join(splitted), "%m/%d/%Y %I:%M:%S %p")
from dataclasses import dataclass
from datetime import datetime
from dataclass_wizard import JSONWizard, json_field


@dataclass
class GlucoseMeasurement(JSONWizard):
type: int
value_in_mg_per_dl: int
trend_arrow: int
measurement_color: int
glucose_units: int
value: float
is_high: bool
is_low: bool
_factory_timestamp: str = json_field("FactoryTimestamp") # type: ignore
_timestamp: str = json_field("Timestamp") # type: ignore
trend_message: str | None = None

@property
def factory_timestamp(self) -> datetime:
return self.parse_dt(self._factory_timestamp)

@property
def timestamp(self) -> datetime:
return self.parse_dt(self._timestamp)

def parse_dt(self, val: str) -> datetime:
splitted = val.split("/")
splitted[0] = splitted[0].zfill(2)
splitted[1] = splitted[1].zfill(2)
return datetime.strptime("/".join(splitted), "%m/%d/%Y %I:%M:%S %p")
32 changes: 16 additions & 16 deletions LibreView/models/Practice.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from dataclasses import dataclass
from uuid import UUID
from dataclass_wizard import JSONWizard


@dataclass
class Practice(JSONWizard):
id: UUID
practice_id: str
name: str
address1: str
city: str
state: str
zip: str
phone_number: str
address2: str | None = None
from dataclasses import dataclass
from uuid import UUID
from dataclass_wizard import JSONWizard


@dataclass
class Practice(JSONWizard):
id: UUID
practice_id: str
name: str
address1: str
city: str
state: str
zip: str
phone_number: str
address2: str | None = None
26 changes: 13 additions & 13 deletions LibreView/models/Sensor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from dataclasses import dataclass
from dataclass_wizard import JSONWizard


@dataclass
class Sensor(JSONWizard):
device_id: str
sn: str
a: int
w: int
pt: int
s: bool
lj: bool
from dataclasses import dataclass
from dataclass_wizard import JSONWizard


@dataclass
class Sensor(JSONWizard):
device_id: str
sn: str
a: int
w: int
pt: int
s: bool
lj: bool
52 changes: 26 additions & 26 deletions LibreView/models/User.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
from dataclasses import dataclass
from typing import Any, List, Dict
from uuid import UUID
from dataclass_wizard import JSONWizard
from LibreView.models import Device, Practice


@dataclass
class User(JSONWizard):
id: UUID
first_name: str
last_name: str
email: str
country: str
ui_language: str
communication_language: str
account_type: str
uom: int
date_format: int
time_format: int
email_day: List[int]
created: int
last_login: int
date_of_birth: int
practices: Dict[UUID, Practice]
devices: Dict[str, Device]
from dataclasses import dataclass
from typing import Any, List, Dict
from uuid import UUID
from dataclass_wizard import JSONWizard
from LibreView.models import Device, Practice


@dataclass
class User(JSONWizard):
id: UUID
first_name: str
last_name: str
email: str
country: str
ui_language: str
communication_language: str
account_type: str
uom: int
date_format: int
time_format: int
email_day: List[int]
created: int
last_login: int
date_of_birth: int
practices: Dict[UUID, Practice]
devices: Dict[str, Device]
12 changes: 6 additions & 6 deletions LibreView/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from LibreView.models.Connection import Connection
from LibreView.models.Device import Device
from LibreView.models.GlucoseMeasurement import GlucoseMeasurement
from LibreView.models.Practice import Practice
from LibreView.models.Sensor import Sensor
from LibreView.models.User import User
from LibreView.models.Connection import Connection
from LibreView.models.Device import Device
from LibreView.models.GlucoseMeasurement import GlucoseMeasurement
from LibreView.models.Practice import Practice
from LibreView.models.Sensor import Sensor
from LibreView.models.User import User
Loading

0 comments on commit 0a4976a

Please sign in to comment.