X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fproto.py;h=b1f0ab375e6faba741cc1dc4da86d85ba3950e0c;hb=7be9e8bb560cd4e969992759bbcb523b40e544af;hp=881f4e477a84152257e7eb037b6571545c53208a;hpb=001ec99e577b56479149fbe39de1d9291a134527;p=wrw.git diff --git a/wrw/proto.py b/wrw/proto.py index 881f4e4..b1f0ab3 100644 --- a/wrw/proto.py +++ b/wrw/proto.py @@ -1,3 +1,5 @@ +import time + statusinfo = { 400: ("Bad Request", "Invalid HTTP request."), 401: ("Unauthorized", "Authentication must be provided for the requested resource."), @@ -113,7 +115,7 @@ def parseurl(url): local = local[:q] return proto, host, local, query -def consurl(proto, host, local, query = ""): +def consurl(proto, host, local, query=""): if len(local) < 1 and local[0] != '/': raise urlerror("Local part of URL must begin with a slash") ret = "%s://%s%s" % (proto, host, local) @@ -142,7 +144,7 @@ def requrl(req): raise Exception("Malformed local part when reconstructing URL") return "%s://%s%s" % (proto, host, req.uri) -def parstring(pars = {}, **augment): +def parstring(pars={}, **augment): buf = "" for key in pars: if key in augment: @@ -156,3 +158,10 @@ def parstring(pars = {}, **augment): if buf != "": buf += "&" buf += urlq(key) + "=" + urlq(str(augment[key])) return buf + +def parurl(url, pars={}, **augment): + qs = parstring(pars, **augment) + if qs != "": + return url + "?" + qs + else: + return url