<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getFeatureByAttribute(self, fieldname, attribute):
 """ get features by field attribute Parameters fieldname: str the name of the queried field attribute: int or str the field value of interest Returns ------- list of :osgeo:class:`ogr.Feature` or :osgeo:class:`ogr.Feature` the feature(s) matching the search query """

        attr = attribute.strip() if isinstance(attribute, str) else attribute
        if fieldname not in self.fieldnames:
            raise KeyError('invalid field name')
        out = []
        self.layer.ResetReading()
        for feature in self.layer:
            field = feature.GetField(fieldname)
            field = field.strip() if isinstance(field, str) else field
            if field == attr:
                out.append(feature.Clone())
        self.layer.ResetReading()
        if len(out) == 0:
            return None
        elif len(out) == 1:
            return out[0]
        else:
            return out