(self, fname)
Write enum definitions.
Write enum definitions.
Write enum definitions .
def write_enums(self, fname):
    """Write enum definitions."""
    with open(fname, "w") as f:
      imports = [
          "import collections",
          "# pylint: disable=invalid-name",
          "# pylint: disable=line-too-long",
      ]
      f.write(self.make_header(imports))
      f.write(codegen_util.comment_line("Enums"))
      for enum_name, members in self.enums_dict.items():
        fields = ["\"{}\"".format(name) for name in members.keys()]
        values = [str(value) for value in members.values()]
        s = textwrap.dedent("""
        {0} = collections.namedtuple(
            "{0}",
            [{1}]
        )({2})
        """).format(enum_name, ",\n     ".join(fields), ", ".join(values))
        f.write(s)
      f.write("\n" + codegen_util.comment_line("End of generated code"))
def write_enums ( self , fname ) : with open ( fname , "w" ) as f : imports = [ "import collections" , "# pylint: disable=invalid-name" , "# pylint: disable=line-too-long" , ] f . write ( self . make_header ( imports ) ) f . write ( codegen_util . comment_line ( "Enums" ) ) for enum_name , members in self . enums_dict . items ( ) : fields = [ "\"{}\"" . format ( name ) for name in members . keys ( ) ] values = [ str ( value ) for value in members . values ( ) ] s = textwrap . dedent ( """
        {0} = collections.namedtuple(
            "{0}",
            [{1}]
        )({2})
        """ ) . format ( enum_name , ",\n     " . join ( fields ) , ", " . join ( values ) ) f . write ( s ) f . write ( "\n" + codegen_util . comment_line ( "End of generated code" ) )