from distutils.version import StrictVersion
from requests.adapters import HTTPAdapter
try:
    from requests.packages.urllib3.poolmanager import PoolManager
except ImportError:
    import urllib3
    from urllib3.poolmanager import PoolManager


class SSLAdapter(HTTPAdapter):
    '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
    def __init__(self, ssl_version=None, **kwargs):
        self.ssl_version = ssl_version
        super(SSLAdapter, self).__init__(**kwargs)

    def init_poolmanager(self, connections, maxsize, block=False):
        urllib_ver = urllib3.__version__
        if urllib3 and StrictVersion(urllib_ver) <= StrictVersion('1.5'):
            self.poolmanager = PoolManager(num_pools=connections,
                                           maxsize=maxsize,
                                           block=block)
        else:
            self.poolmanager = PoolManager(num_pools=connections,
                                           maxsize=maxsize,
                                           block=block,
                                           ssl_version=self.ssl_version)

from distutils.version import StrictVersion
from requests.adapters import HTTPAdapter
try:
    import requests.packages.urllib3 as urllib3
except ImportError:
    import urllib3


PoolManager = urllib3.poolmanager.PoolManager


class SSLAdapter(HTTPAdapter):
    '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
    def __init__(self, ssl_version=None, **kwargs):
        self.ssl_version = ssl_version
        super(SSLAdapter, self).__init__(**kwargs)

    def init_poolmanager(self, connections, maxsize, block=False):
        urllib_ver = urllib3.__version__.split('-')[0]
        if urllib3 and urllib_ver != 'dev' and \
           StrictVersion(urllib_ver) <= StrictVersion('1.5'):
            self.poolmanager = PoolManager(num_pools=connections,
                                           maxsize=maxsize,
                                           block=block)
        else:
            self.poolmanager = PoolManager(num_pools=connections,
                                           maxsize=maxsize,
                                           block=block,
                                           ssl_version=self.ssl_version)

Fix some urllib3 import issues
Fix some urllib3 import issues

  from distutils.version import StrictVersion
  from requests.adapters import HTTPAdapter
  try:
-     from requests.packages.urllib3.poolmanager import PoolManager
+     import requests.packages.urllib3 as urllib3
  except ImportError:
      import urllib3
-     from urllib3.poolmanager import PoolManager
+ 
+ 
+ PoolManager = urllib3.poolmanager.PoolManager
  
  
  class SSLAdapter(HTTPAdapter):
      '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
      def __init__(self, ssl_version=None, **kwargs):
          self.ssl_version = ssl_version
          super(SSLAdapter, self).__init__(**kwargs)
  
      def init_poolmanager(self, connections, maxsize, block=False):
-         urllib_ver = urllib3.__version__
+         urllib_ver = urllib3.__version__.split('-')[0]
+         if urllib3 and urllib_ver != 'dev' and \
-         if urllib3 and StrictVersion(urllib_ver) <= StrictVersion('1.5'):
+            StrictVersion(urllib_ver) <= StrictVersion('1.5'):
              self.poolmanager = PoolManager(num_pools=connections,
                                             maxsize=maxsize,
                                             block=block)
          else:
              self.poolmanager = PoolManager(num_pools=connections,
                                             maxsize=maxsize,
                                             block=block,
                                             ssl_version=self.ssl_version)
  
Fix some urllib3 import issues
## Code Before:
from distutils.version import StrictVersion
from requests.adapters import HTTPAdapter
try:
    from requests.packages.urllib3.poolmanager import PoolManager
except ImportError:
    import urllib3
    from urllib3.poolmanager import PoolManager


class SSLAdapter(HTTPAdapter):
    '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
    def __init__(self, ssl_version=None, **kwargs):
        self.ssl_version = ssl_version
        super(SSLAdapter, self).__init__(**kwargs)

    def init_poolmanager(self, connections, maxsize, block=False):
        urllib_ver = urllib3.__version__
        if urllib3 and StrictVersion(urllib_ver) <= StrictVersion('1.5'):
            self.poolmanager = PoolManager(num_pools=connections,
                                           maxsize=maxsize,
                                           block=block)
        else:
            self.poolmanager = PoolManager(num_pools=connections,
                                           maxsize=maxsize,
                                           block=block,
                                           ssl_version=self.ssl_version)

## Instruction:
Fix some urllib3 import issues
## Code After:
from distutils.version import StrictVersion
from requests.adapters import HTTPAdapter
try:
    import requests.packages.urllib3 as urllib3
except ImportError:
    import urllib3


PoolManager = urllib3.poolmanager.PoolManager


class SSLAdapter(HTTPAdapter):
    '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
    def __init__(self, ssl_version=None, **kwargs):
        self.ssl_version = ssl_version
        super(SSLAdapter, self).__init__(**kwargs)

    def init_poolmanager(self, connections, maxsize, block=False):
        urllib_ver = urllib3.__version__.split('-')[0]
        if urllib3 and urllib_ver != 'dev' and \
           StrictVersion(urllib_ver) <= StrictVersion('1.5'):
            self.poolmanager = PoolManager(num_pools=connections,
                                           maxsize=maxsize,
                                           block=block)
        else:
            self.poolmanager = PoolManager(num_pools=connections,
                                           maxsize=maxsize,
                                           block=block,
                                           ssl_version=self.ssl_version)
