def dumbo(argv=sys.argv): if len(argv) < 2: print 'Usages:' print ' dumbo start <python program> [<options>]' print ' dumbo cat <path> [<options>]' print ' dumbo ls <path> [<options>]' print ' dumbo exists <path> [<options>]' print ' dumbo rm <path> [<options>]' print ' dumbo put <path1> <path2> [<options>]' print ' dumbo get <path1> <path2> [<options>]' print ' dumbo encodepipe [<options>]' print ' dumbo decodepipe [<options>]' print ' dumbo doctest <python program>' print ' dumbo version' print ' dumbo configdump' return 1 if argv[1] == 'start': retval = start(argv[2], parseargs(argv[2:])) elif argv[1] == 'cat': retval = cat(argv[2], parseargs(argv[2:])) elif argv[1] == 'ls': retval = ls(argv[2], parseargs(argv[2:])) elif argv[1] == 'exists': retval = exists(argv[2], parseargs(argv[2:])) elif argv[1] == 'rm': retval = rm(argv[2], parseargs(argv[2:])) elif argv[1] == 'put': retval = put(argv[2], argv[3], parseargs(argv[3:])) elif argv[1] == 'get': retval = get(argv[2], argv[3], parseargs(argv[3:])) elif argv[1] == 'encodepipe': retval = encodepipe(parseargs(argv[2:])) elif argv[1] == 'decodepipe': retval = decodepipe(parseargs(argv[2:])) elif argv[1] == 'doctest': retval = doctest(argv[2]) elif argv[1].endswith('.py'): retval = start(argv[1], parseargs(argv[1:])) elif argv[1] in ('version', '-v', '--version'): print version() return 0 elif argv[1] == 'configdump': retval = config_dump() else: print >> sys.stderr, 'ERROR: unknown dumbo command:', argv[1] retval = 1 return retval
def dumbo(): if len(sys.argv) < 2: print 'Usages:' print ' dumbo start <python program> [<options>]' print ' dumbo cat <path> [<options>]' print ' dumbo convert <python program|module> <path> [<options>]' print ' dumbo ls <path> [<options>]' print ' dumbo exists <path> [<options>]' print ' dumbo rm <path> [<options>]' print ' dumbo put <path1> <path2> [<options>]' print ' dumbo get <path1> <path2> [<options>]' print ' dumbo encodepipe [<options>]' print ' dumbo decodepipe [<options>]' print ' dumbo doctest <python program>' return 1 if sys.argv[1] == 'start': retval = start(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'cat': retval = cat(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'convert': retval = convert(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == 'ls': retval = ls(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'exists': retval = exists(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'rm': retval = rm(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'put': retval = put(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == 'get': retval = get(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == 'encodepipe': retval = encodepipe(parseargs(sys.argv[2:])) elif sys.argv[1] == 'decodepipe': retval = decodepipe(parseargs(sys.argv[2:])) elif sys.argv[1] == 'doctest': retval = doctest(sys.argv[2]) elif sys.argv[1].endswith('.py'): retval = start(sys.argv[1], parseargs(sys.argv[1:])) else: print >> sys.stderr, 'ERROR: unknown dumbo command:', sys.argv[1] retval = 1 return retval
def dumbo(): if len(sys.argv) < 2: print 'Usages:' print ' dumbo start <python program> [<options>]' print ' dumbo cat <path> [<options>]' print ' dumbo ls <path> [<options>]' print ' dumbo exists <path> [<options>]' print ' dumbo rm <path> [<options>]' print ' dumbo put <path1> <path2> [<options>]' print ' dumbo get <path1> <path2> [<options>]' print ' dumbo encodepipe [<options>]' print ' dumbo decodepipe [<options>]' print ' dumbo doctest <python program>' return 1 if sys.argv[1] == 'start': retval = start(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'cat': retval = cat(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'ls': retval = ls(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'exists': retval = exists(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'rm': retval = rm(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'put': retval = put(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == 'get': retval = get(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == 'encodepipe': retval = encodepipe(parseargs(sys.argv[2:])) elif sys.argv[1] == 'decodepipe': retval = decodepipe(parseargs(sys.argv[2:])) elif sys.argv[1] == 'doctest': retval = doctest(sys.argv[2]) elif sys.argv[1].endswith('.py'): retval = start(sys.argv[1], parseargs(sys.argv[1:])) else: print >> sys.stderr, 'ERROR: unknown dumbo command:', sys.argv[1] retval = 1 return retval
def dumbo(): if len(sys.argv) < 2: print "Usages:" print " dumbo start <python program> [<options>]" print " dumbo cat <path> [<options>]" print " dumbo ls <path> [<options>]" print " dumbo rm <path> [<options>]" print " dumbo put <path1> <path2> [<options>]" print " dumbo get <path1> <path2> [<options>]" print " dumbo encodepipe [<options>]" print " dumbo decodepipe [<options>]" print " dumbo doctest <python program>" return 1 if sys.argv[1] == "start": retval = start(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == "submit": retval = submit(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == "cat": retval = cat(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == "ls": retval = ls(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == "rm": retval = rm(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == "put": retval = put(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == "get": retval = get(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == "encodepipe": retval = encodepipe(parseargs(sys.argv[2:])) elif sys.argv[1] == "decodepipe": retval = decodepipe(parseargs(sys.argv[2:])) elif sys.argv[1] == "doctest": retval = doctest(sys.argv[2]) elif sys.argv[1].endswith(".py"): retval = start(sys.argv[1], parseargs(sys.argv[1:])) else: print >> sys.stderr, "ERROR: unknown dumbo command:", sys.argv[1] retval = 1 return retval
def main(): parser = OptionParser() parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False) parser.add_option("--pdb", action="store_true", dest="pdb", default=False, help="Run post mortem pdb on each failure") parser.add_option("--no-colors", action="store_false", dest="colors", default=True, help="Do not report colored [OK] and [FAIL]") parser.add_option("-k", dest="kw", help="only run tests matching the given keyword expression", metavar="KEYWORD", default="") parser.add_option("--tb", dest="tb", help="traceback verboseness (short/no) [default: %default]", metavar="TBSTYLE", default="short") options, args = parser.parse_args() ok = test(*args, **{"verbose": options.verbose, "kw": options.kw, "tb": options.tb, "pdb": options.pdb, "colors": options.colors}) if ok: ok = doctest(*args, **{"verbose": options.verbose, "kw": options.kw, "tb": options.tb, "pdb": options.pdb, "colors": options.colors}) if ok: sys.exit(0) else: sys.exit(1) else: sys.exit(1)
False >>> if a: ... print 'OK' ... OK >>> if b: ... print 'OK' ... >>> """ return self.valido() def plain(self): return ''.join(map(str, self.cpf)) def doctest(): import doctest doctest.testmod() if __name__ == "__main__": doctest() # vim:tabstop=4:shiftwidth=4:expandtab:smartindent:encoding=utf-8
try: self._vertice.remove(pt) except KeyError: pass def calc_area(self): '''Calculate the area of the polygon and returns. http://mathworld.wolfram.com/PolygonArea.html ''' vertices = self._vertices[:] vertices.append(vertices[0]) k = 0 for i in xrange(len(vertices) - 1): k += (vertices[i][1] * vertices[i+1][0]) - \ (vertices[i][0] * vertices[i+1][1]) area = k / 2.0 return area def doctest(): import doctest doctest.testmod() if __name__ == '__main__': doctest() # class Square: