13
13
14
14
You should have received a copy of the GNU General Public License
15
15
along with this program. If not, see <https://www.gnu.org/licenses/>.
16
- """
17
- """
18
16
Source of inspiration: https://github.com/eternnoir/pyTelegramBotAPI/blob/master/telebot/types.py
19
17
"""
20
18
import json
@@ -60,10 +58,9 @@ def check_json(json_type):
60
58
"""
61
59
if isinstance (json_type , dict ):
62
60
return json_type
63
- elif isinstance (json_type , str ):
61
+ if isinstance (json_type , str ):
64
62
return json .loads (json_type )
65
- else :
66
- raise ValueError ("json_type should be a json dict or string." )
63
+ raise ValueError ("json_type should be a json dict or string." )
67
64
68
65
def __str__ (self ):
69
66
d = {}
@@ -194,7 +191,7 @@ def de_json(cls, json_string):
194
191
if json_string is None :
195
192
return None
196
193
obj = cls .check_json (json_string )
197
- id = obj ["id" ]
194
+ identifier = obj ["id" ]
198
195
original_locale = obj ["originalLocale" ]
199
196
creation_time_seconds = obj ["creationTimeSeconds" ]
200
197
author_handle = obj ["authorHandle" ]
@@ -206,7 +203,7 @@ def de_json(cls, json_string):
206
203
rating = obj ["rating" ]
207
204
content = obj .get ("content" )
208
205
return cls (
209
- id ,
206
+ identifier ,
210
207
original_locale ,
211
208
creation_time_seconds ,
212
209
author_handle ,
@@ -221,7 +218,7 @@ def de_json(cls, json_string):
221
218
222
219
def __init__ (
223
220
self ,
224
- id ,
221
+ identifier ,
225
222
original_locale ,
226
223
creation_time_seconds ,
227
224
author_handle ,
@@ -233,7 +230,7 @@ def __init__(
233
230
rating ,
234
231
content = None ,
235
232
):
236
- self .id = id
233
+ self .id = identifier
237
234
self .original_locale = original_locale
238
235
self .creation_time_seconds = creation_time_seconds
239
236
self .author_handle = author_handle
@@ -267,15 +264,15 @@ def de_json(cls, json_string):
267
264
if json_string is None :
268
265
return None
269
266
obj = cls .check_json (json_string )
270
- id = obj ["id" ]
267
+ identifier = obj ["id" ]
271
268
creation_time_seconds = obj ["creationTimeSeconds" ]
272
269
commentator_handle = obj ["commentatorHandle" ]
273
270
locale = obj ["locale" ]
274
271
text = obj ["text" ]
275
272
rating = obj ["rating" ]
276
273
parent_comment_id = obj .get ("parentCommentId" )
277
274
return cls (
278
- id ,
275
+ identifier ,
279
276
creation_time_seconds ,
280
277
commentator_handle ,
281
278
locale ,
@@ -286,15 +283,15 @@ def de_json(cls, json_string):
286
283
287
284
def __init__ (
288
285
self ,
289
- id ,
286
+ identifier ,
290
287
creation_time_seconds ,
291
288
commentator_handle ,
292
289
locale ,
293
290
text ,
294
291
rating ,
295
292
parent_comment_id = None ,
296
293
):
297
- self .id = id
294
+ self .id = identifier
298
295
self .creation_time_seconds = creation_time_seconds
299
296
self .commentator_handle = commentator_handle
300
297
self .locale = locale
@@ -401,7 +398,7 @@ def de_json(cls, json_string):
401
398
if json_string is None :
402
399
return None
403
400
obj = cls .check_json (json_string )
404
- id = obj ["id" ]
401
+ identifier = obj ["id" ]
405
402
name = obj ["name" ]
406
403
contest_type = obj ["type" ]
407
404
phase = obj ["phase" ]
@@ -419,7 +416,7 @@ def de_json(cls, json_string):
419
416
city = obj .get ("city" )
420
417
season = obj .get ("season" )
421
418
return cls (
422
- id ,
419
+ identifier ,
423
420
name ,
424
421
contest_type ,
425
422
phase ,
@@ -440,7 +437,7 @@ def de_json(cls, json_string):
440
437
441
438
def __init__ (
442
439
self ,
443
- id ,
440
+ identifier ,
444
441
name ,
445
442
contest_type ,
446
443
phase ,
@@ -458,7 +455,7 @@ def __init__(
458
455
city = None ,
459
456
season = None ,
460
457
):
461
- self .id = id
458
+ self .id = identifier
462
459
self .name = name
463
460
self .contest_type = contest_type
464
461
self .phase = phase
@@ -650,7 +647,7 @@ def de_json(cls, json_string):
650
647
if json_string is None :
651
648
return None
652
649
obj = cls .check_json (json_string )
653
- id = obj ["id" ]
650
+ identifier = obj ["id" ]
654
651
creation_time_seconds = obj ["creationTimeSeconds" ]
655
652
relative_time_seconds = obj ["relativeTimeSeconds" ]
656
653
problem = Problem .de_json (obj ["problem" ])
@@ -664,7 +661,7 @@ def de_json(cls, json_string):
664
661
verdict = obj .get ("verdict" )
665
662
points = obj .get ("points" )
666
663
return cls (
667
- id ,
664
+ identifier ,
668
665
creation_time_seconds ,
669
666
relative_time_seconds ,
670
667
problem ,
@@ -681,7 +678,7 @@ def de_json(cls, json_string):
681
678
682
679
def __init__ (
683
680
self ,
684
- id ,
681
+ identifier ,
685
682
creation_time_seconds ,
686
683
relative_time_seconds ,
687
684
problem ,
@@ -695,7 +692,7 @@ def __init__(
695
692
verdict = None ,
696
693
points = None ,
697
694
):
698
- self .id = id
695
+ self .id = identifier
699
696
self .creation_time_seconds = creation_time_seconds
700
697
self .relative_time_seconds = relative_time_seconds
701
698
self .problem = problem
@@ -733,7 +730,7 @@ def de_json(cls, json_string):
733
730
if json_string is None :
734
731
return None
735
732
obj = cls .check_json (json_string )
736
- id = obj ["id" ]
733
+ identifier = obj ["id" ]
737
734
creation_time_seconds = obj ["creationTimeSeconds" ]
738
735
hacker = Party .de_json (obj ["hacker" ])
739
736
defender = Party .de_json (obj ["defender" ])
@@ -742,7 +739,7 @@ def de_json(cls, json_string):
742
739
test = obj .get ("test" )
743
740
judge_protocol = obj .get ("judgeProtocol" )
744
741
return cls (
745
- id ,
742
+ identifier ,
746
743
creation_time_seconds ,
747
744
hacker ,
748
745
defender ,
@@ -754,7 +751,7 @@ def de_json(cls, json_string):
754
751
755
752
def __init__ (
756
753
self ,
757
- id ,
754
+ identifier ,
758
755
creation_time_seconds ,
759
756
hacker ,
760
757
defender ,
@@ -763,7 +760,7 @@ def __init__(
763
760
test = None ,
764
761
judge_protocol = None ,
765
762
):
766
- self .id = id
763
+ self .id = identifier
767
764
self .creation_time_seconds = creation_time_seconds
768
765
self .hacker = hacker
769
766
self .defender = defender
0 commit comments