Skip to content

Commit

Permalink
Add support for warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Feb 15, 2014
1 parent e71f4cc commit 406a87b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bin/dots
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import re
import tempfile
import argparse
import hashlib
import warnings

USAGE="""dots - A dot file pre-processor and installer
Expand Down Expand Up @@ -160,6 +161,12 @@ def handle_exception(exc_type, value, trace):

sys.excepthook = handle_exception

# Globaly handle warnings in a clean way
def handle_warning(message, category, filename, line):
sys.stderr.write("\033[93m{}: {}\033[0m\n".format(category.__name__, message))

warnings.showwarning = handle_warning

# Helper function to execute a git diff process
def git_diff(git_args, path1, path2):
subprocess.call(['git', 'diff', '--diff-filter=MA'] + git_args + [path1, path2])
Expand Down

0 comments on commit 406a87b

Please sign in to comment.