aboutsummaryrefslogtreecommitdiffstats
path: root/obfuscator/obfuscate.py
diff options
context:
space:
mode:
authorAlex <git@ajschof.me>2025-02-19 15:58:28 +0000
committerGitHub <noreply@github.com>2025-02-19 15:58:28 +0000
commit4066bf747e1e4c938526957c119f3f1485ee251e (patch)
tree9a1e95f4ccbdd04e19d67a6c13641a19c4d4f3e0 /obfuscator/obfuscate.py
parentf24955044c4c05e37aba4efb505ec63b44113912 (diff)
parent5402af2c7198a685a57a05e29a869e1e72a6b877 (diff)
downloadgdpr-obfuscator-4066bf747e1e4c938526957c119f3f1485ee251e.tar.gz
gdpr-obfuscator-4066bf747e1e4c938526957c119f3f1485ee251e.zip
Merge pull request #8 from ajschofield/refining-phase
mostly minor changes (fixing things up)
Diffstat (limited to 'obfuscator/obfuscate.py')
-rw-r--r--obfuscator/obfuscate.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/obfuscator/obfuscate.py b/obfuscator/obfuscate.py
index 3f589cb..cd12b6d 100644
--- a/obfuscator/obfuscate.py
+++ b/obfuscator/obfuscate.py
@@ -1,8 +1,7 @@
from typing import List, Dict
from obfuscator.logger import get_logger
-# Create the logger
-logger = get_logger("Obfuscator")
+logger = get_logger("OBFUSCATE")
def obfuscate(
@@ -12,14 +11,15 @@ def obfuscate(
A function to obfuscate PII fields in a list of dictionaries, replacing
sensitive values with a string of asterisks.
"""
- # If no data is provided, log a message and return an empty list
if not data:
- logger.info("No valid data was provided to obfuscate")
+ logger.error(
+ "Invalid or empty data was provided to obfuscate. Returning empty list."
+ )
return []
+ if not pii_fields:
+ logger.error("No PII fields provided to obfuscate. Returning data unchanged.")
+ return data
- # Obfuscate the PII fields in each record using a list/dict comprehension
- # This code is good but makes debugging a bit tricky. I may consider
- # breaking it down into a for loop.
return [
{k: ("***" if k in pii_fields else v) for k, v in record.items()}
for record in data
git.ajschof.me — hosted by ajschofield — powered by cgit