Skip to content
This repository was archived by the owner on Dec 27, 2018. It is now read-only.

Commit 7390863

Browse files
committed
Merge pull request #16 from ytjohn/py2to3
made python3 compliant
2 parents 62c95b8 + ffe1104 commit 7390863

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

PythonConfluenceAPI/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
__author__ = 'Robert Cope', 'Pushrod Technology'
1+
from __future__ import absolute_import
2+
from __future__ import division
3+
from __future__ import print_function
4+
from __future__ import unicode_literals
25

3-
from api import ConfluenceAPI, all_of
4-
from cfapi import ConfluenceFuturesAPI
6+
from future import standard_library
7+
standard_library.install_aliases()
8+
9+
__author__ = 'Robert Cope, Pushrod Technology'
10+
11+
from .api import ConfluenceAPI, all_of
12+
from .cfapi import ConfluenceFuturesAPI

PythonConfluenceAPI/api.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
from __future__ import absolute_import
2+
import future.standard_library
3+
future.standard_library.install_aliases()
4+
15
__author__ = "Robert Cope"
26

37
import sys
48
import requests
59
from requests.auth import HTTPBasicAuth
6-
from urlparse import urljoin
10+
from urllib.parse import urljoin
11+
712
import logging
813
try:
914
import anyjson as json
@@ -31,7 +36,7 @@ def all_of(api_call, *args, **kwargs):
3136
:param kwargs: Keyword arguments of the call.
3237
"""
3338
kwargs = kwargs.copy()
34-
pos, outer_limit = 0, kwargs.get('limit', 0) or sys.maxint
39+
pos, outer_limit = 0, kwargs.get('limit', 0) or sys.maxsize
3540
while True:
3641
response = api_call(*args, **kwargs)
3742
for item in response.get('results', []):
@@ -805,9 +810,9 @@ def create_new_attachment_by_content_id(self, content_id, attachments, callback=
805810
or the results of the callback. Will raise requests.HTTPError on bad input, potentially.
806811
"""
807812
if isinstance(attachments, list):
808-
assert all(isinstance(at, dict) and "file" in at.keys() for at in attachments)
813+
assert all(isinstance(at, dict) and "file" in list(at.keys()) for at in attachments)
809814
elif isinstance(attachments, dict):
810-
assert "file" in attachments.keys()
815+
assert "file" in list(attachments.keys())
811816
else:
812817
assert False
813818
return self._service_post_request("rest/api/content/{id}/child/attachment".format(id=content_id),
@@ -1034,7 +1039,7 @@ def update_attachment(self, content_id, attachment_id, attachment, callback=None
10341039
or the results of the callback. Will raise requests.HTTPError on bad input, potentially.
10351040
"""
10361041
if isinstance(attachment, dict):
1037-
assert "file" in attachment.keys()
1042+
assert "file" in list(attachment.keys())
10381043
else:
10391044
assert False
10401045
return self._service_post_request("rest/api/content/{content_id}/child/attachment/{attachment_id}/data"

PythonConfluenceAPI/cfapi.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
from __future__ import absolute_import
2+
import future.standard_library
3+
future.standard_library.install_aliases()
4+
15
__author__ = 'Robert Cope'
26

37
from requests.auth import HTTPBasicAuth
4-
from api import ConfluenceAPI, api_logger, json
8+
from .api import ConfluenceAPI, api_logger, json
59
from requests_futures.sessions import FuturesSession
6-
from urlparse import urljoin
10+
from urllib.parse import urljoin
711

812

913
# By default requests-futures request method returns the response object instead of the results of the callback;
@@ -97,4 +101,4 @@ def base_callback(_, response):
97101
response.raise_for_status()
98102
return response.content if raw else json.loads(response.text)
99103
response_future = self.session.request(request_type, uri, background_callback=base_callback, **kwargs)
100-
return response_future
104+
return response_future

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# on e.g. Ubuntu 14.04 LTS
33

44
anyjson>=0.3.3,<1
5+
future>=0.15.2
56
futures>=3.0.3,<4
67
requests[security]>=2.3.0,<3
78
requests-futures>=0.9.5,<1

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
__author__ = 'Robert Cope', 'Pushrod Technology'
1+
__author__ = 'Robert Cope, Pushrod Technology'
22
__author_email__ = '[email protected]'
3-
__version__ = '0.0.1rc4'
3+
__version__ = '0.0.1rc6'
44

55
import ez_setup
66
ez_setup.use_setuptools()

0 commit comments

Comments
 (0)