parameters: (source)
docstring: Invokes the Protocol Compiler to generate a _pb2.py from the given
    .proto file.  Does nothing if the output already exists and is newer than
    the input.
docstring_summary: Invokes the Protocol Compiler to generate a _pb2.py from the given
    .proto file.  Does nothing if the output already exists and is newer than
    the input.
docstring_tokens: Invokes the Protocol Compiler to generate a _pb2 . py from the given . proto file . Does nothing if the output already exists and is newer than the input .
function: def generate_proto(source):
    """Invokes the Protocol Compiler to generate a _pb2.py from the given
    .proto file.  Does nothing if the output already exists and is newer than
    the input."""
  
    output = source.replace(".proto", "_pb2.py").replace("../src/", "")
  
    if (not os.path.exists(output) or
        (os.path.exists(source) and
         os.path.getmtime(source) > os.path.getmtime(output))):
      print "Generating %s..." % output
  
      if not os.path.exists(source):
        sys.stderr.write("Can't find required file: %s\n" % source)
        sys.exit(-1)
  
      if protoc == None:
        sys.stderr.write(
            "protoc is not installed nor found in ../src.  Please compile it "
            "or install the binary package.\n")
        sys.exit(-1)
  
      protoc_command = [ protoc, "-I../src", "-I.", "--python_out=.", source ]
      if subprocess.call(protoc_command) != 0:
        sys.exit(-1)
function_tokens: def generate_proto ( source ) : output = source . replace ( ".proto" , "_pb2.py" ) . replace ( "../src/" , "" ) if ( not os . path . exists ( output ) or ( os . path . exists ( source ) and os . path . getmtime ( source ) > os . path . getmtime ( output ) ) ) : print "Generating %s..." % output if not os . path . exists ( source ) : sys . stderr . write ( "Can't find required file: %s\n" % source ) sys . exit ( - 1 ) if protoc == None : sys . stderr . write ( "protoc is not installed nor found in ../src.  Please compile it " "or install the binary package.\n" ) sys . exit ( - 1 ) protoc_command = [ protoc , "-I../src" , "-I." , "--python_out=." , source ] if subprocess . call ( protoc_command ) != 0 : sys . exit ( - 1 )