Fixed SurnameListPage. MediaPage and Exif Tags are still not completed. Working on it with Gerald Britton.
svn: r12832
This commit is contained in:
parent
6294c0b1b3
commit
8a474ab807
@ -63,6 +63,13 @@ from cStringIO import StringIO
|
|||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
from unicodedata import normalize
|
from unicodedata import normalize
|
||||||
|
|
||||||
|
# attempt to import the python exif library?
|
||||||
|
try:
|
||||||
|
import pyexiv2
|
||||||
|
pyexiflib = True
|
||||||
|
except ImportError:
|
||||||
|
pyexiflib = False
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Set up logging
|
# Set up logging
|
||||||
@ -1594,6 +1601,7 @@ class MediaPage(BasePage):
|
|||||||
def __init__(self, report, title, handle, src_list, my_media_list, info):
|
def __init__(self, report, title, handle, src_list, my_media_list, info):
|
||||||
(prev, next, page_number, total_pages) = info
|
(prev, next, page_number, total_pages) = info
|
||||||
db = report.database
|
db = report.database
|
||||||
|
|
||||||
photo = db.get_object_from_handle(handle)
|
photo = db.get_object_from_handle(handle)
|
||||||
# TODO. How do we pass my_media_list down for use in BasePage?
|
# TODO. How do we pass my_media_list down for use in BasePage?
|
||||||
BasePage.__init__(self, report, title, photo.gramps_id)
|
BasePage.__init__(self, report, title, photo.gramps_id)
|
||||||
@ -1626,11 +1634,11 @@ class MediaPage(BasePage):
|
|||||||
if not _name or _name == "":
|
if not _name or _name == "":
|
||||||
_name = _obj.get_primary_name().get_first_name()
|
_name = _obj.get_primary_name().get_first_name()
|
||||||
_linkurl = report.build_url_fname_html(_obj.handle, 'ppl', True)
|
_linkurl = report.build_url_fname_html(_obj.handle, 'ppl', True)
|
||||||
if classname == "Event":
|
elif classname == "Event":
|
||||||
_obj = db.get_event_from_handle( newhandle )
|
_obj = db.get_event_from_handle( newhandle )
|
||||||
_name = _obj.get_description()
|
_name = _obj.get_description()
|
||||||
|
|
||||||
# keep looking if we don't have an object
|
# continue looking through the loop for an object...
|
||||||
if _obj is None:
|
if _obj is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -1677,29 +1685,6 @@ class MediaPage(BasePage):
|
|||||||
note_only = True
|
note_only = True
|
||||||
target_exists = False
|
target_exists = False
|
||||||
|
|
||||||
##################################################
|
|
||||||
# Exif Tags/ Keys #
|
|
||||||
# #
|
|
||||||
# Determine if the python exif lib is installed on the system? #
|
|
||||||
# yes, then use it and determine if the photo has anything written #
|
|
||||||
# inside of it? No, if not?, then do not show it on the media page #
|
|
||||||
#################################################
|
|
||||||
exifimagedata = []
|
|
||||||
try:
|
|
||||||
import pyexiv2
|
|
||||||
pylib = True
|
|
||||||
except ImportError:
|
|
||||||
pylib = False
|
|
||||||
|
|
||||||
if (pylib and mime_type.startswith('image/')):
|
|
||||||
image = pyexiv2.Image('%s' % Utils.media_path_full(db, photo.get_path()))
|
|
||||||
image.readMetadata()
|
|
||||||
|
|
||||||
if image.exifKeys():
|
|
||||||
for x in xrange(len(image.exifKeys())):
|
|
||||||
exifimagedata.append(image.exifKeys()[x])
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
self.copy_thumbnail(handle, photo)
|
self.copy_thumbnail(handle, photo)
|
||||||
self.page_title = photo.get_description()
|
self.page_title = photo.get_description()
|
||||||
mediapage, body = self.write_header("%s - %s" % (_('Media'), self.page_title))
|
mediapage, body = self.write_header("%s - %s" % (_('Media'), self.page_title))
|
||||||
@ -1867,7 +1852,20 @@ class MediaPage(BasePage):
|
|||||||
table += trow
|
table += trow
|
||||||
|
|
||||||
# display image Exif tags/ keys if any?
|
# display image Exif tags/ keys if any?
|
||||||
if ((pylib and mime_type.startswith('image/')) and len(exifimagedata)):
|
if (pyexiflib and mime_type.startswith('image/')):
|
||||||
|
#################################################
|
||||||
|
# Exif Tags/ Keys #
|
||||||
|
# #
|
||||||
|
# Determine if the python exif lib is installed on the system? #
|
||||||
|
# yes, then use it and determine if the photo has anything written #
|
||||||
|
# inside of it? No, if not?, then do not show on the media page #
|
||||||
|
#################################################
|
||||||
|
|
||||||
|
image = pyexiv2.Image('%s' % Utils.media_path_full(db, photo.get_path()))
|
||||||
|
image.readMetadata()
|
||||||
|
|
||||||
|
# exif data does exists
|
||||||
|
if len(image.exifKeys()):
|
||||||
|
|
||||||
# add clearline for increased styling
|
# add clearline for increased styling
|
||||||
mediadetail += fullclear
|
mediadetail += fullclear
|
||||||
@ -1882,13 +1880,15 @@ class MediaPage(BasePage):
|
|||||||
with Html('table', class_='exifdata') as table:
|
with Html('table', class_='exifdata') as table:
|
||||||
exifdetail += table
|
exifdetail += table
|
||||||
|
|
||||||
for xdata in exifimagedata:
|
for line in image.exifKeys():
|
||||||
trow = Html('tr') + (
|
trow = Html('tr') + (
|
||||||
Html('td', xdata, class_='ColumnAttribute', inline=True),
|
Html('td', line, class_='ColumnAttribute', inline=True),
|
||||||
Html('td', image[xdata], class_='ColumnValue', inline=True)
|
Html('td', image[line], class_='ColumnValue', inline=True)
|
||||||
)
|
)
|
||||||
table += trow
|
table += trow
|
||||||
|
|
||||||
|
#################################################
|
||||||
|
|
||||||
# get media notes
|
# get media notes
|
||||||
notes = self.display_note_list(photo.get_note_list())
|
notes = self.display_note_list(photo.get_note_list())
|
||||||
if notes is not None:
|
if notes is not None:
|
||||||
@ -2018,10 +2018,10 @@ class SurnameListPage(BasePage):
|
|||||||
|
|
||||||
if order_by == self.ORDER_BY_NAME:
|
if order_by == self.ORDER_BY_NAME:
|
||||||
of = self.report.create_file(filename)
|
of = self.report.create_file(filename)
|
||||||
surnamelist, body = self.write_header(_('Surnames'))
|
surnamelistpage, body = self.write_header(_('Surnames'))
|
||||||
else:
|
else:
|
||||||
of = self.report.create_file("surnames_count")
|
of = self.report.create_file("surnames_count")
|
||||||
surnamelist, body = self.write_header(_('Surnames by person count'))
|
surnamelistpage, body = self.write_header(_('Surnames by person count'))
|
||||||
|
|
||||||
# begin surnames division
|
# begin surnames division
|
||||||
with Html('div', class_='content', id='surnames') as surnamelist:
|
with Html('div', class_='content', id='surnames') as surnamelist:
|
||||||
@ -2053,19 +2053,19 @@ class SurnameListPage(BasePage):
|
|||||||
thead = Html('thead')
|
thead = Html('thead')
|
||||||
table += thead
|
table += thead
|
||||||
|
|
||||||
|
|
||||||
trow = Html('tr') + (
|
trow = Html('tr') + (
|
||||||
Html('th', _('Letter'), class_='ColumnLetter', inline=True)
|
Html('th', _('Letter'), class_='ColumnLetter', inline=True)
|
||||||
)
|
)
|
||||||
thead += trow
|
thead += trow
|
||||||
|
|
||||||
fname = self.report.surname_fname + self.ext
|
fname = self.report.surname_fname + self.ext
|
||||||
with Html('th', class_='ColumnSurname', inline=True) as tcell:
|
tcell = Html('th', class_='ColumnSurname', inline=True)
|
||||||
trow += tcell
|
trow += tcell
|
||||||
hyper = Html('a', _('Surname'), href=fname)
|
hyper = Html('a', _('Surname'), href=fname)
|
||||||
tcell += hyper
|
tcell += hyper
|
||||||
|
|
||||||
fname = "surnames_count" + self.ext
|
fname = "surnames_count" + self.ext
|
||||||
with Html('th', class_='ColumnQuantity', inline=True) as tcell:
|
tcell = Html('th', class_='ColumnQuantity', inline=True)
|
||||||
trow += tcell
|
trow += tcell
|
||||||
hyper = Html('a', _('Number of People'), href=fname)
|
hyper = Html('a', _('Number of People'), href=fname)
|
||||||
tcell += hyper
|
tcell += hyper
|
||||||
@ -2103,26 +2103,28 @@ class SurnameListPage(BasePage):
|
|||||||
if lang_country == "sv_SE" and ( letter == u'W' or letter == u'V' ):
|
if lang_country == "sv_SE" and ( letter == u'W' or letter == u'V' ):
|
||||||
letter = u'V,W'
|
letter = u'V,W'
|
||||||
|
|
||||||
|
trow = Html('tr')
|
||||||
|
tbody += trow
|
||||||
if letter != last_letter:
|
if letter != last_letter:
|
||||||
last_letter = letter
|
last_letter = letter
|
||||||
with Html('tr', class_='BeginLetter') as trow:
|
trow.attr = ' class="BeginLetter" '
|
||||||
tbody += trow
|
|
||||||
with Html('td', class_='ColumnLetter', inline=True) as tcell:
|
tcell = Html('td', class_='ColumnLetter', inline=True) + (
|
||||||
|
Html('a', last_letter, name=last_letter)
|
||||||
|
)
|
||||||
trow += tcell
|
trow += tcell
|
||||||
tcell += Html('a', last_letter, name=last_letter)
|
|
||||||
with Html('td', class_='ColumnSurname') as tcell:
|
tcell = Html('td', class_='ColumnSurname') + \
|
||||||
|
self.surname_link(name_to_md5(surname), surname)
|
||||||
trow += tcell
|
trow += tcell
|
||||||
tcell += self.surname_link(name_to_md5(surname), surname)
|
|
||||||
elif surname != last_surname:
|
elif surname != last_surname:
|
||||||
with Html('tr') as trow:
|
tcell = Html('td', ' ', class_='ColumnLetter', inline=True)
|
||||||
tbody += trow
|
|
||||||
with Html('td', ' ', class_='ColumnLetter', inline=True) as tcell:
|
|
||||||
trow += tcell
|
trow += tcell
|
||||||
with Html('td', class_='ColumnSurname') as tcell:
|
tcell = Html('td', class_='ColumnSurname') + \
|
||||||
|
self.surname_link(name_to_md5(surname), surname)
|
||||||
trow += tcell
|
trow += tcell
|
||||||
tcell += self.surname_link(name_to_md5(surname), surname)
|
|
||||||
last_surname = surname
|
last_surname = surname
|
||||||
with Html('td', len(data_list), class_='ColumnQuantity', inline=True) as tcell:
|
tcell = Html('td', len(data_list), class_='ColumnQuantity', inline=True)
|
||||||
trow += tcell
|
trow += tcell
|
||||||
|
|
||||||
# create footer section
|
# create footer section
|
||||||
@ -2132,7 +2134,7 @@ class SurnameListPage(BasePage):
|
|||||||
|
|
||||||
# send page out for processing
|
# send page out for processing
|
||||||
# and close the file
|
# and close the file
|
||||||
self.mywriter(surnamelist, of)
|
self.mywriter(surnamelistpage, of)
|
||||||
|
|
||||||
def surname_link(self, fname, name, opt_val=None, up=False):
|
def surname_link(self, fname, name, opt_val=None, up=False):
|
||||||
url = self.report.build_url_fname_html(fname, 'srn', up)
|
url = self.report.build_url_fname_html(fname, 'srn', up)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user