File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 46
46
RESPONSE_FIELDS = ENCODED_RESPONSE_FIELDS | EXTRA_RESPONSE_FIELDS
47
47
FIELDS = REQUEST_FIELDS | RESPONSE_FIELDS
48
48
SKIP_FIELDS = {"language_id" , "language" , "status_id" }
49
+ DATETIME_FIELDS = {"created_at" , "finished_at" }
50
+ FLOATING_POINT_FIELDS = {
51
+ "cpu_time_limit" ,
52
+ "cpu_extra_time" ,
53
+ "time" ,
54
+ "wall_time" ,
55
+ "wall_time_limit" ,
56
+ }
49
57
50
58
51
59
class Submission :
@@ -129,15 +137,9 @@ def set_attributes(self, attributes):
129
137
value = decode (value ) if value else None
130
138
elif attr == "status" :
131
139
value = Status (value ["id" ])
132
- elif attr in ( "created_at" , "finished_at" ) :
140
+ elif attr in DATETIME_FIELDS and value is not None :
133
141
value = datetime .strptime (value , "%Y-%m-%dT%H:%M:%S.%fZ" )
134
- elif attr in (
135
- "wall_time" ,
136
- "wall_time_limit" ,
137
- "cpu_extra_time" ,
138
- "cpu_time_limit" ,
139
- "time" ,
140
- ):
142
+ elif attr in FLOATING_POINT_FIELDS and value is not None :
141
143
value = float (value )
142
144
143
145
setattr (self , attr , value )
@@ -149,6 +151,7 @@ def to_dict(self, client: "Client") -> dict:
149
151
"language_id" : client .get_language_id (self .language ),
150
152
}
151
153
154
+ # TODO: Iterate over ENCODED_REQUEST_FIELDS.
152
155
if self .stdin is not None :
153
156
body ["stdin" ] = encode (self .stdin )
154
157
if self .expected_output is not None :
You can’t perform that action at this time.
0 commit comments