Refinements on previous commit; new filter by name 'media by size'
svn: r10190
This commit is contained in:
@ -174,7 +174,7 @@ class SimpleTable:
|
|||||||
# FIXME: add better text representations of these objects
|
# FIXME: add better text representations of these objects
|
||||||
if type(item) in [str, unicode]:
|
if type(item) in [str, unicode]:
|
||||||
retval.append(item)
|
retval.append(item)
|
||||||
elif type(item) in [int, float]:
|
elif type(item) in [int, float, long]:
|
||||||
retval.append(item)
|
retval.append(item)
|
||||||
self.row_sort_val(col, item)
|
self.row_sort_val(col, item)
|
||||||
elif isinstance(item, gen.lib.Person):
|
elif isinstance(item, gen.lib.Person):
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import urllib
|
import urllib
|
||||||
|
import posixpath
|
||||||
|
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from DataViews import register, Gramplet
|
from DataViews import register, Gramplet
|
||||||
@ -550,6 +551,7 @@ class PedigreeGramplet(Gramplet):
|
|||||||
class StatsGramplet(Gramplet):
|
class StatsGramplet(Gramplet):
|
||||||
def init(self):
|
def init(self):
|
||||||
self.set_text(_("No Family Tree loaded."))
|
self.set_text(_("No Family Tree loaded."))
|
||||||
|
self.tooltip = _("Double-click item to see matches")
|
||||||
|
|
||||||
def db_changed(self):
|
def db_changed(self):
|
||||||
self.dbstate.db.connect('person-add', self.update)
|
self.dbstate.db.connect('person-add', self.update)
|
||||||
@ -674,12 +676,14 @@ class StatsGramplet(Gramplet):
|
|||||||
'Filter', 'unique media')
|
'Filter', 'unique media')
|
||||||
self.append_text(" %s" % pobjects)
|
self.append_text(" %s" % pobjects)
|
||||||
self.append_text("\n")
|
self.append_text("\n")
|
||||||
self.append_text("%s: %d %s\n" % (_("Total size of media objects"),
|
|
||||||
bytes,
|
self.link("%s:" % _("Total size of media objects"),
|
||||||
_("bytes")))
|
'Filter', 'media by size')
|
||||||
|
self.append_text(" %d %s" % (bytes, _("bytes")))
|
||||||
|
self.append_text("\n")
|
||||||
self.link("%s:" % _("Missing Media Objects"),
|
self.link("%s:" % _("Missing Media Objects"),
|
||||||
'Filter', 'missing media')
|
'Filter', 'missing media')
|
||||||
self.append_text(" %s\n" % total_photos)
|
self.append_text(" %s\n" % len(notfound))
|
||||||
self.append_text("", scroll_to="begin")
|
self.append_text("", scroll_to="begin")
|
||||||
|
|
||||||
class PythonGramplet(Gramplet):
|
class PythonGramplet(Gramplet):
|
||||||
|
@ -24,13 +24,15 @@ Display filtered data
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from Simple import SimpleAccess, SimpleDoc, SimpleTable
|
from Simple import SimpleAccess, SimpleDoc, SimpleTable
|
||||||
from gettext import gettext as _
|
|
||||||
from PluginUtils import register_quick_report
|
from PluginUtils import register_quick_report
|
||||||
from Utils import media_path_full
|
from Utils import media_path_full
|
||||||
from QuickReports import run_quick_report_by_name_direct
|
from QuickReports import run_quick_report_by_name_direct
|
||||||
from gen.lib import Person
|
from gen.lib import Person
|
||||||
import DateHandler
|
import DateHandler
|
||||||
|
|
||||||
|
import posixpath
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
def run(database, document, filter_name):
|
def run(database, document, filter_name):
|
||||||
"""
|
"""
|
||||||
Loops through the families that the person is a child in, and display
|
Loops through the families that the person is a child in, and display
|
||||||
@ -182,10 +184,22 @@ def run(database, document, filter_name):
|
|||||||
photo = database.get_object_from_handle(photo_id)
|
photo = database.get_object_from_handle(photo_id)
|
||||||
fullname = media_path_full(database, photo.get_path())
|
fullname = media_path_full(database, photo.get_path())
|
||||||
try:
|
try:
|
||||||
bytes = bytes + posixpath.getsize(fullname)
|
posixpath.getsize(fullname)
|
||||||
except:
|
except:
|
||||||
stab.row(fullname)
|
stab.row(fullname)
|
||||||
matches += 1
|
matches += 1
|
||||||
|
elif (filter_name == 'media by size'):
|
||||||
|
stab.columns(_("Media"), _("Size in bytes"))
|
||||||
|
pobjects = database.get_media_object_handles()
|
||||||
|
for photo_id in database.get_media_object_handles():
|
||||||
|
photo = database.get_object_from_handle(photo_id)
|
||||||
|
fullname = media_path_full(database, photo.get_path())
|
||||||
|
try:
|
||||||
|
bytes = posixpath.getsize(fullname)
|
||||||
|
stab.row(fullname, bytes)
|
||||||
|
matches += 1
|
||||||
|
except:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
raise AttributeError, ("invalid filter name: '%s'" % filter_name)
|
raise AttributeError, ("invalid filter name: '%s'" % filter_name)
|
||||||
sdoc.paragraph(_("Filter matched %d records.") % matches)
|
sdoc.paragraph(_("Filter matched %d records.") % matches)
|
||||||
|
Reference in New Issue
Block a user