pybgpkitstream 0.1.4__tar.gz → 0.1.5__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pybgpkitstream
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Drop-in replacement for PyBGPStream using BGPKIT
5
5
  Author: JustinLoye
6
6
  Author-email: JustinLoye <jloye@iij.ad.jp>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pybgpkitstream"
3
- version = "0.1.4"
3
+ version = "0.1.5"
4
4
  description = "Drop-in replacement for PyBGPStream using BGPKIT"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -116,9 +116,8 @@ class BGPKITStream:
116
116
  self.urls = {"rib": defaultdict(list), "update": defaultdict(list)}
117
117
  for data_type in self.data_type:
118
118
  items: list[BrokerItem] = self.broker.query(
119
- ts_start=datetime.datetime.fromtimestamp(self.ts_start)
120
- - datetime.timedelta(minutes=1),
121
- ts_end=datetime.datetime.fromtimestamp(self.ts_end),
119
+ ts_start=int(self.ts_start - 60),
120
+ ts_end=int(self.ts_end),
122
121
  collector_id=self.collector_id,
123
122
  data_type=data_type,
124
123
  )
@@ -1,5 +1,5 @@
1
1
  import datetime
2
- from pydantic import BaseModel, Field, DirectoryPath
2
+ from pydantic import BaseModel, Field, DirectoryPath, field_validator
3
3
  from typing import Literal
4
4
  from ipaddress import IPv4Address, IPv6Address
5
5
 
@@ -70,3 +70,13 @@ class BGPStreamConfig(BaseModel):
70
70
  default=datetime.timedelta(hours=2),
71
71
  description="Interval for the fetch/parse cycle (avoid long prefetch time)",
72
72
  )
73
+
74
+ @field_validator("start_time", "end_time")
75
+ @classmethod
76
+ def normalize_to_utc(cls, dt: datetime.datetime) -> datetime.datetime:
77
+ # if naive datetime (not timezone-aware) assume it's UTC
78
+ if dt.tzinfo is None:
79
+ return dt.replace(tzinfo=datetime.timezone.utc)
80
+ # if timezone-aware, convert to utc
81
+ else:
82
+ return dt.astimezone(datetime.timezone.utc)
File without changes