Package pyx12 :: Module error_debug
[hide private]

Source Code for Module pyx12.error_debug

  1  ###################################################################### 
  2  # Copyright (c) 2001-2005 Kalamazoo Community Mental Health Services, 
  3  #   John Holland <jholland@kazoocmh.org> <john@zoner.org> 
  4  # All rights reserved. 
  5  # 
  6  # This software is licensed as described in the file LICENSE.txt, which 
  7  # you should have received as part of this distribution. 
  8  # 
  9  ###################################################################### 
 10   
 11  #    $Id: error_debug.py 953 2007-03-23 18:23:47Z johnholland $ 
 12   
 13  """ 
 14  Generates error debug output 
 15  Visitor - Visits an error_handler composite 
 16  """ 
 17   
 18  #from types import * 
 19   
 20  # Intrapackage imports 
 21  from errors import * 
 22  from error_visitor import error_visitor 
 23   
24 -class error_debug_visitor(error_visitor):
25 """ 26 27 """
28 - def __init__(self, fd):
29 """ 30 @param fd: target file 31 @type fd: file descriptor 32 """ 33 self.fd = fd 34 self.seg_count = 0 35 self.st_control_num = 0
36
37 - def visit_root_pre(self, errh):
38 """ 39 @param errh: Error_handler instance 40 @type errh: L{error_handler.err_handler} 41 """ 42 self.fd.write('%s\n' % errh.id)
43
44 - def visit_root_post(self, errh):
45 """ 46 @param errh: Error_handler instance 47 @type errh: L{error_handler.err_handler} 48 """ 49 pass
50
51 - def visit_isa_pre(self, err_isa):
52 """ 53 @param err_isa: ISA Loop error handler 54 @type err_isa: L{error_handler.err_isa} 55 """ 56 self.fd.write('%s\n' % err_isa.id) 57 self.fd.write('-- ISA errors --\n') 58 for err in err_isa.errors: 59 self.fd.write(' %s %s\n' % err) 60 for ele in err_isa.elements: 61 self.fd.write(' %s %s\n' % (ele.id, ele.name)) 62 print ele.parent 63 for err in ele.errors: 64 self.fd.write(' ERR %s %s (%s)\n' % err)
65
66 - def visit_isa_post(self, err_isa):
67 """ 68 @param err_isa: ISA Loop error handler 69 @type err_isa: L{error_handler.err_isa} 70 """ 71 pass
72
73 - def visit_gs_pre(self, err_gs):
74 """ 75 @param err_gs: GS Loop error handler 76 @type err_gs: L{error_handler.err_gs} 77 """ 78 self.fd.write('%s\n' % err_gs.id) 79 self.fd.write('-- GS errors --\n') 80 for err in err_gs.errors: 81 self.fd.write(' %s %s\n' % err) 82 for ele in err_gs.elements: 83 self.fd.write(' %s %s\n' % (ele.id, ele.name)) 84 for err in ele.errors: 85 self.fd.write(' ERR %s %s (%s)\n' % err)
86
87 - def visit_gs_post(self, err_gs):
88 """ 89 @param err_gs: GS Loop error handler 90 @type err_gs: L{error_handler.err_gs} 91 """ 92 93 self.fd.write('%s POST\n' % err_gs.id) 94 #AK9 95 #seg = ['AK9', err_gs.ack_code, '%i' % err_gs.st_count_orig, \ 96 # '%i' % err_gs.st_count_recv, '%i' % (err_gs.st_count_recv - err_gs.count_failed_st())] 97 self.fd.write(' GS Ack Code%s\n' % err_gs.ack_code) 98 self.fd.write(' GS st_count_orig%s\n' % err_gs.st_count_orig) 99 self.fd.write(' GS st_count_recv%i\n' % err_gs.st_count_recv) 100 self.fd.write(' GS st_count_accept%i\n' % (err_gs.st_count_recv - err_gs.count_failed_st())) 101
102 - def visit_st_pre(self, err_st):
103 """ 104 @param err_st: ST Loop error handler 105 @type err_st: L{error_handler.err_st} 106 """ 107 self.fd.write('%s\n' % err_st.id) 108 self.fd.write('-- ST errors --\n') 109 for err in err_st.errors: 110 self.fd.write(' ERR %s %s\n' % err) 111 for ele in err_st.elements: 112 self.fd.write(' ST Element: %s %s\n' % (ele.id, ele.name)) 113 for err in ele.errors: 114 self.fd.write(' ERR %s %s (%s)\n' % err)
115
116 - def visit_st_post(self, err_st):
117 """ 118 @param err_st: ST Loop error handler 119 @type err_st: L{error_handler.err_st} 120 """ 121 pass
122
123 - def visit_seg(self, err_seg):
124 """ 125 @param err_seg: Segment error handler 126 @type err_seg: L{error_handler.err_seg} 127 """ 128 #pdb.set_trace() 129 self.fd.write('%s %s %s %s\n' % (err_seg.id, err_seg.name, err_seg.get_cur_line(), err_seg.seg_id)) 130 for (err_cde, err_str, err_value) in err_seg.errors: 131 self.fd.write(' ERR %s (%s) "%s" \n' % (err_cde, err_value, err_str))
132 #for ele in err_seg.elements: 133 # self.fd.write(' %s %s\n' % (ele.id, ele.name)) 134
135 - def visit_ele(self, err_ele):
136 """ 137 Params: err_ele - error_ele instance 138 @param err_ele: Element error handler 139 @type err_ele: L{error_handler.err_ele} 140 """ 141 self.fd.write(' %s %s\n' % (err_ele.id, err_ele.name)) 142 for err in err_ele.errors: 143 self.fd.write(' ERR %s %s (%s)\n' % err) 144