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