/home/lnzliplg/public_html/colorama.zip
PK 7�\w=�2 2 initialise.pyonu �[��� �
��abc @ s� d d l Z d d l Z d d l Z d d l m Z d a d a d a d a e
a d � Z e
d d e
d � Z d � Z e j d � � Z d � Z d � Z d S(
i����Ni ( t AnsiToWin32c C s# t d k r t t � j � n d S( N( R t Nonet orig_stdoutt reset_all( ( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyR s c C s� | r+ t | | | g � r+ t d � � n t j a t j a t j d k rU d a n t t | | | | � t _ a t j d k r� d a
n t t | | | | � t _ a
t s� t j
t � t a n d S( Ns, wrap=False conflicts with any other arg=True( t anyt
ValueErrort syst stdoutR t stderrt orig_stderrR t wrapped_stdoutt wrap_streamt wrapped_stderrt atexit_donet atexitt registerR t True( t autoresett convertt stript wrap( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt init s
c C s4 t d k r t t _ n t d k r0 t t _ n d S( N( R R R R R R ( ( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt deinit3 s c o s% t | | � z d VWd t � Xd S( N( R R ( t argst kwargs( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt
colorama_text: s
c C s4 t d k r t t _ n t d k r0 t t _ n d S( N( R
R R R R R ( ( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt reinitC s c C sC | r? t | d | d | d | �} | j � r? | j } q? n | S( NR R R ( R t should_wrapt stream( R R R R R t wrapper( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyR J s ( R t
contextlibR t ansitowin32R R R R R
R t FalseR
R R R R t contextmanagerR R R ( ( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt <module> s PK 7�\}��/} }
initialise.pynu �[��� # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
import atexit
import contextlib
import sys
from .ansitowin32 import AnsiToWin32
orig_stdout = None
orig_stderr = None
wrapped_stdout = None
wrapped_stderr = None
atexit_done = False
def reset_all():
if AnsiToWin32 is not None: # Issue #74: objects might become None at exit
AnsiToWin32(orig_stdout).reset_all()
def init(autoreset=False, convert=None, strip=None, wrap=True):
if not wrap and any([autoreset, convert, strip]):
raise ValueError('wrap=False conflicts with any other arg=True')
global wrapped_stdout, wrapped_stderr
global orig_stdout, orig_stderr
orig_stdout = sys.stdout
orig_stderr = sys.stderr
if sys.stdout is None:
wrapped_stdout = None
else:
sys.stdout = wrapped_stdout = \
wrap_stream(orig_stdout, convert, strip, autoreset, wrap)
if sys.stderr is None:
wrapped_stderr = None
else:
sys.stderr = wrapped_stderr = \
wrap_stream(orig_stderr, convert, strip, autoreset, wrap)
global atexit_done
if not atexit_done:
atexit.register(reset_all)
atexit_done = True
def deinit():
if orig_stdout is not None:
sys.stdout = orig_stdout
if orig_stderr is not None:
sys.stderr = orig_stderr
@contextlib.contextmanager
def colorama_text(*args, **kwargs):
init(*args, **kwargs)
try:
yield
finally:
deinit()
def reinit():
if wrapped_stdout is not None:
sys.stdout = wrapped_stdout
if wrapped_stderr is not None:
sys.stderr = wrapped_stderr
def wrap_stream(stream, convert, strip, autoreset, wrap):
if wrap:
wrapper = AnsiToWin32(stream,
convert=convert, strip=strip, autoreset=autoreset)
if wrapper.should_wrap():
stream = wrapper.stream
return stream
PK 7�\>�_� � ansi.pynu �[��� # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
'''
This module generates ANSI character codes to printing colors to terminals.
See: http://en.wikipedia.org/wiki/ANSI_escape_code
'''
CSI = '\033['
OSC = '\033]'
BEL = '\007'
def code_to_chars(code):
return CSI + str(code) + 'm'
def set_title(title):
return OSC + '2;' + title + BEL
def clear_screen(mode=2):
return CSI + str(mode) + 'J'
def clear_line(mode=2):
return CSI + str(mode) + 'K'
class AnsiCodes(object):
def __init__(self):
# the subclasses declare class attributes which are numbers.
# Upon instantiation we define instance attributes, which are the same
# as the class attributes but wrapped with the ANSI escape sequence
for name in dir(self):
if not name.startswith('_'):
value = getattr(self, name)
setattr(self, name, code_to_chars(value))
class AnsiCursor(object):
def UP(self, n=1):
return CSI + str(n) + 'A'
def DOWN(self, n=1):
return CSI + str(n) + 'B'
def FORWARD(self, n=1):
return CSI + str(n) + 'C'
def BACK(self, n=1):
return CSI + str(n) + 'D'
def POS(self, x=1, y=1):
return CSI + str(y) + ';' + str(x) + 'H'
class AnsiFore(AnsiCodes):
BLACK = 30
RED = 31
GREEN = 32
YELLOW = 33
BLUE = 34
MAGENTA = 35
CYAN = 36
WHITE = 37
RESET = 39
# These are fairly well supported, but not part of the standard.
LIGHTBLACK_EX = 90
LIGHTRED_EX = 91
LIGHTGREEN_EX = 92
LIGHTYELLOW_EX = 93
LIGHTBLUE_EX = 94
LIGHTMAGENTA_EX = 95
LIGHTCYAN_EX = 96
LIGHTWHITE_EX = 97
class AnsiBack(AnsiCodes):
BLACK = 40
RED = 41
GREEN = 42
YELLOW = 43
BLUE = 44
MAGENTA = 45
CYAN = 46
WHITE = 47
RESET = 49
# These are fairly well supported, but not part of the standard.
LIGHTBLACK_EX = 100
LIGHTRED_EX = 101
LIGHTGREEN_EX = 102
LIGHTYELLOW_EX = 103
LIGHTBLUE_EX = 104
LIGHTMAGENTA_EX = 105
LIGHTCYAN_EX = 106
LIGHTWHITE_EX = 107
class AnsiStyle(AnsiCodes):
BRIGHT = 1
DIM = 2
NORMAL = 22
RESET_ALL = 0
Fore = AnsiFore()
Back = AnsiBack()
Style = AnsiStyle()
Cursor = AnsiCursor()
PK 7�\
m�=� � win32.pynu �[��� # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
# from winbase.h
STDOUT = -11
STDERR = -12
try:
import ctypes
from ctypes import LibraryLoader
windll = LibraryLoader(ctypes.WinDLL)
from ctypes import wintypes
except (AttributeError, ImportError):
windll = None
SetConsoleTextAttribute = lambda *_: None
winapi_test = lambda *_: None
else:
from ctypes import byref, Structure, c_char, POINTER
COORD = wintypes._COORD
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
"""struct in wincon.h."""
_fields_ = [
("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", wintypes.WORD),
("srWindow", wintypes.SMALL_RECT),
("dwMaximumWindowSize", COORD),
]
def __str__(self):
return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % (
self.dwSize.Y, self.dwSize.X
, self.dwCursorPosition.Y, self.dwCursorPosition.X
, self.wAttributes
, self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right
, self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X
)
_GetStdHandle = windll.kernel32.GetStdHandle
_GetStdHandle.argtypes = [
wintypes.DWORD,
]
_GetStdHandle.restype = wintypes.HANDLE
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
_GetConsoleScreenBufferInfo.argtypes = [
wintypes.HANDLE,
POINTER(CONSOLE_SCREEN_BUFFER_INFO),
]
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
_SetConsoleTextAttribute.argtypes = [
wintypes.HANDLE,
wintypes.WORD,
]
_SetConsoleTextAttribute.restype = wintypes.BOOL
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
_SetConsoleCursorPosition.argtypes = [
wintypes.HANDLE,
COORD,
]
_SetConsoleCursorPosition.restype = wintypes.BOOL
_FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA
_FillConsoleOutputCharacterA.argtypes = [
wintypes.HANDLE,
c_char,
wintypes.DWORD,
COORD,
POINTER(wintypes.DWORD),
]
_FillConsoleOutputCharacterA.restype = wintypes.BOOL
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
_FillConsoleOutputAttribute.argtypes = [
wintypes.HANDLE,
wintypes.WORD,
wintypes.DWORD,
COORD,
POINTER(wintypes.DWORD),
]
_FillConsoleOutputAttribute.restype = wintypes.BOOL
_SetConsoleTitleW = windll.kernel32.SetConsoleTitleA
_SetConsoleTitleW.argtypes = [
wintypes.LPCSTR
]
_SetConsoleTitleW.restype = wintypes.BOOL
handles = {
STDOUT: _GetStdHandle(STDOUT),
STDERR: _GetStdHandle(STDERR),
}
def winapi_test():
handle = handles[STDOUT]
csbi = CONSOLE_SCREEN_BUFFER_INFO()
success = _GetConsoleScreenBufferInfo(
handle, byref(csbi))
return bool(success)
def GetConsoleScreenBufferInfo(stream_id=STDOUT):
handle = handles[stream_id]
csbi = CONSOLE_SCREEN_BUFFER_INFO()
success = _GetConsoleScreenBufferInfo(
handle, byref(csbi))
return csbi
def SetConsoleTextAttribute(stream_id, attrs):
handle = handles[stream_id]
return _SetConsoleTextAttribute(handle, attrs)
def SetConsoleCursorPosition(stream_id, position, adjust=True):
position = COORD(*position)
# If the position is out of range, do nothing.
if position.Y <= 0 or position.X <= 0:
return
# Adjust for Windows' SetConsoleCursorPosition:
# 1. being 0-based, while ANSI is 1-based.
# 2. expecting (x,y), while ANSI uses (y,x).
adjusted_position = COORD(position.Y - 1, position.X - 1)
if adjust:
# Adjust for viewport's scroll position
sr = GetConsoleScreenBufferInfo(STDOUT).srWindow
adjusted_position.Y += sr.Top
adjusted_position.X += sr.Left
# Resume normal processing
handle = handles[stream_id]
return _SetConsoleCursorPosition(handle, adjusted_position)
def FillConsoleOutputCharacter(stream_id, char, length, start):
handle = handles[stream_id]
char = c_char(char.encode())
length = wintypes.DWORD(length)
num_written = wintypes.DWORD(0)
# Note that this is hard-coded for ANSI (vs wide) bytes.
success = _FillConsoleOutputCharacterA(
handle, char, length, start, byref(num_written))
return num_written.value
def FillConsoleOutputAttribute(stream_id, attr, length, start):
''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )'''
handle = handles[stream_id]
attribute = wintypes.WORD(attr)
length = wintypes.DWORD(length)
num_written = wintypes.DWORD(0)
# Note that this is hard-coded for ANSI (vs wide) bytes.
return _FillConsoleOutputAttribute(
handle, attribute, length, start, byref(num_written))
def SetConsoleTitle(title):
return _SetConsoleTitleW(title)
PK 7�\X�i9� � __init__.pynu �[��� # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
from .initialise import init, deinit, reinit, colorama_text
from .ansi import Fore, Back, Style, Cursor
from .ansitowin32 import AnsiToWin32
__version__ = '0.3.7'
PK 7�\w=�2 2 initialise.pycnu �[��� �
��abc @ s� d d l Z d d l Z d d l Z d d l m Z d a d a d a d a e
a d � Z e
d d e
d � Z d � Z e j d � � Z d � Z d � Z d S(
i����Ni ( t AnsiToWin32c C s# t d k r t t � j � n d S( N( R t Nonet orig_stdoutt reset_all( ( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyR s c C s� | r+ t | | | g � r+ t d � � n t j a t j a t j d k rU d a n t t | | | | � t _ a t j d k r� d a
n t t | | | | � t _ a
t s� t j
t � t a n d S( Ns, wrap=False conflicts with any other arg=True( t anyt
ValueErrort syst stdoutR t stderrt orig_stderrR t wrapped_stdoutt wrap_streamt wrapped_stderrt atexit_donet atexitt registerR t True( t autoresett convertt stript wrap( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt init s
c C s4 t d k r t t _ n t d k r0 t t _ n d S( N( R R R R R R ( ( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt deinit3 s c o s% t | | � z d VWd t � Xd S( N( R R ( t argst kwargs( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt
colorama_text: s
c C s4 t d k r t t _ n t d k r0 t t _ n d S( N( R
R R R R R ( ( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt reinitC s c C sC | r? t | d | d | d | �} | j � r? | j } q? n | S( NR R R ( R t should_wrapt stream( R R R R R t wrapper( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyR J s ( R t
contextlibR t ansitowin32R R R R R
R t FalseR
R R R R t contextmanagerR R R ( ( ( sC /usr/lib/python2.7/site-packages/pip/_vendor/colorama/initialise.pyt <module> s PK 7�\�.�� � win32.pycnu �[��� �
��abc @ s} d Z d Z y? d d l Z d d l m Z e e j � Z d d l m Z Wn/ e e f k
r| d Z d � Z
d � Z n�Xd d l m Z m
Z
m Z m Z e j Z d e
f d
� � YZ e j j Z e j g e _ e j e _ e j j Z e j e e � g e _ e j e _ e j j
Z e j e j g e _ e j e _ e j j Z e j e g e _ e j e _ e j j! Z"