77from .election_object_base import ElectionObjectBase
88from .group import ElementModQ
99from .hash import CryptoHashable , hash_elems
10- from .logs import log_warning
10+ from .logs import log_warning , log_debug
1111from .serializable import Serializable
12- from .utils import get_optional , to_ticks
12+ from .utils import get_optional , to_iso_date_string
1313
1414
1515@unique
@@ -103,7 +103,9 @@ def crypto_hash(self) -> ElementModQ:
103103 """
104104 A hash representation of the object
105105 """
106- return hash_elems (self .annotation , self .value )
106+ hash = hash_elems (self .annotation , self .value )
107+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
108+ return hash
107109
108110
109111@dataclass (eq = True , unsafe_hash = True )
@@ -120,7 +122,9 @@ def crypto_hash(self) -> ElementModQ:
120122 """
121123 A hash representation of the object
122124 """
123- return hash_elems (self .value , self .language )
125+ hash = hash_elems (self .value , self .language )
126+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
127+ return hash
124128
125129
126130@dataclass (eq = True , unsafe_hash = True )
@@ -136,7 +140,9 @@ def crypto_hash(self) -> ElementModQ:
136140 """
137141 A hash representation of the object
138142 """
139- return hash_elems (self .text )
143+ hash = hash_elems (self .text )
144+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
145+ return hash
140146
141147
142148@dataclass (eq = True , unsafe_hash = True )
@@ -155,7 +161,9 @@ def crypto_hash(self) -> ElementModQ:
155161 """
156162 A hash representation of the object
157163 """
158- return hash_elems (self .name , self .address_line , self .email , self .phone )
164+ hash = hash_elems (self .name , self .address_line , self .email , self .phone )
165+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
166+ return hash
159167
160168
161169@dataclass (eq = True , unsafe_hash = True )
@@ -174,9 +182,11 @@ def crypto_hash(self) -> ElementModQ:
174182 """
175183 A hash representation of the object
176184 """
177- return hash_elems (
185+ hash = hash_elems (
178186 self .object_id , self .name , str (self .type .name ), self .contact_information
179187 )
188+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
189+ return hash
180190
181191
182192@dataclass (eq = True , unsafe_hash = True )
@@ -193,9 +203,11 @@ def crypto_hash(self) -> ElementModQ:
193203 """
194204 A hash representation of the object
195205 """
196- return hash_elems (
206+ hash = hash_elems (
197207 self .object_id , self .geopolitical_unit_ids , self .party_ids , self .image_uri
198208 )
209+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
210+ return hash
199211
200212
201213@dataclass (eq = True , unsafe_hash = True )
@@ -220,13 +232,15 @@ def crypto_hash(self) -> ElementModQ:
220232 """
221233 A hash representation of the object
222234 """
223- return hash_elems (
235+ hash = hash_elems (
224236 self .object_id ,
225237 self .name ,
226238 self .abbreviation ,
227239 self .color ,
228240 self .logo_uri ,
229241 )
242+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
243+ return hash
230244
231245
232246@dataclass (eq = True , unsafe_hash = True )
@@ -256,7 +270,9 @@ def crypto_hash(self) -> ElementModQ:
256270 """
257271 A hash representation of the object
258272 """
259- return hash_elems (self .object_id , self .name , self .party_id , self .image_uri )
273+ hash = hash_elems (self .object_id , self .name , self .party_id , self .image_uri )
274+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
275+ return hash
260276
261277
262278@dataclass (eq = True , unsafe_hash = True )
@@ -287,7 +303,9 @@ def crypto_hash(self) -> ElementModQ:
287303 """
288304 A hash representation of the object
289305 """
290- return hash_elems (self .object_id , self .sequence_order , self .candidate_id )
306+ hash = hash_elems (self .object_id , self .sequence_order , self .candidate_id )
307+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
308+ return hash
291309
292310
293311# pylint: disable=too-many-instance-attributes
@@ -358,7 +376,7 @@ def crypto_hash(self) -> ElementModQ:
358376 description match up.
359377 """
360378 # remove any placeholders from the hash mechanism
361- return hash_elems (
379+ hash = hash_elems (
362380 self .object_id ,
363381 self .sequence_order ,
364382 self .electoral_district_id ,
@@ -370,6 +388,8 @@ def crypto_hash(self) -> ElementModQ:
370388 self .votes_allowed ,
371389 self .ballot_selections ,
372390 )
391+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
392+ return hash
373393
374394 def is_valid (self ) -> bool :
375395 """
@@ -561,19 +581,20 @@ def crypto_hash(self) -> ElementModQ:
561581 """
562582 Returns a hash of the metadata components of the election
563583 """
564-
565- return hash_elems (
584+ hash = hash_elems (
566585 self .election_scope_id ,
567586 str (self .type .name ),
568- to_ticks (self .start_date ),
569- to_ticks (self .end_date ),
587+ to_iso_date_string (self .start_date ),
588+ to_iso_date_string (self .end_date ),
570589 self .name ,
571590 self .contact_information ,
572591 self .geopolitical_units ,
573592 self .parties ,
574593 self .contests ,
575594 self .ballot_styles ,
576595 )
596+ log_debug (f"{ self .__class__ } : crypto_hash: { hash .to_hex ()} " )
597+ return hash
577598
578599 def is_valid (self ) -> bool :
579600 """
0 commit comments