diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-10-19 09:20:40 -0700 |
---|---|---|
committer | Paul McGuire <ptmcg@users.noreply.github.com> | 2019-10-19 11:20:40 -0500 |
commit | 87d14e7ef563263417d3fddccd25636741c5b6c2 (patch) | |
tree | 4a8a5db3c1fe12043955b56e7c7c19253c823c7e /examples | |
parent | 69aea3980e2e3c848ae1c7b0ce7539bbdc8daf27 (diff) | |
download | pyparsing-git-87d14e7ef563263417d3fddccd25636741c5b6c2.tar.gz |
Py3 cleanup: Remove workaround for Python2 urllib (#143)
For Python 3 only code, the import path is known and stable. Can remove
the ImportError workaround.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/getNTPserversNew.py | 8 | ||||
-rw-r--r-- | examples/statemachine/statemachine.py | 11 |
2 files changed, 3 insertions, 16 deletions
diff --git a/examples/getNTPserversNew.py b/examples/getNTPserversNew.py index ab392dc..af47c73 100644 --- a/examples/getNTPserversNew.py +++ b/examples/getNTPserversNew.py @@ -8,13 +8,7 @@ # import pyparsing as pp ppc = pp.pyparsing_common - -try: - import urllib.request - urlopen = urllib.request.urlopen -except ImportError: - import urllib - urlopen = urllib.urlopen +from urllib.request import urlopen integer = pp.Word(pp.nums) ipAddress = ppc.ipv4_address() diff --git a/examples/statemachine/statemachine.py b/examples/statemachine/statemachine.py index 44f64d2..f318ee5 100644 --- a/examples/statemachine/statemachine.py +++ b/examples/statemachine/statemachine.py @@ -8,14 +8,7 @@ import sys import os import types import importlib -try: - import urllib.parse - url_parse = urllib.parse.urlparse -except ImportError: - print("import error, Python 2 not supported") - raise - import urllib - url_parse = urllib.parse +from urllib.parse import urlparse DEBUG = False @@ -271,7 +264,7 @@ class SuffixImporter(object): sys.path.append(cls.trigger_url()) def __init__(self, path_entry): - pr = url_parse(str(path_entry)) + pr = urlparse(str(path_entry)) if pr.scheme != self.scheme or pr.path != self.suffix: raise ImportError() self.path_entry = path_entry |