From 13d3b1fd19246177d0fcc2079d7cc75a93641f93 Mon Sep 17 00:00:00 2001 From: Dec1mo Date: Mon, 5 Apr 2021 15:18:00 +0700 Subject: [PATCH] Change requirement of threshold_combination_type in CLI --- scoss/cli.py | 2 +- scoss/main.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scoss/cli.py b/scoss/cli.py index 78e0c98..e01e991 100644 --- a/scoss/cli.py +++ b/scoss/cli.py @@ -12,7 +12,7 @@ help='Output directory.' ) @click.option( - '--threshold-combination', '-tc', required=True, + '--threshold-combination', '-tc', type=click.Choice(['AND','OR'], case_sensitive=False), help='AND: All metrics are greater than threshold.\nOR: At least 1 metric is greater than threshold.' ) diff --git a/scoss/main.py b/scoss/main.py index 28a746a..c32a099 100644 --- a/scoss/main.py +++ b/scoss/main.py @@ -61,6 +61,8 @@ def get_all_plagiarism(input_dir, output_dir, threshold_combination_type='AND', set_operator_threshold == None and hash_operator_threshold == None: print('Please choose at least 1 metric from [moss, count_operator, set_operator, hash_operator]', file=sys.stderr) sys.exit(-1) + if not threshold_combination_type: + threshold_combination_type = 'AND' all_files = get_all_files(input_dir) output_dir = os.path.join(output_dir, 'plagiarism_report_{}/'.format(os.path.basename(os.path.normpath(input_dir)))) result_dir = os.path.join(output_dir, 'source_code_comparisons/') @@ -98,7 +100,7 @@ def get_all_plagiarism(input_dir, output_dir, threshold_combination_type='AND', problem_dir = os.path.basename(os.path.dirname(f)) sc.add_file(f, '{}_{}'.format(problem_dir, user_filename)) sc.run() - if threshold_combination_type == 'AND': + if threshold_combination_type.upper() == 'AND': scoss_matches = sc.get_matches(or_thresholds=False, and_thresholds=True) else: # Be careful scoss_matches = sc.get_matches(or_thresholds=True, and_thresholds=False)