comparison mercurial/urllibcompat.py @ 34465:80d4681150b9

urllibcompat: new library to help abstract out some python3 urllib2 stuff Doing a new file instead of pycompat because I'm starting to feel like pycompat is getting a little enormous in terms of scope. Differential Revision: https://phab.mercurial-scm.org/D890
author Augie Fackler <augie@google.com>
date Sun, 01 Oct 2017 10:45:03 -0400
parents
children 192f7b126ed2
comparison
equal deleted inserted replaced
34464:b0910102e495 34465:80d4681150b9
1 # urllibcompat.py - adapters to ease using urllib2 on Py2 and urllib on Py3
2 #
3 # Copyright 2017 Google, Inc.
4 #
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
7 from __future__ import absolute_import
8
9 from . import pycompat
10
11 if pycompat.ispy3:
12
13 def getfullurl(req):
14 return req.full_url
15
16 def gethost(req):
17 return req.host
18
19 def getselector(req):
20 return req.selector
21
22 def getdata(req):
23 return req.data
24
25 def hasdata(req):
26 return req.data is not None
27 else:
28
29 def gethost(req):
30 return req.get_host()
31
32 def getselector(req):
33 return req.get_selector()
34
35 def getfullurl(req):
36 return req.get_full_url()
37
38 def getdata(req):
39 return req.get_data()
40
41 def hasdata(req):
42 return req.has_data()