Django

Code

Changeset 9537

Show
Ignore:
Timestamp:
11/30/08 20:20:59 (1 month ago)
Author:
mtredinnick
Message:

Fixed #9723 -- Not all Python distributions contain the bz2 module, so we need to allow for that. Based on a patch from AdamG.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management/commands/loaddata.py

    r9531 r9537  
    1010except NameError: 
    1111    from sets import Set as set   # Python 2.3 fallback 
     12 
     13try: 
     14    import bz2 
     15    has_bz2 = True 
     16except ImportError: 
     17    has_bz2 = False 
    1218 
    1319class Command(BaseCommand): 
     
    6369        compression_types = { 
    6470            None:   file, 
    65             'bz2':  bz2.BZ2File, 
    6671            'gz':   gzip.GzipFile, 
    6772            'zip':  SingleZipReader 
    6873        } 
     74        if has_bz2: 
     75            compression_types['bz2'] = bz2.BZ2File 
    6976 
    7077        app_fixtures = [os.path.join(os.path.dirname(app.__file__), 'fixtures') for app in get_apps()]