Skip to content

Commit

Permalink
save status file in output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip117 committed Aug 15, 2024
1 parent 9ea0792 commit e58aa9f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lld_chxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from difflib import SequenceMatcher
import re
import sys
import os

__version__ = '1.0.0'

Expand Down Expand Up @@ -73,6 +74,7 @@ def main(options: Namespace, inputdir: Path, outputdir: Path):
#
# Refer to the documentation for more options, examples, and advanced uses e.g.
# adding a progress bar and parallelism.
jsonFilePath = os.path.join(options.outputdir, "status.json")
tagStruct = {}
if options.tagInfo:
tagStruct = tagInfo_to_tagStruct(options)
Expand All @@ -81,8 +83,12 @@ def main(options: Namespace, inputdir: Path, outputdir: Path):
for input_file, output_file in mapper:
with open(input_file) as f:
data = json.load(f)
status = analyze_measurements(data,tagStruct, options.measurementsUnit, options.limbDifference)
print(status)
status = analyze_measurements(data,tagStruct, options.measurementsUnit, options.limbDifference) \
# Open a json writer, and use the json.dumps()
# function to dump data
with open(jsonFilePath, 'w', encoding='utf-8') as jsonf:
jsonf.write(json.dumps(status, indent=4))


def tagInfo_to_tagStruct(options):
"""
Expand Down Expand Up @@ -150,10 +156,10 @@ def analyze_measurements(data, tagStruct, unit, diff):
match = re.search(r'\d.\d%',measurements['Difference']).group()
difference = match.replace('%','')
if not float(difference) <= diff:
status['error'] = f"Allowed difference {diff}, actual difference {difference}"
status['error'] = f"Allowed difference {diff}%, actual difference {difference}%"
status['exitCode'] = 3
status['flag'] = False
print(f"Allowed difference {diff}, actual difference {difference}")
print(f"Allowed difference {diff}%, actual difference {difference}%")
return status

print("Analysis check successful.")
Expand Down

0 comments on commit e58aa9f

Please # to comment.