Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow naming additional parameters and display them in the results #110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions criticality_score/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,26 @@ def get_repository_stats(repo, additional_params=None):
additional_params = []
additional_params_total_weight = 0
additional_params_score = 0
additional_params_dict = {}
unnamed_param = 1
for additional_param in additional_params:
try:
name, values = additional_param.split(':', 1)
value, weight, max_threshold = [
int(i) for i in additional_param.split(':')
float(i) for i in values.split(':')
]
except ValueError:
logger.error('Parameter value in bad format: ' + additional_param)
sys.exit(1)
# try parsing without name
try:
value, weight, max_threshold = [
float(i) for i in additional_param.split(':')
]
except ValueError:
logger.error('Additional parameter in bad format: "' + additional_param + '". Format is: [<name>:]<value>:<weight>:<max_threshold>')
sys.exit(1)
name='Unnamed param #' + str(unnamed_param)
unnamed_param += 1
additional_params_dict[name] = value
additional_params_total_weight += weight
additional_params_score += get_param_score(value, max_threshold,
weight)
Expand All @@ -475,6 +487,7 @@ def _worker(repo, param, return_dict):
}
for param in PARAMS:
result_dict[param] = return_dict[param]
result_dict.update(additional_params_dict)

total_weight = (CREATED_SINCE_WEIGHT + UPDATED_SINCE_WEIGHT +
CONTRIBUTOR_COUNT_WEIGHT + ORG_COUNT_WEIGHT +
Expand Down Expand Up @@ -625,7 +638,7 @@ def main():
'--params',
nargs='+',
default=[],
help='Additional parameters in form <value>:<weight>:<max_threshold>',
help='Additional parameters in form [<name>:]<value>:<weight>:<max_threshold>',
required=False)

initialize_logging_handlers()
Expand Down