Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 4a16692

Browse files
author
Junchao Wu
committed
sort the import order
1 parent dcade71 commit 4a16692

Some content is hidden

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

62 files changed

+233
-164
lines changed

examples/stream_client.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020

2121
import os
2222
import sys
23+
2324
import tornado
2425
import tornado.ioloop
2526

2627
from options import get_args
2728
from tchannel.tornado import TChannel
28-
from tchannel.tornado.stream import InMemStream, PipeStream
29+
from tchannel.tornado.stream import InMemStream
30+
from tchannel.tornado.stream import PipeStream
2931
from tchannel.tornado.util import print_arg
3032

3133

examples/tchannel_server.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
import tornado.ioloop
2424

25-
from tchannel.tornado import TChannel
26-
from options import get_args
2725
from handler import get_example_handler
26+
from options import get_args
27+
from tchannel.tornado import TChannel
2828

2929

3030
def main(): # pragma: no cover

examples/thrift_examples/client.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
# THE SOFTWARE.
2020

21-
from tornado import ioloop, gen
22-
23-
from tchannel.tornado import TChannel
24-
from tchannel.thrift import TChannelProtocolFactory, TChannelTornadoTransport
21+
from tornado import gen
22+
from tornado import ioloop
2523

2624
from hello import HelloService
25+
from tchannel.thrift import TChannelProtocolFactory
26+
from tchannel.thrift import TChannelTornadoTransport
27+
from tchannel.tornado import TChannel
2728

2829

2930
@gen.coroutine

examples/thrift_examples/hello/HelloService.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@
2626
# options string: py:tornado,dynamic,utf8strings
2727
#
2828

29-
from thrift.Thrift import TType, TMessageType, TException, TApplicationException
30-
from ttypes import *
29+
from thrift.protocol.TBase import TBase
30+
from thrift.protocol.TBase import TExceptionBase
31+
from thrift.Thrift import TApplicationException
32+
from thrift.Thrift import TException
33+
from thrift.Thrift import TMessageType
3134
from thrift.Thrift import TProcessor
32-
from thrift.protocol.TBase import TBase, TExceptionBase
33-
34-
from tornado import gen
35-
from tornado import concurrent
35+
from thrift.Thrift import TType
3636
from thrift.transport import TTransport
37+
from tornado import concurrent
38+
from tornado import gen
39+
40+
from ttypes import *
41+
3742

3843
class Iface(object):
3944
def hello(self, name):

examples/thrift_examples/hello/constants.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
# options string: py:tornado,dynamic,utf8strings
2727
#
2828

29-
from thrift.Thrift import TType, TMessageType, TException, TApplicationException
30-
from ttypes import *
29+
from thrift.Thrift import TApplicationException
30+
from thrift.Thrift import TException
31+
from thrift.Thrift import TMessageType
32+
from thrift.Thrift import TType
3133

34+
from ttypes import *

examples/thrift_examples/hello/ttypes.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
# options string: py:tornado,dynamic,utf8strings
2727
#
2828

29-
from thrift.Thrift import TType, TMessageType, TException, TApplicationException
30-
31-
from thrift.protocol.TBase import TBase, TExceptionBase
32-
33-
29+
from thrift.protocol.TBase import TBase
30+
from thrift.protocol.TBase import TExceptionBase
31+
from thrift.Thrift import TApplicationException
32+
from thrift.Thrift import TException
33+
from thrift.Thrift import TMessageType
34+
from thrift.Thrift import TType

examples/thrift_examples/server.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
from tornado import ioloop
2222

23-
from tchannel import thrift
24-
from tchannel.tornado import TChannel, TornadoDispatcher
25-
2623
from hello import HelloService
24+
from tchannel import thrift
25+
from tchannel.tornado import TChannel
26+
from tchannel.tornado import TornadoDispatcher
2727

2828

2929
class HelloServiceHandler(object):

examples/tornado_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
import time
2626

27-
import tornado.iostream
2827
import tornado.ioloop
28+
import tornado.iostream
2929

3030
from options import get_args
3131
from tchannel.tornado.connection import StreamConnection

tchannel/event.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
# THE SOFTWARE.
2020

2121
from __future__ import absolute_import
22-
from enum import IntEnum
22+
2323
import logging
2424

25+
from enum import IntEnum
26+
2527
log = logging.getLogger('tchannel')
2628

2729

tchannel/frame.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
from collections import namedtuple
2424

2525
from . import rw
26-
from .io import BytesIO
2726
from .exceptions import ReadException
28-
27+
from .io import BytesIO
2928

3029
FrameHeader = namedtuple('FrameHeader', 'message_type message_id')
3130
Frame = namedtuple('Frame', 'header payload')

tchannel/handler.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
# THE SOFTWARE.
2020
from __future__ import absolute_import
2121

22-
from .messages import Types, ErrorCode
23-
from .messages import PingResponseMessage
2422
from .exceptions import InvalidChecksumException
23+
from .messages import ErrorCode
24+
from .messages import PingResponseMessage
25+
from .messages import Types
2526

2627

2728
class RequestHandler(object):

tchannel/io.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
from __future__ import absolute_import
2222

23-
2423
try:
2524
from cStringIO import StringIO as BytesIO
2625
except ImportError: # pragma: no cover

tchannel/messages/call_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
from __future__ import absolute_import
2222

23+
from . import common
24+
from .. import rw
2325
from .call_request_continue import CallRequestContinueMessage
2426
from .types import Types
25-
from .. import rw
26-
from . import common
2727

2828

2929
class CallRequestMessage(CallRequestContinueMessage):

