Fix PEP8 E301 expected 1 blank line, found 0

pull/1094/head
Lee Clemens 2015-07-04 13:23:08 -04:00
parent e9e00d7599
commit 60c5c6951c
6 changed files with 9 additions and 0 deletions

View File

@ -46,6 +46,7 @@ if sys.version_info >= (3,):
logSys.error('json dumps failed: %s', e) logSys.error('json dumps failed: %s', e)
x = '{}' x = '{}'
return x return x
def _json_loads_safe(x): def _json_loads_safe(x):
try: try:
x = json.loads(x.decode( x = json.loads(x.decode(
@ -64,6 +65,7 @@ else:
return x.encode(locale.getpreferredencoding()) return x.encode(locale.getpreferredencoding())
else: else:
return x return x
def _json_dumps_safe(x): def _json_dumps_safe(x):
try: try:
x = json.dumps(_normalize(x), ensure_ascii=False).decode( x = json.dumps(_normalize(x), ensure_ascii=False).decode(
@ -72,6 +74,7 @@ else:
logSys.error('json dumps failed: %s', e) logSys.error('json dumps failed: %s', e)
x = '{}' x = '{}'
return x return x
def _json_loads_safe(x): def _json_loads_safe(x):
try: try:
x = _normalize(json.loads(x.decode( x = _normalize(json.loads(x.decode(
@ -156,6 +159,7 @@ class Fail2BanDb(object):
"CREATE INDEX bans_jail_ip ON bans(jail, ip);" \ "CREATE INDEX bans_jail_ip ON bans(jail, ip);" \
"CREATE INDEX bans_ip ON bans(ip);" \ "CREATE INDEX bans_ip ON bans(ip);" \
def __init__(self, filename, purgeAge=24*60*60): def __init__(self, filename, purgeAge=24*60*60):
try: try:
self._lock = RLock() self._lock = RLock()

View File

@ -57,6 +57,7 @@ class Regex:
except sre_constants.error: except sre_constants.error:
raise RegexException("Unable to compile regular expression '%s'" % raise RegexException("Unable to compile regular expression '%s'" %
regex) regex)
def __str__(self): def __str__(self):
return "%s(%r)" % (self.__class__.__name__, self._regex) return "%s(%r)" % (self.__class__.__name__, self._regex)
## ##

View File

@ -59,6 +59,7 @@ class JailThread(Thread):
# excepthook workaround for threads, derived from: # excepthook workaround for threads, derived from:
# http://bugs.python.org/issue1230540#msg91244 # http://bugs.python.org/issue1230540#msg91244
run = self.run run = self.run
def run_with_except_hook(*args, **kwargs): def run_with_except_hook(*args, **kwargs):
try: try:
run(*args, **kwargs) run(*args, **kwargs)

View File

@ -475,6 +475,7 @@ def get_monitor_failures_testcase(Filter_):
class MonitorFailures(unittest.TestCase): class MonitorFailures(unittest.TestCase):
count = 0 count = 0
def setUp(self): def setUp(self):
"""Call before every test case.""" """Call before every test case."""
setUpMyTime() setUpMyTime()

View File

@ -50,6 +50,7 @@ TEST_FILES_DIR = os.path.join(os.path.dirname(__file__), "files")
class TestServer(Server): class TestServer(Server):
def setLogLevel(self, *args, **kwargs): def setLogLevel(self, *args, **kwargs):
pass pass
def setLogTarget(self, *args, **kwargs): def setLogTarget(self, *args, **kwargs):
pass pass

View File

@ -86,6 +86,7 @@ def gatherTests(regexps=None, no_network=False):
else: # pragma: no cover else: # pragma: no cover
class FilteredTestSuite(unittest.TestSuite): class FilteredTestSuite(unittest.TestSuite):
_regexps = [re.compile(r) for r in regexps] _regexps = [re.compile(r) for r in regexps]
def addTest(self, suite): def addTest(self, suite):
suite_str = str(suite) suite_str = str(suite)
for r in self._regexps: for r in self._regexps: