Changeset 302


Ignore:
Timestamp:
Mar 12, 2010, 3:33:10 PM (10 years ago)
Author:
jjbot
Message:

Changed class name from FieldParser? to ArrayParser?, now base names on the output that a class creates.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • parsers/basicparsers.py

    r301 r302  
    33__date__ ="$Mar 10, 2010 12:39:06 PM$"
    44
    5 class FieldParser:
     5class ArrayParser:
    66    def __init__(self, fieldnames, delimiter="\t", func_map={}, multi_fields={}):
    77        """Parameters:
  • unit/unitbasicparsers.py

    r301 r302  
    88from parsers import basicparsers
    99
    10 class UnitFieldParser(unittest.TestCase):
     10class UnitArrayParser(unittest.TestCase):
    1111    def setUp(self):
    1212        self.txt1 = "a\tb\tc\t"
     
    1616
    1717    def test_simple_txt(self):
    18         p = basicparsers.FieldParser(range(3))
     18        p = basicparsers.ArrayParser(range(3))
    1919        out = p.parse(self.txt1)
    2020        self.assertEqual(3, len(out))
    2121
    2222    def test_different_delimiter(self):
    23         p = basicparsers.FieldParser(range(3), delimiter="|")
     23        p = basicparsers.ArrayParser(range(3), delimiter="|")
    2424        out = p.parse(self.txt2)
    2525        self.assertEqual(3, len(out))
    2626
    2727    def test_multifield(self):
    28         p = basicparsers.FieldParser(range(4), multi_fields={3:"|"})
     28        p = basicparsers.ArrayParser(range(4), multi_fields={3:"|"})
    2929        out = p.parse(self.txt4)
    3030        self.assertEqual(4, len(out))
     
    3333    def test_different_delimiter_and_function(self):
    3434        f = lambda x: int(x) + 1
    35         p = basicparsers.FieldParser(range(3), delimiter="|", func_map={0:f})
     35        p = basicparsers.ArrayParser(range(3), delimiter="|", func_map={0:f})
    3636        out = p.parse(self.txt3)
    3737        self.assertEqual(3, len(out))
    3838       
    3939    def test_error_on_wrong_multifield(self):
    40         self.assertRaises(AssertionError, lambda: basicparsers.FieldParser(range(3),
     40        self.assertRaises(AssertionError, lambda: basicparsers.ArrayParser(range(3),
    4141                multi_fields={'a':'|'}))
    4242
    4343    def test_error_on_wrong_func_map(self):
    4444        f = lambda x: int(x) + 1
    45         self.assertRaises(AssertionError, lambda: basicparsers.FieldParser(
     45        self.assertRaises(AssertionError, lambda: basicparsers.ArrayParser(
    4646                range(3), func_map={'a':f}))
    4747
Note: See TracChangeset for help on using the changeset viewer.