mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
work with or without colorama
This commit is contained in:
parent
7fde984a4d
commit
9fe74e506b
9
install
9
install
@ -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
|
||||
|
@ -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)
|
||||
|
@ -1 +0,0 @@
|
||||
colorama==0.3.2
|
Loading…
Reference in New Issue
Block a user