-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added new datetime_from_dir() function to parse BackInTime folder names #50
base: master
Are you sure you want to change the base?
Conversation
I didn't realize that committing to my branch after initiating the PR would add these changes too. Hence the force-push in order to reset to previous commit. |
returns a datetime object if the format could be parsed. | ||
raises ValueError if not. | ||
""" | ||
if type(d).__name__ == 'PosixPath': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rather:
if isinstance(d, Path):
returns a datetime object if the format could be parsed. | ||
raises ValueError if not. | ||
""" | ||
if type(d).__name__ == 'PosixPath': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rather:
if isinstance(d, Path):
""" | ||
if type(d).__name__ == 'PosixPath': | ||
s = d.name | ||
elif type(d) == str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar here.
""" | ||
if type(d).__name__ == 'PosixPath': | ||
s = d.name | ||
elif type(d) == str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar here.
# get rid of trailing -??? numbers that BackInTime adds | ||
s = s[:-p].strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is always "dash digits" you could also use s.rsplit('-', 1)
.
# get rid of trailing -??? numbers that BackInTime adds | ||
s = s[:-p].strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is always "dash digits" you could also use s.rsplit('-', 1)
.
dt = datetime.strptime(s, ts_format) | ||
# adjust time zone offset to get UTC | ||
tz = int(time.strftime('%z')[:-2]) | ||
ut = dt - timedelta(hours=tz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe reading the docs again gives a better way here. :-)
dt = datetime.strptime(s, ts_format) | ||
# adjust time zone offset to get UTC | ||
tz = int(time.strftime('%z')[:-2]) | ||
ut = dt - timedelta(hours=tz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe reading the docs again gives a better way here. :-)
Back In Time uses rsync+hardlinks, but (on my machine at least) the timestamps get messed up sometimes, so I needed a more reliable way of getting the original timestamp from the directory name (e.g.
20200428-170001-777
). It's mostly just adjusting thestrptime
format, as well as converting the time to UTC (since the folder times are in local time).To actually use this, a small change in
rsynchl.py
will be required.