Beispiel #1
0
 def test_format_photo_name(self):
     image = self.TestImage('tttt', 'dddd')
     image.event_name = 'eeee'
     image.event_index = 2
     image.event_index0 = '02'
     image.date = datetime.datetime(2010, 12, 26, 11, 33, 12)
     self.assertEqual(
         u'2010-12-26 aaaa eeee tttt 5 05 2 02',
         iu.format_photo_name(image, 'aaaa', 5, '05', 
                              ('{yyyy}/{mm}-{dd} {album} {event} {title} '
                               '{index} {index0} {event_index} {event_index0}')))
     # Bad template
     self.assertEqual(' badfield ', iu.format_photo_name(image, 'aaaa', 5, '05', '{badfield}'))
 def test_format_photo_name(self):
     image = self.TestImage("tttt", "dddd")
     image.event_name = "eeee"
     image.event_index = 2
     image.event_index0 = "02"
     image.date = datetime.datetime(2010, 12, 26, 11, 33, 12)
     self.assertEqual(
         u"2010-12-26 aaaa eeee tttt 5 05 2 02",
         iu.format_photo_name(
             image,
             "aaaa",
             5,
             "05",
             ("{yyyy}/{mm}-{dd} {album} {event} {title} " "{index} {index0} {event_index} {event_index0}"),
         ),
     )
     # Bad template
     self.assertEqual(" badfield ", iu.format_photo_name(image, "aaaa", 5, "05", "{badfield}"))
Beispiel #3
0
 def make_album_basename(self, photo, index, padded_index, name_template):
     """creates unique file name."""
     base_name = imageutils.format_photo_name(photo, self.iphoto_container.name, index, padded_index, name_template)
     index = 0
     while True:
         album_basename = base_name
         if index > 0:
             album_basename += "_%d" % (index)
         if self.files.get(album_basename) is None:
             return album_basename
         index += 1
     return base_name
Beispiel #4
0
 def make_album_basename(self, photo, index, padded_index, name_template):
     """creates unique file name."""
     base_name = imageutils.format_photo_name(photo,
                                              self.iphoto_container.name,
                                              index, padded_index,
                                              name_template)
     index = 0
     while True:
         album_basename = base_name
         if index > 0:
             album_basename += "_%d" % (index)
         if self.files.get(album_basename) is None:
             return album_basename
         index += 1
     return base_name