original_docstring:  Parse a global index clause and return a GlobalIndex 
docstring: Parse a global index clause and return a GlobalIndex
docstring_tokens: Parse a global index clause and return a GlobalIndex
code: def _parse_global_index(self, clause, attrs):
          """ Parse a global index clause and return a GlobalIndex """
          index_type, name = clause[:2]
          name = resolve(name)
  
          def get_key(field, data_type=None):
              """ Get or set the DynamoKey from the field name """
              if field in attrs:
                  key = attrs[field]
                  if data_type is not None:
                      if TYPES[data_type] != key.data_type:
                          raise SyntaxError(
                              "Key %r %s already declared with type %s" % field,
                              data_type,
                              key.data_type,
                          )
              else:
                  if data_type is None:
                      raise SyntaxError("Missing data type for %r" % field)
                  key = DynamoKey(field, data_type=TYPES[data_type])
                  attrs[field] = key
              return key
  
          g_hash_key = get_key(*clause.hash_key)
          g_range_key = None
          # For some reason I can't get the throughput section to have a name
          # Use an index instead
          tp_index = 3
          if clause.range_key:
              tp_index += 1
              g_range_key = get_key(*clause.range_key)
          if clause.include_vars:
              tp_index += 1
          kwargs = {}
          if tp_index < len(clause):
              throughput = clause[tp_index]
              kwargs["throughput"] = Throughput(*map(resolve, throughput))
          index_type = clause.index_type[0]
          if index_type in ("ALL", "INDEX"):
              factory = GlobalIndex.all
          elif index_type == "KEYS":
              factory = GlobalIndex.keys
          elif index_type == "INCLUDE":
              factory = GlobalIndex.include
              if not clause.include_vars:
                  raise SyntaxError("Include index %r missing include fields" % name)
              kwargs["includes"] = [resolve(v) for v in clause.include_vars]
          return factory(name, g_hash_key, g_range_key, **kwargs)
code_tokens: def _parse_global_index ( self , clause , attrs ) : index_type , name = clause [ : 2 ] name = resolve ( name ) def get_key ( field , data_type = None ) : """ Get or set the DynamoKey from the field name """ if field in attrs : key = attrs [ field ] if data_type is not None : if TYPES [ data_type ] != key . data_type : raise SyntaxError ( "Key %r %s already declared with type %s" % field , data_type , key . data_type , ) else : if data_type is None : raise SyntaxError ( "Missing data type for %r" % field ) key = DynamoKey ( field , data_type = TYPES [ data_type ] ) attrs [ field ] = key return key g_hash_key = get_key ( * clause . hash_key ) g_range_key = None tp_index = 3 if clause . range_key : tp_index += 1 g_range_key = get_key ( * clause . range_key ) if clause . include_vars : tp_index += 1 kwargs = { } if tp_index < len ( clause ) : throughput = clause [ tp_index ] kwargs [ "throughput" ] = Throughput ( * map ( resolve , throughput ) ) index_type = clause . index_type [ 0 ] if index_type in ( "ALL" , "INDEX" ) : factory = GlobalIndex . all elif index_type == "KEYS" : factory = GlobalIndex . keys elif index_type == "INCLUDE" : factory = GlobalIndex . include if not clause . include_vars : raise SyntaxError ( "Include index %r missing include fields" % name ) kwargs [ "includes" ] = [ resolve ( v ) for v in clause . include_vars ] return factory ( name , g_hash_key , g_range_key , ** kwargs )
short_docstring: Parse a global index clause and return a GlobalIndex
short_docstring_tokens: Parse a global index clause and return a GlobalIndex
comment: """ Parse a global index clause and return a GlobalIndex """$SEP$""" Get or set the DynamoKey from the field name """$SEP$# For some reason I can't get the throughput section to have a name$SEP$# Use an index instead