def generate_log(dirname, log_object):
print(os.path.dirname(__file__),'dfsdfds')
print(os.listdir())
for smell in log_object:
log = open("../../output/logs/{}_logs".format(smell), "w")
for elem in log_object[smell]:
log.write('filename: {}, smelly_lines: {}, metric: {}\n'.format(elem['filename'], str(elem['lineno']), str(elem['metric'])))
My function tries to write some logs in to the directory output/logs/
The directory that I am calling this function is C:\Users\user\Desktop\proj\src\Detector
. Since I want the output
directory to be generated in /proj
which is my project root, I thought doing ../../
would work, but it gives me
log = open("../../output/logs/{}_logs".format(smell), "w")
FileNotFoundError: [Errno 2] No such file or directory: '../../output/logs/long_method_logs'
Is there anything I can do to fix this?