Initial commit: log_entry.py
Added log_entry class stub with method to convert datetime string from borg output to python datatime object.
This commit is contained in:
parent
e749046f04
commit
560e118bf7
29
log_entry.py
Normal file
29
log_entry.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
from datetime import *
|
||||||
|
import re
|
||||||
|
|
||||||
|
class log_entry(object):
|
||||||
|
|
||||||
|
def __init__(self, name, fingerprint, datetime_string, duration,
|
||||||
|
file_count):
|
||||||
|
self.name = name
|
||||||
|
self.fingerprint = fingerprint
|
||||||
|
self.datetime = self.set_datetime(datetime_string)
|
||||||
|
self.duration = duration
|
||||||
|
self.file_count = file_count
|
||||||
|
|
||||||
|
def set_datetime(self, datetime_string):
|
||||||
|
|
||||||
|
date = re.search(r"....-..-..", datetime_string).group()
|
||||||
|
time = re.search(r"..:..:..", datetime_string).group()
|
||||||
|
|
||||||
|
year = int(date[0:4])
|
||||||
|
month = int(date[5:7])
|
||||||
|
day = int(date[8:10])
|
||||||
|
|
||||||
|
hour = int(time[0:2])
|
||||||
|
minute = int(time[3:5])
|
||||||
|
second = int(time[6:8])
|
||||||
|
|
||||||
|
converted_datetime = datetime(year, month, day, hour, minute, second)
|
||||||
|
|
||||||
|
return converted_datetime
|
Loading…
Reference in New Issue
Block a user