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 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) 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 """