Skip to content

Commit 552c8ed

Browse files
author
rootware
committed
still debugging file not found exception
1 parent b139516 commit 552c8ed

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"module": "pyredactkit",
1212
"justMyCode": true,
13-
"args": ["redacted_attempts.log", "-u", ".hashshadow_attempts.log.json"]
13+
"args": ["redacted_attempts.log", "-u", "hashshadow_attempts.json"]
1414
}
1515
]
1616
}

pyredactkit/pyredactkit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import argparse
7+
from ast import arg
78
from pyredactkit.redact import Redactor
89
from pyredactkit.unredact import Unredactor
910
import os
@@ -106,7 +107,7 @@ def main():
106107
redact_obj.process_file(file, args.redactiontype, args.dirout)
107108
redact_obj.process_report(file, args.dirout)
108109
elif args.unredact:
109-
unredact_obj.unredact(args.unredact, file)
110+
unredact_obj.unredact(file, args.unredact)
110111
else:
111112
redact_obj.process_file(file)
112113
redact_obj.process_report(file)

pyredactkit/unredact.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ def replace_all(self, text, dictionary):
3232
text = text.replace(k, v)
3333
return text
3434

35-
def unredact(self, lookup_file, redacted_file):
35+
def unredact(self, redacted_file=str, lookup_file=str):
3636
"""Function to unredact masked data and produces original unredacted data.
3737
Args:
38-
lookup_file (str): Name of the file to look up key value map of masked data and original data.
3938
redacted_file (str): Name of the redacted file
39+
lookup_file (str): Name of the file to look up key value map of masked data and original data.
40+
4041
4142
Returns:
4243
Writes unredacted_file.txt with original unmasked data.

test/unredact.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import fileinput
77

88

9-
def unredact(lookup_file, redacted_file):
9+
def unredact(redacted_file, lookup_file):
1010
with open(redacted_file, encoding="utf-8") as redacted_target:
1111
try:
1212
with open(lookup_file, encoding="utf-8") as lookup_target:
13+
content = json.load(lookup_target)
1314
with open("unredacted_file.txt", "w", encoding="utf-8") as write_file:
14-
content = json.load(lookup_target)
1515
for line in redacted_target:
1616
line = replace_all(line, content)
1717
write_file.write(line)
@@ -27,7 +27,7 @@ def replace_all(text, dictionary):
2727
return text
2828

2929

30-
unredact(".hashshadow.json", "redacted_test.txt")
30+
unredact("redacted_test.txt", ".hashshadow.json")
3131

3232

3333
# with fileinput.FileInput("redacted_test.txt", inplace=True, backup='.bak') as file:

0 commit comments

Comments
 (0)