Beispiel #1
0
 def __getitem__(self, index):
     """
     Get the Field object at the specified index, which may be either
     an integer or the Field's string label.  Note that the Field object
     is not the field's _value_ -- use the `get` method instead to
     retrieve the value (e.g. an integer) instead of a Field instance.
     """
     if isinstance(index, str):
         i = self.index(index)
     elif 0 <= index < self.num_fields:
         i = index
     else:
         raise IndexError('Index out of range when accessing field in a feature: %s.' % index)
     return Field(self, i)
Beispiel #2
0
 def __getitem__(self, index):
     """
     Gets the Field object at the specified index, which may be either
     an integer or the Field's string label.  Note that the Field object
     is not the field's _value_ -- use the `get` method instead to
     retrieve the value (e.g. an integer) instead of a Field instance.
     """
     if isinstance(index, six.string_types):
         i = self.index(index)
     else:
         if index < 0 or index > self.num_fields:
             raise OGRIndexError('index out of range')
         i = index
     return Field(self, i)
Beispiel #3
0
        Gets the Field object at the specified index, which may be either
=======
        Get the Field object at the specified index, which may be either
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        an integer or the Field's string label.  Note that the Field object
        is not the field's _value_ -- use the `get` method instead to
        retrieve the value (e.g. an integer) instead of a Field instance.
        """
<<<<<<< HEAD
        if isinstance(index, six.string_types):
            i = self.index(index)
        else:
            if index < 0 or index > self.num_fields:
                raise OGRIndexError('index out of range')
            i = index
        return Field(self, i)

    def __iter__(self):
        "Iterates over each field in the Feature."
        for i in range(self.num_fields):
            yield self[i]

    def __len__(self):
        "Returns the count of fields in this feature."
=======
        if isinstance(index, str):
            i = self.index(index)
        elif 0 <= index < self.num_fields:
            i = index
        else:
            raise IndexError('Index out of range when accessing field in a feature: %s.' % index)