Skip to content

Commit

Permalink
Bugfix: using --import could fail when finding dated folders using a …
Browse files Browse the repository at this point in the history
…different delimiter

If the destination folder contained any folders prefixed with %Y_%m_%d,
and you used a different date delimiter, an exception would be raised.

  File "exportiphoto.py", line 454, in build_import_album_dirs
    folder_date = datetime.strptime(m.group(1), "%Y" + delim + "%m" +
delim + "%d")
  File "/usr/lib/python2.7/_strptime.py", line 325, in _strptime
    (data_string, format))
ValueError: time data '2003_02_05' does not match format '%Y-%m-%d'
  • Loading branch information
Guillaume Boudreau committed Jan 3, 2012
1 parent b2b92c8 commit 1a1f489
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions exportiphoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,13 @@ def build_import_album_dirs(self, base_dir):
album_names = [album_name]
folder_date = None
# Folder patter: "2011_01_01 New Years Party"
m = re.match(r"([0-9]{4}.[0-9]{2}.[0-9]{2}) ?(.*)", album_name)
m = re.match(r"([0-9]{4}\%s[0-9]{2}\%s[0-9]{2}) ?(.*)" % (delim, delim), album_name)
if m:
folder_date = datetime.strptime(m.group(1), "%Y" + delim + "%m" + delim + "%d")
album_names.append(m.group(2))

# Folder patter: "2011_01_01"
m = re.match(r"^[0-9]{4}.[0-9]{2}.[0-9]{2}$", album_name)
m = re.match(r"^[0-9]{4}\%s[0-9]{2}\%s[0-9]{2}$" % (delim, delim), album_name)
if m:
folder_date = datetime.strptime(album_name, "%Y" + delim + "%m" + delim + "%d")
month, day, year = folder_date.strftime("%b %d %Y").split(" ")
Expand Down

0 comments on commit 1a1f489

Please sign in to comment.