示例#1
0
 def update_by_cp_name(self, cp_name, value):
     if isinstance(cp_name, int):
         #self._update_field_helper(cp_name, value)
         raise NotImplementedError(
             'element_type=%r has not implemented %r in cp_name_map' %
             (self.type, cp_name))
     #elif cp_name == 'Z0':
     #self.z0 = value
     #elif cp_name == 'SB':
     #self.sb = value
     #elif cp_name == 'TREF':
     #self.tref = value
     #elif cp_name == 'GE':
     #self.ge = value
     elif cp_name.startswith('X'):
         word, num = break_word_by_trailing_integer(cp_name)
         num = int(num)
         if word == 'X':
             self.x[num - 1] = value
         else:
             raise RuntimeError('eid=%s cp_name=%r word=%s\n' %
                                (self.eid, cp_name, word))
     else:
         raise NotImplementedError(
             'element_type=%r has not implemented %r in cp_name_map' %
             (self.type, cp_name))
示例#2
0
 def test_break_words(self):
     """tests break_word_by_trailing_integer"""
     assert break_word_by_trailing_integer('T11') == ('T', '11'), break_word_by_trailing_integer('T11')
     assert break_word_by_trailing_integer('THETA42') == ('THETA', '42'), break_word_by_trailing_integer('THETA42')
     assert break_word_by_trailing_integer('T3') == ('T', '3'), break_word_by_trailing_integer('T3')
     with self.assertRaises(SyntaxError):
         assert break_word_by_trailing_integer('THETA32X')