Skip to content

Commit

Permalink
PEP8 and Code Climate fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mab879 committed Nov 11, 2022
1 parent cf63fff commit bf93136
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions utils/rule_dir_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from collections import defaultdict

import json
from typing import TextIO

import ssg.build_yaml
import ssg.oval
Expand All @@ -27,7 +28,8 @@ def parse_args():
help="Path to SSG root directory (defaults to %s)" % SSG_ROOT)
parser.add_argument("-o", "--output", type=str, action="store", default=BUILD_OUTPUT,
help="File to write json output to (defaults to build/rule_dirs.json)")
parser.add_argument("-q", "--quiet", action="store_true", help="Hides output from the script, just creates the file.")
parser.add_argument("-q", "--quiet", action="store_true",
help="Hides output from the script, just creates the file.")

return parser.parse_args()

Expand Down Expand Up @@ -174,6 +176,11 @@ def handle_remediations(product_list, product_yamls, rule_obj):
return rule_remediations, r_products


def quiet_print(msg: str, quiet, file: TextIO):
if not quiet:
print(msg, file)


def main():
args = parse_args()

Expand Down Expand Up @@ -202,8 +209,7 @@ def main():
all_ovals = ','.join(oval_products[key])
msg = "Product {0} has multiple ovals in rule {1}: {2}"
msg = msg.format(key, rule_id, all_ovals)
if not args.quiet:
print(msg, file=sys.stderr)
quiet_print(msg, args.quiet, sys.stderr)

rule_obj['oval_products'] = oval_products

Expand All @@ -217,8 +223,7 @@ def main():
msg = "Product {0} has multiple remediations of the same type "
msg += "in rule {1}: {2}"
msg = msg.format(key, rule_id, all_fixes)
if not args.quiet:
print(msg, file=sys.stderr)
quiet_print(msg, args.quiet, sys.stderr)

rule_obj['remediation_products'] = r_products

Expand Down

0 comments on commit bf93136

Please sign in to comment.