Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

tiny update code style & fix typo #287

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions thriftpy/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ def __init__(self, extension="_thrift"):
self.extension = extension

def __eq__(self, other):
return self.__class__.__module__ == other.__class__.__module__ and \
self.__class__.__name__ == other.__class__.__name__ and \
self.extension == other.extension
if not other or not isinstance(other, self.__class__):
return False
return self.extension == other.extension

def find_module(self, fullname, path=None):
if fullname.endswith(self.extension):
return self

def load_module(self, fullname):
@classmethod
def load_module(cls, fullname):
return load_module(fullname)


_imp = ThriftImporter()


Expand Down
8 changes: 4 additions & 4 deletions thriftpy/parser/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
literals = ':;,=*{}()<>[]'


thrift_reserved_keywords = (
thrift_reserved_keywords = set([
'BEGIN',
'END',
'__CLASS__',
Expand Down Expand Up @@ -113,7 +113,7 @@
'with',
'xor',
'yield'
)
])


keywords = (
Expand Down Expand Up @@ -159,7 +159,7 @@


def t_error(t):
raise ThriftLexerError('Illegal characher %r at line %d' %
raise ThriftLexerError('Illegal character %r at line %d' %
(t.value[0], t.lineno))


Expand Down Expand Up @@ -236,7 +236,7 @@ def t_LITERAL(t):
if s[i] in maps:
val += maps[s[i]]
else:
msg = 'Unexcepted escaping characher: %s' % s[i]
msg = 'Unexpected escaping character: %s' % s[i]
raise ThriftLexerError(msg)
else:
val += s[i]
Expand Down
4 changes: 2 additions & 2 deletions thriftpy/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def p_include(p):
'''include : INCLUDE LITERAL'''
thrift = thrift_stack[-1]
if thrift.__thrift_file__ is None:
raise ThriftParserError('Unexcepted include statement while loading'
raise ThriftParserError('Unexpected include statement while loading'
'from file like object.')
replace_include_dirs = [os.path.dirname(thrift.__thrift_file__)] \
+ include_dirs_
Expand Down Expand Up @@ -593,7 +593,7 @@ def parse_fp(source, module_name, lexer=None, parser=None, enable_cache=True):
return thrift_cache[module_name]

if not hasattr(source, 'read'):
raise ThriftParserError('Except `source` to be a file-like object with'
raise ThriftParserError('Expect `source` to be a file-like object with'
'a method named \'read\'')

if lexer is None:
Expand Down
14 changes: 8 additions & 6 deletions thriftpy/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@

from __future__ import absolute_import

import logging
import socket
import struct

from contextlib import contextmanager
from tornado import tcpserver, ioloop, iostream, gen
from io import BytesIO
from datetime import timedelta

import toro

from tornado import tcpserver, ioloop, iostream, gen

from .transport import TTransportException, TTransportBase
from .transport.memory import TMemoryBuffer
from .thrift import TApplicationException, TProcessor, TClient

# TODO need TCyTornadoStreamTransport to work with cython binary protocol
from .protocol.binary import TBinaryProtocolFactory

import logging
import socket
import struct
import toro


logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions thriftpy/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import
from __future__ import absolute_import, print_function

import binascii

Expand Down Expand Up @@ -34,4 +34,4 @@ def hexprint(byte_array, delimeter=' ', count=10):

print("\nHex:")
g = hexlify(byte_array, delimeter).split(delimeter)
print('\n'.join(' '.join(g[i:i+10]) for i in range(0, len(g), 10)))
print('\n'.join(' '.join(g[i:i+count]) for i in range(0, len(g), count)))