parameters: (self, py_type)
docstring: Evaluate the value of the variable block and decide its type.
  
          Returns:
              None
docstring_summary: Evaluate the value of the variable block and decide its type.
docstring_tokens: Evaluate the value of the variable block and decide its type .
function: def format_expr(self, py_type):
          """
          Evaluate the value of the variable block and decide its type.
  
          Returns:
              None
          """
          value = self.params['value'].value
          self.cpp_templates = copy.copy(self.orig_cpp_templates)
  
          # Determine the lvalue type
          def get_type(element, _vtype):
              evaluated = None
              try:
                  evaluated = ast.literal_eval(element)
                  if _vtype == None:
                      _vtype = type(evaluated)
              except ValueError or SyntaxError as excp:
                  if _vtype == None:
                      print(excp)
  
              if _vtype in [int, float, bool, list, dict, str, complex]:
                  if _vtype == (int or long):
                      return 'int'
  
                  if _vtype == float:
                      return 'double'
  
                  if _vtype == bool:
                      return 'bool'
  
                  if _vtype == complex:
                      return 'gr_complex'
  
                  if _vtype == list:
                      try:
                          # For container types we must also determine the type of the template parameter(s)
                          return 'std::vector<' + get_type(str(evaluated[0]), type(evaluated[0])) + '>'
  
                      except IndexError:  # empty list
                          return 'std::vector<std::string>'
  
                  if _vtype == dict:
                      try:
                          # For container types we must also determine the type of the template parameter(s)
                          key = list(evaluated)[0]
                          val = list(evaluated.values())[0]
                          return 'std::map<' + get_type(str(key), type(key)) + ', ' + get_type(str(val), type(val)) + '>'
  
                      except IndexError:  # empty dict
                          return 'std::map<std::string, std::string>'
  
                  else:
                      return 'std::string'
  
          # Get the lvalue type
          self.vtype = get_type(value, py_type)
  
          # The r-value for these types must be transformed to create legal C++ syntax.
          if self.vtype in ['bool', 'gr_complex'] or 'std::map' in self.vtype or 'std::vector' in self.vtype:
              evaluated = ast.literal_eval(value)
              self.cpp_templates['var_make'] = self.cpp_templates['var_make'].replace(
                  '${value}', self.get_cpp_value(evaluated))
  
          if 'string' in self.vtype:
              self.cpp_templates['includes'].append('#include <string>')
function_tokens: def format_expr ( self , py_type ) : value = self . params [ 'value' ] . value self . cpp_templates = copy . copy ( self . orig_cpp_templates ) # Determine the lvalue type def get_type ( element , _vtype ) : evaluated = None try : evaluated = ast . literal_eval ( element ) if _vtype == None : _vtype = type ( evaluated ) except ValueError or SyntaxError as excp : if _vtype == None : print ( excp ) if _vtype in [ int , float , bool , list , dict , str , complex ] : if _vtype == ( int or long ) : return 'int' if _vtype == float : return 'double' if _vtype == bool : return 'bool' if _vtype == complex : return 'gr_complex' if _vtype == list : try : # For container types we must also determine the type of the template parameter(s) return 'std::vector<' + get_type ( str ( evaluated [ 0 ] ) , type ( evaluated [ 0 ] ) ) + '>' except IndexError : # empty list return 'std::vector<std::string>' if _vtype == dict : try : # For container types we must also determine the type of the template parameter(s) key = list ( evaluated ) [ 0 ] val = list ( evaluated . values ( ) ) [ 0 ] return 'std::map<' + get_type ( str ( key ) , type ( key ) ) + ', ' + get_type ( str ( val ) , type ( val ) ) + '>' except IndexError : # empty dict return 'std::map<std::string, std::string>' else : return 'std::string' # Get the lvalue type self . vtype = get_type ( value , py_type ) # The r-value for these types must be transformed to create legal C++ syntax. if self . vtype in [ 'bool' , 'gr_complex' ] or 'std::map' in self . vtype or 'std::vector' in self . vtype : evaluated = ast . literal_eval ( value ) self . cpp_templates [ 'var_make' ] = self . cpp_templates [ 'var_make' ] . replace ( '${value}' , self . get_cpp_value ( evaluated ) ) if 'string' in self . vtype : self . cpp_templates [ 'includes' ] . append ( '#include <string>' )