@ -3,16 +3,9 @@ import os
import re
import sys
from html . entities import name2codepoint
from math import ceil , floor
from time import sleep
from urllib . parse import (
quote_plus ,
unquote_plus ,
urlencode ,
urlparse ,
urlunparse ,
)
from urllib . request import HTTPError , URLError , urlopen
from urllib . parse import quote_plus , unquote_plus
from urllib . request import HTTPError , urlopen
groupnamepat = re . compile ( r " ^g \ .( \ w+) \ $ " )
@ -88,16 +81,6 @@ def loadpadinfo(p):
return info
def progressbar ( i , num , label = " " , file = sys . stderr ) :
p = float ( i ) / num
percentage = int ( floor ( p * 100 ) )
bars = int ( ceil ( p * 20 ) )
bar = ( " * " * bars ) + ( " - " * ( 20 - bars ) )
msg = " \r {0} {1} / {2} {3} ... " . format ( bar , ( i + 1 ) , num , label )
sys . stderr . write ( msg )
sys . stderr . flush ( )
# Python developer Fredrik Lundh (author of elementtree, among other things) has such a function on his website, which works with decimal, hex and named entities:
##
# Removes HTML or XML character references and entities from a text string.
@ -125,3 +108,7 @@ def unescape(text):
return text # leave as is
return re . sub ( " &#? \ w+; " , fixup , text )
def istty ( ) :
return sys . stdout . isatty ( ) and os . environ . get ( ' TERM ' ) != ' dumb '