From: Oleg Broytman Date: Thu, 30 Mar 2006 21:26:37 +0000 (+0000) Subject: Compare files before renmaing. X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=3a6c1b4d3f07d18b433aaa9c79114134be3a9517;p=phdru.name%2Fphdru.name.git Compare files before renmaing. git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@45 7bb0bf08-9e0d-0410-b083-99cee3bf18b8 --- diff --git a/dotfiles2html/dotfiles2html.py b/dotfiles2html/dotfiles2html.py index 4d4d016..8952fe8 100755 --- a/dotfiles2html/dotfiles2html.py +++ b/dotfiles2html/dotfiles2html.py @@ -7,7 +7,7 @@ __author__ = "Oleg BroytMann " __copyright__ = "Copyright (C) 2004-2006 PhiloSoft Design" -import os, shutil +import os, shutil, filecmp os.umask(0022) # octal; -rw-r--r-- from m_lib.m_path import get_homedir @@ -69,5 +69,8 @@ for i, (fname, ftype) in enumerate(file_types): else: next = file_types[i+1][0] add_headers(fname, prev, next) - os.rename(fname + ".html", fname + ".tmpl") + if not filecmp.cmp(fname + ".html", fname + ".tmpl"): + os.rename(fname + ".html", fname + ".tmpl") + else: + os.remove(fname + ".html") os.chmod(fname, 0644)