Skip to content

Commit 58de90c

Browse files
committed
Work for Issue #66
1 parent 38d8277 commit 58de90c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+24048
-0
lines changed

thirdparty/__init__.py

Whitespace-only changes.

thirdparty/ansistrm/__init__.py

Whitespace-only changes.

thirdparty/ansistrm/__init__.py~

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2012 sqlmap developers (http://sqlmap.org/)
5+
See the file 'doc/COPYING' for copying permission
6+
"""
7+
8+
pass

thirdparty/ansistrm/ansistrm.py

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#
2+
# Copyright (C) 2010-2012 Vinay Sajip. All rights reserved. Licensed under the new BSD license.
3+
#
4+
import logging
5+
import os
6+
import re
7+
8+
class ColorizingStreamHandler(logging.StreamHandler):
9+
# color names to indices
10+
color_map = {
11+
'black': 0,
12+
'red': 1,
13+
'green': 2,
14+
'yellow': 3,
15+
'blue': 4,
16+
'magenta': 5,
17+
'cyan': 6,
18+
'white': 7,
19+
}
20+
21+
# levels to (background, foreground, bold/intense)
22+
if os.name == 'nt':
23+
level_map = {
24+
logging.DEBUG: (None, 'blue', False),
25+
logging.INFO: (None, 'green', False),
26+
logging.WARNING: (None, 'yellow', False),
27+
logging.ERROR: (None, 'red', False),
28+
logging.CRITICAL: ('red', 'white', False)
29+
}
30+
else:
31+
level_map = {
32+
logging.DEBUG: (None, 'blue', False),
33+
logging.INFO: (None, 'green', False),
34+
logging.WARNING: (None, 'yellow', False),
35+
logging.ERROR: (None, 'red', False),
36+
logging.CRITICAL: ('red', 'white', False)
37+
}
38+
csi = '\x1b['
39+
reset = '\x1b[0m'
40+
41+
@property
42+
def is_tty(self):
43+
isatty = getattr(self.stream, 'isatty', None)
44+
return isatty and isatty()
45+
46+
def emit(self, record):
47+
try:
48+
message = self.format(record)
49+
stream = self.stream
50+
51+
if not self.is_tty:
52+
stream.write(message)
53+
else:
54+
self.output_colorized(message)
55+
stream.write(getattr(self, 'terminator', '\n'))
56+
57+
self.flush()
58+
except (KeyboardInterrupt, SystemExit):
59+
raise
60+
except:
61+
self.handleError(record)
62+
63+
if os.name != 'nt':
64+
def output_colorized(self, message):
65+
self.stream.write(message)
66+
else:
67+
import re
68+
ansi_esc = re.compile(r'\x1b\[((?:\d+)(?:;(?:\d+))*)m')
69+
70+
nt_color_map = {
71+
0: 0x00, # black
72+
1: 0x04, # red
73+
2: 0x02, # green
74+
3: 0x06, # yellow
75+
4: 0x01, # blue
76+
5: 0x05, # magenta
77+
6: 0x03, # cyan
78+
7: 0x07, # white
79+
}
80+
81+
def output_colorized(self, message):
82+
import ctypes
83+
84+
parts = self.ansi_esc.split(message)
85+
write = self.stream.write
86+
h = None
87+
fd = getattr(self.stream, 'fileno', None)
88+
89+
if fd is not None:
90+
fd = fd()
91+
92+
if fd in (1, 2): # stdout or stderr
93+
h = ctypes.windll.kernel32.GetStdHandle(-10 - fd)
94+
95+
while parts:
96+
text = parts.pop(0)
97+
98+
if text:
99+
write(text)
100+
101+
if parts:
102+
params = parts.pop(0)
103+
104+
if h is not None:
105+
params = [int(p) for p in params.split(';')]
106+
color = 0
107+
108+
for p in params:
109+
if 40 <= p <= 47:
110+
color |= self.nt_color_map[p - 40] << 4
111+
elif 30 <= p <= 37:
112+
color |= self.nt_color_map[p - 30]
113+
elif p == 1:
114+
color |= 0x08 # foreground intensity on
115+
elif p == 0: # reset to default color
116+
color = 0x07
117+
else:
118+
pass # error condition ignored
119+
120+
ctypes.windll.kernel32.SetConsoleTextAttribute(h, color)
121+
122+
def colorize(self, message, record):
123+
if record.levelno in self.level_map:
124+
bg, fg, bold = self.level_map[record.levelno]
125+
params = []
126+
127+
if bg in self.color_map:
128+
params.append(str(self.color_map[bg] + 40))
129+
130+
if fg in self.color_map:
131+
params.append(str(self.color_map[fg] + 30))
132+
133+
if bold:
134+
params.append('1')
135+
136+
if params and message:
137+
if message.lstrip() != message:
138+
prefix = re.search(r"\s+", message).group(0)
139+
message = message[len(prefix):]
140+
else:
141+
prefix = ""
142+
143+
message = "%s%s" % (prefix, ''.join((self.csi, ';'.join(params),
144+
'm', message, self.reset)))
145+
146+
return message
147+
148+
def format(self, record):
149+
message = logging.StreamHandler.format(self, record)
150+
return self.colorize(message, record)

thirdparty/ansistrm/ansistrm.py~

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#
2+
# Copyright (C) 2010-2012 Vinay Sajip. All rights reserved. Licensed under the new BSD license.
3+
#
4+
import logging
5+
import os
6+
import re
7+
8+
class ColorizingStreamHandler(logging.StreamHandler):
9+
# color names to indices
10+
color_map = {
11+
'black': 0,
12+
'red': 1,
13+
'green': 2,
14+
'yellow': 3,
15+
'blue': 4,
16+
'magenta': 5,
17+
'cyan': 6,
18+
'white': 7,
19+
}
20+
21+
# levels to (background, foreground, bold/intense)
22+
if os.name == 'nt':
23+
level_map = {
24+
logging.DEBUG: (None, 'blue', False),
25+
logging.INFO: (None, 'green', False),
26+
logging.WARNING: (None, 'yellow', False),
27+
logging.ERROR: (None, 'red', False),
28+
logging.CRITICAL: ('red', 'white', False)
29+
}
30+
else:
31+
level_map = {
32+
logging.DEBUG: (None, 'blue', False),
33+
logging.INFO: (None, 'green', False),
34+
logging.WARNING: (None, 'yellow', False),
35+
logging.ERROR: (None, 'red', False),
36+
logging.CRITICAL: ('red', 'white', False)
37+
}
38+
csi = '\x1b['
39+
reset = '\x1b[0m'
40+
41+
@property
42+
def is_tty(self):
43+
isatty = getattr(self.stream, 'isatty', None)
44+
return isatty and isatty()
45+
46+
def emit(self, record):
47+
try:
48+
message = self.format(record)
49+
stream = self.stream
50+
51+
if not self.is_tty:
52+
stream.write(message)
53+
else:
54+
self.output_colorized(message)
55+
stream.write(getattr(self, 'terminator', '\n'))
56+
57+
self.flush()
58+
except (KeyboardInterrupt, SystemExit):
59+
raise
60+
except:
61+
self.handleError(record)
62+
63+
if os.name != 'nt':
64+
def output_colorized(self, message):
65+
self.stream.write(message)
66+
else:
67+
import re
68+
ansi_esc = re.compile(r'\x1b\[((?:\d+)(?:;(?:\d+))*)m')
69+
70+
nt_color_map = {
71+
0: 0x00, # black
72+
1: 0x04, # red
73+
2: 0x02, # green
74+
3: 0x06, # yellow
75+
4: 0x01, # blue
76+
5: 0x05, # magenta
77+
6: 0x03, # cyan
78+
7: 0x07, # white
79+
}
80+
81+
def output_colorized(self, message):
82+
import ctypes
83+
84+
parts = self.ansi_esc.split(message)
85+
write = self.stream.write
86+
h = None
87+
fd = getattr(self.stream, 'fileno', None)
88+
89+
if fd is not None:
90+
fd = fd()
91+
92+
if fd in (1, 2): # stdout or stderr
93+
h = ctypes.windll.kernel32.GetStdHandle(-10 - fd)
94+
95+
while parts:
96+
text = parts.pop(0)
97+
98+
if text:
99+
write(text)
100+
101+
if parts:
102+
params = parts.pop(0)
103+
104+
if h is not None:
105+
params = [int(p) for p in params.split(';')]
106+
color = 0
107+
108+
for p in params:
109+
if 40 <= p <= 47:
110+
color |= self.nt_color_map[p - 40] << 4
111+
elif 30 <= p <= 37:
112+
color |= self.nt_color_map[p - 30]
113+
elif p == 1:
114+
color |= 0x08 # foreground intensity on
115+
elif p == 0: # reset to default color
116+
color = 0x07
117+
else:
118+
pass # error condition ignored
119+
120+
ctypes.windll.kernel32.SetConsoleTextAttribute(h, color)
121+
122+
def colorize(self, message, record):
123+
if record.levelno in self.level_map:
124+
bg, fg, bold = self.level_map[record.levelno]
125+
params = []
126+
127+
if bg in self.color_map:
128+
params.append(str(self.color_map[bg] + 40))
129+
130+
if fg in self.color_map:
131+
params.append(str(self.color_map[fg] + 30))
132+
133+
if bold:
134+
params.append('1')
135+
136+
if params:
137+
if message.lstrip() != message:
138+
prefix = re.search(r"\s+", message).group(0)
139+
message = message[len(prefix):]
140+
else:
141+
prefix = ""
142+
143+
message = "%s%s" % (prefix, ''.join((self.csi, ';'.join(params),
144+
'm', message, self.reset)))
145+
146+
return message
147+
148+
def format(self, record):
149+
message = logging.StreamHandler.format(self, record)
150+
return self.colorize(message, record)

thirdparty/beautifulsoup/__init__.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright (c) 2004-2010, Leonard Richardson
4+
#
5+
# All rights reserved.
6+
#
7+
# Redistribution and use in source and binary forms, with or without
8+
# modification, are permitted provided that the following conditions are
9+
# met:
10+
#
11+
# * Redistributions of source code must retain the above copyright
12+
# notice, this list of conditions and the following disclaimer.
13+
#
14+
# * Redistributions in binary form must reproduce the above
15+
# copyright notice, this list of conditions and the following
16+
# disclaimer in the documentation and/or other materials provided
17+
# with the distribution.
18+
#
19+
# * Neither the name of the the Beautiful Soup Consortium and All
20+
# Night Kosher Bakery nor the names of its contributors may be
21+
# used to endorse or promote products derived from this software
22+
# without specific prior written permission.
23+
#
24+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE, DAMMIT.
35+
#
36+
37+
pass

0 commit comments

Comments
 (0)