Skip to content

Commit

Permalink
duuurr forgot to add utils to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
priestc committed Apr 10, 2012
1 parent bf7284d commit a904e26
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions easydump/utils.py
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

0 comments on commit a904e26

Please sign in to comment.