Module Expr Str Assign NameStore Str Import alias Import alias Import alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore Dict Str Str Str Str Str Str Assign NameStore ListLoad Str ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Assign AttributeStore NameLoad attr Call NameLoad Assign AttributeStore NameLoad attr BoolOpOr NameLoad Call NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore NameLoad attr Dict Assign AttributeStore NameLoad attr BoolOpOr NameLoad Call NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad For NameStore Call AttributeLoad NameLoad attr NameLoad body Assign NameStore SubscriptLoad NameLoad Slice BinOpAdd Call NameLoad NameLoad Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Dict Str Str Str Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Return Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str If Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str keyword Str Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list TryExcept body Assign SubscriptStore NameLoad Index AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call NameLoad NameLoad NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr body Pass Delete SubscriptDel NameLoad Index AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Str For NameStore Call AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad AttributeLoad NameLoad attr decorator_list Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Dict Str NameLoad For NameStore Call AttributeLoad NameLoad attr NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore NameLoad Assign NameStore SubscriptLoad NameLoad Slice BinOpAdd Call NameLoad NameLoad Num For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body If CompareGtE Call AttributeLoad NameLoad attr NameLoad Num body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad keyword NameLoad If Call AttributeLoad NameLoad attr Str body Expr Call NameLoad NameLoad Continue If Call AttributeLoad NameLoad attr Str body Continue If Call AttributeLoad NameLoad attr Str body Assign NameStore SubscriptLoad NameLoad Slice Num If CompareIn NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If BoolOpAnd NameLoad UnaryOpNot Call NameLoad NameLoad NameLoad body Continue Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad orelse Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If BoolOpAnd NameLoad UnaryOpNot Call NameLoad NameLoad NameLoad body Continue Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad Dict NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body If AttributeLoad NameLoad attr body Return Call AttributeLoad AttributeLoad NameLoad attr attr Str decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str If Call AttributeLoad NameLoad attr Str body Assign AttributeStore NameLoad attr NameLoad orelse Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore BinOpMod Str NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr NameLoad If UnaryOpNot NameLoad body Raise Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Num Assign NameStore BinOpAdd BinOpAdd NameLoad NameLoad Str For NameStore SubscriptLoad NameLoad Index Num body Assign NameStore Call AttributeLoad NameLoad attr NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign NameStore SubscriptLoad NameLoad Slice Num If BoolOpAnd NameLoad UnaryOpNot Call NameLoad NameLoad NameLoad body Continue Assign NameStore Call NameLoad NameLoad Assign SubscriptStore NameLoad Index SubscriptLoad NameLoad Index Num NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr Str BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list
N/A N/A Base library generator.

