Skip to content
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
13 changes: 10 additions & 3 deletions atarashi/libs/commentPreprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,16 @@ def extract(inputFile):
with open(outputFile, 'w') as outFile:
# if the file extension is supported
if fileType in supportedFileExtensions:
data_file = commentExtract(inputFile)
data = licenseComment(data_file)
outFile.write(data)
try:
data_file = commentExtract(inputFile)
data = licenseComment(data_file)
outFile.write(data)
except Exception as e:
#if the nirjas may mis-parse file
with open(inputFile) as inFile:
lines = inFile.read().split('\n')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are loading the entire file in memory and then just writing as it is in outfile. This is not optimised.

Look into shutil maybe? helps reduce python overload.

for line in lines:
outFile.write(line + '\n')
else:
# if file extension is not supported
with open(inputFile) as inFile:
Expand Down