Use six.moves to import urlparse to be python3 compatible
Includes a small amount of pylint fixes.
Should have no functional change.
Bug: 1003186
Change-Id: I72f05e39afc4a6ef8dd0af953da7dd612d754daa
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-py/+/1853004
Commit-Queue: Marc-Antoine Ruel <maruel@chromium.org>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
NOKEYCHECK=True
GitOrigin-RevId: c8d08ddb0f999e0e04c71533de5ee8ae333bfe1e
diff --git a/streamname.py b/streamname.py
index de5a284..bee5388 100644
--- a/streamname.py
+++ b/streamname.py
@@ -5,9 +5,10 @@
import collections
import re
import string
-import types
-import urllib
-import urlparse
+
+# third_party/
+from six.moves import urllib
+
_ALNUM_CHARS = string.ascii_letters + string.digits
_SEGMENT_RE_BASE = r'[a-zA-Z0-9][a-zA-Z0-9:_\-.]*'
@@ -64,7 +65,7 @@
Raises:
ValueError: If normalization could not be successfully performed.
"""
- if len(v) == 0:
+ if not v:
if not prefix:
raise ValueError('Cannot normalize empty name with no prefix.')
v = prefix
@@ -179,12 +180,12 @@
stream_paths: A set of StreamPath instances for the stream paths to
generate the URL for.
"""
- return urlparse.urlunparse((
- 'https', # Scheme
- host, # netloc
- 'v/', # path
- '', # params
- '&'.join(('s=%s' % (urllib.quote('%s/%s' % (project, path), safe=''))
- for path in stream_paths)), # query
- '', # fragment
+ return urllib.parse.urlunparse((
+ 'https', # Scheme
+ host, # netloc
+ 'v/', # path
+ '', # params
+ '&'.join(('s=%s' % (urllib.parse.quote('%s/%s' % (project, path), ''))
+ for path in stream_paths)), # query
+ '', # fragment
))
diff --git a/tests/bootstrap_test.py b/tests/bootstrap_test.py
index a55e160..2ed5553 100755
--- a/tests/bootstrap_test.py
+++ b/tests/bootstrap_test.py
@@ -12,6 +12,10 @@
os.pardir, os.pardir, os.pardir)))
sys.path.insert(0, ROOT_DIR)
+# pylint: disable=no-name-in-module
+from utils import tools
+tools.force_local_third_party(ROOT_DIR)
+
from libs.logdog import bootstrap, stream
diff --git a/tests/stream_test.py b/tests/stream_test.py
index 008379f..b7f98bf 100755
--- a/tests/stream_test.py
+++ b/tests/stream_test.py
@@ -14,6 +14,10 @@
os.pardir, os.pardir, os.pardir)))
sys.path.insert(0, ROOT_DIR)
+# pylint: disable=no-name-in-module
+from utils import tools
+tools.force_local_third_party(ROOT_DIR)
+
from libs.logdog import stream, streamname, varint
diff --git a/tests/streamname_test.py b/tests/streamname_test.py
index 25adfb6..99f0323 100755
--- a/tests/streamname_test.py
+++ b/tests/streamname_test.py
@@ -13,6 +13,10 @@
os.pardir, os.pardir, os.pardir)))
sys.path.insert(0, ROOT_DIR)
+# pylint: disable=no-name-in-module
+from utils import tools
+tools.force_local_third_party(ROOT_DIR)
+
from libs.logdog import streamname