This module holds the base classes used for all code generators.
 N/A __author__ aiuto@google.com (Tony Aiuto) N/A datetime N/A os N/A re N/A StringIO N/A time N/A zipfile googleapis.codegen.django_helpers DjangoRenderTemplate googleapis.codegen.language_model LanguageModel googleapis.codegen.template_objects UseableInTemplates googleapis.codegen template_helpers googleapis.codegen.filesys files N/A _GENERATOR_INFORMATION N/A name version buildDate google-apis-code-generator 1.5.1 2015-03-24 N/A _SPECIAL_FILENAMES N/A app_yaml TemplateGenerator N/A object N/A N/A Base class for walking a template tree to generate output files.

  This class provides methods for processing template trees to produce output
  trees.
  * Provides a common base dictionary of variables for use in templates.
  * Callers can augment that with their own dictionary of variables.
  * Callers can provide a set of replacements to be made to file paths in
    the template tree
   __init__ N/A N/A self language_model options N/A None None N/A N/A N/A self _tool_info N/A ToolInformation N/A N/A self _options N/A options N/A dict N/A N/A self _template_dir N/A N/A N/A os path dirname __file__ N/A N/A self _surface_features N/A N/A N/A self _language_model N/A language_model N/A LanguageModel N/A language_model N/A N/A self N/A N/A N/A N/A self _language_model N/A property IncludeFileTree N/A N/A self path_to_tree package N/A N/A N/A Walk a file tree and copy files directly into an output package.

    Walks a file tree relative to the target language, copying all files
    found into an output package.

    Args:
      path_to_tree: (str) path relative to the language template directory
      package: (LibraryPackage) output package.
     N/A top_of_tree N/A N/A N/A os path join N/A self _template_dir path_to_tree N/A path N/A N/A files IterFiles top_of_tree N/A N/A relative_path N/A path N/A N/A N/A len top_of_tree 1 N/A N/A N/A package IncludeFile path relative_path N/A PathToTemplate N/A N/A self template_name N/A N/A N/A Returns the full path to a template. N/A N/A N/A N/A os path join N/A self _template_dir template_name N/A RenderTemplate N/A N/A self template_path context_dict N/A None N/A N/A Render a template.

    Renders a template with the standard dictionary of bindings.

    Args:
      template_path: (str) Full path to a template.
      context_dict: (dict) A dictionary to augment the standard template
        dictionary.
    Returns:
      (str) The fully rendered template string.
     N/A variables_dict N/A tool options template_dir features language_model N/A self _tool_info N/A self _options N/A self _template_dir N/A self _surface_features N/A self _language_model N/A context_dict N/A N/A N/A N/A variables_dict update context_dict N/A N/A DjangoRenderTemplate template_path variables_dict N/A RenderTemplateToFile N/A N/A self template_path context_dict package output_path N/A N/A N/A Render a template as a file in the output package.

    Args:
      template_path: (str) Full path to a template.
      context_dict: (dict) A dictionary to augment the standard template
        dictionary.
      package: (LibraryPackage) output package.
      output_path: (str) file path in the package.

    Returns:
      None
     N/A N/A output_dir file_name N/A N/A N/A os path split output_path WriteFileInPackage N/A N/A path content N/A N/A N/A Writes content to a path in our current package writer. N/A N/A isinstance content unicode N/A N/A content N/A N/A content encode utf-8 errors ignore N/A out N/A N/A package StartFile N/A N/A N/A os path join output_dir path N/A N/A N/A out write content N/A N/A N/A package EndFile N/A N/A N/A N/A N/A context_dict N/A N/A template_helpers FILE_WRITER WriteFileInPackage N/A content N/A N/A self RenderTemplate template_path context_dict N/A N/A WriteFileInPackage file_name content N/A N/A N/A N/A template_helpers Halt N/A N/A N/A N/A context_dict N/A N/A template_helpers FILE_WRITER N/A WalkTemplateTree N/A N/A self path_to_tree path_replacements list_replacements variables package file_filter N/A None N/A N/A Walk a file tree and copy files or process templates.

    Walks a file tree to write on output package, running all files ending in
    ".tmpl" through the template renderer, and directly copying all the other
    files. While doing so, the caller may provide for some transformations of
    the file path:
    1. They can pass in a dictionary of string literals to replacements which
       are applied directly to the file path. E.g. '___package___' might be
       replaced by a path snippet of the form 'com/google/tasks'
    2. They can pass a dictionary of strings literals which, if found in the
       file path trigger the evaluation of thats template against a list of
       CodeObjects, with a distinct output file being generated for each object.
       E.g. The ApiLibraryGenerator uses the pattern  '___models_className___'
       to generate a set of files, each named by its className member.

    Args:
      path_to_tree: (str) path relative to the language template directory.
      path_replacements: (dict) dict holding elements which should be replaced
        if found in a path.
      list_replacements: (dict) dict holding elements which should be replaced
        by many files when found in a path. The keys of the dict are strings
        to be found in a path. The values are a tuple of
           (name_to_bind, [list of code objects])
        where name_to_bind is a variable name which will be bound to each
        successive code object during template evaluation. See the
        GenerateListOfFiles method for more details about name expansion.
      variables: (dict) The dictionary of variable replacements to pass to the
         templates.
      package: (LibraryPackage) output package.
      file_filter: (func) method to allow the caller to filter files included
         by name. The method is called with 2 arguments, the template file path
         and the path after all path replacements are done.
     ExpandZipFile N/A N/A path N/A N/A N/A Expand a zip file found in the template tree.

      Args:
        path: Path to file, relative to top of template tree.
       N/A full_path N/A N/A N/A os path join N/A self _template_dir path N/A zip_slurp N/A N/A files GetFileContents full_path N/A archive N/A N/A zipfile ZipFile N/A N/A StringIO StringIO zip_slurp r N/A info N/A N/A archive infolist N/A N/A N/A N/A package WriteDataAsFile N/A N/A archive read N/A info filename N/A N/A N/A os path join relative_path N/A info filename N/A N/A top_of_tree N/A N/A N/A os path normpath N/A N/A N/A os path join N/A self _template_dir path_to_tree N/A N/A N/A variables update N/A template_dir top_of_tree N/A path N/A N/A files IterFiles top_of_tree N/A N/A N/A root file_name N/A N/A N/A os path split path N/A template_path file_name N/A relative_path N/A root N/A N/A N/A len top_of_tree 1 N/A N/A path_item replacement N/A N/A path_replacements iteritems N/A N/A relative_path N/A N/A relative_path replace path_item replacement N/A N/A path_item replacement N/A N/A path_replacements iteritems N/A N/A file_name N/A N/A file_name replace path_item replacement N/A full_template_path N/A N/A N/A os path join relative_path template_path N/A N/A path_item call_info N/A N/A list_replacements iteritems N/A N/A N/A N/A N/A file_name find path_item 0 N/A N/A N/A N/A self GenerateListOfFiles path_item call_info path relative_path file_name variables package file_filter file_filter N/A N/A N/A file_name startswith ___unzip___ N/A N/A N/A ExpandZipFile path N/A N/A N/A N/A file_name startswith _ N/A N/A N/A N/A N/A file_name endswith .tmpl N/A N/A name_in_zip N/A file_name N/A -5 N/A N/A name_in_zip _SPECIAL_FILENAMES N/A N/A name_in_zip N/A N/A name_in_zip replace _ . N/A full_output_path N/A N/A N/A os path join relative_path name_in_zip N/A N/A file_filter N/A N/A file_filter full_template_path full_output_path N/A N/A N/A N/A N/A self RenderTemplateToFile path variables package full_output_path N/A N/A full_output_path N/A N/A N/A os path join relative_path file_name N/A N/A file_filter N/A N/A file_filter full_template_path full_output_path N/A N/A N/A N/A N/A package IncludeFile path full_output_path N/A GeneratePackage N/A N/A self package_writer N/A N/A N/A Generate the package.

    Args:
      package_writer: (LibraryPackage) output package
     N/A N/A NotImplementedError GeneratePackage must be implemented by all subclasses N/A DefaultGeneratePackage N/A N/A self package_writer path_replacements variables N/A N/A N/A Default operations to generate the package.

    Do all the default operations for generating a package.
    1. Walk the template tree to generate the source.
    2. Optionally copy in dependencies

    This is a utility method intended for subclasses of TemplateGenerator, so
    that they may implement the bulk of GeneratePackage by calling this.

    Args:
      package_writer: (LibraryPackage) output package.
      path_replacements: (dict) dict holding elements which should be replaced
         if found in a path.
      variables: (dict) The dictionary of variable replacements to pass to the
         templates.
     N/A N/A N/A self WalkTemplateTree templates path_replacements N/A variables package_writer N/A SetFeatures N/A N/A self surface_features N/A N/A N/A Sets the dict to be used for the 'features' variable in templates. N/A N/A self _surface_features surface_features N/A features N/A N/A self N/A N/A N/A N/A self _surface_features N/A property features N/A N/A self surface_features N/A N/A N/A N/A self _surface_features surface_features N/A N/A features setter language_version N/A N/A self N/A N/A N/A N/A self _surface_features N/A N/A N/A N/A N/A self _surface_features get releaseVersion N/A property SetTemplateDir N/A N/A self template_dir N/A N/A N/A Sets the template directory tree to use for WalkTemplateTree.

    Args:
      template_dir: (str) Path to template tree. If it is an absolute path it
        will be used directly. If relative, it is taken relative to the source
        tree.
     N/A N/A N/A template_dir startswith / N/A N/A N/A self _template_dir template_dir N/A N/A N/A self _template_dir N/A N/A N/A os path join N/A self _template_dir template_dir N/A GenerateListOfFiles N/A N/A self path_prefix call_info template_path relative_path template_file_name variables package file_filter N/A None N/A N/A Generate many output files from a template.

    This method blends together a list of CodeObjects (from call_info) with
    the template_file_name to produce an output file for each of the elements
    in the list. The names for each file are derived from a template variable
    of each element.

    Args:
      path_prefix: (str) The piece of path which triggers the replacement.
      call_info: (list) ['name to bind', [list of CodeObjects]]
      template_path: (str) The path of the template file.
      relative_path: (str) The relative path of the output file in the package.
      template_file_name: (str) the file name of the template for this list.
        The file name must contain the form '{path_prefix}{variable_name}___'
        (without the braces). The pair is replaced by the value of variable_name
        from each successive element of the call list.
      variables: (dict) The dictionary of variable replacements to pass to the
         templates.
      package: (LibraryWriter) The output package stream to write to.
      file_filter: (func) See WalkTemplateTree for a description.

    Raises:
      ValueError: If the template_file_name does not match the call_info data.
     N/A path_and_var_regex N/A %s([a-z][A-Za-z]*)___ path_prefix N/A match_obj N/A N/A N/A N/A re compile path_and_var_regex match template_file_name N/A N/A match_obj N/A N/A N/A ValueError file names which match path item for GenerateListOfFiles must contain a variable for substitution. E.g. "___models_codeName___" N/A variable_name N/A N/A match_obj group 1 N/A file_name_piece_to_replace N/A N/A path_prefix variable_name ___ N/A element N/A call_info N/A 1 N/A N/A file_name N/A N/A template_file_name replace file_name_piece_to_replace N/A N/A element values N/A variable_name N/A name_in_zip N/A file_name N/A -5 N/A N/A file_filter N/A N/A file_filter None name_in_zip N/A N/A N/A d N/A dict variables N/A N/A d N/A N/A call_info N/A 0 element N/A N/A N/A self RenderTemplateToFile template_path d package N/A N/A N/A os path join relative_path name_in_zip N/A N/A ToolInformation N/A UseableInTemplates N/A N/A Defines information about this generator tool itself. __init__ N/A N/A self N/A N/A N/A N/A N/A N/A super ToolInformation self __init__ _GENERATOR_INFORMATION N/A now N/A N/A N/A datetime datetime utcnow N/A N/A N/A self SetTemplateValue runDate N/A %4d-%02d-%02d N/A N/A now year N/A now month N/A now day N/A N/A N/A self SetTemplateValue runTime N/A %02d:%02d:%02d UTC N/A N/A now hour N/A now minute N/A now second N/A N/A