code: def load_source(source):
      
      if isinstance(source, collections.Mapping):
          return deepcopy(source)
      elif hasattr(source, 'read') and callable(source.read):
          raw_source = source.read()
      elif os.path.exists(os.path.expanduser(str(source))):
          with open(os.path.expanduser(str(source)), 'r') as source_file:
              raw_source = source_file.read()
      elif isinstance(source, six.string_types):
          parts = urlparse.urlparse(source)
          if parts.scheme and parts.netloc:
              response = requests.get(source)
              if isinstance(response.content, six.binary_type):
                  raw_source = six.text_type(response.content, encoding='utf-8')
              else:
                  raw_source = response.content
          else:
              raw_source = source
  
      try:
          try:
              return json.loads(raw_source)
          except ValueError:
              pass
  
          try:
              return yaml.safe_load(raw_source)
          except (yaml.scanner.ScannerError, yaml.parser.ParserError):
              pass
      except NameError:
          pass
  
      raise ValueError(
          "Unable to parse `{0}`.  Tried yaml and json.".format(source),
      )
docs: Common entry point for loading some form of raw swagger schema.
  
      Supports:
          - python object (dictionary-like)
          - path to yaml file
          - path to json file
          - file object (json or yaml).
          - json string.
          - yaml string.