Skip to content

Commit 7152a52

Browse files
authored
Merge pull request #651 from zancas/py3_compat_stage1
Stage1 Python3 compatibility
2 parents a33645e + 842a088 commit 7152a52

16 files changed

Lines changed: 38 additions & 12 deletions

File tree

devtools/code_generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import absolute_import
12
# Copyright 2016 F5 Networks Inc.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,8 +14,8 @@
1314
# limitations under the License.
1415
#
1516

16-
from source_engine import SourceEngine
17-
from template_engine import TemplateEngine
17+
from f5.devtools.source_engine import SourceEngine
18+
from f5.devtools.template_engine import TemplateEngine
1819

1920
import os
2021

devtools/crawler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import absolute_import
12
# Copyright 2016 F5 Networks Inc.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +14,7 @@
1314
# limitations under the License.
1415
#
1516

16-
from code_generator import DEVICECONFDIR
17+
from f5.devtools.code_generator import DEVICECONFDIR
1718

1819
import json
1920
import os

devtools/source_engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#
1515

1616
'''Source engine container, combines code on filesystem with other sources.'''
17+
from __future__ import print_function
1718

1819
LICENSE_AND_MODULE_DOCSTRING = """# Copyright 2016 F5 Networks Inc.
1920
#

devtools/template_engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Copyright 2016 F5 Networks Inc.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");

f5/bigip/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919

2020
from icontrol.session import iControlRESTSession
21-
from urlparse import parse_qs
22-
from urlparse import urlparse
23-
21+
try:
22+
import urlparse
23+
except ImportError:
24+
import urllib.parse as urlparse
2425

2526
from f5.bigip.cm import Cm
2627
from f5.bigip.resource import PathElement
@@ -80,7 +81,8 @@ def _get_tmos_version(self):
8081
base_uri = self._meta_data['uri'] + 'tm/sys/'
8182
response = connect.get(base_uri)
8283
ver = response.json()
83-
version = parse_qs(urlparse(ver['selfLink']).query)['ver'][0]
84+
version = urlparse.parse_qs(
85+
urlparse.urlparse(ver['selfLink']).query)['ver'][0]
8486
self._meta_data['tmos_version'] = version
8587

8688

f5/bigip/cm/autodeploy/test/test_software_image_uploads.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Copyright 2016 F5 Networks Inc.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");

f5/bigip/resource.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@
9191
import keyword
9292
import re
9393
import tokenize
94-
import urlparse
94+
try:
95+
import urlparse
96+
except ImportError:
97+
from urllib import parse as urlparse
9598

9699
from f5.bigip.mixins import LazyAttributeMixin
97100
from f5.bigip.mixins import ToDictMixin

f5/bigip/shared/file_transfer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
#
1818

1919
import os
20-
from StringIO import StringIO
20+
try:
21+
from StringIO import StringIO
22+
except ImportError:
23+
from io import StringIO
2124

2225
from f5.bigip.mixins import FileUploadMixin
2326
from f5.bigip.resource import PathElement

f5/bigip/shared/test/test_file_uploads.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Copyright 2016 F5 Networks Inc.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +16,10 @@
1516

1617
import mock
1718
import pytest
18-
from StringIO import StringIO
19+
try:
20+
from StringIO import StringIO
21+
except ImportError:
22+
from io import StringIO
1923

2024
from f5.bigip import ManagementRoot
2125
from f5.bigip.shared.file_transfer import\

f5/bigip/test/test___init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
import mock
1616
import pytest
17-
import urlparse
17+
try:
18+
import urlparse
19+
except ImportError:
20+
from urllib import parse as urlparse
1821

1922
from f5.bigip import BigIP
2023

0 commit comments

Comments
 (0)