def testCanonicalise(self):
        def assertCanon(reference, worksheetNames, expected):
            ref = FLReferenceParseNode(None, [reference, '!', sentinel.onlyChild])
            ref.canonicalise(worksheetNames)
            self.assertEquals(ref.children[0], expected)

        assertCanon('foo', ['foO'], 'foO')
        assertCanon('foo', [], 'foo')
        assertCanon("'''s'", ["'S"], "'''S'")
        assertCanon("foo  ", [], 'foo  ')

        ref = FLReferenceParseNode(None, ['A1'])
        ref.canonicalise([])
        self.assertEquals(ref.worksheetReference, None)
コード例 #2
0
    def testCanonicalise(self):
        def assertCanon(reference, worksheetNames, expected):
            ref = FLReferenceParseNode(None,
                                       [reference, '!', sentinel.onlyChild])
            ref.canonicalise(worksheetNames)
            self.assertEquals(ref.children[0], expected)

        assertCanon('foo', ['foO'], 'foO')
        assertCanon('foo', [], 'foo')
        assertCanon("'''s'", ["'S"], "'''S'")
        assertCanon("foo  ", [], 'foo  ')

        ref = FLReferenceParseNode(None, ['A1'])
        ref.canonicalise([])
        self.assertEquals(ref.worksheetReference, None)
コード例 #3
0
    def testInit(self):
        self.assertRaises(AssertionError, FLReferenceParseNode, sentinel.type,
                          [sentinel.firstChild, sentinel.secondChild])
        self.assertRaises(AssertionError, FLReferenceParseNode, sentinel.type,
                          [sentinel.child] * 4)

        ref = FLReferenceParseNode(sentinel.type, [sentinel.firstChild])
        self.assertEquals(ref.type, sentinel.type)
        self.assertEquals(ref.children, [sentinel.firstChild])

        ref = FLReferenceParseNode(
            sentinel.type,
            [sentinel.firstChild, sentinel.secondChild, sentinel.thirdChild])
        self.assertEquals(ref.type, sentinel.type)
        self.assertEquals(
            ref.children,
            [sentinel.firstChild, sentinel.secondChild, sentinel.thirdChild])
コード例 #4
0
    def testWorksheetReferenceProperty(self):
        ref = FLReferenceParseNode(None, [sentinel.onlyChild])
        self.assertEquals(ref.worksheetReference, None)

        ref = FLReferenceParseNode(
            None, ["'Thin Lizzy'    ", sentinel.second, sentinel.third])
        self.assertEquals(ref.children[0], "'Thin Lizzy'    ")
        self.assertEquals(ref.worksheetReference, 'Thin Lizzy')

        # loses the whitespace information
        ref.worksheetReference = None
        self.assertEquals(ref.children, [sentinel.third])

        # therefore no whitespace information here
        ref.worksheetReference = "Ben Folds' Five    "
        self.assertEquals(ref.children,
                          ["'Ben Folds'' Five    '", '!', sentinel.third])
        self.assertEquals(ref.worksheetReference, "Ben Folds' Five    ")

        ref.children[0] = "'with trailing whitespace'   "
        ref.worksheetReference = "Shihad"
        self.assertEquals(ref.children, ["Shihad   ", '!', sentinel.third])
    def testWorksheetReferenceProperty(self):
        ref = FLReferenceParseNode(None, [sentinel.onlyChild])
        self.assertEquals(ref.worksheetReference, None)

        ref = FLReferenceParseNode(None, ["'Thin Lizzy'    ", sentinel.second, sentinel.third])
        self.assertEquals(ref.children[0], "'Thin Lizzy'    ")
        self.assertEquals(ref.worksheetReference, 'Thin Lizzy')

        # loses the whitespace information
        ref.worksheetReference = None
        self.assertEquals(ref.children, [sentinel.third])

        # therefore no whitespace information here
        ref.worksheetReference = "Ben Folds' Five    "
        self.assertEquals(ref.children, ["'Ben Folds'' Five    '", '!', sentinel.third])
        self.assertEquals(ref.worksheetReference, "Ben Folds' Five    ")

        ref.children[0] = "'with trailing whitespace'   "
        ref.worksheetReference = "Shihad"
        self.assertEquals(ref.children, ["Shihad   ", '!', sentinel.third])
コード例 #6
0
 def canonicalise(self, wsNames):
     self.localReference = self.localReference.upper()
     FLReferenceParseNode.canonicalise(self, wsNames)
コード例 #7
0
 def __init__(self, children):
     FLReferenceParseNode.__init__(self, ParseNode.FL_COLUMN_REFERENCE, children)
コード例 #8
0
 def canonicalise(self, wsNames):
     self.localReference = self.localReference.upper()
     FLReferenceParseNode.canonicalise(self, wsNames)
コード例 #9
0
 def __init__(self, children):
     FLReferenceParseNode.__init__(self, ParseNode.FL_CELL_REFERENCE,
                                   children)
コード例 #10
0
 def assertCanon(reference, worksheetNames, expected):
     ref = FLReferenceParseNode(None, [reference, '!', sentinel.onlyChild])
     ref.canonicalise(worksheetNames)
     self.assertEquals(ref.children[0], expected)
コード例 #11
0
 def __init__(self, children):
     FLReferenceParseNode.__init__(self, ParseNode.FL_NAMED_ROW_REFERENCE,
                                   children)
コード例 #12
0
 def assertCanon(reference, worksheetNames, expected):
     ref = FLReferenceParseNode(None,
                                [reference, '!', sentinel.onlyChild])
     ref.canonicalise(worksheetNames)
     self.assertEquals(ref.children[0], expected)
 def __init__(self, children):
     FLReferenceParseNode.__init__(self, ParseNode.FL_NAMED_ROW_REFERENCE, children)