#NEWLINE# def config_dir( self ) : #NEWLINE# #INDENT# "Get the path to the user configuration directory. The\n        directory is guaranteed to exist as a postcondition (one may be\n        created if none exist).\n\n        If the application's ``...DIR`` environment variable is set, it\n        is used as the configuration directory. Otherwise,\n        platform-specific standard configuration locations are searched\n        for a ``config.yaml`` file. If no configuration file is found, a\n        fallback path is used.\n        " #NEWLINE# if ( self . _env_var in os . environ ) : #NEWLINE# #INDENT# appdir = os . environ [ self . _env_var ] #NEWLINE# appdir = os . path . abspath ( os . path . expanduser ( appdir ) ) #NEWLINE# if os . path . isfile ( appdir ) : #NEWLINE# #INDENT# raise ConfigError ( '{0} must be a directory' . format ( self . _env_var ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for confdir in config_dirs ( ) : #NEWLINE# #INDENT# appdir = os . path . join ( confdir , self . appname ) #NEWLINE# if os . path . isfile ( os . path . join ( appdir , CONFIG_FILENAME ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not os . path . isdir ( appdir ) ) : #NEWLINE# #INDENT# os . makedirs ( appdir ) #NEWLINE# #UNINDENT# return appdir