Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add lint target to test and make it happier.

  • Loading branch information...
commit c01147278a2b0b268224f89112a8ef1ea0fc3d34 1 parent 0982c2a
@mnot authored
View
9 test/Makefile
@@ -7,4 +7,11 @@ test: $(PY_TESTS)
.PHONY: $(PY_TESTS)
$(PY_TESTS):
- $(python) $@
+ PYTHONPATH=../ $(python) $@
+
+.PHONY: lint
+lint:
+ PYTHONPATH=../ pylint-2.7 -i y \
+ -d C0103,R0801,W0612,W0613 \
+ thor
+
View
1  test/framework.py
@@ -10,7 +10,6 @@
import threading
import unittest
-sys.path.insert(0, "..")
import thor
test_host = "127.0.0.1"
View
1  test/test_events.py
@@ -3,7 +3,6 @@
import sys
import unittest
-sys.path.insert(0, "..")
from thor.events import EventEmitter, on
class TestEventEmitter(unittest.TestCase):
View
1  test/test_http_client.py
@@ -8,7 +8,6 @@
import framework
from framework import test_host, test_port
-sys.path.insert(0, "..")
import thor
from thor.events import on
View
1  test/test_http_parser.py
@@ -6,7 +6,6 @@
from framework import DummyHttpParser
-sys.path.insert(0, "..")
import thor.http.error as error
View
1  test/test_http_server.py
@@ -7,7 +7,6 @@
import framework
-sys.path.insert(0, "..")
import thor
from thor.events import on
View
1  test/test_http_utils.py
@@ -3,7 +3,6 @@
import sys
import unittest
-sys.path.insert(0, "..")
from thor.http.common import header_names, header_dict, get_header
hdrs = [
View
1  test/test_loop.py
@@ -10,7 +10,6 @@
from framework import make_fifo
-sys.path.insert(0, "../")
import thor.loop
View
2  test/test_tcp_client.py
@@ -7,8 +7,6 @@
import threading
import unittest
-sys.path.insert(0, "..")
-
from thor import loop
from thor.tcp import TcpClient
View
1  test/test_tcp_server.py
@@ -7,7 +7,6 @@
import framework
-sys.path.insert(0, "..")
import thor
from thor.events import on
View
1  test/test_udp.py
@@ -6,7 +6,6 @@
import threading
import unittest
-sys.path.insert(0, "..")
from thor import loop
from thor.udp import UdpEndpoint
View
13 thor/__init__.py
@@ -3,13 +3,14 @@
"""
Simple Event-Driven IO for Python
-Thor is a Python library for evented IO, with a focus on enabling high-performance HTTP intermediaries.
+Thor is a Python library for evented IO, with a focus on enabling
+high-performance HTTP intermediaries.
"""
__version__ = "0.1"
-from loop import run, stop, time, schedule, running
-from tcp import TcpClient, TcpServer
-from udp import UdpEndpoint
-from http.client import HttpClient
-from http.server import HttpServer
+from thor.loop import run, stop, time, schedule, running
+from thor.tcp import TcpClient, TcpServer
+from thor.udp import UdpEndpoint
+from thor.http.client import HttpClient
+from thor.http.server import HttpServer
View
8 thor/http/__init__.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-from client import HttpClient
-from server import HttpServer
-from common import header_names, header_dict, get_header, \
- safe_methods, idempotent_methods, hop_by_hop_hdrs
+from thor.http.client import HttpClient
+from thor.http.server import HttpServer
+from thor.http.common import header_names, header_dict, get_header, \
+ safe_methods, idempotent_methods, hop_by_hop_hdrs
View
4 thor/http/client.py
@@ -41,12 +41,12 @@
from thor.tcp import TcpClient
from thor.tls import TlsClient
-from common import HttpMessageHandler, \
+from thor.http.common import HttpMessageHandler, \
CLOSE, COUNTED, CHUNKED, NOBODY, \
WAITING, ERROR, \
idempotent_methods, no_body_status, hop_by_hop_hdrs, \
header_names
-from error import UrlError, ConnectError, \
+from thor.http.error import UrlError, ConnectError, \
ReadTimeoutError, HttpVersionError
req_rm_hdrs = hop_by_hop_hdrs + ['host']
View
13 thor/http/common.py
@@ -33,7 +33,7 @@
from collections import defaultdict
import re
-import error
+from thor.http import error
lws = re.compile("\r?\n[ \t]+", re.M)
hdr_end = re.compile(r"\r?\n\r?\n", re.M)
@@ -303,18 +303,18 @@ def _parse_fields(self, header_lines, gather_conn_info=False):
else: # top header starts with whitespace
self.input_error(error.TopLineSpaceError(line))
if not self.inspecting:
- return
+ return
try:
fn, fv = line.split(":", 1)
except ValueError:
if self.inspecting:
- hdr_tuples.append(line)
+ hdr_tuples.append(line)
else:
- continue # TODO: error on unparseable field?
+ continue # TODO: error on unparseable field?
if fn[-1] in [" ", "\t"]:
self.input_error(error.HeaderSpaceError(fn))
if not self.inspecting:
- return
+ return
hdr_tuples.append((fn, fv))
if gather_conn_info:
@@ -453,7 +453,8 @@ def output_end(self, trailers):
elif self._output_delimit == COUNTED:
pass # TODO: double-check the length
elif self._output_delimit == CLOSE:
- self.tcp_conn.close() # TODO: abstract out?
+ # FIXME: abstract out
+ self.tcp_conn.close() # pylint: disable=E1101
elif self._output_delimit == None:
pass # encountered an error before we found a delmiter
else:
View
7 thor/http/server.py
@@ -40,12 +40,13 @@
from thor.events import EventEmitter, on
from thor.tcp import TcpServer
-from common import HttpMessageHandler, \
+from thor.http.common import HttpMessageHandler, \
CLOSE, COUNTED, CHUNKED, \
- WAITING, \
+ ERROR, \
hop_by_hop_hdrs, \
get_header, header_names
-from error import HttpVersionError, HostRequiredError, TransferCodeError
+from thor.http.error import HttpVersionError, HostRequiredError, \
+ TransferCodeError
class HttpServer(EventEmitter):
View
6 thor/loop.py
@@ -35,7 +35,7 @@
import sys
import time as systime
-from events import EventEmitter
+from thor.events import EventEmitter
assert sys.version_info[0] == 2 and sys.version_info[1] >= 6, \
"Please use Python 2.6 or greater"
@@ -217,6 +217,7 @@ class PollLoop(LoopBase):
"""
def __init__(self, *args):
+ # pylint: disable=E1101
self._event_types = {
select.POLLIN: 'readable',
select.POLLOUT: 'writable',
@@ -226,6 +227,7 @@ def __init__(self, *args):
}
LoopBase.__init__(self, *args)
self._poll = select.poll()
+ # pylint: enable=E1101
def register_fd(self, fd, events, target):
self._fd_targets[fd] = target
@@ -256,6 +258,7 @@ class EpollLoop(LoopBase):
"""
def __init__(self, *args):
+ # pylint: disable=E1101
self._event_types = {
select.EPOLLIN: 'readable',
select.EPOLLOUT: 'writable',
@@ -264,6 +267,7 @@ def __init__(self, *args):
}
LoopBase.__init__(self, *args)
self._epoll = select.epoll()
+ # pylint: enable=E1101
def register_fd(self, fd, events, target):
eventmask = self._eventmask(events)
View
4 thor/tcp.py
@@ -38,7 +38,7 @@
import sys
import socket
-from loop import EventSource
+from thor.loop import EventSource
class TcpConnection(EventSource):
@@ -377,7 +377,7 @@ def handle_conn_error(self, err_type=None, err=None, close=False):
if __name__ == "__main__":
# quick demo server
- from loop import run, stop
+ from thor.loop import run, stop
server = TcpServer('localhost', int(sys.argv[-1]))
def handle_conn(conn):
conn.pause(False)
View
17 thor/tls.py
@@ -32,11 +32,10 @@
"""
import errno
-import sys
import socket
import ssl as sys_ssl
-from tcp import TcpServer, TcpClient, TcpConnection, server_listen
+from thor.tcp import TcpServer, TcpClient, TcpConnection, server_listen
TcpConnection._block_errs.add(sys_ssl.SSL_ERROR_WANT_READ)
TcpConnection._block_errs.add(sys_ssl.SSL_ERROR_WANT_WRITE)
@@ -125,7 +124,9 @@ def monkey_patch_ssl():
import _ssl
def _real_connect(self, addr, return_errno):
if self._sslobj:
- raise ValueError("attempt to connect already-connected SSLSocket!")
+ raise ValueError(
+ "attempt to connect already-connected SSLSocket!"
+ )
self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile,
self.certfile, self.cert_reqs, self.ssl_version,
self.ca_certs, self.ciphers)
@@ -153,15 +154,15 @@ def connect_ex(self, addr):
if __name__ == "__main__":
import sys
from thor import run
- host = sys.argv[1]
+ test_host = sys.argv[1]
def go(conn):
- conn.on('data', sys.stdout.write)
- conn.write("GET / HTTP/1.1\r\nHost: %s\r\n\r\n" % host)
- conn.pause(False)
+ conn.on('data', sys.stdout.write)
+ conn.write("GET / HTTP/1.1\r\nHost: %s\r\n\r\n" % test_host)
+ conn.pause(False)
print conn.socket.cipher()
c = TlsClient()
c.on('connect', go)
- c.connect(host, 443)
+ c.connect(test_host, 443)
run()
View
2  thor/udp.py
@@ -33,7 +33,7 @@
import errno
import socket
-from loop import EventSource
+from thor.loop import EventSource
Please sign in to comment.
Something went wrong with that request. Please try again.