Ticket #22258: 22258#test.diff

File 22258#test.diff, 1.2 KB (added by ANUBHAV JOSHI, 10 years ago)
  • django/core/serializers/json.py

    diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py
    index 72053e1..0246ad6 100644
    a b class Serializer(PythonSerializer):  
    3636            # Prevent trailing spaces
    3737            self.json_kwargs['separators'] = (',', ': ')
    3838        self.stream.write("[")
     39        self.progress = 1.0
    3940
    4041    def end_serialization(self):
    4142        if self.options.get("indent"):
    class Serializer(PythonSerializer):  
    4647
    4748    def end_object(self, obj):
    4849        # self._current has the field data
     50        import sys
     51        from django.core.management.base import OutputWrapper
    4952        indent = self.options.get("indent")
    5053        if not self.first:
    5154            self.stream.write(",")
    class Serializer(PythonSerializer):  
    5659        json.dump(self.get_dump_object(obj), self.stream,
    5760                  cls=DjangoJSONEncoder, **self.json_kwargs)
    5861        self._current = None
     62        if not isinstance(self.stream, OutputWrapper):
     63            sys.stdout.write("\rProgress: "+str(self.progress)+"%")
     64            self.progress+=5.0
    5965
    6066    def getvalue(self):
    6167        # Grand-parent super
Back to Top