Skip to content
This repository has been archived by the owner on Mar 13, 2020. It is now read-only.

Commit

Permalink
Strip trailing whitespaces @ EOL when dumping FST
Browse files Browse the repository at this point in the history
It's a workaround for PyCQA/redbaron#190
  • Loading branch information
webknjaz committed Jan 15, 2020
1 parent 2b095f8 commit ed07529
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ def write_text_into_file(path, text):
return f.write(text)


def write_fst_into_file(path, fst):
"""Dump fst into the given file path."""
write_text_into_file(path, fst.dumps().rstrip())


@contextlib.contextmanager
def working_directory(target_dir):
"""Temporary change dir to the target and change back on exit."""
Expand Down Expand Up @@ -788,13 +793,13 @@ def fst_rewrite_session(src_path, dst_path):

yield mod_fst

new_mod_src_text = mod_fst.dumps()
new_mod_src_text = mod_fst.dumps().rstrip()

if src_path == dst_path and mod_src_text == new_mod_src_text:
return

logger.info('Rewriting plugin references in %s', dst_path)
write_text_into_file(dst_path, new_mod_src_text)
write_fst_into_file(dst_path, mod_fst)


def read_module_txt_n_fst(path):
Expand Down

0 comments on commit ed07529

Please sign in to comment.