12345678910111213141516171819202122232425262728 |
- def anonymize_one(self, column, delete: bool, pattern: AnonymizationPattern = None):
- if column is None:
- return Logger.log_none_type_error('column')
- Logger.log_info_table_manipulation_started(self.filename, f'Anonymize One ({column})')
- # delete column in every dataset if found
- error_count = 0
- if delete:
- for ds in self.datasets:
- out = ds.delete_column(column)
- if out < 1:
- error_count += 1
- self.remove_columnnames([column])
- else:
- # if column is not deleted: generate a value for column, random or by pattern
- if pattern is None:
- for ds in self.datasets:
- out = ds.set_columnvalue_random(column)
- if out < 1:
- error_count += 1
- else:
- for ds in self.datasets:
- out = ds.set_columnvalue_by_pattern(column, pattern)
- if out < 1:
- error_count += 1
- Logger.log_info_table_manipulation_finished(error_count)
- return error_count
|