Repository: DMTF/python-redfish-library

Issue:
Remove old library dependency - urlparse2
urlparse2 is an unmaintained library - last commit is 6 years old.
The library is not python3 compatible (at least it's dependecy - recordtype library).

HP's fork of python-redfish-library dropped urlparse2 last year...
https://github.com/HewlettPackard/python-ilorest-library/issues/28

Please, remove this dependency and use built-in functions to parse URL.
Thanks.

Discussion:

Patch:
diff --git a/requirements.txt b/requirements.txt
index 060d85f..fba487f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-jsonpatch
+jsonpatch<=1.24 ; python_version == '3.4'
+jsonpatch ; python_version >= '3.5' or python_version == '2.7'
 jsonpath_rw
 jsonpointer
-urlparse2
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 344e597..c5ea3b7 100644
--- a/setup.py
+++ b/setup.py
@@ -24,8 +24,14 @@ setup(name='redfish',
       packages=find_packages('src'),
       package_dir={'': 'src'},
       install_requires=[
-          'jsonpatch',
           'jsonpath_rw',
           'jsonpointer',
-          'urlparse2',
-      ])
+      ],
+      extras_require={
+          ':python_version == "3.4"': [
+              'jsonpatch<=1.24'
+          ],
+          ':python_version >= "3.5" or python_version == "2.7"': [
+              'jsonpatch'
+          ]
+      })
diff --git a/src/redfish/ris/rmc_helper.py b/src/redfish/ris/rmc_helper.py
index e633a49..da402ab 100644
--- a/src/redfish/ris/rmc_helper.py
+++ b/src/redfish/ris/rmc_helper.py
@@ -1,5 +1,5 @@
 # Copyright Notice:
-# Copyright 2016-2019 DMTF. All rights reserved.
+# Copyright 2016-2020 DMTF. All rights reserved.
 # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md
 
 # -*- coding: utf-8 -*-
@@ -12,9 +12,10 @@ import json
 import errno
 import logging
 import hashlib
-import urlparse2
 import redfish.rest
 
+from six.moves.urllib.parse import urlparse
+
 from .ris import (RisMonolith)
 from .sharedtypes import (JSONEncoder)
 from .config import (AutoConfigParser)
@@ -146,7 +147,7 @@ class RmcClient(object):
 
     def get_cache_dirname(self):
         """The rest client's current base URL converted to path"""
-        parts = urlparse2.urlparse(self.get_base_url())
+        parts = urlparse(self.get_base_url())
         pathstr = '%s/%s' % (parts.netloc, parts.path)
         return pathstr.replace('//', '/')
 
diff --git a/tox.ini b/tox.ini
index 986f141..b1b8a84 100644
--- a/tox.ini
+++ b/tox.ini
@@ -14,6 +14,14 @@ commands =
     --with-timer \
     --with-coverage --cover-erase --cover-package=src
 
+[testenv:py27]
+deps =
+    coverage
+    fixtures
+    mock
+    nose
+    nose-timer
+
 [testenv:pep8]
 basepython = python3.6
 deps = flake8


Test patch:
diff --git a/tests/ris/test_rmc_helper.py b/tests/ris/test_rmc_helper.py
new file mode 100644
index 0000000..dbf4a29
--- /dev/null
+++ b/tests/ris/test_rmc_helper.py
@@ -0,0 +1,29 @@
+# Copyright Notice:
+# Copyright 2020 DMTF. All rights reserved.
+# License: BSD 3-Clause License. For full text see link:
+#     https://github.com/DMTF/Redfish-Protocol-Validator/blob/master/LICENSE.md
+
+import unittest
+try:
+    from unittest import mock
+except ImportError:
+    import mock
+
+from redfish.ris import rmc_helper
+
+
+class RmcHelper(unittest.TestCase):
+    def setUp(self):
+        super(RmcHelper, self).setUp()
+
+    @mock.patch('redfish.rest.v1.HttpClient')
+    def test_get_cache_dirname(self, mock_http_client):
+        url = 'http://example.com'
+        helper = rmc_helper.RmcClient(url=url, username='oper', password='xyz')
+        mock_http_client.return_value.get_base_url.return_value = url
+        dir_name = helper.get_cache_dirname()
+        self.assertEqual(dir_name, 'example.com/')
+
+
+if __name__ == '__main__':
+    unittest.main()