-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from dateutil.parser import parse as iso_parse | ||
import logging | ||
log = logging.getLogger(__name__) | ||
|
||
def key_parser(key, prefix): | ||
""" | ||
Given a key, parse out the prefix and parse the iso date into a datetime | ||
object (for comparison). | ||
""" | ||
try: | ||
key_prefix, iso_date = key.split('|') | ||
except: | ||
# some weird key that was not put there by easydump | ||
log.debug("found weird key: %s" % key) | ||
return None | ||
|
||
if prefix == key_prefix: | ||
return iso_parse(iso_date) | ||
else: | ||
# a dump from another manifest | ||
log.debug("wrong prefix: %s" % key) | ||
return None |