From f668c4b20ce715e71e534432c247750da908fd4f Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 21 Aug 2020 10:37:32 +0300 Subject: [PATCH] Feat(dotfiles2html): Always read the original file --- dotfiles2html/dotfiles2html.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dotfiles2html/dotfiles2html.py b/dotfiles2html/dotfiles2html.py index 640aa6a..e8e52ae 100755 --- a/dotfiles2html/dotfiles2html.py +++ b/dotfiles2html/dotfiles2html.py @@ -75,10 +75,11 @@ def process_dotfile(i, fname, ftype, file_types): if not os.path.exists(fname): return + file = open(fname, 'r') + text = file.read() + file.close() + if fname in ('mailcap', 'mc.ext', 'menu'): - file = open(fname, 'r') - text = file.read() - file.close() file = open(fname, 'w') text = text.replace('mplay', 'mplayer') text = text.replace('mplayerer', 'mplayer') @@ -90,11 +91,9 @@ def process_dotfile(i, fname, ftype, file_types): file.close() elif fname == 'vimrc': - file = open('vimrc', 'r') - text = file.read() - file.close() - file = open('vimrc', 'w') - file.write(text.replace('\033', '')) + file = open(fname, 'w') + text = text.replace('\033', '') + file.write(text) file.close() os.system("""exec gvim -f -c "set filetype=%s" -c ":source %s/dotfile2html.vim" "%s" -- 2.39.2