parameters: (self, init)
docstring: Translate initialisation statement AST
          Args:
              init: object like [typeAST, identifierAST, exprAST],
                    [typeAST, identifierAST, argumentListAST], etc.
docstring_summary: Translate initialisation statement AST
          Args:
              init: object like [typeAST, identifierAST, exprAST],
                    [typeAST, identifierAST, argumentListAST], etc.
docstring_tokens: Translate initialisation statement AST Args : init : object like [ typeAST identifierAST exprAST ] [ typeAST identifierAST argumentListAST ] etc .
function: def translateInit(self, init):
          """ Translate initialisation statement AST
          Args:
              init: object like [typeAST, identifierAST, exprAST],
                    [typeAST, identifierAST, argumentListAST], etc.
          """
          typeDict = init[0]
          typeString = self.translateType(typeDict)
          nameString = init[1]["Identifier"]
          initialisation = init[2]
          typeKey = list(typeDict.keys())[0]
  
          self.variableTypes[nameString] = typeDict
  
          # python2/3 safe dictionary keys
          if list(initialisation.keys())[0] == "Expr":
              template = Template(self.targetDict["Init"]["Copy"])
              result = self.translateExpr(
                  initialisation["Expr"], returnKwargs=True
              )
              exprString = result
              kwargs = []
              if isinstance(result, tuple):
                  exprString, kwargs = result
  
              kwargsString = self.translateKwargs(
                  kwargs, nameString, typeString
              )
              return template.substitute(name=nameString,
                                         typeName=typeString,
                                         expr=exprString,
                                         kwargs=kwargsString)
          elif list(initialisation.keys())[0] == "ArgumentList":
  
              template = Template(self.targetDict["Init"]["Construct"])
  
              # Optional custom SGType construction
              if typeKey == "ShogunSGType" and init[0][typeKey] in self.targetDict["Init"]:
                  template = Template(self.targetDict["Init"][init[0][typeKey]])
  
              argsString, kwargs = self.translateArgumentList(
                  initialisation, returnKwargs=True
              )
  
              normalArgs = [
                  arg for arg in initialisation["ArgumentList"]
                      if not "KeywordArgument" in arg
              ]
              kwargsString = self.translateKwargs(
                  kwargs, nameString, typeString,
                  argsGtZero=len(normalArgs) > 0
              )
              return template.substitute(name=nameString,
                                         typeName=typeString,
                                         arguments=argsString,
                                         kwargs=kwargsString)
function_tokens: def translateInit ( self , init ) : typeDict = init [ 0 ] typeString = self . translateType ( typeDict ) nameString = init [ 1 ] [ "Identifier" ] initialisation = init [ 2 ] typeKey = list ( typeDict . keys ( ) ) [ 0 ] self . variableTypes [ nameString ] = typeDict # python2/3 safe dictionary keys if list ( initialisation . keys ( ) ) [ 0 ] == "Expr" : template = Template ( self . targetDict [ "Init" ] [ "Copy" ] ) result = self . translateExpr ( initialisation [ "Expr" ] , returnKwargs = True ) exprString = result kwargs = [ ] if isinstance ( result , tuple ) : exprString , kwargs = result kwargsString = self . translateKwargs ( kwargs , nameString , typeString ) return template . substitute ( name = nameString , typeName = typeString , expr = exprString , kwargs = kwargsString ) elif list ( initialisation . keys ( ) ) [ 0 ] == "ArgumentList" : template = Template ( self . targetDict [ "Init" ] [ "Construct" ] ) # Optional custom SGType construction if typeKey == "ShogunSGType" and init [ 0 ] [ typeKey ] in self . targetDict [ "Init" ] : template = Template ( self . targetDict [ "Init" ] [ init [ 0 ] [ typeKey ] ] ) argsString , kwargs = self . translateArgumentList ( initialisation , returnKwargs = True ) normalArgs = [ arg for arg in initialisation [ "ArgumentList" ] if not "KeywordArgument" in arg ] kwargsString = self . translateKwargs ( kwargs , nameString , typeString , argsGtZero = len ( normalArgs ) > 0 ) return template . substitute ( name = nameString , typeName = typeString , arguments = argsString , kwargs = kwargsString )