1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-09 09:59:51 +01:00

work with or without colorama

This commit is contained in:
Viktor Stanchev 2015-03-23 18:29:54 -04:00
parent 7fde984a4d
commit 9fe74e506b
3 changed files with 13 additions and 22 deletions

View File

@ -11,13 +11,6 @@ TMP=$(mktemp pirate-get-XXXXXX)
python='python'
fi
if [ $(which pip3) ]
then
pip='pip3'
else
pip='pip'
fi
echo "#!/usr/bin/env $python" > "$TMP" &&
sed 1d $(dirname $0)/pirate-get.py >> "$TMP"
@ -26,7 +19,5 @@ TMP=$(mktemp pirate-get-XXXXXX)
chmod +x /usr/bin/pirate-get &&
chmod 755 /usr/bin/pirate-get &&
$pip install -r requirements.txt &&
rm $TMP
} || rm $TMP

View File

@ -145,22 +145,23 @@ class BayParser(HTMLParser):
def print(*args, **kwargs):
if kwargs.get('color', False):
import colorama
colorama.init()
color_dict = {
'default': '',
'header': colorama.Back.BLACK + colorama.Fore.WHITE,
'alt': colorama.Fore.YELLOW,
'zebra_0': '',
'zebra_1': colorama.Fore.BLUE,
'WARN': colorama.Fore.MAGENTA,
'ERROR': colorama.Fore.RED}
try:
import colorama
colorama.init()
color_dict = {
'default': '',
'header': colorama.Back.BLACK + colorama.Fore.WHITE,
'alt': colorama.Fore.YELLOW,
'zebra_0': '',
'zebra_1': colorama.Fore.BLUE,
'WARN': colorama.Fore.MAGENTA,
'ERROR': colorama.Fore.RED}
c = color_dict[kwargs.pop('color')]
args = (c + args[0],) + args[1:] + (colorama.Style.RESET_ALL,)
except (KeyError, IndexError):
except (KeyError, IndexError, ImportError):
pass
kwargs.pop('color', None)
return builtins.print(*args, **kwargs)
else:
kwargs.pop('color', None)

View File

@ -1 +0,0 @@
colorama==0.3.2