__init__.py000064400000005717147205465650006705 0ustar00# Copyright (c) 2012 Giorgos Verigakis # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from __future__ import division from collections import deque from datetime import timedelta from math import ceil from sys import stderr from time import time __version__ = '1.2' class Infinite(object): file = stderr sma_window = 10 def __init__(self, *args, **kwargs): self.index = 0 self.start_ts = time() self._ts = self.start_ts self._dt = deque(maxlen=self.sma_window) for key, val in kwargs.items(): setattr(self, key, val) def __getitem__(self, key): if key.startswith('_'): return None return getattr(self, key, None) @property def avg(self): return sum(self._dt) / len(self._dt) if self._dt else 0 @property def elapsed(self): return int(time() - self.start_ts) @property def elapsed_td(self): return timedelta(seconds=self.elapsed) def update(self): pass def start(self): pass def finish(self): pass def next(self, n=1): if n > 0: now = time() dt = (now - self._ts) / n self._dt.append(dt) self._ts = now self.index = self.index + n self.update() def iter(self, it): for x in it: yield x self.next() self.finish() class Progress(Infinite): def __init__(self, *args, **kwargs): super(Progress, self).__init__(*args, **kwargs) self.max = kwargs.get('max', 100) @property def eta(self): return int(ceil(self.avg * self.remaining)) @property def eta_td(self): return timedelta(seconds=self.eta) @property def percent(self): return self.progress * 100 @property def progress(self): return min(1, self.index / self.max) @property def remaining(self): return max(self.max - self.index, 0) def start(self): self.update() def goto(self, index): incr = index - self.index self.next(incr) def iter(self, it): try: self.max = len(it) except TypeError: pass for x in it: yield x self.next() self.finish() __init__.pyc000064400000012264147205465650007043 0ustar00 abc@ sddlmZddlmZddlmZddlmZddlm Z ddl m Z dZ de fd YZ d e fd YZd S( i(tdivision(tdeque(t timedelta(tceil(tstderr(ttimes1.2tInfinitecB seZeZdZdZdZedZedZ edZ dZ dZ dZ d d Zd ZRS( i cO sgd|_t|_|j|_td|j|_x*|jD]\}}t|||qCWdS(Nitmaxlen( tindexRtstart_tst_tsRt sma_windowt_dttitemstsetattr(tselftargstkwargstkeytval((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyt__init__s    cC s#|jdrdSt||dS(Nt_(t startswithtNonetgetattr(RR((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyt __getitem__'scC s'|jr#t|jt|jSdS(Ni(R tsumtlen(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytavg,scC stt|jS(N(tintRR (R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytelapsed0scC std|jS(Ntseconds(RR(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyt elapsed_td4scC sdS(N((R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytupdate8scC sdS(N((R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytstart;scC sdS(N((R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytfinish>sicC s`|dkrBt}||j|}|jj|||_n|j||_|jdS(Ni(RR R tappendRR!(Rtntnowtdt((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytnextAs   cc s.x|D]}|V|jqW|jdS(N(R(R#(Rtittx((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytiterKs (t__name__t __module__RtfileR RRtpropertyRRR R!R"R#R(R+(((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyRs      tProgresscB sweZdZedZedZedZedZedZdZ dZ dZ RS( cO s2tt|j|||jdd|_dS(Ntmaxid(tsuperR0RtgetR1(RRR((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyRSscC stt|j|jS(N(RRRt remaining(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytetaWscC std|jS(NR(RR5(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyteta_td[scC s |jdS(Nid(tprogress(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytpercent_scC std|j|jS(Ni(tminRR1(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR7cscC st|j|jdS(Ni(R1R(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR4gscC s|jdS(N(R!(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR"kscC s||j}|j|dS(N(RR((RRtincr((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytgotons cc sUyt||_Wntk r&nXx|D]}|V|jq.W|jdS(N(RR1t TypeErrorR(R#(RR)R*((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR+rs  ( R,R-RR/R5R6R8R7R4R"R;R+(((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR0Rs   N(t __future__Rt collectionsRtdatetimeRtmathRtsysRRt __version__tobjectRR0(((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyts7__init__.pyo000064400000012264147205465650007057 0ustar00 abc@ sddlmZddlmZddlmZddlmZddlm Z ddl m Z dZ de fd YZ d e fd YZd S( i(tdivision(tdeque(t timedelta(tceil(tstderr(ttimes1.2tInfinitecB seZeZdZdZdZedZedZ edZ dZ dZ dZ d d Zd ZRS( i cO sgd|_t|_|j|_td|j|_x*|jD]\}}t|||qCWdS(Nitmaxlen( tindexRtstart_tst_tsRt sma_windowt_dttitemstsetattr(tselftargstkwargstkeytval((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyt__init__s    cC s#|jdrdSt||dS(Nt_(t startswithtNonetgetattr(RR((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyt __getitem__'scC s'|jr#t|jt|jSdS(Ni(R tsumtlen(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytavg,scC stt|jS(N(tintRR (R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytelapsed0scC std|jS(Ntseconds(RR(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyt elapsed_td4scC sdS(N((R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytupdate8scC sdS(N((R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytstart;scC sdS(N((R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytfinish>sicC s`|dkrBt}||j|}|jj|||_n|j||_|jdS(Ni(RR R tappendRR!(Rtntnowtdt((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytnextAs   cc s.x|D]}|V|jqW|jdS(N(R(R#(Rtittx((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytiterKs (t__name__t __module__RtfileR RRtpropertyRRR R!R"R#R(R+(((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyRs      tProgresscB sweZdZedZedZedZedZedZdZ dZ dZ RS( cO s2tt|j|||jdd|_dS(Ntmaxid(tsuperR0RtgetR1(RRR((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyRSscC stt|j|jS(N(RRRt remaining(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytetaWscC std|jS(NR(RR5(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyteta_td[scC s |jdS(Nid(tprogress(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytpercent_scC std|j|jS(Ni(tminRR1(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR7cscC st|j|jdS(Ni(R1R(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR4gscC s|jdS(N(R!(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR"kscC s||j}|j|dS(N(RR((RRtincr((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pytgotons cc sUyt||_Wntk r&nXx|D]}|V|jq.W|jdS(N(RR1t TypeErrorR(R#(RR)R*((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR+rs  ( R,R-RR/R5R6R8R7R4R"R;R+(((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyR0Rs   N(t __future__Rt collectionsRtdatetimeRtmathRtsysRRt __version__tobjectRR0(((sA/usr/lib/python2.7/site-packages/pip/_vendor/progress/__init__.pyts7bar.py000064400000005175147205465650005710 0ustar00# -*- coding: utf-8 -*- # Copyright (c) 2012 Giorgos Verigakis # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from . import Progress from .helpers import WritelnMixin class Bar(WritelnMixin, Progress): width = 32 message = '' suffix = '%(index)d/%(max)d' bar_prefix = ' |' bar_suffix = '| ' empty_fill = ' ' fill = '#' hide_cursor = True def update(self): filled_length = int(self.width * self.progress) empty_length = self.width - filled_length message = self.message % self bar = self.fill * filled_length empty = self.empty_fill * empty_length suffix = self.suffix % self line = ''.join([message, self.bar_prefix, bar, empty, self.bar_suffix, suffix]) self.writeln(line) class ChargingBar(Bar): suffix = '%(percent)d%%' bar_prefix = ' ' bar_suffix = ' ' empty_fill = u'∙' fill = u'█' class FillingSquaresBar(ChargingBar): empty_fill = u'▢' fill = u'▣' class FillingCirclesBar(ChargingBar): empty_fill = u'◯' fill = u'◉' class IncrementalBar(Bar): phases = (u' ', u'▏', u'▎', u'▍', u'▌', u'▋', u'▊', u'▉', u'█') def update(self): nphases = len(self.phases) expanded_length = int(nphases * self.width * self.progress) filled_length = int(self.width * self.progress) empty_length = self.width - filled_length phase = expanded_length - (filled_length * nphases) message = self.message % self bar = self.phases[-1] * filled_length current = self.phases[phase] if phase > 0 else '' empty = self.empty_fill * max(0, empty_length - len(current)) suffix = self.suffix % self line = ''.join([message, self.bar_prefix, bar, current, empty, self.bar_suffix, suffix]) self.writeln(line) class ShadyBar(IncrementalBar): phases = (u' ', u'░', u'▒', u'▓', u'█') bar.pyc000064400000006141147205465650006045 0ustar00 abc@sddlmZddlmZdeefdYZdefdYZdefdYZd efd YZd efd YZd efdYZ dS(i(tProgress(t WritelnMixintBarcBsAeZdZdZdZdZdZdZdZe Z dZ RS(i ts%(index)d/%(max)ds |s| t t#cCst|j|j}|j|}|j|}|j|}|j|}|j|}dj||j|||j |g}|j |dS(NR( tinttwidthtprogresstmessagetfillt empty_filltsuffixtjoint bar_prefixt bar_suffixtwriteln(tselft filled_lengtht empty_lengthR tbartemptyR tline((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pytupdates      ( t__name__t __module__RR R RRR R tTruet hide_cursorR(((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyRst ChargingBarcBs&eZdZdZdZdZdZRS(s %(percent)d%%Ru∙u█(RRR RRR R (((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR,s tFillingSquaresBarcBseZdZdZRS(u▢u▣(RRR R (((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR4stFillingCirclesBarcBseZdZdZRS(u◯u◉(RRR R (((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR9stIncrementalBarc BseZd Zd ZRS( u u▏u▎u▍u▌u▋u▊u▉u█c Cst|j}t||j|j}t|j|j}|j|}|||}|j|}|jd|}|dkr|j|nd}|jtd|t|} |j|} dj ||j ||| |j | g} |j | dS(NiiR( tlentphasesRRRR R tmaxR R RRR( Rtnphasestexpanded_lengthRRtphaseR RtcurrentRR R((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyRAs    ( u u▏u▎u▍u▌u▋u▊u▉u█(RRR!R(((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR>stShadyBarcBseZdZRS(u u░u▒u▓u█(u u░u▒u▓u█(RRR!(((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR'RsN( RRthelpersRRRRRRR'(((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pytsbar.pyo000064400000006141147205465650006061 0ustar00 abc@sddlmZddlmZdeefdYZdefdYZdefdYZd efd YZd efd YZd efdYZ dS(i(tProgress(t WritelnMixintBarcBsAeZdZdZdZdZdZdZdZe Z dZ RS(i ts%(index)d/%(max)ds |s| t t#cCst|j|j}|j|}|j|}|j|}|j|}|j|}dj||j|||j |g}|j |dS(NR( tinttwidthtprogresstmessagetfillt empty_filltsuffixtjoint bar_prefixt bar_suffixtwriteln(tselft filled_lengtht empty_lengthR tbartemptyR tline((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pytupdates      ( t__name__t __module__RR R RRR R tTruet hide_cursorR(((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyRst ChargingBarcBs&eZdZdZdZdZdZRS(s %(percent)d%%Ru∙u█(RRR RRR R (((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR,s tFillingSquaresBarcBseZdZdZRS(u▢u▣(RRR R (((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR4stFillingCirclesBarcBseZdZdZRS(u◯u◉(RRR R (((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR9stIncrementalBarc BseZd Zd ZRS( u u▏u▎u▍u▌u▋u▊u▉u█c Cst|j}t||j|j}t|j|j}|j|}|||}|j|}|jd|}|dkr|j|nd}|jtd|t|} |j|} dj ||j ||| |j | g} |j | dS(NiiR( tlentphasesRRRR R tmaxR R RRR( Rtnphasestexpanded_lengthRRtphaseR RtcurrentRR R((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyRAs    ( u u▏u▎u▍u▌u▋u▊u▉u█(RRR!R(((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR>stShadyBarcBseZdZRS(u u░u▒u▓u█(u u░u▒u▓u█(RRR!(((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pyR'RsN( RRthelpersRRRRRRR'(((s</usr/lib/python2.7/site-packages/pip/_vendor/progress/bar.pytscounter.py000064400000002736147205465650006623 0ustar00# -*- coding: utf-8 -*- # Copyright (c) 2012 Giorgos Verigakis # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from . import Infinite, Progress from .helpers import WriteMixin class Counter(WriteMixin, Infinite): message = '' hide_cursor = True def update(self): self.write(str(self.index)) class Countdown(WriteMixin, Progress): hide_cursor = True def update(self): self.write(str(self.remaining)) class Stack(WriteMixin, Progress): phases = (u' ', u'▁', u'▂', u'▃', u'▄', u'▅', u'▆', u'▇', u'█') hide_cursor = True def update(self): nphases = len(self.phases) i = min(nphases - 1, int(self.progress * nphases)) self.write(self.phases[i]) class Pie(Stack): phases = (u'○', u'◔', u'◑', u'◕', u'●') counter.pyc000064400000004127147205465650006762 0ustar00 abc@sddlmZmZddlmZdeefdYZdeefdYZdeefdYZd efd YZd S( i(tInfinitetProgress(t WriteMixintCountercBseZdZeZdZRS(tcCs|jt|jdS(N(twritetstrtindex(tself((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pytupdates(t__name__t __module__tmessagetTruet hide_cursorR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyRst CountdowncBseZeZdZRS(cCs|jt|jdS(N(RRt remaining(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyR s(R R R RR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyRstStackc BseZd ZeZd ZRS( u u▁u▂u▃u▄u▅u▆u▇u█cCsGt|j}t|dt|j|}|j|j|dS(Ni(tlentphasestmintinttprogressR(Rtnphasesti((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyR (s ( u u▁u▂u▃u▄u▅u▆u▇u█(R R RR RR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyR$stPiecBseZdZRS(u○u◔u◑u◕u●(u○u◔u◑u◕u●(R R R(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyR.sN( RRRthelpersRRRRR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyts  counter.pyo000064400000004127147205465650006776 0ustar00 abc@sddlmZmZddlmZdeefdYZdeefdYZdeefdYZd efd YZd S( i(tInfinitetProgress(t WriteMixintCountercBseZdZeZdZRS(tcCs|jt|jdS(N(twritetstrtindex(tself((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pytupdates(t__name__t __module__tmessagetTruet hide_cursorR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyRst CountdowncBseZeZdZRS(cCs|jt|jdS(N(RRt remaining(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyR s(R R R RR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyRstStackc BseZd ZeZd ZRS( u u▁u▂u▃u▄u▅u▆u▇u█cCsGt|j}t|dt|j|}|j|j|dS(Ni(tlentphasestmintinttprogressR(Rtnphasesti((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyR (s ( u u▁u▂u▃u▄u▅u▆u▇u█(R R RR RR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyR$stPiecBseZdZRS(u○u◔u◑u◕u●(u○u◔u◑u◕u●(R R R(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyR.sN( RRRthelpersRRRRR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/counter.pyts  helpers.py000064400000005446147205465650006607 0ustar00# Copyright (c) 2012 Giorgos Verigakis # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from __future__ import print_function HIDE_CURSOR = '\x1b[?25l' SHOW_CURSOR = '\x1b[?25h' class WriteMixin(object): hide_cursor = False def __init__(self, message=None, **kwargs): super(WriteMixin, self).__init__(**kwargs) self._width = 0 if message: self.message = message if self.file.isatty(): if self.hide_cursor: print(HIDE_CURSOR, end='', file=self.file) print(self.message, end='', file=self.file) self.file.flush() def write(self, s): if self.file.isatty(): b = '\b' * self._width c = s.ljust(self._width) print(b + c, end='', file=self.file) self._width = max(self._width, len(s)) self.file.flush() def finish(self): if self.file.isatty() and self.hide_cursor: print(SHOW_CURSOR, end='', file=self.file) class WritelnMixin(object): hide_cursor = False def __init__(self, message=None, **kwargs): super(WritelnMixin, self).__init__(**kwargs) if message: self.message = message if self.file.isatty() and self.hide_cursor: print(HIDE_CURSOR, end='', file=self.file) def clearln(self): if self.file.isatty(): print('\r\x1b[K', end='', file=self.file) def writeln(self, line): if self.file.isatty(): self.clearln() print(line, end='', file=self.file) self.file.flush() def finish(self): if self.file.isatty(): print(file=self.file) if self.hide_cursor: print(SHOW_CURSOR, end='', file=self.file) from signal import signal, SIGINT from sys import exit class SigIntMixin(object): """Registers a signal handler that calls finish on SIGINT""" def __init__(self, *args, **kwargs): super(SigIntMixin, self).__init__(*args, **kwargs) signal(SIGINT, self._sigint_handler) def _sigint_handler(self, signum, frame): self.finish() exit(0) helpers.pyc000064400000007435147205465650006752 0ustar00 abc@sddlmZdZdZdefdYZdefdYZddlmZmZdd l m Z d efd YZ d S( i(tprint_functions[?25ls[?25ht WriteMixincBs,eZeZddZdZdZRS(cKstt|j|d|_|r1||_n|jjr|jrett ddd|jnt|jddd|j|jj ndS(Nitendttfile( tsuperRt__init__t_widthtmessageRtisattyt hide_cursortprintt HIDE_CURSORtflush(tselfRtkwargs((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyRs   cCsz|jjrvd|j}|j|j}t||ddd|jt|jt||_|jjndS(NsRRR(RR RtljustR tmaxtlenR (Rtstbtc((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytwrite%s  cCs8|jjr4|jr4ttddd|jndS(NRRR(RR R R t SHOW_CURSOR(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytfinish-sN(t__name__t __module__tFalseR tNoneRRR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyRs t WritelnMixincBs5eZeZddZdZdZdZRS(cKs`tt|j||r(||_n|jjr\|jr\ttddd|jndS(NRRR( RRRRRR R R R (RRR((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyR5s  cCs/|jjr+tdddd|jndS(Ns RRR(RR R (R((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytclearln=scCsF|jjrB|jt|ddd|j|jjndS(NRRR(RR RR R (Rtline((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytwritelnAs cCsK|jjrGtd|j|jrGttddd|jqGndS(NRRR(RR R R R(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyRGs N( RRRR RRRR R(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyR2s    (tsignaltSIGINT(texitt SigIntMixincBs eZdZdZdZRS(s6Registers a signal handler that calls finish on SIGINTcOs-tt|j||tt|jdS(N(RR$RR!R"t_sigint_handler(RtargsR((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyRUscCs|jtddS(Ni(RR#(Rtsignumtframe((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyR%Ys (RRt__doc__RR%(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyR$Rs N( t __future__RR RtobjectRRR!R"tsysR#R$(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytshelpers.pyo000064400000007435147205465650006766 0ustar00 abc@sddlmZdZdZdefdYZdefdYZddlmZmZdd l m Z d efd YZ d S( i(tprint_functions[?25ls[?25ht WriteMixincBs,eZeZddZdZdZRS(cKstt|j|d|_|r1||_n|jjr|jrett ddd|jnt|jddd|j|jj ndS(Nitendttfile( tsuperRt__init__t_widthtmessageRtisattyt hide_cursortprintt HIDE_CURSORtflush(tselfRtkwargs((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyRs   cCsz|jjrvd|j}|j|j}t||ddd|jt|jt||_|jjndS(NsRRR(RR RtljustR tmaxtlenR (Rtstbtc((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytwrite%s  cCs8|jjr4|jr4ttddd|jndS(NRRR(RR R R t SHOW_CURSOR(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytfinish-sN(t__name__t __module__tFalseR tNoneRRR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyRs t WritelnMixincBs5eZeZddZdZdZdZRS(cKs`tt|j||r(||_n|jjr\|jr\ttddd|jndS(NRRR( RRRRRR R R R (RRR((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyR5s  cCs/|jjr+tdddd|jndS(Ns RRR(RR R (R((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytclearln=scCsF|jjrB|jt|ddd|j|jjndS(NRRR(RR RR R (Rtline((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytwritelnAs cCsK|jjrGtd|j|jrGttddd|jqGndS(NRRR(RR R R R(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyRGs N( RRRR RRRR R(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyR2s    (tsignaltSIGINT(texitt SigIntMixincBs eZdZdZdZRS(s6Registers a signal handler that calls finish on SIGINTcOs-tt|j||tt|jdS(N(RR$RR!R"t_sigint_handler(RtargsR((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyRUscCs|jtddS(Ni(RR#(Rtsignumtframe((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyR%Ys (RRt__doc__RR%(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pyR$Rs N( t __future__RR RtobjectRRR!R"tsysR#R$(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/helpers.pytsspinner.py000064400000002442147205465650006614 0ustar00# -*- coding: utf-8 -*- # Copyright (c) 2012 Giorgos Verigakis # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from . import Infinite from .helpers import WriteMixin class Spinner(WriteMixin, Infinite): message = '' phases = ('-', '\\', '|', '/') hide_cursor = True def update(self): i = self.index % len(self.phases) self.write(self.phases[i]) class PieSpinner(Spinner): phases = [u'◷', u'◶', u'◵', u'◴'] class MoonSpinner(Spinner): phases = [u'◑', u'◒', u'◐', u'◓'] class LineSpinner(Spinner): phases = [u'⎺', u'⎻', u'⎼', u'⎽', u'⎼', u'⎻'] spinner.pyc000064400000003076147205465650006763 0ustar00 abc@sddlmZddlmZdeefdYZdefdYZdefdYZd efd YZd S( i(tInfinite(t WriteMixintSpinnercBs#eZdZdZeZdZRS(tt-s\t|t/cCs.|jt|j}|j|j|dS(N(tindextlentphasestwrite(tselfti((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pytupdates(Rs\RR(t__name__t __module__tmessageR tTruet hide_cursorR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyRst PieSpinnercBseZddddgZRS(u◷u◶u◵u◴(RRR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyRst MoonSpinnercBseZddddgZRS(u◑u◒u◐u◓(RRR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyR#st LineSpinnercBs eZddddddgZRS(u⎺u⎻u⎼u⎽(RRR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyR'sN(RRthelpersRRRRR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyts  spinner.pyo000064400000003076147205465650006777 0ustar00 abc@sddlmZddlmZdeefdYZdefdYZdefdYZd efd YZd S( i(tInfinite(t WriteMixintSpinnercBs#eZdZdZeZdZRS(tt-s\t|t/cCs.|jt|j}|j|j|dS(N(tindextlentphasestwrite(tselfti((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pytupdates(Rs\RR(t__name__t __module__tmessageR tTruet hide_cursorR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyRst PieSpinnercBseZddddgZRS(u◷u◶u◵u◴(RRR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyRst MoonSpinnercBseZddddgZRS(u◑u◒u◐u◓(RRR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyR#st LineSpinnercBs eZddddddgZRS(u⎺u⎻u⎼u⎽(RRR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyR'sN(RRthelpersRRRRR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/progress/spinner.pyts