diff options
author | wagoodman <wagoodman@gmail.com> | 2016-12-23 17:56:41 -0500 |
---|---|---|
committer | wagoodman <wagoodman@gmail.com> | 2016-12-23 17:56:41 -0500 |
commit | 64d513dde6783f9232e57bb8bfcfbbc26fe10689 (patch) | |
tree | 7aeaa3c64238843be4cb4b07581ab334812abe89 | |
parent | d6b00ca7900eeda840f30e0d7615c24505372894 (diff) | |
download | wsdiff-64d513dde6783f9232e57bb8bfcfbbc26fe10689.tar.gz wsdiff-64d513dde6783f9232e57bb8bfcfbbc26fe10689.tar.bz2 wsdiff-64d513dde6783f9232e57bb8bfcfbbc26fe10689.zip |
added -s option to show diff in a browser
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | diff2HtmlCompare.py | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8049d93 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +index.html +test/ +venv/ diff --git a/diff2HtmlCompare.py b/diff2HtmlCompare.py index d11c9a7..d6e2bfb 100644 --- a/diff2HtmlCompare.py +++ b/diff2HtmlCompare.py @@ -394,11 +394,21 @@ def main(fromfile, tofile, verbose=False): codeDiff.write() +def show(): + import os + import webbrowser + + path = os.path.abspath('index.html') + webbrowser.open('file://' + path) + + if __name__ == "__main__": description = """Given two source files this application\ creates an html page which highlights the differences between the two. """ parser = argparse.ArgumentParser(description=description) + parser.add_argument('-s', '--show', action='store_true', + help='show html in a browser.') parser.add_argument('-v', action='store_true', help='show verbose output.') parser.add_argument( 'file1', help='source file to compare ("before" file).') @@ -407,3 +417,5 @@ creates an html page which highlights the differences between the two. """ args = parser.parse_args() main(args.file1, args.file2, args.v) + if args.show: + show() |