Source code for pyNastran.bdf.field_writer_8

"""
Defines functions for single precision 8 character field writing.
"""
from __future__ import (nested_scopes, generators, division, absolute_import,
                        print_function, unicode_literals)
from six import string_types
from six.moves import range
import sys
from numpy import float32


[docs]def set_string8_blank_if_default(value, default): """helper method for writing BDFs""" val = set_blank_if_default(value, default) if val is None: return ' ' return '%8s' % val
[docs]def is_same(value1, value2): """ Checks to see if 2 values are the same .. note:: this method is used by almost every card when printing """ if isinstance(value1, string_types) or value1 is None: return True if value1 == value2 else False if value1 == value2: return True return False
[docs]def set_blank_if_default(value, default): """ Used when setting the output data of a card to clear default values :param value: the field value the may be set to None (blank) if value=default, the default value for the field .. note:: this method is used by almost every card when printing """ return None if is_same(value, default) else value
[docs]def set_default_if_blank(value, default): """ Used when initializing a card and the default value isn't set Used on PBARL """ return default if value is None or value == '' else value