<s> from django import VERSION <EOL> from django . core . management . commands . loaddata import Command as LoadDataCommand <EOL> from wagtail_modeltranslation import settings as mt_settings <EOL> from wagtail_modeltranslation . utils import auto_populate <EOL> ALLOWED = ( None , False , '<STR_LIT:all>' , '<STR_LIT:default>' , '<STR_LIT>' ) <EOL> ALLOWED_FOR_PRINT = '<STR_LIT:U+002CU+0020>' . join ( str ( i ) for i in ( <NUM_LIT:0> , ) + ALLOWED [ <NUM_LIT:1> : ] ) <EOL> def check_mode ( option , opt_str , value , parser , namespace = None ) : <EOL> if value == '<STR_LIT:0>' or value . lower ( ) == '<STR_LIT:false>' : <EOL> value = False <EOL> if value not in ALLOWED : <EOL> raise ValueError ( "<STR_LIT>" % ( opt_str , ALLOWED_FOR_PRINT ) ) <EOL> setattr ( namespace or parser . values , option . dest , value ) <EOL> class Command ( LoadDataCommand ) : <EOL> leave_locale_alone = mt_settings . LOADDATA_RETAIN_LOCALE <EOL> help = ( '<STR_LIT>' + <EOL> '<STR_LIT>' % ALLOWED_FOR_PRINT ) <EOL> if VERSION < ( <NUM_LIT:1> , <NUM_LIT:8> ) : <EOL> from optparse import make_option <EOL> option_list = LoadDataCommand . option_list + ( <EOL> make_option ( '<STR_LIT>' , action = '<STR_LIT>' , callback = check_mode , type = '<STR_LIT:string>' , <EOL> dest = '<STR_LIT>' , metavar = '<STR_LIT>' , help = help ) , <EOL> ) <EOL> else : <EOL> import argparse <EOL> class CheckAction ( argparse . Action ) : <EOL> def __call__ ( self , parser , namespace , value , option_string = None ) : <EOL> check_mode ( self , option_string , value , parser , namespace ) <EOL> def add_arguments ( self , parser ) : <EOL> super ( Command , self ) . add_arguments ( parser ) <EOL> parser . add_argument ( '<STR_LIT>' , action = self . CheckAction , type = str , dest = '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , help = self . help ) <EOL> def __init__ ( self ) : <EOL> super ( Command , self ) . __init__ ( ) <EOL> if mt_settings . LOADDATA_RETAIN_LOCALE and VERSION < ( <NUM_LIT:1> , <NUM_LIT:6> ) : <EOL> from django . utils import translation <EOL> self . locale = translation . get_language ( ) <EOL> def handle ( self , * fixture_labels , ** options ) : <EOL> if self . can_import_settings and hasattr ( self , '<STR_LIT>' ) : <EOL> from django . utils import translation <EOL> translation . activate ( self . locale ) <EOL> mode = options . get ( '<STR_LIT>' ) <EOL> if mode is not None : <EOL> with auto_populate ( mode ) : <EOL> return super ( Command , self ) . handle ( * fixture_labels , ** options ) <EOL> else : <EOL> return super ( Command , self ) . handle ( * fixture_labels , ** options ) </s>
