Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #16080 now redone using six.moves
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed Nov 16, 2015
1 parent 3ac77d3 commit 99699f6
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 83 deletions.
5 changes: 1 addition & 4 deletions src/sage/coding/linear_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,7 @@
from encoder import Encoder

# import compatible with py2 and py3
try:
from urllib import urlopen
except ImportError:
from urllib.request import urlopen
from six.moves.urllib.request import urlopen

ZZ = IntegerRing()

Expand Down
5 changes: 1 addition & 4 deletions src/sage/combinat/designs/covering_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,7 @@ def best_known_covering_design_www(v, k, t, verbose=False):
found in the database.
"""
# import compatible with py2 and py3
try:
from urllib import urlopen
except ImportError:
from urllib.request import urlopen
from six.moves.urllib.request import urlopen

from sage.misc.sage_eval import sage_eval

Expand Down
5 changes: 1 addition & 4 deletions src/sage/combinat/designs/ext_rep.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@
import sys

# import compatible with py2 and py3
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen
from six.moves.urllib.request import urlopen

XML_NAMESPACE = 'http://designtheory.org/xml-namespace'
DTRS_PROTOCOL = '2.0'
Expand Down
8 changes: 2 additions & 6 deletions src/sage/databases/findstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,8 @@ def increasing_tree_shape(elt, compare=min):
import cgi

# import compatible with py2 and py3
try:
from urllib import urlencode
from urllib2 import Request, urlopen, HTTPError
except ImportError:
from urllib.parse import urlencode
from urllib.request import Request, urlopen, HTTPError
from six.moves.urllib.parse import urlencode
from six.moves.urllib.request import Request, urlopen, HTTPError

# Combinatoral collections
from sage.combinat.alternating_sign_matrix import AlternatingSignMatrix, AlternatingSignMatrices
Expand Down
5 changes: 1 addition & 4 deletions src/sage/databases/sloane.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@
import re

# import compatible with py2 and py3
try:
from urllib import urlretrieve
except ImportError:
from urllib.request import urlretrieve
from six.moves.urllib.request import urlretrieve

from sage.misc.all import verbose
from sage.env import SAGE_SHARE
Expand Down
11 changes: 3 additions & 8 deletions src/sage/dev/digest_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@
from xmlrpclib import SafeTransport, Fault

# import compatible with py2 and py3
try:
from urllib2 import (build_opener, HTTPDigestAuthHandler,
Request, HTTPError)
from urlparse import urlunparse
except ImportError:
from urllib.request import (build_opener, HTTPDigestAuthHandler,
Request, HTTPError)
from urllib.parse import urlunparse
from six.moves.urllib.request import (build_opener, HTTPDigestAuthHandler,
Request, HTTPError)
from six.moves.urllib.parse import urlunparse


class DigestTransport(object, SafeTransport):
Expand Down
9 changes: 1 addition & 8 deletions src/sage/dev/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@
import re

# import compatible with py2 and py3
try:
from urllib import urlretrieve
except ImportError:
from urllib.request import urlretrieve
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen
from six.moves.urllib.request import urlretrieve, urlopen


# regular expressions to parse mercurial patches
Expand Down
8 changes: 2 additions & 6 deletions src/sage/dev/sagedev.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@
import re

# import compatible with py2 and py3
try:
from urlparse import urljoin
from urllib import pathname2url
except ImportError:
from urllib.parse import urljoin
from urllib.request import pathname2url
from six.moves.urllib.parse import urljoin
from six.moves.urllib.request import pathname2url

from user_interface_error import OperationCancelledError
from trac_error import TracConnectionError, TracInternalError, TracError
Expand Down
5 changes: 1 addition & 4 deletions src/sage/dev/test/server_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,7 @@ def update(self, ticket, comment, attributes, notify=False):
from sage.env import TRAC_SERVER_URI

# import compatible with py2 and py3
try:
from urlparse import urljoin
except ImportError:
from urllib.parse import urljoin
from six.moves.urllib.parse import urljoin

return urljoin(TRAC_SERVER_URI, 'ticket/%s#comment:%s' % (ticket.id, len(ticket.comments)))

Expand Down
8 changes: 2 additions & 6 deletions src/sage/dev/trac_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@
import datetime

# import compatible with py2 and py3
try:
from urlparse import urljoin
from urllib import pathname2url
except ImportError:
from urllib.parse import urljoin
from urllib.request import pathname2url
from six.moves.urllib.parse import urljoin
from six.moves.urllib.request import pathname2url


FIELD_REGEX = re.compile("^([A-Za-z ]+):(.*)$")
Expand Down
5 changes: 1 addition & 4 deletions src/sage/finance/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
from datetime import date

# import compatible with py2 and py3
try:
from urllib import urlopen
except ImportError:
from urllib.request import urlopen
from six.moves.urllib.request import urlopen


class OHLC:
Expand Down
5 changes: 1 addition & 4 deletions src/sage/graphs/isgci.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,10 +803,7 @@ def _download_db(self):
sage: graph_classes._download_db() # Not tested -- requires internet
"""
# import compatible with py2 and py3
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen
from six.moves.urllib.request import urlopen

from sage.misc.misc import SAGE_TMP
import os.path
Expand Down
5 changes: 1 addition & 4 deletions src/sage/interfaces/magma_free.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ def magma_free_eval(code, strip=True, columns=0):
[ <2, 5>, <290323377887, 1> ]
"""
# import compatible with py2 and py3
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencode
from six.moves.urllib.parse import urlencode
import httplib
from xml.dom.minidom import parseString

Expand Down
5 changes: 1 addition & 4 deletions src/sage/misc/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ def pushover(message, **kwds):
import httplib

# import compatible with py2 and py3
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencode
from six.moves.urllib.parse import urlencode

request = {"message": message}
request.update(pushover_defaults)
Expand Down
5 changes: 1 addition & 4 deletions src/sage/misc/remote_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ def get_remote_file(filename, verbose=True):
# so do not import it in the module scope.

# import compatible with py2 and py3
try:
from urllib import urlretrieve
except ImportError:
from urllib.request import urlretrieve
from six.moves.urllib.request import urlretrieve

global cur
cur = 0
Expand Down
5 changes: 1 addition & 4 deletions src/sage/rings/arith.py
Original file line number Diff line number Diff line change
Expand Up @@ -1967,10 +1967,7 @@ def xkcd(n=""):
from sage.misc.html import html

# import compatible with py2 and py3
try:
from urllib2 import urlopen, HTTPError, URLError
except ImportError:
from urllib.request import urlopen, HTTPError, URLError
from six.moves.urllib.request import urlopen, HTTPError, URLError

data = None
url = "http://dynamic.xkcd.com/api-0/jsonp/comic/{}".format(n)
Expand Down
7 changes: 2 additions & 5 deletions src/sage/symbolic/integration/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ def mma_free_integrator(expression, v, a=None, b=None):
"""
import re
# import compatible with py2 and py3
try:
from urllib import urlopen, urlencode
except ImportError:
from urllib.request import urlopen
from urllib.parse import urlencode
from six.moves.urllib.request import urlopen
from six.moves.urllib.parse import urlencode
# We need to integrate against x
vars = [str(x) for x in expression.variables()]
if any(len(x)>1 for x in vars):
Expand Down

0 comments on commit 99699f6

Please sign in to comment.