code: def _extract_all_python_namespaces(self, thrift_file_sources_by_target):
      
      py_namespaces_by_target = OrderedDict()
      failing_py_thrift_by_target = defaultdict(list)
      for t, all_content in thrift_file_sources_by_target.items():
        py_namespaces_by_target[t] = []
        for (path, content) in all_content:
          try:
            py_namespaces_by_target[t].append(
              # File content is provided as a binary string, so we have to decode it.
              (path, self._extract_py_namespace_from_content(t, path, content.decode('utf-8'))))
          except self.NamespaceParseFailure:
            failing_py_thrift_by_target[t].append(path)
  
      if failing_py_thrift_by_target:
        # We dump the output to a file here because the output can be very long in some repos.
        no_py_namespace_output_file = os.path.join(self.workdir, 'no-python-namespace-output.txt')
  
        pretty_printed_failures = '\n'.join(
          '{}: [{}]'.format(t.address.spec, ', '.join(paths))
          for t, paths in failing_py_thrift_by_target.items())
        error = self.NamespaceExtractionError(no_py_namespace_output_file, """\
  Python namespaces could not be extracted from some thrift sources. Declaring a `namespace py` in
  thrift sources for python thrift library targets will soon become required.
  
  {} python library target(s) contained thrift sources not declaring a python namespace. The targets
  and/or files which need to be edited will be dumped to: {}
  """.format(len(failing_py_thrift_by_target), no_py_namespace_output_file))
  
        safe_file_dump(no_py_namespace_output_file, '{}\n'.format(pretty_printed_failures))
  
        if self.get_options().strict:
          raise error
        else:
          self.context.log.warn(error)
      return py_namespaces_by_target
docs: Extract the python namespace from each thrift source file.