parameters: ()
return_statement: return gen_client_lib.DescriptorGenerator(
          discovery_doc, client_info, names, root_package, outdir,
          base_package=FLAGS.base_package,
          generate_cli=FLAGS.generate_cli,
          use_proto2=FLAGS.experimental_proto2_output,
          unelidable_request_methods=FLAGS.unelidable_request_methods)
docstring: Create a codegen object from flags.
docstring_summary: Create a codegen object from flags.
docstring_tokens: Create a codegen object from flags .
function: def _GetCodegenFromFlags():
      """Create a codegen object from flags."""
      discovery_doc = _GetDiscoveryDocFromFlags()
      names = util.Names(
          FLAGS.strip_prefix,
          FLAGS.experimental_name_convention,
          FLAGS.experimental_capitalize_enums)
  
      if FLAGS.client_json:
          try:
              with open(FLAGS.client_json) as client_json:
                  f = json.loads(client_json.read())
                  web = f.get('installed', f.get('web', {}))
                  client_id = web.get('client_id')
                  client_secret = web.get('client_secret')
          except IOError:
              raise exceptions.NotFoundError(
                  'Failed to open client json file: %s' % FLAGS.client_json)
      else:
          client_id = FLAGS.client_id
          client_secret = FLAGS.client_secret
  
      if not client_id:
          logging.warning('No client ID supplied')
          client_id = ''
  
      if not client_secret:
          logging.warning('No client secret supplied')
          client_secret = ''
  
      client_info = util.ClientInfo.Create(
          discovery_doc, FLAGS.scope, client_id, client_secret,
          FLAGS.user_agent, names, FLAGS.api_key)
      outdir = os.path.expanduser(FLAGS.outdir) or client_info.default_directory
      if os.path.exists(outdir) and not FLAGS.overwrite:
          raise exceptions.ConfigurationValueError(
              'Output directory exists, pass --overwrite to replace '
              'the existing files.')
      if not os.path.exists(outdir):
          os.makedirs(outdir)
  
      root_package = FLAGS.root_package or util.GetPackage(outdir)
      return gen_client_lib.DescriptorGenerator(
          discovery_doc, client_info, names, root_package, outdir,
          base_package=FLAGS.base_package,
          generate_cli=FLAGS.generate_cli,
          use_proto2=FLAGS.experimental_proto2_output,
          unelidable_request_methods=FLAGS.unelidable_request_methods)
function_tokens: def _GetCodegenFromFlags ( ) : discovery_doc = _GetDiscoveryDocFromFlags ( ) names = util . Names ( FLAGS . strip_prefix , FLAGS . experimental_name_convention , FLAGS . experimental_capitalize_enums ) if FLAGS . client_json : try : with open ( FLAGS . client_json ) as client_json : f = json . loads ( client_json . read ( ) ) web = f . get ( 'installed' , f . get ( 'web' , { } ) ) client_id = web . get ( 'client_id' ) client_secret = web . get ( 'client_secret' ) except IOError : raise exceptions . NotFoundError ( 'Failed to open client json file: %s' % FLAGS . client_json ) else : client_id = FLAGS . client_id client_secret = FLAGS . client_secret if not client_id : logging . warning ( 'No client ID supplied' ) client_id = '' if not client_secret : logging . warning ( 'No client secret supplied' ) client_secret = '' client_info = util . ClientInfo . Create ( discovery_doc , FLAGS . scope , client_id , client_secret , FLAGS . user_agent , names , FLAGS . api_key ) outdir = os . path . expanduser ( FLAGS . outdir ) or client_info . default_directory if os . path . exists ( outdir ) and not FLAGS . overwrite : raise exceptions . ConfigurationValueError ( 'Output directory exists, pass --overwrite to replace ' 'the existing files.' ) if not os . path . exists ( outdir ) : os . makedirs ( outdir ) root_package = FLAGS . root_package or util . GetPackage ( outdir ) return gen_client_lib . DescriptorGenerator ( discovery_doc , client_info , names , root_package , outdir , base_package = FLAGS . base_package , generate_cli = FLAGS . generate_cli , use_proto2 = FLAGS . experimental_proto2_output , unelidable_request_methods = FLAGS . unelidable_request_methods )