Skip to content

Commit

Permalink
Make ColumnType._create_column public. Closes #211.
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxfish committed Sep 6, 2015
1 parent eca6b62 commit 145c0f5
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion agate/column_types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ def test(self, d):
def cast(self, d):
raise NotImplementedError

def _create_column(self, table, index):
def create_column(self, table, index):
raise NotImplementedError
2 changes: 1 addition & 1 deletion agate/column_types/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def cast(self, d):

raise CastError('Can not convert value %s to bool for BooleanColumn.' % d)

def _create_column(self, table, index):
def create_column(self, table, index):
from agate.columns import BooleanColumn

return BooleanColumn(table, index)
2 changes: 1 addition & 1 deletion agate/column_types/date_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def cast(self, d):
except:
raise CastError('Can not parse value "%s" to as datetime for DateTimeColumn.' % d)

def _create_column(self, table, index):
def create_column(self, table, index):
from agate.columns import DateTimeColumn

return DateTimeColumn(table, index)
4 changes: 2 additions & 2 deletions agate/column_types/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from cdecimal import Decimal, InvalidOperation
except ImportError: #pragma: no cover
from decimal import Decimal, InvalidOperation

import six

from agate.column_types.base import *
Expand Down Expand Up @@ -54,7 +54,7 @@ def cast(self, d):
except InvalidOperation:
raise CastError('Can not convert value "%s" to Decimal for NumberColumn.' % d)

def _create_column(self, table, index):
def create_column(self, table, index):
from agate.columns import NumberColumn

return NumberColumn(table, index)
2 changes: 1 addition & 1 deletion agate/column_types/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def cast(self, d):

return six.text_type(d)

def _create_column(self, table, index):
def create_column(self, table, index):
from agate.columns import TextColumn

return TextColumn(table, index)
2 changes: 1 addition & 1 deletion agate/column_types/time_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def cast(self, d):

return datetime.timedelta(seconds=seconds)

def _create_column(self, table, index):
def create_column(self, table, index):
from agate.columns import TimeDeltaColumn

return TimeDeltaColumn(table, index)
2 changes: 1 addition & 1 deletion agate/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _get_column(self, i):
if i not in self._cached_columns:
column_type = self._column_types[i]

self._cached_columns[i] = column_type._create_column(self, i)
self._cached_columns[i] = column_type.create_column(self, i)

return self._cached_columns[i]

Expand Down
10 changes: 5 additions & 5 deletions tests/test_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

class TestColumnTypes(unittest.TestCase):
def test_text(self):
self.assertIsInstance(TextType()._create_column(None, 1), TextColumn)
self.assertIsInstance(TextType().create_column(None, 1), TextColumn)

def test_text_cast(self):
values = ('a', 1, None, Decimal('2.7'), 'n/a')
casted = tuple(TextType().cast(v) for v in values)
self.assertSequenceEqual(casted, ('a', '1', None, '2.7', None))

def test_boolean(self):
self.assertIsInstance(BooleanType()._create_column(None, 1), BooleanColumn)
self.assertIsInstance(BooleanType().create_column(None, 1), BooleanColumn)

def test_boolean_cast(self):
values = (True, 'yes', None, False, 'no', 'n/a')
Expand All @@ -45,7 +45,7 @@ def test_boolean_cast_custom_strings(self):
self.assertSequenceEqual(casted, (True, True, None, False, False, None))

def test_number(self):
self.assertIsInstance(NumberType()._create_column(None, 1), NumberColumn)
self.assertIsInstance(NumberType().create_column(None, 1), NumberColumn)

def test_number_cast(self):
values = (2, 1, None, Decimal('2.7'), 'n/a')
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_date_cast_parser(self):
))

def test_datetime(self):
self.assertIsInstance(DateTimeType()._create_column(None, 1), DateTimeColumn)
self.assertIsInstance(DateTimeType().create_column(None, 1), DateTimeColumn)

def test_datetime_cast_format(self):
datetime_type = DateTimeType(datetime_format='%m-%d-%Y %I:%M %p')
Expand All @@ -112,7 +112,7 @@ def test_datetime_cast_parser(self):
))

def test_timedelta(self):
self.assertIsInstance(TimeDeltaType()._create_column(None, 1), TimeDeltaColumn)
self.assertIsInstance(TimeDeltaType().create_column(None, 1), TimeDeltaColumn)

def test_timedelta_cast_parser(self):
values = ('4:10', '1.2m', '172 hours', '5 weeks, 2 days', 'n/a')
Expand Down

0 comments on commit 145c0f5

Please sign in to comment.