Skip to content

Commit 74a787c

Browse files
author
rootware
committed
adding this to work on refactoring later
1 parent 7d6c5a4 commit 74a787c

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

pyredactkit/runner.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"""
55

66
import argparse
7+
from genericpath import isdir
8+
9+
from numpy import full
710

811
from pyredactkit.core_redactor import CoreRedactorEngine
912
from pyredactkit.custom_redactor import CustomRedactorEngine
@@ -51,20 +54,19 @@ def arg_helper() -> argparse.Namespace:
5154
)
5255
parser.add_argument(
5356
"text",
54-
type=str,
5557
help="""Redact sensitive data of a sentence from command prompt.""",
5658
nargs="*"
5759
)
5860
if len(sys.argv) == 1:
5961
print(help_menu)
6062
parser.print_help(sys.stderr)
6163
sys.exit(1)
62-
parser.add_argument(
63-
"-f",
64-
"--file",
65-
nargs="+",
66-
help="""Path of a file or a directory of files."""
67-
)
64+
# parser.add_argument(
65+
# "-f",
66+
# "--file",
67+
# nargs="+",
68+
# help="""Path of a file or a directory of files."""
69+
# )
6870
parser.add_argument(
6971
"-u",
7072
"--unredact",
@@ -109,9 +111,14 @@ def arg_helper() -> argparse.Namespace:
109111

110112
def execute_file_arg() -> None:
111113
args = arg_helper()
112-
full_paths = [os.path.join(os.getcwd(), path) for path in args.file]
113-
files = set()
114+
print(args.text)
114115

116+
if not os.path.isfile(args.text[0]) or not os.path.isdir(args.text[0]):
117+
redact_obj.process_text(args.text)
118+
119+
full_paths = [os.path.join(os.getcwd(), path) for path in args.text]
120+
print(full_paths)
121+
files = set()
115122
for path in full_paths:
116123
if os.path.isfile(path):
117124
file_name, file_ext = os.path.splitext(path)
@@ -131,16 +138,18 @@ def execute_file_arg() -> None:
131138
unredact_obj.unredact(file, args.unredact)
132139
else:
133140
redact_obj.process_core_file(file)
141+
134142

135143

136144
def main():
137145
print(banner)
138146

139147
args = arg_helper()
140-
if args.file or (args.file and args.dirout):
141-
execute_file_arg()
142-
else:
143-
redact_obj.process_text(args.text)
148+
execute_file_arg()
149+
# if args.file or (args.file and args.dirout):
150+
# execute_file_arg()
151+
# else:
152+
# redact_obj.process_text(args.text)
144153

145154

146155
def api_identify_sensitive_data(text: str) -> list:

0 commit comments

Comments
 (0)