def addException(): global errors #self.widget._report_exception() try: typ, val, tb = sys.exc_info() traceback.print_exception(typ, val, tb) if errors: errors.append("") exception = traceback.format_exception(typ, val, tb) errors.extend(exception) if len(errors) > 100: # If too many errors are found send the error report ReportDialog(self.widget) except: say(str(sys.exc_info()))
if i<l and (str[i]=='-' or str[i]=='+'): i += 1 # accept many digits if i<l and '0'<=str[i]<='9': while i<l and '0'<=str[i]<='9': i += 1 else: return False if i != l: return False return True if __name__=="__main__": from log import say say("abbrev") assert abbrev('information','info',4) assert abbrev('information','',0) assert not abbrev('information','Info',4) assert not abbrev('information','info',5) assert not abbrev('information','info ') assert abbrev('information','info',3) assert not abbrev('info','information',3) assert not abbrev('info','info',5) say("center") assert center('****',0,'-') == '' assert center('****',8,'-') == '--****--' assert center('****',7,'-') == '-****--' assert center('*****',8,'-') == '-*****--' assert center('*****',7,'-') == '-*****-'
# accept many digits if i < l and '0' <= s[i] <= '9': while i < l and '0' <= s[i] <= '9': i += 1 else: return False if i != l: return False return True #------------------------------------------------------------------------------- if __name__ == "__main__": from log import say say("abbrev") assert abbrev('information', 'info', 4) assert abbrev('information', '', 0) assert not abbrev('information', 'Info', 4) assert not abbrev('information', 'info', 5) assert not abbrev('information', 'info ') assert abbrev('information', 'info', 3) assert not abbrev('info', 'information', 3) assert not abbrev('info', 'info', 5) say("center") assert center('****', 0, '-') == '' assert center('****', 8, '-') == '--****--' assert center('****', 7, '-') == '-****--' assert center('*****', 8, '-') == '-*****--' assert center('*****', 7, '-') == '-*****-'