Beispiel #1
0
    def add_attribute(self, v, a):
        """
        Adds value "v" for attribute "a" with index "i" to the DSN;
        see the self.attributes dictionary for more info.
        """

        i = a['index']

        if a['type'] == 'INTEGER':
            retcode = hspf.wdbsaipy(self.wdm, self.number, self.message, i, v)
            var = '%d'
        if a['type'] == 'REAL':
            retcode = hspf.wdbsarpy(self.wdm, self.number, self.message, i, v)
            var = '%.6e'
        if a['type'] == 'CHARACTER':

            # this is a bit tricky since FORTRAN pre-allocates the character
            # size, so add blanks to the end

            v = v[:a['length']] + ' ' * (a['length'] - len(v))

            retcode = hspf.wdbsacpy(self.wdm, self.number, self.message, i, v)
            var = '%s'

            if retcode < 0:
                print('problem adding attribute to %d, retcode = %d' %
                      (i, retcode))

        return retcode, var
Beispiel #2
0
    def add_attribute(self, v, a):
        """
        Adds value "v" for attribute "a" with index "i" to the DSN; 
        see the self.attributes dictionary for more info.
        """

        i = a['index']

        if a['type'] == 'INTEGER':
            retcode = hspf.wdbsaipy(self.wdm, self.number, self.message, i, v)
            var = '%d'
        if a['type'] == 'REAL':
            retcode = hspf.wdbsarpy(self.wdm, self.number, self.message, i, v)
            var = '%.6e'
        if a['type'] == 'CHARACTER':
            
            # this is a bit tricky since FORTRAN pre-allocates the character
            # size, so add blanks to the end

            v = v[:a['length']] + ' ' * (a['length'] - len(v))

            retcode = hspf.wdbsacpy(self.wdm, self.number, self.message, i, v)
            var = '%s'
            
            if retcode < 0: print('problem adding attribute to %d, retcode = %d'
                                  % (i, retcode))

        return retcode, var