GEPS008: Moved Sort module

svn: r19801
This commit is contained in:
Nick Hall 2012-06-08 20:58:40 +00:00
parent a2af7d66b3
commit d13b4e585d
10 changed files with 22 additions and 23 deletions

View File

@ -6,7 +6,6 @@
#src #src
src/AutoComp.py src/AutoComp.py
src/ImgManip.py src/ImgManip.py
src/Sort.py
src/TreeTips.py src/TreeTips.py
# cli # cli
@ -17,6 +16,7 @@ src/cli/user.py
src/gen/errors.py src/gen/errors.py
src/gen/__init__.py src/gen/__init__.py
src/gen/recentfiles.py src/gen/recentfiles.py
src/gen/sort.py
src/gen/soundex.py src/gen/soundex.py
src/gen/updatecallback.py src/gen/updatecallback.py
src/gen/user.py src/gen/user.py

View File

@ -21,7 +21,6 @@ gdir_PYTHON = \
ImgManip.py\ ImgManip.py\
LdsUtils.py \ LdsUtils.py \
MacTransUtils.py\ MacTransUtils.py\
Sort.py\
Spell.py\ Spell.py\
ToolTips.py\ ToolTips.py\
TransUtils.py\ TransUtils.py\

View File

@ -27,6 +27,7 @@ pkgpython_PYTHON = \
ggettext.py \ ggettext.py \
recentfiles.py \ recentfiles.py \
relationship.py \ relationship.py \
sort.py \
soundex.py \ soundex.py \
updatecallback.py \ updatecallback.py \
user.py user.py

View File

@ -45,7 +45,7 @@ from gen.plug.report import MenuReportOptions
pt2cm = ReportUtils.pt2cm pt2cm = ReportUtils.pt2cm
from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
FONT_SANS_SERIF, DASHED, PARA_ALIGN_CENTER) FONT_SANS_SERIF, DASHED, PARA_ALIGN_CENTER)
import Sort from gen.sort import Sort
from gen.display.name import displayer as name_displayer from gen.display.name import displayer as name_displayer
import config import config
from gen.utils import get_birth_or_fallback, get_death_or_fallback from gen.utils import get_birth_or_fallback, get_death_or_fallback
@ -99,7 +99,7 @@ class TimeLine(Report):
self.filter = menu.get_option_by_name('filter').get_filter() self.filter = menu.get_option_by_name('filter').get_filter()
sort_func_num = menu.get_option_by_name('sortby').get_value() sort_func_num = menu.get_option_by_name('sortby').get_value()
sort_functions = _get_sort_functions(Sort.Sort(database)) sort_functions = _get_sort_functions(Sort(database))
self.sort_name = sort_functions[sort_func_num][0] self.sort_name = sort_functions[sort_func_num][0]
self.sort_func = sort_functions[sort_func_num][1] self.sort_func = sort_functions[sort_func_num][1]
self.calendar = config.get('preferences.calendar-format-report') self.calendar = config.get('preferences.calendar-format-report')
@ -381,7 +381,7 @@ class TimeLineOptions(MenuReportOptions):
sortby = EnumeratedListOption(_('Sort by'), 0 ) sortby = EnumeratedListOption(_('Sort by'), 0 )
idx = 0 idx = 0
for item in _get_sort_functions(Sort.Sort(self.__db)): for item in _get_sort_functions(Sort(self.__db)):
sortby.add_item(idx,item[0]) sortby.add_item(idx,item[0])
idx += 1 idx += 1
sortby.set_help( _("Sorting method to use")) sortby.set_help( _("Sorting method to use"))

View File

