Enhance the new method, remove single return method

This commit is contained in:
Alireza Adli 2024-08-16 09:47:08 -04:00
parent fe03556e7c
commit 47837f073a

View File

@ -30,20 +30,18 @@ class ScrubLayer:
def cell_value(self, fid, field_name): def cell_value(self, fid, field_name):
return self.layer.getFeature(fid)[field_name] return self.layer.getFeature(fid)[field_name]
def cell_field_field(self, field_name, field_name_value, field_field_value): def cell_field_fields(
expression = QgsExpression(f'{field_name} = {field_name_value}') self,
request = QgsFeatureRequest(expression) field_name, field_name_value, field_field_value,
features = self.layer.getFeatures(request) return_one_value=False):
for feature in features:
return feature[field_field_value]
def cell_field_fields(self, field_name, field_name_value, field_field_value):
expression = QgsExpression(f'{field_name} = {field_name_value}') expression = QgsExpression(f'{field_name} = {field_name_value}')
request = QgsFeatureRequest(expression) request = QgsFeatureRequest(expression)
features = self.layer.getFeatures(request) features = self.layer.getFeatures(request)
field_field_values = [] field_field_values = []
for feature in features: for feature in features:
field_field_values.append(feature[field_field_value]) field_field_values.append(feature[field_field_value])
if return_one_value and field_field_values:
return field_field_values[0]
return field_field_values return field_field_values
def load_layer(self): def load_layer(self):