From ae790dedb33d90032613ff7d27bb7d7f457b667b Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Wed, 13 Apr 2022 21:19:25 -0700 Subject: Add more indicators for file state Make the --pretend flag distinguish between new links, overwriting existing files, and unchanged links. * ` =>` indicates an existing (unchanged) link * `*=>` indicates an newly created link * `!=>` indicates a file that was overwritten --- setup.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 71f4fd2..040d277 100755 --- a/setup.py +++ b/setup.py @@ -57,7 +57,10 @@ def makeLinks(dotfiles, prefix, nice, pretend): os.unlink(realDest) # Only remove symlinks. Don't try to replace a file with a directory. if not os.path.isdir(realDest): os.mkdir(realDest) - print "%50s => " % (realDest) + if os.path.lexists(realDest): + print "%50s => " % (realDest) + else: + print "%50s *=> " % (realDest) makeLinks(src, realDest + "/", nice, pretend) except OSError,e: print "Could not mkdir %s. Will not link subitems: %s" % (realDest, str(e)) @@ -68,10 +71,13 @@ def makeLinks(dotfiles, prefix, nice, pretend): if not pretend: success = makeLink(src, realDest, nice) - if fileExists: - print "%50s !=> %s" % (realDest, src) + if fileExists: + if os.path.realpath(realDest) == os.path.realpath(src): + print "%50s => %s" % (realDest, src) + else: + print "%50s !=> %s" % (realDest, src) else: - print "%50s => %s" % (realDest, src) + print "%50s *=> %s" % (realDest, src) except IOError,e: print "Not linking %s to %s because IOError: %s" % (realDest, src, str(e)) -- cgit v1.2.3