示例#1
0
 def update_preview(self, chooser, label, image):
     """Display photo thumbnail and geotag data in file chooser."""
     label.set_label(self.strings.preview)
     image.set_from_stock(Gtk.STOCK_FILE, Gtk.IconSize.DIALOG)
     try:
         photo = Photograph(chooser.get_preview_filename(), lambda x: None,
                            300)
         photo.read()
     except IOError:
         return
     image.set_from_pixbuf(photo.thumb)
     label.set_label('\n'.join([photo.short_summary(), photo.maps_link()]))
示例#2
0
 def update_preview(self, chooser, label, image):
     """Display photo thumbnail and geotag data in file chooser."""
     label.set_label(self.strings.preview)
     image.set_from_stock(Gtk.STOCK_FILE, Gtk.IconSize.DIALOG)
     try:
         photo = Photograph(chooser.get_preview_filename(), 300)
         photo.read()
     except IOError:
         return
     image.set_from_pixbuf(photo.thumb)
     label.set_label(
         '\n'.join([photo.short_summary(), photo.maps_link()]))
示例#3
0
    def test_string_functions(self):
        """Ensure that strings print properly."""
        environ['TZ'] = 'America/Edmonton'
        tzset()
        
        # Make a photo with a dummy ChamplainLabel.
        label = Struct()
        label.get_text = lambda: DEMOFILES[5]
        photo = Photograph(label.get_text(), lambda x: None)
        photo.read()
        photo.label = label
        
        photo.latitude  = None
        photo.longitude = None
        self.assertEqual(photo.pretty_coords(), 'Not geotagged')
        photo.latitude  = 10.0
        photo.longitude = 10.0
        self.assertEqual(photo.pretty_coords(), 'N 10.00000, E 10.00000')
        photo.latitude  = -10.0
        photo.longitude = -10.0
        self.assertEqual(photo.pretty_coords(), 'S 10.00000, W 10.00000')
        
        photo.timestamp = None
        self.assertIsNone(photo.pretty_time())
        photo.timestamp = 999999999
        self.assertEqual(photo.pretty_time(), '2001-09-08 07:46:39 PM')
        
        photo.altitude = None
        self.assertIsNone(photo.pretty_elevation())
        photo.altitude = -10.20005
        self.assertEqual(photo.pretty_elevation(), '10.2m below sea level')
        photo.altitude = 600.71
        self.assertEqual(photo.pretty_elevation(), '600.7m above sea level')
        
        self.assertEqual(photo.short_summary(),
"""2001-09-08 07:46:39 PM
S 10.00000, W 10.00000
600.7m above sea level""")
        self.assertEqual(photo.long_summary(),
"""<span size="larger">IMG_2411.JPG</span>
<span style="italic" size="smaller">2001-09-08 07:46:39 PM
S 10.00000, W 10.00000
600.7m above sea level</span>""")
        
        self.assertRegexpMatches(
            get_obj('maps_link').get_label(),
            r'href="http://maps.google.com'
        )
示例#4
0
    def test_string_functions(self):
        """Ensure that strings print properly."""
        environ['TZ'] = 'America/Edmonton'
        tzset()
        
        # Make a photo with a dummy ChamplainLabel.
        label = Struct()
        label.get_text = lambda: DEMOFILES[5]
        photo = Photograph(label.get_text(), lambda x: None)
        photo.read()
        photo.label = label
        
        photo.latitude  = None
        photo.longitude = None
        self.assertEqual(photo.pretty_coords(), 'Not geotagged')
        photo.latitude  = 10.0
        photo.longitude = 10.0
        self.assertEqual(photo.pretty_coords(), 'N 10.00000, E 10.00000')
        photo.latitude  = -10.0
        photo.longitude = -10.0
        self.assertEqual(photo.pretty_coords(), 'S 10.00000, W 10.00000')
        
        photo.timestamp = None
        self.assertIsNone(photo.pretty_time())
        photo.timestamp = 999999999
        self.assertEqual(photo.pretty_time(), '2001-09-08 07:46:39 PM')
        
        photo.altitude = None
        self.assertIsNone(photo.pretty_elevation())
        photo.altitude = -10.20005
        self.assertEqual(photo.pretty_elevation(), '10.2m below sea level')
        photo.altitude = 600.71
        self.assertEqual(photo.pretty_elevation(), '600.7m above sea level')
        
        self.assertEqual(photo.short_summary(),
"""2001-09-08 07:46:39 PM
S 10.00000, W 10.00000
600.7m above sea level""")
        self.assertEqual(photo.long_summary(),
"""<span size="larger">IMG_2411.JPG</span>
<span style="italic" size="smaller">2001-09-08 07:46:39 PM
S 10.00000, W 10.00000
600.7m above sea level</span>""")
        
        self.assertRegexpMatches(
            get_obj('maps_link').get_label(),
            r'href="http://maps.google.com'
        )