]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
Compare files before renmaing.
authorOleg Broytman <phd@phdru.name>
Thu, 30 Mar 2006 21:26:37 +0000 (21:26 +0000)
committerOleg Broytman <phd@phdru.name>
Thu, 30 Mar 2006 21:26:37 +0000 (21:26 +0000)
git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@45 7bb0bf08-9e0d-0410-b083-99cee3bf18b8

dotfiles2html/dotfiles2html.py

index 4d4d0165bdb7cd90165bbf88bc2a90857835bc44..8952fe862931ed14f0aeff1672eb3ecfe5444e8d 100755 (executable)
@@ -7,7 +7,7 @@ __author__ = "Oleg BroytMann <phd@phd.pp.ru>"
 __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)