Skip to content

Commit 8fc4233

Browse files
author
rootware
committed
working unredaction
1 parent 552c8ed commit 8fc4233

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pyredactkit/unredact.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import sys
3+
import os
34

45

56
class Unredactor:
@@ -42,14 +43,17 @@ def unredact(self, redacted_file=str, lookup_file=str):
4243
Returns:
4344
Writes unredacted_file.txt with original unmasked data.
4445
"""
46+
count = 0
4547
with open(redacted_file, encoding="utf-8") as redacted_target:
4648
try:
4749
with open(lookup_file, encoding="utf-8") as lookup_target:
48-
with open(f"unredacted_{redacted_file}", "w", encoding="utf-8") as write_file:
49-
content = json.load(lookup_target)
50+
content = json.load(lookup_target)
51+
with open(f"unredacted_{os.path.basename(redacted_file)}", "w", encoding="utf-8") as write_file:
5052
for line in redacted_target:
5153
line = self.replace_all(line, content)
5254
write_file.write(line)
55+
print(
56+
f"[ + ] Unredacted results saved to unredacted_{os.path.basename(redacted_file)}")
5357
except FileNotFoundError:
5458
sys.exit(f"[ - ] {lookup_file} file was not found")
5559
except json.JSONDecodeError:

0 commit comments

Comments
 (0)