Ticket #6496: 0041-Support-gzipped-fixture-data.patch

File 0041-Support-gzipped-fixture-data.patch, 1.4 KB (added by Bastian Kleineidam <calvin@…>, 16 years ago)
  • django/core/management/commands/loaddata.py

    From 50b59c4874265110234976367838df067989e27b Mon Sep 17 00:00:00 2001
    From: Bastian Kleineidam <calvin@debian.org>
    Date: Mon, 28 Jan 2008 08:33:09 +0100
    Subject: Support gzipped fixture data
    
    
    Signed-off-by: Bastian Kleineidam <calvin@debian.org>
    
    diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
    index fb03259..d47e65f 100644
    a b from django.core.management.color import no_style  
    33from optparse import make_option
    44import sys
    55import os
     6import gzip
    67
    78try:
    89    set
    class Command(BaseCommand):  
    7778                            (humanize(fixture_dir), format, fixture_name)
    7879                    try:
    7980                        full_path = os.path.join(fixture_dir, '.'.join([fixture_name, format]))
    80                         fixture = open(full_path, 'r')
     81                        if os.path.exists(full_path+".gz"):
     82                            full_path += ".gz"
     83                            fixture = gzip.open(full_path)
     84                        else:
     85                            fixture = open(full_path, 'r')
    8186                        if label_found:
    8287                            fixture.close()
    8388                            print self.style.ERROR("Multiple fixtures named '%s' in %s. Aborting." %
Back to Top