code: def from_file(proto_file):
      '''
      Take a filename |protoc_file|, compile it via the Protobuf
      compiler, and import the module.
  
      Return the module if successfully compiled, otherwise raise either
      a ProtocNotFound or BadProtobuf exception.
      '''
      if not proto_file.endswith('.proto'):
          raise BadProtobuf()
  
      dest = tempfile.mkdtemp()
      full_path = os.path.abspath(proto_file)
      _compile_proto(full_path, dest)
  
      filename = os.path.split(full_path)[-1]
      name = re.search(r'^(.*)\.proto$', filename).group(1)
      target = os.path.join(dest, name+'_pb2.py')
  
      return _load_module(targetf from_file(proto_file):
      '''
      Take a filename |protoc_file|, compile it via the Protobuf
      compiler, and import the module.
  
      Return the module if successfully compiled, otherwise raise either
      a ProtocNotFound or BadProtobuf exception.
      '''
      if not proto_file.endswith('.proto'):
          raise BadProtobuf()
  
      dest = tempfile.mkdtemp()
      full_path = os.path.abspath(proto_file)
      _compile_proto(full_path, dest)
  
      filename = os.path.split(full_path)[-1]
      name = re.search(r'^(.*)\.proto$', filename).group(1)
      target = os.path.join(dest, name+'_pb2.py')
  
      return _load_module(target)
docs: Take a filename |protoc_file|, compile it via the Protobuf
      compiler, and import the module.
  
      Return the module if successfully compiled, otherwise raise either
      a ProtocNotFound or BadProtobuf exception.