77 validates_schema ,
88)
99from marshmallow .exceptions import ValidationError
10- from marshmallow_enum import EnumField
1110
1211from .content_storage import get_indexed_package
1312from .enums import (
@@ -122,7 +121,7 @@ class Authors(OrderedSchema):
122121
123122
124123class Dependency (OrderedSchema ):
125- content_type = EnumField (ContentType , data_key = "content-type" , by_value = True )
124+ content_type = fields . Enum (ContentType , data_key = "content-type" , by_value = True )
126125 unique_id = fields .String (data_key = "unique-id" , validate = validate .Length (equal = 8 ))
127126 md5sum_partial = fields .String (data_key = "md5sum-partial" , validate = validate .Length (equal = 8 ))
128127
@@ -150,7 +149,7 @@ def validate_dependency(self, data, **kwargs):
150149
151150
152151class Compatability (OrderedSchema ):
153- name = EnumField (Branch , by_value = True )
152+ name = fields . Enum (Branch , by_value = True )
154153 conditions = fields .List (fields .String (), validate = validate .Length (min = 1 , max = 2 ))
155154
156155 @validates ("conditions" )
@@ -207,36 +206,36 @@ def validate_conditions(self, data, **kwargs):
207206
208207
209208class Classification (OrderedSchema ):
210- set = EnumField (NewGRFSet , by_value = True )
211- palette = EnumField (Palette , by_value = True )
209+ set = fields . Enum (NewGRFSet , by_value = True )
210+ palette = fields . Enum (Palette , by_value = True )
212211 has_high_res = fields .Boolean (data_key = "has-high-res" )
213212 has_sound_effects = fields .Boolean (data_key = "has-sound-effects" )
214- shape = EnumField (Shape , by_value = True )
215- resolution = EnumField (Resolution , by_value = True )
216- terrain_type = EnumField (TerrainType , by_value = True , data_key = "terrain-type" )
217- size = EnumField (Size , by_value = True )
218- climate = EnumField (Climate , by_value = True )
213+ shape = fields . Enum (Shape , by_value = True )
214+ resolution = fields . Enum (Resolution , by_value = True )
215+ terrain_type = fields . Enum (TerrainType , by_value = True , data_key = "terrain-type" )
216+ size = fields . Enum (Size , by_value = True )
217+ climate = fields . Enum (Climate , by_value = True )
219218
220219
221220class VersionMinimized (Global ):
222221 read_only = ["upload_date" , "md5sum_partial" , "classification" , "filesize" , "license" , "availability" ]
223222 read_only_for_new = ["upload_date" , "md5sum_partial" , "classification" , "filesize" , "availability" ]
224223
225224 version = fields .String (validate = ValidateBytesLength (max = 15 ))
226- license = EnumField (License , by_value = True )
225+ license = fields . Enum (License , by_value = True )
227226 upload_date = fields .DateTime (data_key = "upload-date" , format = "iso" )
228227 md5sum_partial = fields .String (data_key = "md5sum-partial" , validate = validate .Length (equal = 8 ))
229228 classification = fields .Nested (Classification ())
230229 filesize = fields .Integer ()
231- availability = EnumField (Availability , by_value = True )
230+ availability = fields . Enum (Availability , by_value = True )
232231 dependencies = fields .List (fields .Nested (Dependency ()))
233232 compatibility = fields .List (fields .Nested (Compatability ()))
234233
235234
236235class Package (Global ):
237236 read_only = ["content_type" , "unique_id" , "archived" , "replaced_by" ]
238237
239- content_type = EnumField (ContentType , data_key = "content-type" , by_value = True )
238+ content_type = fields . Enum (ContentType , data_key = "content-type" , by_value = True )
240239 unique_id = fields .String (data_key = "unique-id" , validate = validate .Length (equal = 8 ))
241240 authors = fields .List (fields .Nested (Author ))
242241 versions = fields .List (fields .Nested (VersionMinimized ))
@@ -245,7 +244,7 @@ class Package(Global):
245244class Version (VersionMinimized ):
246245 read_only = ["content_type" , "unique_id" ]
247246
248- content_type = EnumField (ContentType , data_key = "content-type" , by_value = True )
247+ content_type = fields . Enum (ContentType , data_key = "content-type" , by_value = True )
249248 unique_id = fields .String (data_key = "unique-id" , validate = validate .Length (equal = 8 ))
250249
251250
@@ -260,7 +259,7 @@ class UploadStatus(Version):
260259 files = fields .List (fields .Nested (UploadStatusFiles ))
261260 warnings = fields .List (fields .String )
262261 errors = fields .List (fields .String )
263- status = EnumField (Status , by_value = True )
262+ status = fields . Enum (Status , by_value = True )
264263
265264
266265class UploadNew (OrderedSchema ):
0 commit comments