<s> from __future__ import absolute_import , print_function , unicode_literals <EOL> import argparse <EOL> import locale <EOL> import os . path <EOL> import sys <EOL> import warnings <EOL> import six <EOL> from tzlocal import get_localzone <EOL> from . import data , ini <EOL> from . . import compat , utils <EOL> from . . utils import less_than_version , supported_versions <EOL> from . internal import DbAction , validate_project <EOL> def parse ( args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = DbAction , <EOL> default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> choices = ( '<STR_LIT:yes>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT:yes>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> choices = ( '<STR_LIT:yes>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT:yes>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> required = False , default = get_localzone ( ) , <EOL> action = '<STR_LIT:store>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> choices = ( '<STR_LIT:yes>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT:yes>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> choices = ( '<STR_LIT:yes>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT:yes>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' , default = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> choices = data . DJANGO_SUPPORTED , <EOL> default = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> choices = data . DJANGOCMS_SUPPORTED , <EOL> default = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> required = True , default = '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> choices = ( '<STR_LIT:yes>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> default = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> choices = ( '<STR_LIT:yes>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> default = None , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> default = None , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> default = None , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> if '<STR_LIT>' in args : <EOL> for action in parser . _positionals . _actions : <EOL> if action . dest == '<STR_LIT>' : <EOL> action . default = '<STR_LIT>' <EOL> config_args = ini . parse_config_file ( parser , args ) <EOL> args = parser . parse_args ( config_args + args ) <EOL> if not validate_project ( args . project_name ) : <EOL> sys . stderr . write ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( args . project_name ) <EOL> ) <EOL> sys . exit ( <NUM_LIT:3> ) <EOL> setattr ( args , '<STR_LIT>' , <EOL> os . path . join ( args . project_directory , args . project_name ) . strip ( ) ) <EOL> if not args . skip_project_dir_check : <EOL> if ( os . path . exists ( args . project_directory ) and <EOL> [ path for path in os . listdir ( args . project_directory ) if not path . startswith ( '<STR_LIT:.>' ) ] ) : <EOL> sys . stderr . write ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( args . project_directory ) <EOL> ) <EOL> sys . exit ( <NUM_LIT:4> ) <EOL> if os . path . exists ( args . project_path ) : <EOL> sys . stderr . write ( <EOL> '<STR_LIT>' . format ( args . project_path ) <EOL> ) <EOL> sys . exit ( <NUM_LIT:4> ) <EOL> if args . config_dump and os . path . isfile ( args . config_dump ) : <EOL> sys . stdout . write ( <EOL> '<STR_LIT>' . format ( args . config_dump ) <EOL> ) <EOL> sys . exit ( <NUM_LIT:8> ) <EOL> args = _manage_args ( parser , args ) <EOL> if not args . languages : <EOL> try : <EOL> args . languages = [ locale . getdefaultlocale ( ) [ <NUM_LIT:0> ] . split ( '<STR_LIT:_>' ) [ <NUM_LIT:0> ] ] <EOL> except : <EOL> args . languages = [ '<STR_LIT>' ] <EOL> elif isinstance ( args . languages , six . string_types ) : <EOL> args . languages = args . languages . split ( '<STR_LIT:U+002C>' ) <EOL> elif len ( args . languages ) == <NUM_LIT:1> and isinstance ( args . languages [ <NUM_LIT:0> ] , six . string_types ) : <EOL> args . languages = args . languages [ <NUM_LIT:0> ] . split ( '<STR_LIT:U+002C>' ) <EOL> args . languages = [ lang . strip ( ) . lower ( ) for lang in args . languages ] <EOL> args . aldryn = False <EOL> try : <EOL> django_version , cms_version = supported_versions ( args . django_version , <EOL> args . cms_version ) <EOL> except RuntimeError as e : <EOL> sys . stderr . write ( compat . unicode ( e ) ) <EOL> sys . exit ( <NUM_LIT:6> ) <EOL> if django_version is None : <EOL> sys . stderr . write ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( '<STR_LIT:U+002CU+0020>' . join ( data . DJANGO_SUPPORTED ) ) <EOL> ) <EOL> sys . exit ( <NUM_LIT:6> ) <EOL> if django_version is None : <EOL> sys . stderr . write ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( '<STR_LIT:U+002CU+0020>' . join ( data . DJANGOCMS_SUPPORTED ) ) <EOL> ) <EOL> sys . exit ( <NUM_LIT:6> ) <EOL> if not getattr ( args , '<STR_LIT>' ) : <EOL> requirements = [ ] <EOL> if args . cms_version == '<STR_LIT>' : <EOL> requirements . append ( data . DJANGOCMS_DEVELOP ) <EOL> warnings . warn ( data . VERSION_WARNING . format ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> elif args . cms_version == '<STR_LIT>' : <EOL> requirements . append ( data . DJANGOCMS_RC ) <EOL> elif args . cms_version == '<STR_LIT>' : <EOL> requirements . append ( data . DJANGOCMS_BETA ) <EOL> warnings . warn ( data . VERSION_WARNING . format ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> else : <EOL> requirements . append ( '<STR_LIT>' . format ( less_than_version ( cms_version ) ) ) <EOL> if cms_version >= <NUM_LIT> : <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> if not args . no_db_driver : <EOL> requirements . append ( args . db_driver ) <EOL> if not args . no_plugins : <EOL> if args . filer : <EOL> if cms_version >= <NUM_LIT:3> : <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> elif cms_version >= <NUM_LIT:3> : <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> if cms_version >= <NUM_LIT> : <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> if args . aldryn : <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> if args . django_version == '<STR_LIT>' : <EOL> requirements . append ( data . DJANGO_DEVELOP ) <EOL> warnings . warn ( data . VERSION_WARNING . format ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> elif args . django_version == '<STR_LIT>' : <EOL> requirements . append ( data . DJANGO_BETA ) <EOL> warnings . warn ( data . VERSION_WARNING . format ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> else : <EOL> requirements . append ( '<STR_LIT>' . format ( less_than_version ( django_version ) ) ) <EOL> if args . use_timezone : <EOL> requirements . append ( '<STR_LIT>' ) <EOL> if args . reversion : <EOL> if django_version == <NUM_LIT> : <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> elif django_version == <NUM_LIT> : <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT>' ] ) <EOL> requirements . extend ( data . REQUIREMENTS [ '<STR_LIT:default>' ] ) <EOL> setattr ( args , '<STR_LIT>' , '<STR_LIT:\n>' . join ( requirements ) . strip ( ) ) <EOL> setattr ( args , '<STR_LIT>' , cms_version ) <EOL> setattr ( args , '<STR_LIT>' , django_version ) <EOL> setattr ( args , '<STR_LIT>' , <EOL> os . path . join ( args . project_directory , args . project_name , '<STR_LIT>' ) . strip ( ) ) <EOL> setattr ( args , '<STR_LIT>' , <EOL> os . path . join ( args . project_directory , args . project_name , '<STR_LIT>' ) . strip ( ) ) <EOL> if args . config_dump : <EOL> ini . dump_config_file ( args . config_dump , args , parser ) <EOL> return args <EOL> def get_settings ( ) : <EOL> module = __import__ ( str ( '<STR_LIT>' ) , globals ( ) , locals ( ) , [ str ( '<STR_LIT>' ) ] ) <EOL> return module . settings <EOL> def write_default ( config ) : <EOL> pass <EOL> def show_plugins ( ) : <EOL> """<STR_LIT>""" <EOL> sys . stdout . write ( compat . unicode ( data . PLUGIN_LIST_TEXT ) ) <EOL> def show_requirements ( args ) : <EOL> """<STR_LIT>""" <EOL> sys . stdout . write ( compat . unicode ( args . requirements ) ) <EOL> def _manage_args ( parser , args ) : <EOL> """<STR_LIT>""" <EOL> for item in data . CONFIGURABLE_OPTIONS : <EOL> action = parser . _option_string_actions [ item ] <EOL> choices = default = '<STR_LIT>' <EOL> input_value = getattr ( args , action . dest ) <EOL> new_val = None <EOL> if not args . noinput : <EOL> if action . choices : <EOL> choices = '<STR_LIT>' . format ( '<STR_LIT:U+002CU+0020>' . join ( action . choices ) ) <EOL> if input_value : <EOL> if type ( input_value ) == list : <EOL> default = '<STR_LIT>' . format ( '<STR_LIT:U+002CU+0020>' . join ( input_value ) ) <EOL> else : <EOL> default = '<STR_LIT>' . format ( input_value ) <EOL> while not new_val : <EOL> prompt = '<STR_LIT>' . format ( action . help , choices , default ) <EOL> if action . choices in ( '<STR_LIT:yes>' , '<STR_LIT>' ) : <EOL> new_val = utils . query_yes_no ( prompt ) <EOL> else : <EOL> new_val = compat . input ( prompt ) <EOL> new_val = compat . clean ( new_val ) <EOL> if not new_val and input_value : <EOL> new_val = input_value <EOL> if new_val and action . dest == '<STR_LIT>' : <EOL> if new_val != '<STR_LIT>' and not os . path . isdir ( new_val ) : <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> new_val = False <EOL> if new_val and action . dest == '<STR_LIT>' : <EOL> action ( parser , args , new_val , action . option_strings ) <EOL> new_val = getattr ( args , action . dest ) <EOL> else : <EOL> if not input_value and action . required : <EOL> raise ValueError ( <EOL> '<STR_LIT>' . format ( action . dest ) <EOL> ) <EOL> new_val = input_value <EOL> if action . dest == '<STR_LIT>' : <EOL> action ( parser , args , new_val , action . option_strings ) <EOL> new_val = getattr ( args , action . dest ) <EOL> if action . dest == '<STR_LIT>' and ( new_val == '<STR_LIT>' or not os . path . isdir ( new_val ) ) : <EOL> new_val = False <EOL> if action . dest in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> new_val = ( new_val == '<STR_LIT:yes>' ) <EOL> setattr ( args , action . dest , new_val ) <EOL> return args </s>
