代码实现:
class SapMessageType(enum.Enum): SUCCESS = "S" WARNING = "W" ERROR = "E" ABORT = "A" INFORMATION = "I" class SapStatusMessage: def __init__(self, message_as_popup, message_type, message_text, message_id, message_number, message_parameters): self.message_as_popup = message_as_popup self.message_type = SapMessageType(message_type) self.message_text = message_text self.message_id = message_id self.message_number = message_number self.message_parameters = message_parameters class SapStatusBar: def __new__(cls, *args, **kwargs): if not hasattr(cls, 'instance'): cls.instance = super().__new__(cls, *args, **kwargs) return cls.instance @staticmethod def get_message(session, status_bar): message = None if session and status_bar: try: bar = session.findById(status_bar) message_type = bar.MessageType.strip() if message_type: message_as_popup = bar.MessageAsPopup message_text = bar.Text.strip() message_id = bar.MessageId.strip() message_number = bar.MessageNumber.strip() parameters = SAP_MESSAGES.get(message_id + message_number, [str(i) for i in range(8)]) message_parameters = {name: bar.MessageParameter(i).strip() for i, name in enumerate(parameters)} message = SapStatusMessage( message_as_popup, message_type, message_text, message_id, message_number, message_parameters ) except Exception as _: pass return message # 标识SAP的消息信息,提取需要的数据。 # # 名称: [ID][NUMBER] # 对应的参数含义。 SAP_MESSAGES = { 'F5149': ('date',) } class SapMessages: """ 标识SAP的消息信息,提取需要的数据。 名称: [ID][NUMBER] 对应的参数含义。 """ F5149 = ('date')
https://blog.csdn.net/chenguangqi/article/details/125524474?spm=1001.2014.3001.5502
标签:bar,状态栏,parameters,处理,self,number,消息,message,id From: https://www.cnblogs.com/pythonClub/p/17655269.html