docs: def load_config(extra_args=None,
                  doc=None,
                  filenames=None,
                  invalidate_cache=False,
                  fedmsg_command=False,
                  disable_defaults=False):
      """ Setup a runtime config dict by integrating the following sources
      (ordered by precedence):
  
        - defaults (unless disable_defaults = True)
        - config file
        - command line arguments
  
      If the ``fedmsg_command`` argument is False, no command line arguments are
      checked.
  
      """
      warnings.warn('Using "load_config" is deprecated and will be removed in a future release;'
                    ' use the "fedmsg.config.conf" dictionary instead.', DeprecationWarning)
      global __cache
  
      if invalidate_cache:
          __cache = {}
  
      if __cache:
          return __cache
  
      # Coerce defaults if arguments are not supplied.
      extra_args = extra_args or []
      doc = doc or ""
  
      if not disable_defaults:
          config = copy.deepcopy(defaults)
      else:
          config = {}
  
      config.update(_process_config_file(filenames=filenames))
  
      # This is optional (and defaults to false) so that only 'fedmsg-*' commands
      # are required to provide these arguments.
      # For instance, the moksha-hub command takes a '-v' argument and internally
      # makes calls to fedmsg.  We don't want to impose all of fedmsg's CLI
      # option constraints on programs that use fedmsg, so we make it optional.
      if fedmsg_command:
          config.update(_process_arguments(extra_args, doc, config))
  
      # If the user specified a config file on the command line, then start over
      # but read in that file instead.
      if not filenames and config.get('config_filename', None):
          return load_config(extra_args, doc,
                             filenames=[config['config_filename']],
                             fedmsg_command=fedmsg_command,
                             disable_defaults=disable_defaults)
  
      # Just a little debug option.  :)
      if config.get('print_config'):
          print(pretty_dumps(config))
          sys.exit(0)
  
      if not disable_defaults and 'endpoints' not in config:
          raise ValueError("No config value 'endpoints' found.")
  
      if not isinstance(config.get('endpoints', {}), dict):
          raise ValueError("The 'endpoints' config value must be a dict.")
  
      if 'endpoints' in config:
          config['endpoints'] = dict([
              (k, list(iterate(v))) for k, v in config['endpoints'].items()
          ])
  
      if 'srv_endpoints' in config and len(config['srv_endpoints']) > 0:
          from dns.resolver import query, NXDOMAIN, Timeout, NoNameservers
          for e in config['srv_endpoints']:
              urls = []
              try:
                  records = query('_fedmsg._tcp.{0}'.format(e), 'SRV')
              except NXDOMAIN:
                  warnings.warn("There is no appropriate SRV records " +
                                "for {0}".format(e))
                  continue
              except Timeout:
                  warnings.warn("The DNS query for the SRV records of" +
                                " {0} timed out.".format(e))
                  continue
              except NoNameservers:
                  warnings.warn("No name server is available, please " +
                                "check the configuration")
                  break
  
              for rec in records:
                  urls.append('tcp://{hostname}:{port}'.format(
                      hostname=rec.target.to_text(),
                      port=rec.port
                  ))
              config['endpoints'][e] = list(iterate(urls))
  
      if 'topic_prefix_re' not in config and 'topic_prefix' in config:
          # Turn "org.fedoraproject" into "org\.fedoraproject\.[^\W\d_]+"
          config['topic_prefix_re'] = config['topic_prefix'].replace('.', '\.')\
              + '\.[^\W\d_]+'
  
      __cache = config
      return config