Write Structure Link to File Method

def _writeStructureLink(self, link, fileObject, replaceParamFile):
        """
        Write Structure Link to File Method
        """
        fileObject.write('%s\n' % link.type)
        fileObject.write('NUMSTRUCTS     %s\n' % link.numElements)

        # Retrieve lists of structures
        weirs = link.weirs
        culverts = link.culverts

        # Write weirs to file
        for weir in weirs:
            fileObject.write('STRUCTTYPE     %s\n' % weir.type)

            # Check for replacement vars
            crestLength = vwp(weir.crestLength, replaceParamFile)
            crestLowElevation = vwp(weir.crestLowElevation, replaceParamFile)
            dischargeCoeffForward = vwp(weir.dischargeCoeffForward, replaceParamFile)
            dischargeCoeffReverse = vwp(weir.dischargeCoeffReverse, replaceParamFile)
            crestLowLocation = vwp(weir.crestLowLocation, replaceParamFile)
            steepSlope = vwp(weir.steepSlope, replaceParamFile)
            shallowSlope = vwp(weir.shallowSlope, replaceParamFile)

            if weir.crestLength != None:
                try:
                    fileObject.write('CREST_LENGTH             %.6f\n' % crestLength)
                except:
                    fileObject.write('CREST_LENGTH             %s\n' % crestLength)

            if weir.crestLowElevation != None:
                try:
                    fileObject.write('CREST_LOW_ELEV           %.6f\n' % crestLowElevation)
                except:
                    fileObject.write('CREST_LOW_ELEV           %s\n' % crestLowElevation)

            if weir.dischargeCoeffForward != None:
                try:
                    fileObject.write('DISCHARGE_COEFF_FORWARD  %.6f\n' % dischargeCoeffForward)
                except:
                    fileObject.write('DISCHARGE_COEFF_FORWARD  %s\n' % dischargeCoeffForward)

            if weir.dischargeCoeffReverse != None:
                try:
                    fileObject.write('DISCHARGE_COEFF_REVERSE  %.6f\n' % dischargeCoeffReverse)
                except:
                    fileObject.write('DISCHARGE_COEFF_REVERSE  %s\n' % dischargeCoeffReverse)

            if weir.crestLowLocation != None:
                    fileObject.write('CREST_LOW_LOC            %s\n' % crestLowLocation)

            if weir.steepSlope != None:
                try:
                    fileObject.write('STEEP_SLOPE              %.6f\n' % steepSlope)
                except:
                    fileObject.write('STEEP_SLOPE              %s\n' % steepSlope)

            if weir.shallowSlope != None:
                try:
                    fileObject.write('SHALLOW_SLOPE            %.6f\n' % shallowSlope)
                except:
                    fileObject.write('SHALLOW_SLOPE            %s\n' % shallowSlope)

        # Write culverts to file
        for culvert in culverts:
            fileObject.write('STRUCTTYPE     %s\n' % culvert.type)

            # Check for replacement vars
            upstreamInvert = vwp(culvert.upstreamInvert, replaceParamFile)
            downstreamInvert = vwp(culvert.downstreamInvert, replaceParamFile)
            inletDischargeCoeff = vwp(culvert.inletDischargeCoeff, replaceParamFile)
            reverseFlowDischargeCoeff = vwp(culvert.reverseFlowDischargeCoeff, replaceParamFile)
            slope = vwp(culvert.slope, replaceParamFile)
            length = vwp(culvert.length, replaceParamFile)
            roughness = vwp(culvert.roughness, replaceParamFile)
            diameter = vwp(culvert.diameter, replaceParamFile)
            width = vwp(culvert.width, replaceParamFile)
            height = vwp(culvert.height, replaceParamFile)

            if culvert.upstreamInvert != None:
                try:
                    fileObject.write('UPINVERT                 %.6f\n' % upstreamInvert)
                except:
                    fileObject.write('UPINVERT                 %s\n' % upstreamInvert)

            if culvert.downstreamInvert != None:
                try:
                    fileObject.write('DOWNINVERT               %.6f\n' % downstreamInvert)
                except:
                    fileObject.write('DOWNINVERT               %s\n' % downstreamInvert)

            if culvert.inletDischargeCoeff != None:
                try:
                    fileObject.write('INLET_DISCH_COEFF        %.6f\n' % inletDischargeCoeff)
                except:
                    fileObject.write('INLET_DISCH_COEFF        %s\n' % inletDischargeCoeff)

            if culvert.reverseFlowDischargeCoeff != None:
                try:
                    fileObject.write('REV_FLOW_DISCH_COEFF     %.6f\n' % reverseFlowDischargeCoeff)
                except:
                    fileObject.write('REV_FLOW_DISCH_COEFF     %s\n' % reverseFlowDischargeCoeff)

            if culvert.slope != None:
                try:
                    fileObject.write('SLOPE                    %.6f\n' % slope)
                except:
                    fileObject.write('SLOPE                    %s\n' % slope)

            if culvert.length != None:
                try:
                    fileObject.write('LENGTH                   %.6f\n' % length)
                except:
                    fileObject.write('LENGTH                   %s\n' % length)

            if culvert.roughness != None:
                try:
                    fileObject.write('ROUGH_COEFF              %.6f\n' % roughness)
                except:
                    fileObject.write('ROUGH_COEFF              %s\n' % roughness)

            if culvert.diameter != None:
                try:
                    fileObject.write('DIAMETER                 %.6f\n' % diameter)
                except:
                    fileObject.write('DIAMETER                 %s\n' % diameter)


            if culvert.width != None:
                try:
                    fileObject.write('WIDTH                    %.6f\n' % width)
                except:
                    fileObject.write('WIDTH                    %s\n' % width)

            if culvert.height != None:
                try:
                    fileObject.write('HEIGHT                   %.6f\n' % height)
                except:
                    fileObject.write('HEIGHT                   %s\n' % height)