pathod: remove six

This commit is contained in:
Aldo Cortesi 2016-10-17 15:43:38 +13:00
parent 8360f70024
commit d60ef617e3
7 changed files with 11 additions and 19 deletions

View File

@ -3,7 +3,6 @@ from __future__ import absolute_import
import itertools import itertools
import time import time
from six.moves import range
import pyparsing as pp import pyparsing as pp
from . import http, http2, websockets, writer, exceptions from . import http, http2, websockets, writer, exceptions

View File

@ -1,9 +1,9 @@
import operator import operator
import os import os
import abc import abc
import functools
import pyparsing as pp import pyparsing as pp
from six.moves import reduce
from netlib import strutils from netlib import strutils
from netlib import human from netlib import human
@ -171,14 +171,14 @@ class TokValueGenerate(Token):
def expr(cls): def expr(cls):
e = pp.Literal("@").suppress() + v_integer e = pp.Literal("@").suppress() + v_integer
u = reduce( u = functools.reduce(
operator.or_, operator.or_,
[pp.Literal(i) for i in human.SIZE_UNITS.keys()] [pp.Literal(i) for i in human.SIZE_UNITS.keys()]
).leaveWhitespace() ).leaveWhitespace()
e = e + pp.Optional(u, default=None) e = e + pp.Optional(u, default=None)
s = pp.Literal(",").suppress() s = pp.Literal(",").suppress()
s += reduce( s += functools.reduce(
operator.or_, operator.or_,
[pp.Literal(i) for i in generators.DATATYPES.keys()] [pp.Literal(i) for i in generators.DATATYPES.keys()]
) )

View File

@ -2,7 +2,6 @@ import string
import random import random
import mmap import mmap
import six
import sys import sys
DATATYPES = dict( DATATYPES = dict(
@ -52,8 +51,6 @@ def rand_byte(chars):
""" """
# bytearray has consistent behaviour on both Python 2 and 3 # bytearray has consistent behaviour on both Python 2 and 3
# while bytes does not # while bytes does not
if six.PY2:
return random.choice(chars)
return bytes([random.choice(chars)]) return bytes([random.choice(chars)])

View File

@ -1,7 +1,5 @@
import time import time
import six
from netlib import strutils, human from netlib import strutils, human
@ -52,7 +50,7 @@ class LogCtx(object):
timestamp = self.timestamp timestamp = self.timestamp
) )
if exc_value: if exc_value:
six.reraise(exc_type, exc_value, traceback) raise exc_value
def suppress(self): def suppress(self):
self.suppressed = True self.suppressed = True

View File

@ -4,13 +4,12 @@ import sys
import os import os
import itertools import itertools
import hashlib import hashlib
from six.moves import queue import queue
import random import random
import select import select
import time import time
import OpenSSL.crypto import OpenSSL.crypto
import six
import logging import logging
from netlib.tutils import treq from netlib.tutils import treq
@ -250,9 +249,9 @@ class Pathoc(tcp.TCPClient):
if resp.status_code != 200: if resp.status_code != 200:
raise exceptions.HttpException("Unexpected status code: %s" % resp.status_code) raise exceptions.HttpException("Unexpected status code: %s" % resp.status_code)
except exceptions.HttpException as e: except exceptions.HttpException as e:
six.reraise(PathocError, PathocError( raise PathocError(
"Proxy CONNECT failed: %s" % repr(e) "Proxy CONNECT failed: %s" % repr(e)
)) )
def socks_connect(self, connect_to): def socks_connect(self, connect_to):
try: try:

View File

@ -10,7 +10,7 @@ from netlib import certutils
from netlib import websockets from netlib import websockets
from netlib import version from netlib import version
from six.moves import urllib import urllib
from netlib.exceptions import HttpException, HttpReadDisconnect, TcpTimeout, TcpDisconnect, \ from netlib.exceptions import HttpException, HttpReadDisconnect, TcpTimeout, TcpDisconnect, \
TlsException TlsException

View File

@ -1,7 +1,6 @@
from six.moves import cStringIO as StringIO import io
import time import time
import queue
from six.moves import queue
from . import pathod from . import pathod
from netlib import basethread from netlib import basethread
@ -12,7 +11,7 @@ class Daemon:
def __init__(self, ssl=None, **daemonargs): def __init__(self, ssl=None, **daemonargs):
self.q = queue.Queue() self.q = queue.Queue()
self.logfp = StringIO() self.logfp = io.StringIO()
daemonargs["logfp"] = self.logfp daemonargs["logfp"] = self.logfp
self.thread = _PaThread(self.IFACE, self.q, ssl, daemonargs) self.thread = _PaThread(self.IFACE, self.q, ssl, daemonargs)
self.thread.start() self.thread.start()