예제 #1
0
 def testPythonVisitorCompile(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     # print( "***Manual Inspection" )
     # print( text )
     exec text
예제 #2
0
 def testPythonVisitorCompile( self ):
     python= FlatPythonVisitor( "parse_278" )
     parse_278.visit( python )
     text= python.getSource()
     #print( "***Manual Inspection" )
     #print( text )
     exec text
예제 #3
0
 def testPythonVisitorWorks(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     exec(text)
     self.assertEqual(type(parse_278), Message)
     msg = parse_278.unmarshall(self.msg1)
     # XXX - check the resulting structure
     self.assertEqual(self.msg1, msg.marshall())
예제 #4
0
 def testPythonVisitorWorks(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     exec text
     self.assertEqual(type(parse_278), Message)
     msg = parse_278.unmarshall(self.msg1)
     # XXX - check the resulting structure
     self.assertEquals(self.msg1, msg.marshall())
예제 #5
0
    def setUp( self ):
        # a 278-13 - I think this is a referral response
        self.msg1="""ISA*03*gjohnson2 *01*0000000000*ZZ*0000000Eliginet*ZZ*BLUECROSS BLUES*071015*0903*U*00401*000242835*0*P*:~GS*HI*0000000Eliginet*BLUECROSS BLUES*20071015*0903*241935*X*004010X094A1~ST*278*242835~BHT*0078*13*GXEDWLXQYKII*20071015*0903~HL*1**20*1~NM1*X3*2*BLUECROSS BLUESHIELD OF WESTERN NEW*****PI*55204~HL*2*1*21*1~NM1*1P*1*SHEIKH*ZIA****24*161590688~REF*ZH*000524454008~N3*4039 ROUTE 219*SUITE 102~N4*SALAMANCA*NY*14779~HL*3*2*22*1~HI*BF:706.1~NM1*IL*1*burton*amanda****MI*yjw88034076701~DMG*D8*19900815*U~HL*4*3*19*1~NM1*SJ*1*JAREMKO*WILLIAM****24*161482964~REF*ZH*000511127003~N3*2646 WEST STATE STREET*SUITE 405~N4*OLEAN*NY*147600000~HL*5*4*SS*0~TRN*1*1*9999955204~UM*SC*I*******Y~DTP*472*RD8*20071015-20080415~HSD*VS*30~SE*24*242835~GE*1*241935~IEA*1*000242835~"""

        bldParser= convertPyX12.ParserBuilder()

        xml= convertPyX12.XMLParser()
        xml.data( open("tests/map/dataele.xml") )
        xml.codes( open("tests/map/codes.xml") )
        #The 278 definition doesn't have the correct nested LOOP structure to parse
        xml.read( open("tests/map/278.4010.X094.A1.xml") )
        #This 278 definition seems to parse better.
        #xml.read( os.path.join( "test", "278.4010.X094.A1.xml" ) )
        self.x12p= bldParser.build( xml )

        sql= SQLTableVisitor( )
        self.x12p.visit( sql )
        self.sqlCode= sql.getSource()

        python= FlatPythonVisitor( "parse_278" )
        self.x12p.visit( python )
        self.pyCode= python.getSource()
예제 #6
0
    def setUp(self):
        # a 278-13 - I think this is a referral response
        self.msg1 = """ISA*03*gjohnson2 *01*0000000000*ZZ*0000000Eliginet*ZZ*BLUECROSS BLUES*071015*0903*U*00401*000242835*0*P*:~GS*HI*0000000Eliginet*BLUECROSS BLUES*20071015*0903*241935*X*004010X094A1~ST*278*242835~BHT*0078*13*GXEDWLXQYKII*20071015*0903~HL*1**20*1~NM1*X3*2*BLUECROSS BLUESHIELD OF WESTERN NEW*****PI*55204~HL*2*1*21*1~NM1*1P*1*SHEIKH*ZIA****24*161590688~REF*ZH*000524454008~N3*4039 ROUTE 219*SUITE 102~N4*SALAMANCA*NY*14779~HL*3*2*22*1~HI*BF:706.1~NM1*IL*1*burton*amanda****MI*yjw88034076701~DMG*D8*19900815*U~HL*4*3*19*1~NM1*SJ*1*JAREMKO*WILLIAM****24*161482964~REF*ZH*000511127003~N3*2646 WEST STATE STREET*SUITE 405~N4*OLEAN*NY*147600000~HL*5*4*SS*0~TRN*1*1*9999955204~UM*SC*I*******Y~DTP*472*RD8*20071015-20080415~HSD*VS*30~SE*24*242835~GE*1*241935~IEA*1*000242835~"""

        bldParser = convertPyX12.ParserBuilder()

        xml = convertPyX12.XMLParser()
        xml.data(open("tests/map/dataele.xml"))
        xml.codes(open("tests/map/codes.xml"))
        #The 278 definition doesn't have the correct nested LOOP structure to parse
        xml.read(open("tests/map/278.4010.X094.A1.xml"))
        #This 278 definition seems to parse better.
        #xml.read( os.path.join( "test", "278.4010.X094.A1.xml" ) )
        self.x12p = bldParser.build(xml)

        sql = SQLTableVisitor()
        self.x12p.visit(sql)
        self.sqlCode = sql.getSource()

        python = FlatPythonVisitor("parse_278")
        self.x12p.visit(python)
        self.pyCode = python.getSource()
예제 #7
0
def writeFile(aFile, name, x12, structure="flat"):
    """Write the x12 python module to a file.
    
    :param aFile: Filename of destination file.
    :type aFile: String
    :param name: The name of the generated class.
    :type name: String
    :param x12: The `X12.parse.Message` object to write.
    :type x12: `X12.parse.Message`
    """
    if structure == "nested":
        pyMap = PythonVisitor(name)
    else:
        pyMap = FlatPythonVisitor(name)
    x12.visit(pyMap)
    pySrc = pyMap.getSource()
    with open(aFile, 'w') as f:
        f.write("#\n# Generated by TigerShark.tools.convertPyX12 on %s\n#\n" %
                datetime.now())
        f.write(pySrc)
        f.write('\n\n')
예제 #8
0
 def testPythonVisitorCompile(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     exec(text)
예제 #9
0
 def testPythonVisitorCompile(self):
     python = FlatPythonVisitor("parse_278")
     parse_278.visit(python)
     text = python.getSource()
     exec text