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

made python3 compliant #16

Merged
merged 1 commit into from
Mar 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions PythonConfluenceAPI/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
__author__ = 'Robert Cope', 'Pushrod Technology'
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from api import ConfluenceAPI, all_of
from cfapi import ConfluenceFuturesAPI
from future import standard_library
standard_library.install_aliases()

__author__ = 'Robert Cope, Pushrod Technology'

from .api import ConfluenceAPI, all_of
from .cfapi import ConfluenceFuturesAPI
15 changes: 10 additions & 5 deletions PythonConfluenceAPI/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from __future__ import absolute_import
import future.standard_library
future.standard_library.install_aliases()

__author__ = "Robert Cope"

import sys
import requests
from requests.auth import HTTPBasicAuth
from urlparse import urljoin
from urllib.parse import urljoin

import logging
try:
import anyjson as json
Expand Down Expand Up @@ -31,7 +36,7 @@ def all_of(api_call, *args, **kwargs):
:param kwargs: Keyword arguments of the call.
"""
kwargs = kwargs.copy()
pos, outer_limit = 0, kwargs.get('limit', 0) or sys.maxint
pos, outer_limit = 0, kwargs.get('limit', 0) or sys.maxsize
while True:
response = api_call(*args, **kwargs)
for item in response.get('results', []):
Expand Down Expand Up @@ -805,9 +810,9 @@ def create_new_attachment_by_content_id(self, content_id, attachments, callback=
or the results of the callback. Will raise requests.HTTPError on bad input, potentially.
"""
if isinstance(attachments, list):
assert all(isinstance(at, dict) and "file" in at.keys() for at in attachments)
assert all(isinstance(at, dict) and "file" in list(at.keys()) for at in attachments)
elif isinstance(attachments, dict):
assert "file" in attachments.keys()
assert "file" in list(attachments.keys())
else:
assert False
return self._service_post_request("rest/api/content/{id}/child/attachment".format(id=content_id),
Expand Down Expand Up @@ -1034,7 +1039,7 @@ def update_attachment(self, content_id, attachment_id, attachment, callback=None
or the results of the callback. Will raise requests.HTTPError on bad input, potentially.
"""
if isinstance(attachment, dict):
assert "file" in attachment.keys()
assert "file" in list(attachment.keys())
else:
assert False
return self._service_post_request("rest/api/content/{content_id}/child/attachment/{attachment_id}/data"
Expand Down
10 changes: 7 additions & 3 deletions PythonConfluenceAPI/cfapi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from __future__ import absolute_import
import future.standard_library
future.standard_library.install_aliases()

__author__ = 'Robert Cope'

from requests.auth import HTTPBasicAuth
from api import ConfluenceAPI, api_logger, json
from .api import ConfluenceAPI, api_logger, json
from requests_futures.sessions import FuturesSession
from urlparse import urljoin
from urllib.parse import urljoin


# By default requests-futures request method returns the response object instead of the results of the callback;
Expand Down Expand Up @@ -97,4 +101,4 @@ def base_callback(_, response):
response.raise_for_status()
return response.content if raw else json.loads(response.text)
response_future = self.session.request(request_type, uri, background_callback=base_callback, **kwargs)
return response_future
return response_future
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# on e.g. Ubuntu 14.04 LTS

anyjson>=0.3.3,<1
future>=0.15.2
futures>=3.0.3,<4
requests[security]>=2.3.0,<3
requests-futures>=0.9.5,<1
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = 'Robert Cope', 'Pushrod Technology'
__author__ = 'Robert Cope, Pushrod Technology'
__author_email__ = '[email protected]'
__version__ = '0.0.1rc4'
__version__ = '0.0.1rc6'

import ez_setup
ez_setup.use_setuptools()
Expand Down