buggy
stringlengths
35
5.03k
fixed
stringlengths
46
62.5k
def test_http11_list(self): def test_http11_listlentwo(self): body = string.ascii_letters to_send = "GET /list_lentwo HTTP/1.1\n" "Content-Length: %s\n\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http11_list(self): def test_http11_listlentwo(self): body = string.ascii_letters to_send = "GET /list_lentwo HTTP/1.1\r\nContent-Length: %s\r\n\r\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_short_body(self): # check to see if server closes connection when body is too short # for cl header to_send = tobytes( "GET /short_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() ...
def test_short_body(self): # check to see if server closes connection when body is too short # for cl header to_send = tobytes( "GET /short_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connec...
def test_long_body(self): # check server doesnt close connection when body is too long # for cl header to_send = tobytes( "GET /long_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() sel...
def test_long_body(self): # check server doesnt close connection when body is too long # for cl header to_send = tobytes( "GET /long_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connect() ...
def test_equal_body(self): # check server doesnt close connection when body is equal to # cl header to_send = tobytes( "GET /equal_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() self....
def test_equal_body(self): # check server doesnt close connection when body is equal to # cl header to_send = tobytes( "GET /equal_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connect() ...
def test_equal_body(self): def test_no_content_length(self): # wtf happens when there's no content-length to_send = tobytes( "GET /no_content_length HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() ...
def test_equal_body(self): def test_no_content_length(self): # wtf happens when there's no content-length to_send = tobytes( "GET /no_content_length HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connec...
def tearDown(self): def test_request_body_too_large_with_wrong_cl_http10(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\n" "Content-Length: 5\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def tearDown(self): def test_request_body_too_large_with_wrong_cl_http10(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\r\nContent-Length: 5\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_wrong_cl_http10(self): def test_request_body_too_large_with_wrong_cl_http10_keepalive(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\n" "Content-Length: 5\n" "Connection: Keep-Alive\n\n" to_send += body to_send = tobytes(to_send) ...
def test_request_body_too_large_with_wrong_cl_http10(self): def test_request_body_too_large_with_wrong_cl_http10_keepalive(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\r\nContent-Length: 5\r\nConnection: Keep-Alive\r\n\r\n" to_send += body to_send = tobytes(to_send) ...
def test_request_body_too_large_with_wrong_cl_http10_keepalive(self): def test_request_body_too_large_with_no_cl_http10(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_wrong_cl_http10_keepalive(self): def test_request_body_too_large_with_no_cl_http10(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http10(self): def test_request_body_too_large_with_no_cl_http10_keepalive(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\nConnection: Keep-Alive\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http10(self): def test_request_body_too_large_with_no_cl_http10_keepalive(self): body = "a" * self.toobig to_send = "GET / HTTP/1.0\r\nConnection: Keep-Alive\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http10_keepalive(self): def test_request_body_too_large_with_wrong_cl_http11(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\n" "Content-Length: 5\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http10_keepalive(self): def test_request_body_too_large_with_wrong_cl_http11(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\r\nContent-Length: 5\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_wrong_cl_http11(self): def test_request_body_too_large_with_wrong_cl_http11_connclose(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\nContent-Length: 5\nConnection: close\n\n" to_send += body to_send = tobytes(to_send) self.con...
def test_request_body_too_large_with_wrong_cl_http11(self): def test_request_body_too_large_with_wrong_cl_http11_connclose(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\r\nContent-Length: 5\r\nConnection: close\r\n\r\n" to_send += body to_send = tobytes(to_send) ...
def test_request_body_too_large_with_wrong_cl_http11_connclose(self): def test_request_body_too_large_with_no_cl_http11(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_wrong_cl_http11_connclose(self): def test_request_body_too_large_with_no_cl_http11(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http11(self): def test_request_body_too_large_with_no_cl_http11_connclose(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\nConnection: close\n\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http11(self): def test_request_body_too_large_with_no_cl_http11_connclose(self): body = "a" * self.toobig to_send = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n" to_send += body to_send = tobytes(to_send) self.connect()
def test_request_body_too_large_with_no_cl_http11_connclose(self): def test_request_body_too_large_chunked_encoding(self): control_line = "20;\r\n" # 20 hex = 32 dec s = "This string has 32 characters.\r\n" to_send = "GET / HTTP/1.1\nTransfer-Encoding: chunked\n\n" repeat = control_...
def test_request_body_too_large_with_no_cl_http11_connclose(self): def test_request_body_too_large_chunked_encoding(self): control_line = "20;\r\n" # 20 hex = 32 dec s = "This string has 32 characters.\r\n" to_send = "GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n" repeat = co...
def tearDown(self): self.stop_subprocess() def test_before_start_response_http_10(self): to_send = "GET /before_start_response HTTP/1.0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def tearDown(self): self.stop_subprocess() def test_before_start_response_http_10(self): to_send = "GET /before_start_response HTTP/1.0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_before_start_response_http_10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_before_start_response_http_11(self): to_send = "GET /before_start_response HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_before_start_response_http_10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_before_start_response_http_11(self): to_send = "GET /before_start_response HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_before_start_response_http_11(self): def test_before_start_response_http_11_close(self): to_send = tobytes( "GET /before_start_response HTTP/1.1\n" "Connection: close\n\n" ) self.connect() self.sock.send(to_send)
def test_before_start_response_http_11(self): def test_before_start_response_http_11_close(self): to_send = tobytes( "GET /before_start_response HTTP/1.1\r\nConnection: close\r\n\r\n" ) self.connect() self.sock.send(to_send)
def test_before_start_response_http_11_close(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_start_response_http10(self): to_send = "GET /after_start_response HTTP/1.0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_before_start_response_http_11_close(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_start_response_http10(self): to_send = "GET /after_start_response HTTP/1.0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_start_response_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_start_response_http11(self): to_send = "GET /after_start_response HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_start_response_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_start_response_http11(self): to_send = "GET /after_start_response HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_start_response_http11(self): def test_after_start_response_http11_close(self): to_send = tobytes( "GET /after_start_response HTTP/1.1\n" "Connection: close\n\n" ) self.connect() self.sock.send(to_send)
def test_after_start_response_http11(self): def test_after_start_response_http11_close(self): to_send = tobytes( "GET /after_start_response HTTP/1.1\r\nConnection: close\r\n\r\n" ) self.connect() self.sock.send(to_send)
def test_after_start_response_http11_close(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_write_cb(self): to_send = "GET /after_write_cb HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_start_response_http11_close(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_after_write_cb(self): to_send = "GET /after_write_cb HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_write_cb(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_in_generator(self): to_send = "GET /in_generator HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_after_write_cb(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_in_generator(self): to_send = "GET /in_generator HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def tearDown(self): self.stop_subprocess() def test_filelike_http11(self): to_send = "GET /filelike HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def tearDown(self): self.stop_subprocess() def test_filelike_http11(self): to_send = "GET /filelike HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_http11(self): # connection has not been closed def test_filelike_nocl_http11(self): to_send = "GET /filelike_nocl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_http11(self): # connection has not been closed def test_filelike_nocl_http11(self): to_send = "GET /filelike_nocl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_nocl_http11(self): # connection has not been closed def test_filelike_shortcl_http11(self): to_send = "GET /filelike_shortcl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_nocl_http11(self): # connection has not been closed def test_filelike_shortcl_http11(self): to_send = "GET /filelike_shortcl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_shortcl_http11(self): # connection has not been closed def test_filelike_longcl_http11(self): to_send = "GET /filelike_longcl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_shortcl_http11(self): # connection has not been closed def test_filelike_longcl_http11(self): to_send = "GET /filelike_longcl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_longcl_http11(self): # connection has not been closed def test_notfilelike_http11(self): to_send = "GET /notfilelike HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_longcl_http11(self): # connection has not been closed def test_notfilelike_http11(self): to_send = "GET /notfilelike HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_http11(self): # connection has not been closed def test_notfilelike_iobase_http11(self): to_send = "GET /notfilelike_iobase HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_http11(self): # connection has not been closed def test_notfilelike_iobase_http11(self): to_send = "GET /notfilelike_iobase HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_iobase_http11(self): # connection has not been closed def test_notfilelike_nocl_http11(self): to_send = "GET /notfilelike_nocl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_iobase_http11(self): # connection has not been closed def test_notfilelike_nocl_http11(self): to_send = "GET /notfilelike_nocl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_nocl_http11(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_notfilelike_shortcl_http11(self): to_send = "GET /notfilelike_shortcl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_nocl_http11(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_notfilelike_shortcl_http11(self): to_send = "GET /notfilelike_shortcl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_shortcl_http11(self): # connection has not been closed def test_notfilelike_longcl_http11(self): to_send = "GET /notfilelike_longcl HTTP/1.1\n\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_shortcl_http11(self): # connection has not been closed def test_notfilelike_longcl_http11(self): to_send = "GET /notfilelike_longcl HTTP/1.1\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_longcl_http11(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_filelike_http10(self): to_send = "GET /filelike HTTP/1.0\n\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_longcl_http11(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_filelike_http10(self): to_send = "GET /filelike HTTP/1.0\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_filelike_nocl_http10(self): to_send = "GET /filelike_nocl HTTP/1.0\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_filelike_nocl_http10(self): to_send = "GET /filelike_nocl HTTP/1.0\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_filelike_nocl_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_notfilelike_http10(self): to_send = "GET /notfilelike HTTP/1.0\n\n" to_send = tobytes(to_send) self.connect()
def test_filelike_nocl_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_notfilelike_http10(self): to_send = "GET /notfilelike HTTP/1.0\r\n\r\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_notfilelike_nocl_http10(self): to_send = "GET /notfilelike_nocl HTTP/1.0\n\n" to_send = tobytes(to_send) self.connect()
def test_notfilelike_http10(self): self.assertRaises(ConnectionClosed, read_http, fp) def test_notfilelike_nocl_http10(self): to_send = "GET /notfilelike_nocl HTTP/1.0\r\n\r\n" to_send = tobytes(to_send) self.connect()
def read_http(fp): # pragma: no cover header_lines = [] while True: line = fp.readline() if line in (b"\r\n", b"\n", b""): break else: header_lines.append(line)
def read_http(fp): # pragma: no cover header_lines = [] while True: line = fp.readline() if line in (b"\r\n", b"\r\n", b""): break else: header_lines.append(line)
""" import unittest from waitress.compat import ( text_, tobytes, ) class TestHTTPRequestParser(unittest.TestCase):
""" import unittest from waitress.compat import text_, tobytes class TestHTTPRequestParser(unittest.TestCase):
def test_get_body_stream_nonNone(self): result = self.parser.get_body_stream() self.assertEqual(result, body_rcv) def test_received_nonsense_with_double_cr(self): data = b"""\ HTTP/1.0 GET /foobar """ result = self.parser.received(data) self.assertEqual(result, 22) ...
def test_get_body_stream_nonNone(self): result = self.parser.get_body_stream() self.assertEqual(result, body_rcv) def test_received_get_no_headers(self): data = b"HTTP/1.0 GET /foobar\r\n\r\n" result = self.parser.received(data) self.assertEqual(result, 24) self.asse...
def test_received_cl_too_large(self): from waitress.utilities import RequestEntityTooLarge self.parser.adj.max_request_body_size = 2 data = b"""\ GET /foobar HTTP/8.4 Content-Length: 10 """ result = self.parser.received(data) self.assertEqual(result, 41) self.assertTrue...
def test_received_cl_too_large(self): from waitress.utilities import RequestEntityTooLarge self.parser.adj.max_request_body_size = 2 data = b"GET /foobar HTTP/8.4\r\nContent-Length: 10\r\n\r\n" result = self.parser.received(data) self.assertEqual(result, 44) self.assertT...
def test_received_headers_too_large(self): from waitress.utilities import RequestHeaderFieldsTooLarge self.parser.adj.max_request_header_size = 2 data = b"""\ GET /foobar HTTP/8.4 X-Foo: 1 """ result = self.parser.received(data) self.assertEqual(result, 30) self.assertTr...
def test_received_headers_too_large(self): from waitress.utilities import RequestHeaderFieldsTooLarge self.parser.adj.max_request_header_size = 2 data = b"GET /foobar HTTP/8.4\r\nX-Foo: 1\r\n\r\n" result = self.parser.received(data) self.assertEqual(result, 34) self.asse...
def test_received_body_too_large(self): from waitress.utilities import RequestEntityTooLarge self.parser.adj.max_request_body_size = 2 data = b"""\ GET /foobar HTTP/1.1 Transfer-Encoding: chunked X-Foo: 1 20;\r\n This string has 32 characters\r\n 0\r\n\r\n""" result = self.parser.recei...
def test_received_body_too_large(self): from waitress.utilities import RequestEntityTooLarge self.parser.adj.max_request_body_size = 2 data = ( b"GET /foobar HTTP/1.1\r\n" b"Transfer-Encoding: chunked\r\n" b"X-Foo: 1\r\n" b"\r\n" b"1d;...
def test_received_body_too_large(self): def test_received_error_from_parser(self): from waitress.utilities import BadRequest data = b"""\ GET /foobar HTTP/1.1 Transfer-Encoding: chunked X-Foo: 1 garbage """ # header result = self.parser.received(data) # body result ...
def test_received_body_too_large(self): def test_received_error_from_parser(self): from waitress.utilities import BadRequest data = ( b"GET /foobar HTTP/1.1\r\n" b"Transfer-Encoding: chunked\r\n" b"X-Foo: 1\r\n" b"\r\n" b"garbage\r\n" ...
def test_close_with_no_body_rcv(self): self.parser.body_rcv = None self.parser.close() # doesn't raise class Test_split_uri(unittest.TestCase): def _callFUT(self, uri):
def test_close_with_no_body_rcv(self): self.parser.body_rcv = None self.parser.close() # doesn't raise def test_parse_header_lf_only(self): from waitress.parser import ParsingError data = b"GET /foobar HTTP/8.4\nfoo: bar" try: self.parser.parse_header(data) ...
def _callFUT(self, data): return get_header_lines(data) def test_get_header_lines(self): result = self._callFUT(b"slam\nslim") self.assertEqual(result, [b"slam", b"slim"]) def test_get_header_lines_folded(self):
def _callFUT(self, data): return get_header_lines(data) def test_get_header_lines(self): result = self._callFUT(b"slam\r\nslim") self.assertEqual(result, [b"slam", b"slim"]) def test_get_header_lines_folded(self):
def test_get_header_lines_folded(self): # interpreting the field value or forwarding the message downstream. # We are just preserving the whitespace that indicates folding. result = self._callFUT(b"slim\n slam") self.assertEqual(result, [b"slim slam"]) def test_get_header_lines_tab...
def test_get_header_lines_folded(self): # interpreting the field value or forwarding the message downstream. # We are just preserving the whitespace that indicates folding. result = self._callFUT(b"slim\r\n slam") self.assertEqual(result, [b"slim slam"]) def test_get_header_lines_t...
def setUp(self): def feed(self, data): parser = self.parser for n in range(100): # make sure we never loop forever consumed = parser.received(data) data = data[consumed:] if parser.completed: return raise ValueError("Looping") # pragma: ...
def setUp(self): def feed(self, data): parser = self.parser for n in range(100): # make sure we never loop forever consumed = parser.received(data) data = data[consumed:] if parser.completed: return raise ValueError("Looping") # pragma...
def testSimpleGET(self): self.assertFalse(parser.empty) self.assertEqual( parser.headers, {"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "7",}, ) self.assertEqual(parser.path, "/foobar") self.assertEqual(parser.command, "GET") self....
def testSimpleGET(self): self.assertFalse(parser.empty) self.assertEqual( parser.headers, {"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "6",}, ) self.assertEqual(parser.path, "/foobar") self.assertEqual(parser.command, "GET") self....
def testComplexGET(self): self.assertFalse(parser.empty) self.assertEqual( parser.headers, {"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "10",}, ) # path should be utf-8 encoded self.assertEqual(
def testComplexGET(self): self.assertFalse(parser.empty) self.assertEqual( parser.headers, {"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "10"}, ) # path should be utf-8 encoded self.assertEqual(
def testComplexGET(self): self.assertEqual(parser.get_body_stream().getvalue(), b"Hello mick") def testProxyGET(self): data = b"""\ GET https://example.com:8080/foobar HTTP/8.4 content-length: 7 Hello. """ parser = self.parser self.feed(data) self.assertTrue(parser.complete...
def testComplexGET(self): self.assertEqual(parser.get_body_stream().getvalue(), b"Hello mick") def testProxyGET(self): data = ( b"GET https://example.com:8080/foobar HTTP/8.4\r\n" b"content-length: 6\r\n" b"\r\n" b"Hello." ) parser = s...
def test_received_control_line_notfinished(self): def test_received_control_line_finished_garbage_in_input(self): buf = DummyBuffer() inst = self._makeOne(buf) result = inst.received(b"garbage\n") self.assertEqual(result, 8) self.assertTrue(inst.error) def test_received_...
def test_received_control_line_notfinished(self): def test_received_control_line_finished_garbage_in_input(self): buf = DummyBuffer() inst = self._makeOne(buf) result = inst.received(b"garbage\r\n") self.assertEqual(result, 9) self.assertTrue(inst.error) def test_receive...
def test_received_trailer_startswith_lf(self): inst.all_chunks_received = True result = inst.received(b"\n") self.assertEqual(result, 1) self.assertEqual(inst.completed, True) def test_received_trailer_not_finished(self): buf = DummyBuffer()
def test_received_trailer_startswith_lf(self): inst.all_chunks_received = True result = inst.received(b"\n") self.assertEqual(result, 1) self.assertEqual(inst.completed, False) def test_received_trailer_not_finished(self): buf = DummyBuffer()
def test___len__(self): inst = self._makeOne(buf) self.assertEqual(inst.__len__(), 2) class DummyBuffer(object): def __init__(self, data=None):
def test___len__(self): inst = self._makeOne(buf) self.assertEqual(inst.__len__(), 2) def test_received_chunk_is_properly_terminated(self): buf = DummyBuffer() inst = self._makeOne(buf) data = b"4\r\nWiki\r\n" result = inst.received(data) self.assertEqual(res...
def test_one_linefeed(self): self.assertEqual(self._callFUT(b"\n"), -1) def test_double_linefeed(self): self.assertEqual(self._callFUT(b"\n\n"), 2) def test_one_crlf(self): self.assertEqual(self._callFUT(b"\r\n"), -1)
def test_one_linefeed(self): self.assertEqual(self._callFUT(b"\n"), -1) def test_double_linefeed(self): self.assertEqual(self._callFUT(b"\n\n"), -1) def test_one_crlf(self): self.assertEqual(self._callFUT(b"\r\n"), -1)
def test_double_crfl(self): self.assertEqual(self._callFUT(b"\r\n\r\n"), 4) def test_mixed(self): self.assertEqual(self._callFUT(b"\n\n00\r\n\r\n"), 2) class TestBadRequest(unittest.TestCase):
def test_double_crfl(self): self.assertEqual(self._callFUT(b"\r\n\r\n"), 4) def test_mixed(self): self.assertEqual(self._callFUT(b"\n\n00\r\n\r\n"), 8) class TestBadRequest(unittest.TestCase):
def find_double_newline(s): """Returns the position just after a double newline in the given string.""" pos1 = s.find(b"\n\r\n") # One kind of double newline if pos1 >= 0: pos1 += 3 pos2 = s.find(b"\n\n") # Another kind of double newline if pos2 >= 0: pos2 += 2 if pos1 >= 0: ...
def find_double_newline(s): """Returns the position just after a double newline in the given string.""" pos = s.find(b"\r\n\r\n") if pos >= 0: pos += 4 return pos def concat(*args):
def _parse_jp2_header(fp): else: hlen = 8 if tbox == b'jp2h': header = fp.read(lbox - hlen) break
def _parse_jp2_header(fp): else: hlen = 8 if lbox < hlen: raise SyntaxError('Invalid JP2 header length') if tbox == b'jp2h': header = fp.read(lbox - hlen) break
from lookatme.exceptions import IgnoredByContrib def render_code(token, body, stack, loop): lang = token["lang"] or "" if lang != "calendar":
from lookatme.exceptions import IgnoredByContrib def user_warnings(): """No warnings exist for this extension. Anything you want to warn the user about, such as security risks in processing untrusted markdown, should go here. """ return [] def render_code(token, body, stack, loop): lang = to...
is_flag=True, default=False, ) @click.option( "-e", "--exts",
is_flag=True, default=False, ) @click.option( "-s", "--safe", help="Do not load any new extensions specified in the source markdown. " "Extensions specified via env var or -e are still loaded", is_flag=True, default=False, ) @click.option( "--no-ext-warn", help="Load new ext...
nargs=-1, ) def main(debug, log_path, theme, code_style, dump_styles, input_files, live_reload, extensions, single_slide): """lookatme - An interactive, terminal-based markdown presentation tool. """ if debug: lookatme.config.LOG = lookatme.log.create_log(log_path)
nargs=-1, ) def main(debug, log_path, theme, code_style, dump_styles, input_files, live_reload, extensions, single_slide, safe, no_ext_warn, ignore_ext_failure): """lookatme - An interactive, terminal-based markdown presentation tool. See https://lookatme.readthedocs.io/en/v{{VERSION}...
def main(debug, log_path, theme, code_style, dump_styles, live_reload=live_reload, single_slide=single_slide, preload_extensions=preload_exts, ) if dump_styles:
def main(debug, log_path, theme, code_style, dump_styles, live_reload=live_reload, single_slide=single_slide, preload_extensions=preload_exts, safe=safe, no_ext_warn=no_ext_warn, ignore_ext_failure=ignore_ext_failure, ) if dump_styles:
import contextlib from lookatme.exceptions import IgnoredByContrib from . import terminal from . import file_loader CONTRIB_MODULES = [ terminal, file_loader, ] def load_contribs(contrib_names): """Load all contrib modules specified by ``contrib_names``. These should all be namespaced packages und...
import contextlib import lookatme.ascii_art from lookatme.exceptions import IgnoredByContrib import lookatme.prompt from . import terminal from . import file_loader CONTRIB_MODULES = [] def validate_extension_mod(ext_name, ext_mod): """Validate the extension, returns an array of warnings associated with the ...
from lookatme.exceptions import IgnoredByContrib class YamlRender: loads = lambda data: yaml.safe_load(data) dumps = lambda data: yaml.safe_dump(data)
from lookatme.exceptions import IgnoredByContrib def user_warnings(): """Provide warnings to the user that loading this extension may cause shell commands specified in the markdown to be run. """ return [ "Code-blocks with a language starting with 'file' may cause shell", " commands f...
import lookatme.config class YamlRender: loads = lambda data: yaml.safe_load(data) dumps = lambda data: yaml.safe_dump(data)
import lookatme.config def user_warnings(): """Provide warnings to the user that loading this extension may cause shell commands specified in the markdown to be run. """ return [ "Code-blocks with a language starting with 'terminal' will cause shell", " commands from the source markdo...
import lookatme.config import lookatme.contrib from lookatme.parser import Parser import lookatme.themes import lookatme.tui from lookatme.utils import dict_deep_update
import lookatme.config import lookatme.contrib from lookatme.parser import Parser import lookatme.prompt import lookatme.themes import lookatme.tui from lookatme.utils import dict_deep_update
class Presentation(object): """Defines a presentation """ def __init__(self, input_stream, theme, style_override=None, live_reload=False, single_slide=False, preload_extensions=None): """Creates a new Presentation :param stream input_stream: An input stream from which to re...
class Presentation(object): """Defines a presentation """ def __init__(self, input_stream, theme, style_override=None, live_reload=False, single_slide=False, preload_extensions=None, safe=False, no_ext_warn=False, ignore_ext_failure=False): """Creates a new Presenta...
def __init__(self, input_stream, theme, style_override=None, live_reload=False, self.live_reload = live_reload self.tui = None self.single_slide = single_slide self.theme_mod = __import__("lookatme.themes." + theme, fromlist=[theme])
def __init__(self, input_stream, theme, style_override=None, live_reload=False, self.live_reload = live_reload self.tui = None self.single_slide = single_slide self.safe = safe self.no_ext_warn = no_ext_warn self.ignore_ext_failure = ignore_ext_failure self.initia...
def __init__(self, input_stream, theme, style_override=None, live_reload=False, self.reload_thread.start() self.reload(data=input_stream.read()) def reload_watcher(self): """Watch for changes to the input filename, automatically reloading
def __init__(self, input_stream, theme, style_override=None, live_reload=False, self.reload_thread.start() self.reload(data=input_stream.read()) self.initial_load_complete = True def reload_watcher(self): """Watch for changes to the input filename, automatically reloading
def reload(self, data=None): parser = Parser(single_slide=self.single_slide) self.meta, self.slides = parser.parse(data) all_exts = set(self.preload_extensions) all_exts |= set(self.meta.get("extensions", [])) lookatme.contrib.load_contribs(all_exts) self.styles = looka...
def reload(self, data=None): parser = Parser(single_slide=self.single_slide) self.meta, self.slides = parser.parse(data) # only load extensions once! Live editing does not support # auto-extension reloading if not self.initial_load_complete: safe_exts = set(self.prel...
def reload(self, data=None): self.styles["style"] = self.style_override lookatme.config.STYLE = self.styles def run(self, start_slide=0): """Run the presentation!
def reload(self, data=None): self.styles["style"] = self.style_override lookatme.config.STYLE = self.styles self.initial_load_complete = True def warn_exts(self, exts): """Warn about source-provided extensions that are to-be-loaded """ if len(exts) == 0 or self....
class Index(IndexOpsMixin, PandasObject): self._invalid_indexer("label", key) elif kind == "loc" and is_integer(key): if not self.holds_integer(): self._invalid_indexer("label", key) return key
class Index(IndexOpsMixin, PandasObject): self._invalid_indexer("label", key) elif kind == "loc" and is_integer(key): if not (is_integer_dtype(self.dtype) or is_object_dtype(self.dtype)): self._invalid_indexer("label", key) return key
class Series(base.IndexOpsMixin, generic.NDFrame): if takeable: return self._values[label] # We assume that _convert_scalar_indexer has already been called, # with kind="loc", if necessary, by the time we get here return self.index.get_value(self, label) def __setitem_...
class Series(base.IndexOpsMixin, generic.NDFrame): if takeable: return self._values[label] # Similar to Index.get_value, but we do not fall back to positional loc = self.index.get_loc(label) # We assume that _convert_scalar_indexer has already been called, # with ki...
class TestCategoricalIndex: with pytest.raises(TypeError, match=msg): df.loc["d", "C"] = 10 msg = ( "cannot do label indexing on CategoricalIndex with these " r"indexers \[1\] of type int" ) with pytest.raises(TypeError, match=msg): df.loc...
class TestCategoricalIndex: with pytest.raises(TypeError, match=msg): df.loc["d", "C"] = 10 with pytest.raises(KeyError, match="^1$"): df.loc[1] def test_getitem_scalar(self):
class TestLoc(Base): def test_loc_getitem_int(self): # int label self.check_result("loc", 2, typs=["labels"], fails=TypeError) def test_loc_getitem_label(self):
class TestLoc(Base): def test_loc_getitem_int(self): # int label self.check_result("loc", 2, typs=["labels"], fails=KeyError) def test_loc_getitem_label(self):
class TestLoc(Base): self.check_result( "loc", 20, typs=["ints", "uints", "mixed"], fails=KeyError, ) self.check_result("loc", 20, typs=["labels"], fails=TypeError) self.check_result("loc", 20, typs=["ts"], axes=0, fails=TypeError) self.check_result("loc", 20, typs=["...
class TestLoc(Base): self.check_result( "loc", 20, typs=["ints", "uints", "mixed"], fails=KeyError, ) self.check_result("loc", 20, typs=["labels"], fails=KeyError) self.check_result("loc", 20, typs=["ts"], axes=0, fails=TypeError) self.check_result("loc", 20, typs=["f...
def test_loc_set_dataframe_multiindex(): result = expected.copy() result.loc[0, [(0, 1)]] = result.loc[0, [(0, 1)]] tm.assert_frame_equal(result, expected)
def test_loc_set_dataframe_multiindex(): result = expected.copy() result.loc[0, [(0, 1)]] = result.loc[0, [(0, 1)]] tm.assert_frame_equal(result, expected) def test_loc_mixed_int_float(): # GH#19456 ser = pd.Series(range(2), pd.Index([1, 2.0], dtype=object)) result = ser.loc[1] assert res...
class TestScalar2: result = ser.loc["a"] assert result == 1 msg = ( "cannot do label indexing on Index " r"with these indexers \[0\] of type int" ) with pytest.raises(TypeError, match=msg): ser.at[0] with pytest.raises(TypeError, match...
class TestScalar2: result = ser.loc["a"] assert result == 1 with pytest.raises(KeyError, match="^0$"): ser.at[0] with pytest.raises(KeyError, match="^0$"): ser.loc[0] def test_frame_raises_key_error(self): # GH#31724 .at should match .loc df ...
class TestScalar2: result = df.loc["a", "A"] assert result == 1 msg = ( "cannot do label indexing on Index " r"with these indexers \[0\] of type int" ) with pytest.raises(TypeError, match=msg): df.at["a", 0] with pytest.raises(TypeErro...
class TestScalar2: result = df.loc["a", "A"] assert result == 1 with pytest.raises(KeyError, match="^0$"): df.at["a", 0] with pytest.raises(KeyError, match="^0$"): df.loc["a", 0] def test_series_at_raises_key_error(self):
class Series(base.IndexOpsMixin, generic.NDFrame): else: return self.iloc[key] if isinstance(key, list): # handle the dup indexing case GH#4246 return self.loc[key] return self.reindex(key) def _get_values_tuple(self, key): # mpl hackaro...
class Series(base.IndexOpsMixin, generic.NDFrame): else: return self.iloc[key] # handle the dup indexing case GH#4246 return self.loc[key] def _get_values_tuple(self, key): # mpl hackaround
def test_getitem_boolean_empty(): # GH5877 # indexing with empty series s = Series(["A", "B"]) expected = Series(np.nan, index=["C"], dtype=object) result = s[Series(["C"], dtype=object)] tm.assert_series_equal(result, expected) s = Series(["A", "B"]) expected = Series(dtype=object, in...
def test_getitem_boolean_empty(): # GH5877 # indexing with empty series s = Series(["A", "B"]) expected = Series(dtype=object, index=Index([], dtype="int64")) result = s[Series([], dtype=object)]
class TestSeriesGetitemSlices: class TestSeriesGetitemListLike: def test_getitem_intlist_intindex_periodvalues(self): ser = Series(period_range("2000-01-01", periods=10, freq="D"))
class TestSeriesGetitemSlices: class TestSeriesGetitemListLike: @pytest.mark.parametrize("box", [list, np.array, pd.Index, pd.Series]) def test_getitem_no_matches(self, box): # GH#33462 we expect the same behavior for list/ndarray/Index/Series ser = Series(["A", "B"]) key = Series(["C...
import re import shlex import pkgutil import xml.etree.ElementTree as ET from ansible.errors import AnsibleError from ansible.module_utils._text import to_bytes, to_text
import re import shlex import pkgutil import xml.etree.ElementTree as ET import ntpath from ansible.errors import AnsibleError from ansible.module_utils._text import to_bytes, to_text
class ShellModule(ShellBase): return "" def join_path(self, *args): parts = [] for arg in args: arg = self._unquote(arg).replace('/', '\\') parts.extend([a for a in arg.split('\\') if a]) path = '\\'.join(parts) if path.startswith('~'): re...
class ShellModule(ShellBase): return "" def join_path(self, *args): # use normpath() to remove doubled slashed and convert forward to backslashes parts = [ntpath.normpath(self._unquote(arg)) for arg in args] # Becuase ntpath.join treats any component that begins with a backslash as...
from ansible.plugins.shell.powershell import _parse_clixml def test_parse_clixml_empty():
from ansible.plugins.shell.powershell import _parse_clixml, ShellModule def test_parse_clixml_empty():
def test_parse_clixml_multiple_streams(): expected = b"hi info" actual = _parse_clixml(multiple_stream, stream="Info") assert actual == expected
def test_parse_clixml_multiple_streams(): expected = b"hi info" actual = _parse_clixml(multiple_stream, stream="Info") assert actual == expected def test_join_path_unc(): pwsh = ShellModule() unc_path_parts = ['\\\\host\\share\\dir1\\\\dir2\\', '\\dir3/dir4', 'dir5', 'dir6\\'] expected = '\\\\...
class Index(IndexOpsMixin, PandasObject): if is_categorical(target): tgt_values = np.asarray(target) elif self.is_all_dates: tgt_values = target.asi8 else: tgt_values = target._ndarray_values
class Index(IndexOpsMixin, PandasObject): if is_categorical(target): tgt_values = np.asarray(target) elif self.is_all_dates and target.is_all_dates: # GH 30399 tgt_values = target.asi8 else: tgt_values = target._ndarray_values
def test_drop_not_lexsorted(): tm.assert_index_equal(lexsorted_mi, not_lexsorted_mi) with tm.assert_produces_warning(PerformanceWarning): tm.assert_index_equal(lexsorted_mi.drop("a"), not_lexsorted_mi.drop("a"))
def test_drop_not_lexsorted(): tm.assert_index_equal(lexsorted_mi, not_lexsorted_mi) with tm.assert_produces_warning(PerformanceWarning): tm.assert_index_equal(lexsorted_mi.drop("a"), not_lexsorted_mi.drop("a")) def test_drop_with_non_unique_datetime_index_and_invalid_keys(): # GH 30399 # def...
class URLValidator(RegexValidator): r'\Z', re.IGNORECASE) message = _('Enter a valid URL.') schemes = ['http', 'https', 'ftp', 'ftps'] def __init__(self, schemes=None, **kwargs): super().__init__(**kwargs)
class URLValidator(RegexValidator): r'\Z', re.IGNORECASE) message = _('Enter a valid URL.') schemes = ['http', 'https', 'ftp', 'ftps'] unsafe_chars = frozenset('\t\r\n') def __init__(self, schemes=None, **kwargs): super().__init__(**kwargs)
class URLValidator(RegexValidator): def __call__(self, value): if not isinstance(value, str): raise ValidationError(self.message, code=self.code, params={'value': value}) # Check if the scheme is valid. scheme = value.split('://')[0].lower() if scheme not in self.schemes:
class URLValidator(RegexValidator): def __call__(self, value): if not isinstance(value, str): raise ValidationError(self.message, code=self.code, params={'value': value}) if self.unsafe_chars.intersection(value): raise ValidationError(self.message, code=self.code, params={'va...
TEST_DATA = [ (URLValidator(), None, ValidationError), (URLValidator(), 56, ValidationError), (URLValidator(), 'no_scheme', ValidationError), # Trailing newlines not accepted (URLValidator(), 'http://www.djangoproject.com/\n', ValidationError), (URLValidator(), 'http://[::ffff:192.9.5.5]\n', Val...
TEST_DATA = [ (URLValidator(), None, ValidationError), (URLValidator(), 56, ValidationError), (URLValidator(), 'no_scheme', ValidationError), # Newlines and tabs are not accepted. (URLValidator(), 'http://www.djangoproject.com/\n', ValidationError), (URLValidator(), 'http://[::ffff:192.9.5.5]\n'...
class TestUtil(unittest.TestCase): self.assertEqual(unified_strdate('8/7/2009'), '20090708') self.assertEqual(unified_strdate('Dec 14, 2012'), '20121214') self.assertEqual(unified_strdate('2012/10/11 01:56:38 +0000'), '20121011') def test_find_xpath_attr(self): testxml = u'''<root>
class TestUtil(unittest.TestCase): self.assertEqual(unified_strdate('8/7/2009'), '20090708') self.assertEqual(unified_strdate('Dec 14, 2012'), '20121214') self.assertEqual(unified_strdate('2012/10/11 01:56:38 +0000'), '20121011') self.assertEqual(unified_strdate('1968-12-10'), '19681210'...
def unified_strdate(date_str): """Return a string with the date in the format YYYYMMDD""" upload_date = None #Replace commas date_str = date_str.replace(',',' ') # %z (UTC offset) is only supported in python>=3.2 date_str = re.sub(r' ?(\+|-)[0-9:]*$', '', date_str) format_expressions = [ ...
def unified_strdate(date_str): """Return a string with the date in the format YYYYMMDD""" upload_date = None #Replace commas date_str = date_str.replace(',', ' ') # %z (UTC offset) is only supported in python>=3.2 date_str = re.sub(r' ?(\+|-)[0-9]{2}:?[0-9]{2}$', '', date_str) format_express...
ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4') <p begin="3" dur="-1">Ignored, three</p> </div> </body> </tt>''' srt_data = '''1 00:00:00,000 --> 00:00:01,000 The following line contains Chinese characters and special symbols
ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4') <p begin="3" dur="-1">Ignored, three</p> </div> </body> </tt>'''.encode('utf-8') srt_data = '''1 00:00:00,000 --> 00:00:01,000 The following line contains Chinese characters and ...
Line <p begin="0" end="1">The first line</p> </div> </body> </tt>''' srt_data = '''1 00:00:00,000 --> 00:00:01,000 The first line
Line <p begin="0" end="1">The first line</p> </div> </body> </tt>'''.encode('utf-8') srt_data = '''1 00:00:00,000 --> 00:00:01,000 The first line
The first line <p style="s1" tts:textDecoration="underline" begin="00:00:09.56" id="p2" end="00:00:12.36"><span style="s2" tts:color="lime">inner<br /> </span>style</p> </div> </body> </tt>''' srt_data = '''1 00:00:02,080 --> 00:00:05,839 <font color="white" face="sansSerif" size="16">default style<...
The first line <p style="s1" tts:textDecoration="underline" begin="00:00:09.56" id="p2" end="00:00:12.36"><span style="s2" tts:color="lime">inner<br /> </span>style</p> </div> </body> </tt>'''.encode('utf-8') srt_data = '''1 00:00:02,080 --> 00:00:05,839 <font color="white" face="sansSerif" size="16...
part 3</font></u> ''' self.assertEqual(dfxp2srt(dfxp_data_with_style), srt_data) def test_cli_option(self): self.assertEqual(cli_option({'proxy': '127.0.0.1:3128'}, '--proxy', 'proxy'), ['--proxy', '127.0.0.1:3128']) self.assertEqual(cli_option({'proxy': None}, '--proxy', 'proxy'), [])
part 3</font></u> ''' self.assertEqual(dfxp2srt(dfxp_data_with_style), srt_data) dfxp_data_non_utf8 = '''<?xml version="1.0" encoding="UTF-16"?> <tt xmlns="http://www.w3.org/ns/ttml" xml:lang="en" xmlns:tts="http://www.w3.org/ns/ttml#parameter"> <body> <div xml:l...
class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor): dfxp_file = old_file srt_file = subtitles_filename(filename, lang, 'srt') with io.open(dfxp_file, 'rt', encoding='utf-8') as f: srt_data = dfxp2srt(f.read()) with io.open(srt_file...
class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor): dfxp_file = old_file srt_file = subtitles_filename(filename, lang, 'srt') with open(dfxp_file, 'rb') as f: srt_data = dfxp2srt(f.read()) with io.open(srt_file, 'wt', encoding='utf...
def srt_subtitles_timecode(seconds): def dfxp2srt(dfxp_data): LEGACY_NAMESPACES = ( ('http://www.w3.org/ns/ttml', [ 'http://www.w3.org/2004/11/ttaf1', 'http://www.w3.org/2006/04/ttaf1', 'http://www.w3.org/2006/10/ttaf1', ]), ('http://www.w3.org/ns/ttml#s...
def srt_subtitles_timecode(seconds): def dfxp2srt(dfxp_data): ''' @param dfxp_data A bytes-like object containing DFXP data @returns A unicode object containing converted SRT data ''' LEGACY_NAMESPACES = ( (b'http://www.w3.org/ns/ttml', [ b'http://www.w3.org/2004/11/ttaf1', ...
def dfxp2srt(dfxp_data): for ns in v: dfxp_data = dfxp_data.replace(ns, k) dfxp = compat_etree_fromstring(dfxp_data.encode('utf-8')) out = [] paras = dfxp.findall(_x('.//ttml:p')) or dfxp.findall('.//p')
def dfxp2srt(dfxp_data): for ns in v: dfxp_data = dfxp_data.replace(ns, k) dfxp = compat_etree_fromstring(dfxp_data) out = [] paras = dfxp.findall(_x('.//ttml:p')) or dfxp.findall('.//p')
def test_osx_proxy_bypass(self): bypass = {'exclude_simple': True, 'exceptions': []} self.assertTrue(_proxy_bypass_macosx_sysconf('test', bypass)) def test_basic_auth(self, quote_char='"'): opener = OpenerDirector() password_manager = MockPasswordManager() auth_handler = url...
def test_osx_proxy_bypass(self): bypass = {'exclude_simple': True, 'exceptions': []} self.assertTrue(_proxy_bypass_macosx_sysconf('test', bypass)) def check_basic_auth(self, headers, realm): with self.subTest(realm=realm, headers=headers): opener = OpenerDirector() p...
class AbstractBasicAuthHandler: # allow for double- and single-quoted realm values # (single quotes are a violation of the RFC, but appear in the wild) rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+' 'realm=(["\']?)([^"\']*)\\2', re.I) # XXX could pre-emptively send auth info alrea...
class AbstractBasicAuthHandler: # allow for double- and single-quoted realm values # (single quotes are a violation of the RFC, but appear in the wild) rx = re.compile('(?:^|,)' # start of the string or ',' '[ \t]*' # optional whitespaces '([^ \t]+)' # scheme li...