From 42ac53afd27073af2fe95dcc87326868990e37c0 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 16 Sep 2013 14:39:53 +0100 Subject: [PATCH 1/3] parse output when only a single .tex file is present --- gitwalker/tools.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gitwalker/tools.py b/gitwalker/tools.py index ebbd760..70fc49e 100644 --- a/gitwalker/tools.py +++ b/gitwalker/tools.py @@ -73,9 +73,12 @@ def run(self, path): if not os.path.exists(os.path.join(path, self.fname)): raise IOError("Couldn't find TeX file: %s" % self.fname) (out, wc) = self.word_count(path, self.fname) - if not "total" in wc: + if "total" in wc: + return self.extract_wordcount(wc["total"]) + elif len(wc) == 1: + return self.extract_wordcount(wc[wc.keys()[0]]) + else: raise ValueError("Error parsing output: %s" % out) - else: return self.extract_wordcount(wc["total"]) class ShellCmd(Cmd): """ Execute a shell command """ From 79da40f93f3b88e553aedb59d5cea40bd6b05888 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 16 Sep 2013 15:57:57 +0100 Subject: [PATCH 2/3] use correct out-path with --update flag --- gitwalker/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitwalker/main.py b/gitwalker/main.py index d03ff14..e5728ba 100644 --- a/gitwalker/main.py +++ b/gitwalker/main.py @@ -105,8 +105,8 @@ def main(): log("[%s] %s", cmd.name, pprint.pformat(rec["results"][cmd.name])) out[sha1] = rec - log("Writing output file: %s", opts.out_path) - json.dump(out, open(opts.out_path, "w"), indent=1) + log("Writing output file: %s", out_path) + json.dump(out, open(out_path, "w"), indent=1) finally: log("Tidying temp dir: %s", git_new) shutil.rmtree(git_new) From 01fc8c7aae9616d21dd7591d3153c4fc336fdac9 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 4 Nov 2013 17:39:24 +0000 Subject: [PATCH 3/3] add missing import of CmdError and log --- gitwalker/git.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gitwalker/git.py b/gitwalker/git.py index 6a6e051..89b7e63 100644 --- a/gitwalker/git.py +++ b/gitwalker/git.py @@ -1,5 +1,6 @@ import subprocess import os.path +from util import log, CmdError from datetime import datetime from util import get_output