Esempio n. 1
0
 def __str__(self):
     if len(self.keys()) > 0: # Don't print empty namelists.
         if self.name is not None:
             return Namelist.__str__(self)
         else:
             # Modify the Namelist print behavior for a NoneType namelist.
             # Namely, don't print the "&name" section and ending slash.
             return '\n'.join([' %s=%s'%(k,v) for k,v in self.iteritems()])
     else:
         return ''
Esempio n. 2
0
 def __str__(self):
     # Convert list values to strings.
     self['iat'] = ','.join([str(i) for i in self['iat']])
     try:
         self['rstwt'] = ','.join([str(i) for i in self['rstwt']])
     except KeyError:
         pass
     txt = Namelist.__str__(self)
     # Convert back to lists.
     self['iat'] = [int(i) for i in self['iat'].split(',')]
     try:
         self['rstwt'] = [float(i) for i in self['rstwt'].split(',')]
     except KeyError:
         pass
     return txt