@ -52,7 +52,7 @@ from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils from gen.plug.report import utils as ReportUtils
from gen.plug.report import MenuReportOptions from gen.plug.report import MenuReportOptions
import gen.datehandler import gen.datehandler
import Sort from gen.sort import Sort
from gen.utils import (get_birth_or_fallback, get_death_or_fallback, from gen.utils import (get_birth_or_fallback, get_death_or_fallback,
get_marriage_or_fallback, get_divorce_or_fallback) get_marriage_or_fallback, get_divorce_or_fallback)
@ -333,7 +333,7 @@ class DescendantReport(Report):
if (self.center_person == None) : if (self.center_person == None) :
raise ReportError(_("Person %s is not in the Database") % pid ) raise ReportError(_("Person %s is not in the Database") % pid )
sort = Sort.Sort(self.database) sort = Sort(self.database)
self.by_birthdate = sort.by_birthdate self.by_birthdate = sort.by_birthdate
#Initialize the Printinfo class #Initialize the Printinfo class

View File

@ -45,7 +45,7 @@ from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, TableStyle,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER) INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
from gen.proxy import PrivateProxyDb from gen.proxy import PrivateProxyDb
import gen.datehandler import gen.datehandler
import Sort from gen.sort import Sort
from gen.display.name import displayer as _nd from gen.display.name import displayer as _nd
class PlaceReport(Report): class PlaceReport(Report):
@ -87,7 +87,7 @@ class PlaceReport(Report):
filter_option = menu.get_option_by_name('filter') filter_option = menu.get_option_by_name('filter')
self.filter = filter_option.get_filter() self.filter = filter_option.get_filter()
self.sort = Sort.Sort(self.database) self.sort = Sort(self.database)
if self.filter.get_name() != '': if self.filter.get_name() != '':
# Use the selected filter to provide a list of place handles # Use the selected filter to provide a list of place handles

View File

@ -46,7 +46,7 @@ import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gen.filters import GenericFilter, rules from gen.filters import GenericFilter, rules
from gui.filters import build_filter_model from gui.filters import build_filter_model
import Sort from gen.sort import Sort
import Utils import Utils
from gui.utils import ProgressMeter from gui.utils import ProgressMeter
from docgen import ODSTab from docgen import ODSTab
@ -243,7 +243,7 @@ class DisplayChart(ManagedWindow):
_('Event Comparison Results')) _('Event Comparison Results'))
self.eventlist = self.topDialog.get_object('treeview') self.eventlist = self.topDialog.get_object('treeview')
self.sort = Sort.Sort(self.db) self.sort = Sort(self.db)
self.my_list.sort(self.sort.by_last_name) self.my_list.sort(self.sort.by_last_name)
self.event_titles = self.make_event_titles() self.event_titles = self.make_event_titles()

View File

@ -35,8 +35,7 @@ from gen.ggettext import gettext as _
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import Sort from gen.sort import Sort
from gen.db import DbTxn from gen.db import DbTxn
from gui.plug import MenuToolOptions, PluginWindows from gui.plug import MenuToolOptions, PluginWindows
from gen.plug.report import utils as ReportUtils from gen.plug.report import utils as ReportUtils
@ -92,10 +91,10 @@ class SortEvents(PluginWindows.ToolManagedWindowBatch):
sort_func_num = menu.get_option_by_name('sort_by').get_value() sort_func_num = menu.get_option_by_name('sort_by').get_value()
self.sort_desc = menu.get_option_by_name('sort_desc').get_value() self.sort_desc = menu.get_option_by_name('sort_desc').get_value()
self.fam_events = menu.get_option_by_name('family_events').get_value() self.fam_events = menu.get_option_by_name('family_events').get_value()
sort_functions = _get_sort_functions(Sort.Sort(self.db)) sort_functions = _get_sort_functions(Sort(self.db))
self.sort_name = sort_functions[sort_func_num][0] self.sort_name = sort_functions[sort_func_num][0]
self.sort_func = sort_functions[sort_func_num][1] self.sort_func = sort_functions[sort_func_num][1]
self.sort = Sort.Sort(self.db) self.sort = Sort(self.db)
with DbTxn(_("Sort event changes"), self.db, batch=True) as trans: with DbTxn(_("Sort event changes"), self.db, batch=True) as trans:
self.db.disable_signals() self.db.disable_signals()
family_handles = self.sort_person_events(trans) family_handles = self.sort_person_events(trans)
@ -179,7 +178,7 @@ class SortEventOptions(MenuToolOptions):
sort_by = EnumeratedListOption(_('Sort by'), 0 ) sort_by = EnumeratedListOption(_('Sort by'), 0 )
idx = 0 idx = 0
for item in _get_sort_functions(Sort.Sort(self.__db)): for item in _get_sort_functions(Sort(self.__db)):
sort_by.add_item(idx, item[0]) sort_by.add_item(idx, item[0])
idx += 1 idx += 1
sort_by.set_help( _("Sorting method to use")) sort_by.set_help( _("Sorting method to use"))

View File

@ -80,7 +80,7 @@ from gen.ggettext import sgettext as _
import gen.lib import gen.lib
from gen.lib import UrlType, date, NoteType, EventRoleType from gen.lib import UrlType, date, NoteType, EventRoleType
import const import const
import Sort from gen.sort import Sort
from gen.plug.menu import PersonOption, NumberOption, StringOption, \ from gen.plug.menu import PersonOption, NumberOption, StringOption, \
BooleanOption, EnumeratedListOption, FilterOption, \ BooleanOption, EnumeratedListOption, FilterOption, \
NoteOption, MediaOption, DestinationOption NoteOption, MediaOption, DestinationOption
@ -3374,7 +3374,7 @@ class PlaceListPage(BasePage):
[_("Longitude"), "ColumnLongitude"] ] [_("Longitude"), "ColumnLongitude"] ]
) )
sort = Sort.Sort(self.dbase_) sort = Sort(self.dbase_)
handle_list = sorted(place_handles, key = sort.by_place_title_key) handle_list = sorted(place_handles, key = sort.by_place_title_key)
last_letter = '' last_letter = ''
@ -4701,7 +4701,7 @@ class SourcePage(BasePage):
# Citation Referents has Media Objects... # Citation Referents has Media Objects...
if (self.create_media and media_list): if (self.create_media and media_list):
sort = Sort.Sort(self.dbase_) sort = Sort(self.dbase_)
media_list = sorted(media_list, key = sort.by_media_title_key) media_list = sorted(media_list, key = sort.by_media_title_key)
list2 = Html("li") list2 = Html("li")
@ -4894,7 +4894,7 @@ class MediaListPage(BasePage):
table += tbody table += tbody
index = 1 index = 1
sort = Sort.Sort(self.dbase_) sort = Sort(self.dbase_)
mlist = sorted(self.report.photo_list, key = sort.by_media_title_key) mlist = sorted(self.report.photo_list, key = sort.by_media_title_key)
for media_handle in mlist: for media_handle in mlist:
@ -4946,7 +4946,7 @@ class ThumbnailPreviewPage(BasePage):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
self.create_thumbs_only = report.options['create_thumbs_only'] self.create_thumbs_only = report.options['create_thumbs_only']
sort = Sort.Sort(self.dbase_) sort = Sort(self.dbase_)
self.photo_keys = sorted(self.report.photo_list, key =sort.by_media_title_key) self.photo_keys = sorted(self.report.photo_list, key =sort.by_media_title_key)
if not self.photo_keys: if not self.photo_keys:
return return
@ -7330,7 +7330,7 @@ class NavWebReport(Report):
prev = None prev = None
total = len(self.photo_list) total = len(self.photo_list)
sort = Sort.Sort(self.database) sort = Sort(self.database)
photo_keys = sorted(self.photo_list, key =sort.by_media_title_key) photo_keys = sorted(self.photo_list, key =sort.by_media_title_key)
index = 1 index = 1
@ -8218,7 +8218,7 @@ class NavWebOptions(MenuReportOptions):
else: else:
self.__googleopts.set_available(False) self.__googleopts.set_available(False)
# FIXME. Why do we need our own sorting? Why not use Sort.Sort? # FIXME. Why do we need our own sorting? Why not use Sort?
def sort_people(dbase, handle_list): def sort_people(dbase, handle_list):
""" """
will sort the database people by surname will sort the database people by surname