mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-16 10:22:07 +08:00
811fd5086f
version: dragonpilot v2023.02.08 release for EON/C2
date: 2023-02-08T05:01:31
dp-dev(priv2) beta2 commit: f770882b7f
21 lines
714 B
Python
21 lines
714 B
Python
import datetime
|
|
|
|
TIME_FMT = "%Y-%m-%d--%H-%M-%S"
|
|
|
|
# regex patterns
|
|
class RE:
|
|
DONGLE_ID = r'(?P<dongle_id>[a-z0-9]{16})'
|
|
TIMESTAMP = r'(?P<timestamp>[0-9]{4}-[0-9]{2}-[0-9]{2}--[0-9]{2}-[0-9]{2}-[0-9]{2})'
|
|
ROUTE_NAME = r'{}[|_/]{}'.format(DONGLE_ID, TIMESTAMP)
|
|
SEGMENT_NAME = r'{}(?:--|/)(?P<segment_num>[0-9]+)'.format(ROUTE_NAME)
|
|
BOOTLOG_NAME = ROUTE_NAME
|
|
|
|
EXPLORER_FILE = r'^(?P<segment_name>{})--(?P<file_name>[a-z]+\.[a-z0-9]+)$'.format(SEGMENT_NAME)
|
|
OP_SEGMENT_DIR = r'^(?P<segment_name>{})$'.format(SEGMENT_NAME)
|
|
|
|
def timestamp_to_datetime(t: str) -> datetime.datetime:
|
|
"""
|
|
Convert an openpilot route timestamp to a python datetime
|
|
"""
|
|
return datetime.datetime.strptime(t, TIME_FMT)
|