Merge branch 'master' of git.dolda2000.com:/srv/git/r/wrw
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 5 Aug 2012 16:18:22 +0000 (18:18 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 5 Aug 2012 16:18:22 +0000 (18:18 +0200)
1  2 
wrw/proto.py

diff --combined wrw/proto.py
@@@ -1,3 -1,5 +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 +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 +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:
          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