Skip to content
6 changes: 6 additions & 0 deletions src/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def parse(args):
help="Whether to get only passed build reports",
)

parser.add_argument(
"--record",
required=False,
type=str,
help="Record the analysis to a separate file",
)
# parse the arguments and return the finished result
arguments_finished = parser.parse_args(args)
return arguments_finished
43 changes: 35 additions & 8 deletions textmining.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
"""CLI Entry point"""
import json
import sys
import os

import src.analyzer as az
import src.summarizer as sz
import src.arguments as arg

from src import analyzer as az
from src import summarizer as sz
from src import arguments

if __name__ == "__main__":
tm_arguments = arguments.parse(sys.argv[1:])

# Making a new directory to store the files.
directory = "records"
path = os.path.join(directory)
try:
os.mkdir(path)
except OSError as error:
print(error)

tm_arguments = arg.parse(sys.argv[1:])
directory = tm_arguments.directory
function = tm_arguments.function
if function == "frequency":
print(az.dir_frequency(directory))
elif function == "summary":
print(sz.summarizer(directory))
record = tm_arguments.record
if function == "summary":
# Determine if user wants to keep a record of the result.
if record:
# Write the summary into a json file.
data = sz.summarizer(directory)
file = open(path + "/" + record + ".json", "w")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

us os.path.sep instead of /

json.dump(data, file, indent=4)
file.close()
else:
print(sz.summarizer(directory))
elif function == "frequency":
if record:
data = az.dir_frequency(directory)
file = open(path + "/" + record + ".json", "w")
json.dump(data, file, indent=4)
file.close()
else:
print(az.dir_frequency(directory))