<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_paths_and_config(self, config, pkg_dir_name, pkg_cache_dir=None):
 """Handle remote source defined sys.paths & configs. Args: config (dict):
 git config dictionary pkg_dir_name (string):
 directory name of the stacker archive pkg_cache_dir (string):
 fully qualified path to stacker cache cache directory """

        if pkg_cache_dir is None:
            pkg_cache_dir = self.package_cache_dir
        cached_dir_path = os.path.join(pkg_cache_dir, pkg_dir_name)

        # Add the appropriate directory (or directories) to sys.path
        if config.get('paths'):
            for path in config['paths']:
                path_to_append = os.path.join(cached_dir_path,
                                              path)
                logger.debug("Appending \"%s\" to python sys.path",
                             path_to_append)
                sys.path.append(path_to_append)
        else:
            sys.path.append(cached_dir_path)

        # If the configuration defines a set of remote config yamls to
        # include, add them to the list for merging
        if config.get('configs'):
            for config_filename in config['configs']:
                self.configs_to_merge.append(os.path.join(cached_dir_path,
                                                          config_filename))