コード例 #1
0
ファイル: Parser.py プロジェクト: scottbdr/ofxtools
    def parse(self, source):
        if not hasattr(source, 'read'):
            source = open(source)
        with source as s:
            source = s.read()
            if hasattr(source, 'decode'):
                source = source.decode()

        # Validate and strip the OFX header
        source = OFXHeader.strip(source)

        # Then parse tag soup into tree of Elements
        parser = TreeBuilder(element_factory=self.element_factory)
        parser.feed(source)
        self._root = parser.close()
コード例 #2
0
ファイル: test_parser.py プロジェクト: redstreet/ofxtools
    def _testFeedSonrs(self, body):
        """
        str -> Element tests reused to test responses with identical content
        but different formatting.
        """
        builder = TreeBuilder()
        builder.feed(body)
        root = builder.close()

        self._testElement(root, tag="OFX", text=None, length=1)

        msgsrs = root[0]
        self._testElement(msgsrs, tag="SIGNONMSGSRSV1", text=None, length=1)

        sonrs = msgsrs[0]
        self._testElement(sonrs, tag="SONRS", text=None, length=6)

        status, dtserver, language, dtprofup, dtacctup, fi = sonrs

        self._testElement(status, tag="STATUS", text=None, length=2)

        code, severity = status

        self._testElement(code, tag="CODE", text="0", length=0)
        self._testElement(severity, tag="SEVERITY", text="INFO", length=0)

        self._testElement(dtserver,
                          tag="DTSERVER",
                          text="20051029101003",
                          length=0)
        self._testElement(language, tag="LANGUAGE", text="ENG", length=0)
        self._testElement(dtprofup,
                          tag="DTPROFUP",
                          text="19991029101003",
                          length=0)
        self._testElement(dtacctup,
                          tag="DTACCTUP",
                          text="20031029101003",
                          length=0)
        self._testElement(fi, tag="FI", text=None, length=2)

        org, fid = fi

        self._testElement(org, tag="ORG", text="NCH", length=0)
        self._testElement(fid, tag="FID", text="1001", length=0)
コード例 #3
0
ファイル: test_parser.py プロジェクト: csingley/ofxtools
    def _testFeedSonrs(self, body):
        """
        str -> Element tests reused to test responses with identical content
        but different formatting.
        """
        builder = TreeBuilder()
        builder.feed(body)
        root = builder.close()

        self._testElement(root, tag="OFX", text=None, length=1)

        msgsrs = root[0]
        self._testElement(msgsrs, tag="SIGNONMSGSRSV1", text=None, length=1)

        sonrs = msgsrs[0]
        self._testElement(sonrs, tag="SONRS", text=None, length=6)

        status, dtserver, language, dtprofup, dtacctup, fi = sonrs

        self._testElement(status, tag="STATUS", text=None, length=2)

        code, severity = status

        self._testElement(code, tag="CODE", text="0", length=0)
        self._testElement(severity, tag="SEVERITY", text="INFO", length=0)

        self._testElement(dtserver, tag="DTSERVER", text="20051029101003", length=0)
        self._testElement(language, tag="LANGUAGE", text="ENG", length=0)
        self._testElement(dtprofup, tag="DTPROFUP", text="19991029101003", length=0)
        self._testElement(dtacctup, tag="DTACCTUP", text="20031029101003", length=0)
        self._testElement(fi, tag="FI", text=None, length=2)

        org, fid = fi

        self._testElement(org, tag="ORG", text="NCH", length=0)
        self._testElement(fid, tag="FID", text="1001", length=0)
コード例 #4
0
ファイル: base.py プロジェクト: stoklund/ofxtools
 def setUpClass(cls):
     cls.tree = OFXTree()
     parser = TreeBuilder()
     parser.feed(cls.ofx)
     cls.tree._root = parser.close()
コード例 #5
0
ファイル: base.py プロジェクト: csingley/ofxtools
 def setUpClass(cls):
     cls.tree = OFXTree()
     parser = TreeBuilder()
     parser.feed(cls.ofx)
     cls.tree._root = parser.close()