def __init__(self, info = None, warn = 'stdout', errr = 'stdout'): self.info_case = -1 self.warn_case = -1 self.errr_case = -1 if info is None: pass elif type(info) is not type(' '): raise error('wrong info argument for Printer constructor') elif info in {'stdout', 'stderr', 'cout', 'cerr'}: self.info = pystir.newTextPrinter(info) self.info_case = 0 else: self.info = pystir.newTextWriter(info) self.info_case = 1 if warn is None: pass elif type(warn) is not type(' '): raise error('wrong warn argument for Printer constructor') elif warn in {'stdout', 'stderr', 'cout', 'cerr'}: self.warn = pystir.newTextPrinter(warn) self.warn_case = 0 else: self.warn = pystir.newTextWriter(warn) self.warn_case = 1 if errr is None: pass elif type(errr) is not type(' '): raise error('wrong errr argument for Printer constructor') elif errr in {'stdout', 'stderr', 'cout', 'cerr'}: self.errr = pystir.newTextPrinter(errr) self.errr_case = 0 else: self.errr = pystir.newTextWriter(errr) self.errr_case = 1 if self.info_case is not -1: pystir.openChannel(0, self.info) if self.warn_case is not -1: pystir.openChannel(1, self.warn) if self.errr_case is not -1: pystir.openChannel(2, self.errr)
def __init__(self, dest, channel = -1): self.case = -1 if dest is None: return elif type(dest) is not type(' '): raise error('wrong info argument for Printer constructor') elif dest in {'stdout', 'stderr', 'cout', 'cerr'}: self.printer = pystir.newTextPrinter(dest) self.case = 0 else: self.printer = pystir.newTextWriter(dest) self.case = 1 pystir.openChannel(channel, self.printer) self.channel = channel