Code cleaning (thanks to flake8)
This commit is contained in:
parent
6f5784e516
commit
4b5d37a32f
@ -1,3 +1,7 @@
|
||||
from wsme.api import expose, validate
|
||||
from wsme.root import WSRoot
|
||||
from wsme.types import wsattr, wsproperty, Unset
|
||||
|
||||
__all__ = ['expose', 'validate',
|
||||
'WSRoot',
|
||||
'wsattr', 'wsproperty', 'Unset']
|
||||
|
@ -1,7 +1,5 @@
|
||||
import inspect
|
||||
|
||||
import pkg_resources
|
||||
|
||||
from wsme.types import register_type
|
||||
|
||||
__all__ = ['expose', 'validate']
|
||||
|
@ -1,4 +1,3 @@
|
||||
import base64
|
||||
import datetime
|
||||
|
||||
try:
|
||||
@ -9,7 +8,6 @@ except ImportError:
|
||||
from simplegeneric import generic
|
||||
|
||||
from wsme.protocols.rest import RestProtocol
|
||||
from wsme.exc import *
|
||||
import wsme.types
|
||||
|
||||
import re
|
||||
|
@ -173,7 +173,7 @@ class WSRoot(object):
|
||||
else:
|
||||
res.status = protocol.get_response_status(request)
|
||||
res_content_type = protocol.get_response_contenttype(request)
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
infos = self._format_exception(sys.exc_info())
|
||||
request.server_errorcount += 1
|
||||
res.body = protocol.encode_error(context, infos)
|
||||
@ -181,7 +181,6 @@ class WSRoot(object):
|
||||
|
||||
if res_content_type is None:
|
||||
# Attempt to correctly guess what content-type we should return.
|
||||
last_q = 0
|
||||
ctypes = [ct for ct in protocol.content_types if ct]
|
||||
if ctypes:
|
||||
res_content_type = request.accept.best_match(ctypes)
|
||||
|
@ -6,10 +6,10 @@ import datetime
|
||||
import decimal
|
||||
import base64
|
||||
|
||||
from webob.dec import wsgify
|
||||
from webtest import TestApp
|
||||
|
||||
from wsme import *
|
||||
from wsme import WSRoot, Unset
|
||||
from wsme import expose, validate
|
||||
import wsme.wsgi
|
||||
import wsme.types
|
||||
|
||||
@ -284,6 +284,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
def test_invalid_path(self):
|
||||
try:
|
||||
res = self.call('invalid_function')
|
||||
print res
|
||||
assert "No error raised"
|
||||
except CallException, e:
|
||||
assert e.faultcode == 'Client'
|
||||
@ -293,6 +294,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
def test_serverside_error(self):
|
||||
try:
|
||||
res = self.call('witherrors/divide_by_zero')
|
||||
print res
|
||||
assert "No error raised"
|
||||
except CallException, e:
|
||||
print e
|
||||
@ -304,6 +306,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
self.root._debug = False
|
||||
try:
|
||||
res = self.call('witherrors/divide_by_zero')
|
||||
print res
|
||||
assert "No error raised"
|
||||
except CallException, e:
|
||||
print e
|
||||
@ -414,6 +417,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
value = binarysample
|
||||
r = self.call('argtypes/setbinary', value=(value, wsme.types.binary),
|
||||
_rt=wsme.types.binary) == value
|
||||
print r
|
||||
|
||||
def test_setnested(self):
|
||||
value = {'inner': {'aint': 54}}
|
||||
@ -469,6 +473,7 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
def test_missing_argument(self):
|
||||
try:
|
||||
r = self.call('argtypes/setdatetime')
|
||||
print r
|
||||
assert "No error raised"
|
||||
except CallException, e:
|
||||
print e
|
||||
@ -482,4 +487,3 @@ class ProtocolTestCase(unittest.TestCase):
|
||||
res = self.call('argtypes/setdatetime', _accept="text/html",
|
||||
_no_result_decode=True)
|
||||
assert res.content_type == 'text/html', res.content_type
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import wsme
|
||||
import cherrypy
|
||||
import webob
|
||||
from turbogears import expose
|
||||
|
@ -190,6 +190,7 @@ class wsattr(object):
|
||||
def __delete__(self, instance):
|
||||
self.__set__(instance, Unset)
|
||||
|
||||
|
||||
def iswsattr(attr):
|
||||
if inspect.isfunction(attr) or inspect.ismethod(attr):
|
||||
return False
|
||||
|
@ -1,5 +1,6 @@
|
||||
import re
|
||||
import decimal
|
||||
import datetime
|
||||
import re
|
||||
|
||||
date_re = r'(?P<year>-?\d{4,})-(?P<month>\d{2})-(?P<day>\d{2})'
|
||||
time_re = r'(?P<hour>\d{2}):(?P<min>\d{2}):(?P<sec>\d{2})' + \
|
||||
@ -22,7 +23,7 @@ def parse_isodate(value):
|
||||
int(m.group('year')),
|
||||
int(m.group('month')),
|
||||
int(m.group('day')))
|
||||
except ValueError, e:
|
||||
except ValueError:
|
||||
raise ValueError("'%s' is a out-of-range date" % (value))
|
||||
|
||||
|
||||
@ -41,7 +42,7 @@ def parse_isotime(value):
|
||||
int(m.group('min')),
|
||||
int(m.group('sec')),
|
||||
ms)
|
||||
except ValueError, e:
|
||||
except ValueError:
|
||||
raise ValueError("'%s' is a out-of-range time" % (value))
|
||||
|
||||
|
||||
@ -64,5 +65,5 @@ def parse_isodatetime(value):
|
||||
int(m.group('min')),
|
||||
int(m.group('sec')),
|
||||
ms)
|
||||
except ValueError, e:
|
||||
except ValueError:
|
||||
raise ValueError("'%s' is a out-of-range datetime" % (value))
|
||||
|
Loading…
x
Reference in New Issue
Block a user