(discovery_doc, package_writer,
             include_timestamp=False,
             version_package=False,
             package_path=None,
             output_type='plain',
             language='java',
             language_variant='default',
             callback=None)
Generate a library package from discovery and options.
Generate a library package from discovery and options.
Generate a library package from discovery and options .
def Generate(discovery_doc, package_writer,
             include_timestamp=False,
             version_package=False,
             package_path=None,
             output_type='plain',
             language='java',
             language_variant='default',
             callback=None):
  """Generate a library package from discovery and options."""
  options = {
      # Include other files needed to compile (e.g. base jar files)
      'include_dependencies': False,
      # Include the timestamp in the generated library
      'include_timestamp': include_timestamp,
      # Put API version in the package
      'version_package': version_package,
      # Custom package name
      'package_path': package_path,
      }
  if FLAGS.monolithic_source_name:
    options['useSingleSourceFile'] = True
  if output_type == 'full':
    options['include_dependencies'] = True
  if FLAGS.reparent_methods_using_id:
    discovery_doc['reparentMethodsUsingId'] = True

  # determine language version from language variant.
  language_variations = Targets().VariationsForLanguage(language)
  if not language_variations:
    raise app.UsageError('Language %s missing from '
                         'apiserving/libgen/gen/targets.json' %
                         language)
  features = language_variations.GetFeatures(language_variant)
  if not features:
    raise app.UsageError('Unsupported language variant: '
                         '%s/%s/features.json is missing' %
                         language, language_variant)
  try:
    generator_class = generator_lookup.GetGeneratorByLanguage(
        features.get('generator', language))
  except ValueError:
    raise app.UsageError('Unsupported language: %s' % language)

  generator = generator_class(discovery_doc, options=options)
  if FLAGS.monolithic_source_name:
    generator.api.SetTemplateValue('monolithicSourceName',
                                   FLAGS.monolithic_source_name)
  generator.SetTemplateDir(features.template_dir)
  generator.SetFeatures(features)
  generator.GeneratePackage(package_writer)
  package_writer.DoneWritingArchive()
  if callback:
    callback(discovery_doc=discovery_doc,
             package_writer=package_writer,
             include_timestamp=include_timestamp,
             version_package=version_package,
             package_path=package_path,
             output_type=output_type,
             language=language,
             language_variant=language_variant)
def Generate ( discovery_doc , package_writer , include_timestamp = False , version_package = False , package_path = None , output_type = 'plain' , language = 'java' , language_variant = 'default' , callback = None ) : options = { # Include other files needed to compile (e.g. base jar files) 'include_dependencies' : False , # Include the timestamp in the generated library 'include_timestamp' : include_timestamp , # Put API version in the package 'version_package' : version_package , # Custom package name 'package_path' : package_path , } if FLAGS . monolithic_source_name : options [ 'useSingleSourceFile' ] = True if output_type == 'full' : options [ 'include_dependencies' ] = True if FLAGS . reparent_methods_using_id : discovery_doc [ 'reparentMethodsUsingId' ] = True # determine language version from language variant. language_variations = Targets ( ) . VariationsForLanguage ( language ) if not language_variations : raise app . UsageError ( 'Language %s missing from ' 'apiserving/libgen/gen/targets.json' % language ) features = language_variations . GetFeatures ( language_variant ) if not features : raise app . UsageError ( 'Unsupported language variant: ' '%s/%s/features.json is missing' % language , language_variant ) try : generator_class = generator_lookup . GetGeneratorByLanguage ( features . get ( 'generator' , language ) ) except ValueError : raise app . UsageError ( 'Unsupported language: %s' % language ) generator = generator_class ( discovery_doc , options = options ) if FLAGS . monolithic_source_name : generator . api . SetTemplateValue ( 'monolithicSourceName' , FLAGS . monolithic_source_name ) generator . SetTemplateDir ( features . template_dir ) generator . SetFeatures ( features ) generator . GeneratePackage ( package_writer ) package_writer . DoneWritingArchive ( ) if callback : callback ( discovery_doc = discovery_doc , package_writer = package_writer , include_timestamp = include_timestamp , version_package = version_package , package_path = package_path , output_type = output_type , language = language , language_variant = language_variant )