From: Dan White Date: Thu, 20 Dec 2012 21:11:03 +0000 (-0600) Subject: Add date stamp when add/mod tags, report relative paths X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=73731a9bf1a1a981499a7c7134843ec7d08ddae5;p=pubbin.git Add date stamp when add/mod tags, report relative paths --- diff --git a/tag b/tag index 9e5d288..db17adf 100755 --- a/tag +++ b/tag @@ -5,6 +5,7 @@ """Recurse from current or given directory and display all folders with tags.""" +import datetime import optparse import os import sys @@ -82,12 +83,16 @@ def findTag(tag, baseDir): def addTag(tag, baseDir): - try: - open(baseDir + '/' + TAG_PREFIX + tag, 'r') - print "ee's already got one (%s)" % tag - except IOError: - t = open(baseDir + '/' + TAG_PREFIX + tag, 'w') - t.close() + fname = baseDir + '/' + TAG_PREFIX + tag + #if os.path.exists(fname): + fd = open(fname, 'a') + print >>fd, datetime.datetime.now().strftime('%F %T') + #try: + #open(baseDir + '/' + TAG_PREFIX + tag, 'r') + #print "ee's already got one (%s)" % tag + #except IOError: + #t = open(baseDir + '/' + TAG_PREFIX + tag, 'w') + #t.close() def deleteTag(tag, baseDir): @@ -109,7 +114,8 @@ def main(): taglist = [] if arglen == 0: - walkDir = _cwd + #walkDir = _cwd + walkDir = '.' elif arglen == 1: walkDir = os.path.expandvars(os.path.expanduser(args[0])) walkDir = walkDir.rstrip(os.sep) @@ -145,7 +151,6 @@ def main(): print '\n'.join(listTags(walkDir)) elif opt.tag: for t in opt.tag.split(',') + taglist: - print 'adding', t print findTag(t, walkDir) elif opt.add: for t in opt.add.split(',') + taglist: