예제 #1
0
    def edit(self, args):
        """Opens up an editor so that you can write the day's words."""

        for date in args.date:
            editor = self.configuration.get('Editor', 'command')
            path = self.get_path(date)
            old_wordcount = analysis.word_count(path)
            subprocess.call([editor, path])
            wordcount = analysis.word_count(path)
            difference = wordcount - old_wordcount
            if GIT_INSTALLED:
                message = 'added %i words to %s for a total of %i' % \
                        (difference, os.path.basename(path), wordcount)
                git_commit(path, message)

            if wordcount < 750:
                print 'You have written %i out of 750 words so far.' % wordcount
            else:
                print 'You wrote %i words today. Great job!' % wordcount
예제 #2
0
 def wc(self, args):
     if not args.paths:
         args.paths = [self.get_path()]
     counts = [(analysis.word_count(path), path) for path in args.paths]
     if len(counts) == 1:
         print counts[0][0], counts[0][1]
     else:
         total = sum(wordcount for wordcount, filename in counts)
         width = len(str(total))
         for wordcount, filename in counts:
             print str(wordcount).rjust(width), filename
         print total, 'total'