<s> import pickle <EOL> from vectorformats . Feature import Feature <EOL> from vectorformats . Formats . Format import Format <EOL> class Django ( Format ) : <EOL> """<STR_LIT>""" <EOL> geodjango = False <EOL> """<STR_LIT>""" <EOL> pickled_geometry = False <EOL> """<STR_LIT>""" <EOL> pickled_properties = False <EOL> """<STR_LIT>""" <EOL> properties = [ ] <EOL> """<STR_LIT>""" <EOL> def decode ( self , query_set , generator = False ) : <EOL> results = [ ] <EOL> for res in query_set : <EOL> feature = Feature ( res . pk ) <EOL> if self . pickled_geometry : <EOL> feature . geometry = pickle . loads ( res . geometry ) <EOL> elif self . geodjango : <EOL> geometry = None <EOL> geom = getattr ( res , self . geodjango ) <EOL> if geom : <EOL> geometry = { } <EOL> geometry [ '<STR_LIT:type>' ] = geom . geom_type <EOL> geometry [ '<STR_LIT>' ] = geom . coords <EOL> feature . geometry = geometry <EOL> if self . pickled_properties : <EOL> props = getattr ( res , self . pickled_properties ) <EOL> feature . properties = pickle . loads ( props . encode ( "<STR_LIT:utf-8>" ) ) <EOL> if self . properties : <EOL> for p in self . properties : <EOL> feature . properties [ p ] = getattr ( res , p ) <EOL> results . append ( feature ) <EOL> return results </s>
