-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpullup_field_main.py
31 lines (28 loc) · 1.25 KB
/
pullup_field_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json
import logging
import os
from qualitymeter.refactoring_opportunities import pullup_field_identification
from qualitymeter.refactoring_opportunities.pullup_field_identification_utils import prettify, print_prettified
# Set the output directory
OUTPUT_DIR = r'.\output'
# Create the directory if it doesn't already exist
if not os.path.isdir(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
# Configure a logger
logging.basicConfig(filename=os.path.join(OUTPUT_DIR, 'app.log'),
filemode='w',
format='[%(levelname)s] %(asctime)s | %(message)s')
logger = logging.getLogger()
# Pass the logger to the main module
pullup_field_identification.initialize(logger, OUTPUT_DIR)
# Get the code base/backup address from user
path = input('Please enter your codebase/backup path:\n')
# Analyze the codebase and get the result and then prettify it
final_result = prettify(pullup_field_identification.analyze(path), logger=logger)
# Print prettified suggestions
print_prettified(final_result, 0, logger=logger)
# Put the full output in a file
out_path = os.path.join(OUTPUT_DIR, 'output.json')
logger.info(f'Saving the result inside "{out_path}"')
with open(out_path, 'w', encoding='utf-8') as file:
json.dump(final_result, file, indent=2)