<s> from __future__ import absolute_import <EOL> import os <EOL> from . import config_option <EOL> from . import prompt <EOL> import digits <EOL> class LogFileOption ( config_option . Option ) : <EOL> @ staticmethod <EOL> def config_file_key ( ) : <EOL> return '<STR_LIT>' <EOL> @ classmethod <EOL> def prompt_title ( cls ) : <EOL> return '<STR_LIT>' <EOL> @ classmethod <EOL> def prompt_message ( cls ) : <EOL> return '<STR_LIT>' <EOL> def optional ( self ) : <EOL> return True <EOL> def suggestions ( self ) : <EOL> suggested_dir = os . path . dirname ( digits . __file__ ) <EOL> if os . access ( suggested_dir , os . W_OK ) : <EOL> return [ prompt . Suggestion ( <EOL> os . path . join ( suggested_dir , '<STR_LIT>' ) , '<STR_LIT:D>' , <EOL> desc = '<STR_LIT:default>' , default = True ) <EOL> ] <EOL> else : <EOL> return [ ] <EOL> @ staticmethod <EOL> def is_path ( ) : <EOL> return True <EOL> @ staticmethod <EOL> def has_test_value ( ) : <EOL> return True <EOL> @ staticmethod <EOL> def test_value ( ) : <EOL> return None <EOL> @ classmethod <EOL> def validate ( cls , value ) : <EOL> if not value : <EOL> return value <EOL> value = os . path . abspath ( value ) <EOL> dirname = os . path . dirname ( value ) <EOL> if os . path . isfile ( value ) : <EOL> if not os . access ( value , os . W_OK ) : <EOL> raise config_option . BadValue ( '<STR_LIT>' ) <EOL> if not os . access ( dirname , os . W_OK ) : <EOL> raise config_option . BadValue ( '<STR_LIT>' % dirname ) <EOL> return value <EOL> elif os . path . isdir ( value ) : <EOL> raise config_option . BadValue ( '<STR_LIT>' % value ) <EOL> else : <EOL> if os . path . isdir ( dirname ) : <EOL> if not os . access ( dirname , os . W_OK ) : <EOL> raise config_option . BadValue ( '<STR_LIT>' % dirname ) <EOL> return value <EOL> previous_dir = os . path . dirname ( dirname ) <EOL> if not os . path . isdir ( previous_dir ) : <EOL> raise config_option . BadValue ( '<STR_LIT>' % value ) <EOL> if not os . access ( previous_dir , os . W_OK ) : <EOL> raise config_option . BadValue ( '<STR_LIT>' % previous_dir ) <EOL> return value <EOL> def apply ( self ) : <EOL> if not self . _config_file_value : <EOL> return <EOL> dirname = os . path . dirname ( self . _config_file_value ) <EOL> if not os . path . exists ( dirname ) : <EOL> os . mkdir ( dirname ) </s>
