def _get_filepath(self, filename=None, config_dir=None):
<EOL>config_file = None<EOL>config_dir_env_var = self.env_prefix + '<STR_LIT>'<EOL>if not filename:<EOL><INDENT>filename = os.getenv(self.env_prefix, default=self.default_file)<EOL>if os.path.dirname(filename) and os.path.exists(filename):<EOL><INDENT>config_file = filename<EOL><DEDENT><DEDENT>if not config_file:<EOL><INDENT>filename = os.path.basename(filename)<EOL>if not config_dir:<EOL><INDENT>config_dir = os.getenv(config_dir_env_var, default='<STR_LIT>')<EOL><DEDENT>for path in [self.basepath, self.config_root]:<EOL><INDENT>filepath = os.path.join(path, config_dir, filename)<EOL>if os.path.exists(filepath):<EOL><INDENT>config_file = filepath<EOL>break<EOL><DEDENT><DEDENT><DEDENT>return config_file<EOL>
Get config file.

    :param filename: name of config file (not path)
    :param config_dir: dir name prepended to file name.

Note: we use e.g. GBR_CONFIG_DIR here, this is the default
value in GBR but it is actually self.env_prefix + '_DIR' etc.

If config_dir is not supplied it will be set to the value of the
environment variable GBR_CONFIG_DIR or None.

If filename is not supplied and the environment variable GBR_CONFIG
is set and contains a path, its value will be tested to see if a file
exists, if so that is returned as the config file otherwise filename
will be set to GBR_CONFIG, if it exists, otherwise 'config.yaml'.

If a filename is supplied or GBR_CONFIG is not an existing file:

    If the environment variable GBR_CONFIG_PATH exists the path
    GBR_CONFIG_PATH/config_dir/filename is checked.

    If it doesn't exist config/CONFIG_DIR/filename  is checked
        (relative to the root of the (GBR) repo)
    finally GBR_CONFIG_DEFAULT/CONFIG_DIR/filename is tried

If no file is found None will be returned.