cleanup flake8
This commit is contained in:
parent
230039fa90
commit
041518e760
@ -203,7 +203,7 @@ class ConditionalPathFilter(Filter):
|
|||||||
|
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
## Generic Filters ##
|
# Generic Filters #
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
|
|
||||||
@ -518,7 +518,7 @@ class UniqueIDValidator(UniqueID):
|
|||||||
|
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
## Commonly Used Filters ##
|
# Commonly Used Filters #
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
|
|
||||||
@ -535,7 +535,7 @@ class PhoneNumberCleaner(FieldFilter):
|
|||||||
def __init__(self, keys, number_format="%s%s%s.%s%s%s.%s%s%s%s"):
|
def __init__(self, keys, number_format="%s%s%s.%s%s%s.%s%s%s%s"):
|
||||||
super(PhoneNumberCleaner, self).__init__(keys)
|
super(PhoneNumberCleaner, self).__init__(keys)
|
||||||
self._number_format = number_format
|
self._number_format = number_format
|
||||||
self._num_re = re.compile("\d")
|
self._num_re = re.compile(r"\d")
|
||||||
|
|
||||||
def process_field(self, item):
|
def process_field(self, item):
|
||||||
nums = self._num_re.findall(item)
|
nums = self._num_re.findall(item)
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
All sources must implement the iterable interface and return python
|
All sources must implement the iterable interface and return python
|
||||||
dictionaries.
|
dictionaries.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from saucebrush import utils
|
from saucebrush import utils
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
from __future__ import unicode_literals
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
import os
|
import os
|
||||||
@ -72,7 +71,7 @@ class EmitterTestCase(unittest.TestCase):
|
|||||||
import cStringIO # if Python 2.x then use old cStringIO
|
import cStringIO # if Python 2.x then use old cStringIO
|
||||||
|
|
||||||
io = cStringIO.StringIO()
|
io = cStringIO.StringIO()
|
||||||
except:
|
except Exception:
|
||||||
io = StringIO() # if Python 3.x then use StringIO
|
io = StringIO() # if Python 3.x then use StringIO
|
||||||
|
|
||||||
with closing(io) as output:
|
with closing(io) as output:
|
||||||
@ -82,7 +81,8 @@ class EmitterTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_sqlite_emitter(self):
|
def test_sqlite_emitter(self):
|
||||||
|
|
||||||
import sqlite3, tempfile
|
import sqlite3
|
||||||
|
import tempfile
|
||||||
|
|
||||||
with closing(tempfile.NamedTemporaryFile(suffix=".db")) as f:
|
with closing(tempfile.NamedTemporaryFile(suffix=".db")) as f:
|
||||||
db_path = f.name
|
db_path = f.name
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import operator
|
|
||||||
import types
|
import types
|
||||||
from saucebrush.filters import (
|
from saucebrush.filters import (
|
||||||
Filter,
|
Filter,
|
||||||
@ -133,7 +132,7 @@ class FilterTestCase(unittest.TestCase):
|
|||||||
# ensure only even numbers remain
|
# ensure only even numbers remain
|
||||||
self.assertEqual(list(result), [0, 2, 4, 6, 8])
|
self.assertEqual(list(result), [0, 2, 4, 6, 8])
|
||||||
|
|
||||||
### Tests for Subrecord
|
# Tests for Subrecord
|
||||||
|
|
||||||
def test_subrecord_filter_list(self):
|
def test_subrecord_filter_list(self):
|
||||||
data = [
|
data = [
|
||||||
@ -209,7 +208,7 @@ class FilterTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_conditional_path(self):
|
def test_conditional_path(self):
|
||||||
|
|
||||||
predicate = lambda r: r["a"] == 1
|
predicate = lambda r: r["a"] == 1 # noqa
|
||||||
|
|
||||||
# double b if a == 1, otherwise double c
|
# double b if a == 1, otherwise double c
|
||||||
cpf = ConditionalPathFilter(predicate, FieldDoubler("b"), FieldDoubler("c"))
|
cpf = ConditionalPathFilter(predicate, FieldDoubler("b"), FieldDoubler("c"))
|
||||||
@ -221,7 +220,7 @@ class FilterTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
self.assert_filter_result(cpf, expected_data)
|
self.assert_filter_result(cpf, expected_data)
|
||||||
|
|
||||||
### Tests for Generic Filters
|
# Tests for Generic Filters
|
||||||
|
|
||||||
def test_field_modifier(self):
|
def test_field_modifier(self):
|
||||||
# another version of FieldDoubler
|
# another version of FieldDoubler
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import doctest
|
|
||||||
import unittest
|
import unittest
|
||||||
from saucebrush import Recipe, run_recipe, SaucebrushError, OvercookedError
|
from saucebrush import Recipe, run_recipe, SaucebrushError, OvercookedError
|
||||||
from saucebrush.filters import Filter
|
from saucebrush.filters import Filter
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from __future__ import unicode_literals
|
from io import StringIO
|
||||||
from io import BytesIO, StringIO
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from saucebrush.sources import (
|
from saucebrush.sources import (
|
||||||
@ -85,8 +84,6 @@ class SourceTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
import lxml
|
|
||||||
|
|
||||||
hts = HtmlTableSource(content, "thetable")
|
hts = HtmlTableSource(content, "thetable")
|
||||||
self.assertEqual(list(hts), [{"a": "1", "b": "2", "c": "3"}])
|
self.assertEqual(list(hts), [{"a": "1", "b": "2", "c": "3"}])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user