Remove remaining to_struct calls
This commit is contained in:
parent
41bcfefd67
commit
fe1fa8b505
@ -63,7 +63,7 @@ class DateHandlerTest(unittest.TestCase):
|
||||
self.assertTrue(test_date.is_equal(new_date),
|
||||
"{} -> {}\n{} -> {}".format(
|
||||
test_date, new_date,
|
||||
test_date.to_struct(), new_date.to_struct()))
|
||||
test_date.__dict__, new_date.__dict__))
|
||||
|
||||
def test_simple(self):
|
||||
|
||||
|
@ -1652,7 +1652,7 @@ class Date:
|
||||
self.__compare(sanity.dateval, value, year_delta)
|
||||
except DateError as err:
|
||||
LOG.debug("Sanity check failed - self: {}, sanity: {}".
|
||||
format(self.to_struct(), sanity.to_struct()))
|
||||
format(self.__dict__, sanity.__dict__))
|
||||
err.date = self
|
||||
raise
|
||||
|
||||
|
@ -245,7 +245,8 @@ class ParserDateTest(BaseDateTest):
|
||||
"dateval fails is_equal in format %d:\n"
|
||||
" '%s' != '%s'\n"
|
||||
" '%s' != '%s'\n" %
|
||||
(date_format, dateval, ndate, dateval.to_struct(), ndate.to_struct()))
|
||||
(date_format, dateval, ndate,
|
||||
dateval.__dict__, ndate.__dict__))
|
||||
|
||||
def test_basic(self):
|
||||
self.do_case("basic test")
|
||||
@ -380,7 +381,7 @@ class MatchDateTest(BaseDateTest):
|
||||
d1,
|
||||
("did not match" if expected else "matched"),
|
||||
d2,
|
||||
date1.to_struct(), date2.to_struct()))
|
||||
date1.__dict__, date2.__dict__))
|
||||
|
||||
def test_match(self):
|
||||
for testdata in self.tests:
|
||||
|
@ -22,11 +22,20 @@
|
||||
This package implements an object difference engine.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
from gramps.cli.user import User
|
||||
from ..db.utils import import_as_dict
|
||||
from ..lib.serialize import to_json
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
def to_struct(obj):
|
||||
"""
|
||||
Convert an object into a struct.
|
||||
"""
|
||||
return json.loads(to_json(obj))
|
||||
|
||||
def diff_dates(json1, json2):
|
||||
"""
|
||||
Compare two json date objects. Returns True if different.
|
||||
@ -110,7 +119,7 @@ def diff_dbs(db1, db2, user=None):
|
||||
if handles1[p1] == handles2[p2]: # in both
|
||||
item1 = db1.get_table_func(item,"handle_func")(handles1[p1])
|
||||
item2 = db2.get_table_func(item,"handle_func")(handles2[p2])
|
||||
diff = diff_items(item, item1.to_struct(), item2.to_struct())
|
||||
diff = diff_items(item, to_struct(item1), to_struct(item2))
|
||||
if diff:
|
||||
diffs += [(item, item1, item2)]
|
||||
# else same!
|
||||
|
@ -258,7 +258,7 @@ class EditDate(ManagedWindow):
|
||||
newyear=the_newyear)
|
||||
# didn't throw yet?
|
||||
self.validated_date = d
|
||||
LOG.debug("validated_date set to: {0}".format(d.to_struct()))
|
||||
LOG.debug("validated_date set to: {0}".format(d.__dict__))
|
||||
self.ok_button.set_sensitive(1)
|
||||
self.calendar_box.set_sensitive(1)
|
||||
return True
|
||||
|
@ -909,7 +909,7 @@ class GeneWebParser:
|
||||
LOG.warning(_(
|
||||
"Invalid date {date} in {gw_snippet}, "
|
||||
"preserving date as text."
|
||||
).format(date=e.date.to_struct(), gw_snippet=field))
|
||||
).format(date=e.date.__dict__, gw_snippet=field))
|
||||
date.set(modifier=Date.MOD_TEXTONLY, text=field)
|
||||
return date
|
||||
else:
|
||||
|
@ -2499,7 +2499,7 @@ class GrampsParser(UpdateCallback):
|
||||
# TRANSLATORS: leave the {date} and {xml} untranslated in the format string,
|
||||
# but you may re-order them if needed.
|
||||
LOG.warning(_("Invalid date {date} in XML {xml}, preserving XML as text"
|
||||
).format(date=date_error.date.to_struct(), xml=xml))
|
||||
).format(date=date_error.date.__dict__, xml=xml))
|
||||
date_value.set(modifier=Date.MOD_TEXTONLY, text=xml)
|
||||
|
||||
def start_datestr(self, attrs):
|
||||
|
@ -30,7 +30,7 @@ from unittest.mock import patch
|
||||
#import logging
|
||||
|
||||
from gramps.gen.db.utils import import_as_dict
|
||||
from gramps.gen.merge.diff import diff_dbs
|
||||
from gramps.gen.merge.diff import diff_dbs, to_struct
|
||||
from gramps.gen.simple import SimpleAccess
|
||||
from gramps.gen.utils.id import set_det_id
|
||||
from gramps.cli.user import User
|
||||
@ -75,8 +75,8 @@ class CompleteCheck(unittest.TestCase):
|
||||
if diffs:
|
||||
for diff in diffs:
|
||||
obj_type, item1, item2 = diff
|
||||
msg = self._report_diff(obj_type, item1.to_struct(),
|
||||
item2.to_struct())
|
||||
msg = self._report_diff(obj_type, to_struct(item1),
|
||||
to_struct(item2))
|
||||
if msg != "":
|
||||
if hasattr(item1, "gramps_id"):
|
||||
self.msg += "%s: %s handle=%s\n" % \
|
||||
|
Loading…
x
Reference in New Issue
Block a user