Skip to content

Commit

Permalink
prettify: run fprettify if file contains Fypp directives
Browse files Browse the repository at this point in the history
previously the complete prettification step was skipped
  • Loading branch information
dev-zero committed Nov 20, 2019
1 parent d74bfc0 commit c107dbd
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tools/prettify/prettify.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,14 @@ def prettifyFile(
logger = logging.getLogger("fprettify-logger")

if is_fypp(infile):
logger.error("{}: fypp directives not supported.\n".format(filename))
return infile
logger.warning(
"{}: fypp directives not fully supported, running only fprettify".format(
filename
)
)
replace = False
normalize_use = False
upcase_keywords = False

# create a temporary file first as a copy of the input file
inbuf = StringIO(infile.read())
Expand Down Expand Up @@ -207,11 +213,12 @@ def prettifyFile(
log_exception(
e, "fprettify could not parse file, file is not prettified"
)
outbuf.write(inbuf.read())

outbuf.seek(0)
inbuf.close()
inbuf = outbuf
outbuf.close()
inbuf.seek(0)
else:
outbuf.seek(0)
inbuf.close()
inbuf = outbuf

if normalize_use:
outbuf = StringIO()
Expand Down Expand Up @@ -242,7 +249,7 @@ def prettifyFile(
hash_prev = hash_new

except:
logger.critical("error processing file '{}'\n".format(filename))
logger.critical("error processing file '{}'".format(filename))
raise

else:
Expand Down

0 comments on commit c107dbd

Please sign in to comment.