gallery.py: Python-3-compatible integer division
authorW. Trevor King <wking@tremily.us>
Mon, 9 Dec 2013 05:11:02 +0000 (21:11 -0800)
committerW. Trevor King <wking@tremily.us>
Mon, 9 Dec 2013 05:11:02 +0000 (21:11 -0800)
Avoid:

  Traceback (most recent call last):
    …
    File "/.../gallery.py", line 610, in page
      self._page(path=file_path, stream=stream)
    File "/.../gallery.py", line 719, in _page
      gallery_page = '{}/?pp={:d}'.format(gallery, page + 1)
  ValueError: Unknown format code 'd' for object of type 'float'

posts/gallery/gallery.py

index c938c8a5775b29ba6f78b93763754ca9e4002358..5799641f09ec449737aebb17409fd0829166badc 100755 (executable)
@@ -691,7 +691,7 @@ class CGIGalleryServer (object):
         images = list(self._images(gallery))
         images_per_page = self._rows * self._columns
         i = images.index(path)
-        page = i / images_per_page
+        page = i // images_per_page
         gallery_page = '{}/?pp={:d}'.format(gallery, page + 1)
         prev_page = self._image_page(images[i - 1])
         next_page = self._image_page(images[(i + 1) % len(images)])