@@ -323,7 +323,7 @@ def de_json(cls, json_string):
323
323
time_seconds = obj ["timeSeconds" ]
324
324
opts = dict ()
325
325
if "blogEntry" in obj :
326
- opts ["blogEntry " ] = BlogEntry .de_json (obj ["blogEntry" ])
326
+ opts ["blog_entry " ] = BlogEntry .de_json (obj ["blogEntry" ])
327
327
if "comment" in obj :
328
328
opts ["comment" ] = Comment .de_json (obj ["comment" ])
329
329
return cls (time_seconds , opts )
@@ -334,7 +334,12 @@ def __init__(self, time_seconds, options):
334
334
setattr (self , key , options [key ])
335
335
336
336
def to_dict (self ):
337
- return super ().to_dict ()
337
+ dictionary = {"time_seconds" : self .time_seconds }
338
+ if "blog_entry" in self .__dict__ .keys ():
339
+ dictionary ["blog_entry" ] = self .blog_entry .to_dict ()
340
+ if "comment" in self .__dict__ .keys ():
341
+ dictionary ["comment" ] = self .blog_entry .to_dict ()
342
+ return dictionary
338
343
339
344
340
345
class RatingChange (JSONDeserializable , Dictionaryable ):
@@ -538,7 +543,7 @@ def __init__(
538
543
539
544
def to_dict (self ):
540
545
return {
541
- "members" : self .members ,
546
+ "members" : [ member . to_dict () for member in self .members ] ,
542
547
"participant_type" : self .participant_type ,
543
548
"ghost" : self .ghost ,
544
549
"team_id" : self .team_id ,
@@ -560,6 +565,9 @@ def de_json(cls, json_string):
560
565
def __init__ (self , handle ):
561
566
self .handle = handle
562
567
568
+ def to_dict (self ):
569
+ return {"handle" : self .handle }
570
+
563
571
564
572
class Problem (JSONDeserializable , Dictionaryable ):
565
573
@classmethod
@@ -706,8 +714,8 @@ def to_dict(self):
706
714
"id" : self .id ,
707
715
"creation_time_seconds" : self .creation_time_seconds ,
708
716
"relative_time_seconds" : self .relative_time_seconds ,
709
- "problem" : self .problem ,
710
- "author" : self .author ,
717
+ "problem" : self .problem . to_dict () ,
718
+ "author" : self .author . to_dict () ,
711
719
"programming_language" : self .programming_language ,
712
720
"testset" : self .testset ,
713
721
"passed_test_count" : self .passed_test_count ,
@@ -768,9 +776,9 @@ def to_dict(self):
768
776
return {
769
777
"id" : self .id ,
770
778
"creation_time_seconds" : self .creation_time_seconds ,
771
- "hacker" : self .hacker ,
772
- "defender" : self .defender ,
773
- "problem" : self .problem ,
779
+ "hacker" : self .hacker . to_dict () ,
780
+ "defender" : self .defender . to_dict () ,
781
+ "problem" : self .problem . to_dict () ,
774
782
"verdict" : self .verdict ,
775
783
"test" : self .test ,
776
784
"judge_protocol" : self .judge_protocol ,
@@ -826,13 +834,15 @@ def __init__(
826
834
827
835
def to_dict (self ):
828
836
return {
829
- "party" : self .party ,
837
+ "party" : self .party . to_dict () ,
830
838
"rank" : self .rank ,
831
839
"points" : self .points ,
832
840
"penalty" : self .penalty ,
833
841
"successful_hack_count" : self .successful_hack_count ,
834
842
"unsuccessful_hack_count" : self .unsuccessful_hack_count ,
835
- "problem_results" : self .problem_results ,
843
+ "problem_results" : [
844
+ problem_result .to_dict () for problem_result in self .problem_results
845
+ ],
836
846
"last_submission_time_seconds" : self .last_submission_time_seconds ,
837
847
}
838
848
0 commit comments