tchannel/messages/call_request_continue.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
from __future__ import absolute_import
2222

23-
from .types import Types
24-
from .. import rw
2523
from . import common
24+
from .. import rw
2625
from .call_continue import CallContinueMessage
26+
from .types import Types
2727

2828

2929
class CallRequestContinueMessage(CallContinueMessage):

tchannel/messages/call_response.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
from __future__ import absolute_import
2222

23+
from . import common
24+
from .. import rw
2325
from .call_response_continue import CallResponseContinueMessage
2426
from .types import Types
25-
from .. import rw
26-
from . import common
2727

2828

2929
class CallResponseMessage(CallResponseContinueMessage):

tchannel/messages/call_response_continue.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
from __future__ import absolute_import
2222

23+
from . import common
24+
from .. import rw
2325
from .call_continue import CallContinueMessage
2426
from .types import Types
25-
from .. import rw
26-
from . import common
2727

2828

2929
class CallResponseContinueMessage(CallContinueMessage):

tchannel/messages/common.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
from __future__ import absolute_import
2222

2323
import zlib
24-
import crcmod.predefined
2524
from collections import namedtuple
25+
26+
import crcmod.predefined
27+
2628
from enum import IntEnum
2729

2830
from .. import rw
@@ -112,29 +114,29 @@ def compute_checksum(checksum_type, args, csum=0):
112114
return csum
113115

114116

115-
def generate_checksum(message, pre_csum=0):
117+
def generate_checksum(message, previous_csum=0):
116118
"""Generate checksum for messages with
117119
CALL_REQ, CALL_REQ_CONTINUE,
118120
CALL_RES,CALL_RES_CONTINUE types.
119121
120122
:param message: outgoing message
121-
:param pre_csum: accumulated checksum value
123+
:param previous_csum: accumulated checksum value
122124
"""
123125
if message.message_type in CHECKSUM_MSG_TYPES:
124126
csum = compute_checksum(
125127
message.checksum[0],
126128
message.args,
127-
pre_csum,
129+
previous_csum,
128130
)
129131

130132
message.checksum = (message.checksum[0], csum)
131133

132134

133-
def verify_checksum(message, pre_csum=0):
135+
def verify_checksum(message, previous_csum=0):
134136
"""Verify checksum for incoming message.
135137
136138
:param message: incoming message
137-
:param pre_csum: accumulated checksum value
139+
:param previous_csum: accumulated checksum value
138140
139141
:return return True if message checksum type is None
140142
or checksum is correct
@@ -143,7 +145,7 @@ def verify_checksum(message, pre_csum=0):
143145
csum = compute_checksum(
144146
message.checksum[0],
145147
message.args,
146-
pre_csum,
148+
previous_csum,
147149
)
148150

149151
if csum == message.checksum[1]:

tchannel/messages/error.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
import enum
2424

25+
from . import common
2526
from .. import rw
2627
from .base import BaseMessage
2728
from .types import Types
28-
from . import common
2929

3030

3131
@enum.unique

tchannel/messages/init_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
from __future__ import absolute_import
2222

23+
from .. import rw
2324
from .base import BaseMessage
2425
from .common import PROTOCOL_VERSION
2526
from .types import Types
26-
from .. import rw
2727

2828

2929
class InitRequestMessage(BaseMessage):

tchannel/messages/init_response.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
from __future__ import absolute_import
2222

23-
from .types import Types
24-
from .init_request import InitRequestMessage
2523
from .. import rw
24+
from .init_request import InitRequestMessage
25+
from .types import Types
2626

2727

2828
class InitResponseMessage(InitRequestMessage):

tchannel/net.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020

2121
from __future__ import absolute_import
2222

23-
import socket
2423
import fcntl
24+
import socket
2525
import struct
2626

27+
2728
# TODO This module is unix-only. Figure out something for Windows.
2829

2930

tchannel/rw.py

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
from .exceptions import ReadException
2626

27-
2827
skip = '_'
2928

3029

tchannel/tcurl.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from __future__ import absolute_import
2222

23+
import argparse
2324
import collections
2425
import contextlib
2526
import cProfile
@@ -29,13 +30,12 @@
2930
import sys
3031
import time
3132

32-
import argparse
3333
import tornado.ioloop
34-
from .tornado.stream import InMemStream
35-
from .tornado.util import print_arg
34+
3635
from .tornado import TChannel
3736
from .tornado.dispatch import TornadoDispatcher
38-
37+
from .tornado.stream import InMemStream
38+
from .tornado.util import print_arg
3939

4040
log = logging.getLogger('tchannel')
4141

tchannel/thrift/protocol.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
from collections import namedtuple
2424

2525
from thrift import Thrift
26-
from thrift.protocol import TProtocol, TBinaryProtocol, fastbinary
26+
from thrift.protocol import TBinaryProtocol
27+
from thrift.protocol import TProtocol
28+
from thrift.protocol import fastbinary
2729

2830
from .transport import TChannelTransportBase
2931

tchannel/thrift/server.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
import inspect
2424

25-
from thrift.transport import TTransport
2625
from thrift.protocol import TBinaryProtocol
26+
from thrift.transport import TTransport
27+
2728
from tchannel.tornado.stream import InMemStream
2829

2930

tchannel/thrift/transport/tornado.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
from __future__ import absolute_import
2222

2323
from tornado import gen
24+
2425
from tchannel.io import BytesIO
2526
from tchannel.tornado.stream import InMemStream
27+
2628
from .tornado_base import TChannelTornadoTransportBase
2729

2830

0 commit comments

Comments
 (0)