neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/43516?usp=email )
Change subject: saip/batch: add blacklist to to_csv_rows() ......................................................................
saip/batch: add blacklist to to_csv_rows()
Allow calling code to mute specific parameters from an output CSV.
For example, the SUCI CalcInfo data should be identical for all profiles of a batch, and is also very long data. After this patch, an application can name specific parameters to omit from an output CSV.
Change-Id: I5e567e59a007cf4b5d75a4dcea5371ff4404bf24 Jenkins: skip-card-test --- M pySim/esim/saip/batch.py 1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/16/43516/1
diff --git a/pySim/esim/saip/batch.py b/pySim/esim/saip/batch.py index 338c5d1..5939d65 100644 --- a/pySim/esim/saip/batch.py +++ b/pySim/esim/saip/batch.py @@ -324,12 +324,15 @@
return batch_audit
- def to_csv_rows(self, headers=True, sort_key=None): + def to_csv_rows(self, headers=True, sort_key=None, column_blacklist=None): """generator that yields all audits' values as rows, useful feed to a csv.writer.""" columns = set() for audit in self: columns.update(audit.keys())
+ if column_blacklist: + columns.difference_update(set(column_blacklist)) + columns = tuple(sorted(columns, key=sort_key))
if headers: