<s> """<STR_LIT>""" <EOL> from StringIO import StringIO <EOL> import decimal <EOL> import yaml <EOL> from google . appengine . _internal . django . db import models <EOL> from google . appengine . _internal . django . core . serializers . python import Serializer as PythonSerializer <EOL> from google . appengine . _internal . django . core . serializers . python import Deserializer as PythonDeserializer <EOL> class DjangoSafeDumper ( yaml . SafeDumper ) : <EOL> def represent_decimal ( self , data ) : <EOL> return self . represent_scalar ( '<STR_LIT>' , str ( data ) ) <EOL> DjangoSafeDumper . add_representer ( decimal . Decimal , DjangoSafeDumper . represent_decimal ) <EOL> class Serializer ( PythonSerializer ) : <EOL> """<STR_LIT>""" <EOL> internal_use_only = False <EOL> def handle_field ( self , obj , field ) : <EOL> if isinstance ( field , models . TimeField ) and getattr ( obj , field . name ) is not None : <EOL> self . _current [ field . name ] = str ( getattr ( obj , field . name ) ) <EOL> else : <EOL> super ( Serializer , self ) . handle_field ( obj , field ) <EOL> def end_serialization ( self ) : <EOL> yaml . dump ( self . objects , self . stream , Dumper = DjangoSafeDumper , ** self . options ) <EOL> def getvalue ( self ) : <EOL> return self . stream . getvalue ( ) <EOL> def Deserializer ( stream_or_string , ** options ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( stream_or_string , basestring ) : <EOL> stream = StringIO ( stream_or_string ) <EOL> else : <EOL> stream = stream_or_string <EOL> for obj in PythonDeserializer ( yaml . load ( stream ) , ** options ) : <EOL> yield obj </s>
