diff --git a/CHANGELOG.md b/CHANGELOG.md index ba3a2218..b865d34b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## [0.5.1] - 2017-08-02 +### General +- Moved documentation to [Read the Docs](http://canvasapi.readthedocs.io). + +### Bugfixes + +- Fixed an issue where kwargs in Python 2.7 wouldn't be properly formatted when converted to get parameters. + ## [0.5.0] - 2017-07-10 ### New Endpoint Coverage @@ -99,6 +107,8 @@ - Fixed some incorrectly defined parameters - Fixed an issue where tests would fail due to an improperly configured requires block +[0.5.1]: https://github.com/ucfopen/canvasapi/compare/v0.5.0...v0.5.1 +[0.5.0]: https://github.com/ucfopen/canvasapi/compare/v0.4.0...v0.5.0 [0.4.0]: https://github.com/ucfopen/canvasapi/compare/v0.3.0...v0.4.0 [0.3.0]: https://github.com/ucfopen/canvasapi/compare/v0.2.0...v0.3.0 [0.2.0]: https://github.com/ucfopen/canvasapi/compare/v0.1.2...v0.2.0 diff --git a/canvasapi/__init__.py b/canvasapi/__init__.py index fd2bebb1..fd07b624 100644 --- a/canvasapi/__init__.py +++ b/canvasapi/__init__.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals from canvasapi.canvas import Canvas __all__ = ["Canvas"] -__version__ = '0.5.0' +__version__ = '0.5.1' diff --git a/canvasapi/account.py b/canvasapi/account.py index 019a943c..8e492dc4 100644 --- a/canvasapi/account.py +++ b/canvasapi/account.py @@ -1,6 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.exceptions import RequiredFieldMissing @@ -8,6 +8,7 @@ from canvasapi.util import combine_kwargs, obj_or_id +@python_2_unicode_compatible class Account(CanvasObject): def __str__(self): @@ -920,25 +921,29 @@ def update_account_auth_settings(self, **kwargs): return SSOSettings(self._requester, response.json()) +@python_2_unicode_compatible class AccountNotification(CanvasObject): def __str__(self): # pragma: no cover - return str(self.subject) + return "{}".format(self.subject) +@python_2_unicode_compatible class AccountReport(CanvasObject): def __str__(self): # pragma: no cover return "{} ({})".format(self.report, self.id) +@python_2_unicode_compatible class Role(CanvasObject): def __str__(self): # pragma: no cover return "{} ({})".format(self.label, self.base_role_type) +@python_2_unicode_compatible class SSOSettings(CanvasObject): - def __str___(self): # pragma: no cover + def __str__(self): # pragma: no cover return"{} ({})".format(self.login_handle_name, self.change_password_url) diff --git a/canvasapi/appointment_group.py b/canvasapi/appointment_group.py index 84ef2236..5b5049b5 100644 --- a/canvasapi/appointment_group.py +++ b/canvasapi/appointment_group.py @@ -1,12 +1,18 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.exceptions import RequiredFieldMissing from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class AppointmentGroup(CanvasObject): + def __str__(self): + return "{} ({})".format(self.title, self.id) + def delete(self, **kwargs): """ Delete this appointment group. @@ -49,6 +55,3 @@ def edit(self, appointment_group, **kwargs): super(AppointmentGroup, self).set_attributes(response.json()) return AppointmentGroup(self._requester, response.json()) - - def __str__(self): - return "{} ({})".format(self.title, self.id) diff --git a/canvasapi/assignment.py b/canvasapi/assignment.py index 79152a32..e6528c4d 100644 --- a/canvasapi/assignment.py +++ b/canvasapi/assignment.py @@ -1,9 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Assignment(CanvasObject): def __str__(self): @@ -45,6 +48,7 @@ def edit(self, **kwargs): return Assignment(self._requester, response.json()) +@python_2_unicode_compatible class AssignmentGroup(CanvasObject): def __str__(self): diff --git a/canvasapi/authentication_provider.py b/canvasapi/authentication_provider.py index dec3b33c..7c888e03 100644 --- a/canvasapi/authentication_provider.py +++ b/canvasapi/authentication_provider.py @@ -1,9 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class AuthenticationProvider(CanvasObject): def __str__(self): # pragma: no cover diff --git a/canvasapi/avatar.py b/canvasapi/avatar.py index 315f42b8..653951cf 100644 --- a/canvasapi/avatar.py +++ b/canvasapi/avatar.py @@ -1,11 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class Avatar(CanvasObject): def __str__(self): # pragma: no cover - return str(self.display_name) + return "{}".format(self.display_name) diff --git a/canvasapi/bookmark.py b/canvasapi/bookmark.py index 98b481fe..2ccee5fe 100644 --- a/canvasapi/bookmark.py +++ b/canvasapi/bookmark.py @@ -1,11 +1,17 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Bookmark(CanvasObject): + def __str__(self): + return "{} ({})".format(self.name, self.id) + def delete(self): """ Delete this bookmark. @@ -40,6 +46,3 @@ def edit(self, **kwargs): super(Bookmark, self).set_attributes(response.json()) return Bookmark(self._requester, response.json()) - - def __str__(self): - return "{} ({})".format(self.name, self.id) diff --git a/canvasapi/calendar_event.py b/canvasapi/calendar_event.py index 1b811c5f..aebc450d 100644 --- a/canvasapi/calendar_event.py +++ b/canvasapi/calendar_event.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs @@ -6,6 +6,9 @@ class CalendarEvent(CanvasObject): + def __str__(self): + return "{} ({})".format(self.title, self.id) + def delete(self, **kwargs): """ Delete this calendar event. @@ -41,6 +44,3 @@ def edit(self, **kwargs): super(CalendarEvent, self).set_attributes(response.json()) return CalendarEvent(self._requester, response.json()) - - def __str__(self): - return "{} ({})".format(self.title, self.id) diff --git a/canvasapi/canvas.py b/canvasapi/canvas.py index c7d2778f..c295820c 100644 --- a/canvasapi/canvas.py +++ b/canvasapi/canvas.py @@ -1,6 +1,4 @@ -from __future__ import unicode_literals - -from builtins import object +from __future__ import absolute_import, division, print_function, unicode_literals from canvasapi.account import Account from canvasapi.course import Course diff --git a/canvasapi/canvas_object.py b/canvasapi/canvas_object.py index 46b56d9a..59908440 100644 --- a/canvasapi/canvas_object.py +++ b/canvasapi/canvas_object.py @@ -1,9 +1,9 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals from datetime import datetime import json import re -from builtins import str, object +from six import text_type DATE_PATTERN = re.compile('[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z') @@ -68,6 +68,6 @@ def set_attributes(self, attributes): self.__setattr__(attribute, value) # datetime field - if DATE_PATTERN.match(str(value)): + if DATE_PATTERN.match(text_type(value)): date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ') self.__setattr__(attribute + '_date', date) diff --git a/canvasapi/communication_channel.py b/canvasapi/communication_channel.py index 2e4ccd5a..e8edc0af 100644 --- a/canvasapi/communication_channel.py +++ b/canvasapi/communication_channel.py @@ -1,9 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.notification_preference import NotificationPreference +@python_2_unicode_compatible class CommunicationChannel(CanvasObject): def __str__(self): diff --git a/canvasapi/conversation.py b/canvasapi/conversation.py index 52c433b3..28269a28 100644 --- a/canvasapi/conversation.py +++ b/canvasapi/conversation.py @@ -1,9 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Conversation(CanvasObject): def __str__(self): diff --git a/canvasapi/course.py b/canvasapi/course.py index 296c8d79..214895f5 100644 --- a/canvasapi/course.py +++ b/canvasapi/course.py @@ -1,4 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.discussion_topic import DiscussionTopic @@ -13,6 +15,7 @@ from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Course(CanvasObject): def __str__(self): @@ -1409,6 +1412,7 @@ def update_tab(self, tab_id, **kwargs): return Tab(self._requester, response.json()) +@python_2_unicode_compatible class CourseNickname(CanvasObject): def __str__(self): diff --git a/canvasapi/discussion_topic.py b/canvasapi/discussion_topic.py index 19fdf5ad..58fc7381 100644 --- a/canvasapi/discussion_topic.py +++ b/canvasapi/discussion_topic.py @@ -1,10 +1,13 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.paginated_list import PaginatedList from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class DiscussionTopic(CanvasObject): def __str__(self): return "{} ({})".format(self.title, self.id) diff --git a/canvasapi/enrollment.py b/canvasapi/enrollment.py index 7cda3fae..6a5ac00e 100644 --- a/canvasapi/enrollment.py +++ b/canvasapi/enrollment.py @@ -1,8 +1,11 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class Enrollment(CanvasObject): def __str__(self): diff --git a/canvasapi/enrollment_term.py b/canvasapi/enrollment_term.py index 77107448..eac5607d 100644 --- a/canvasapi/enrollment_term.py +++ b/canvasapi/enrollment_term.py @@ -1,11 +1,17 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class EnrollmentTerm(CanvasObject): + def __str__(self): + return "{} ({})".format(self.name, self.id) + def delete(self): """ Delete this Enrollment Term. @@ -37,6 +43,3 @@ def edit(self, **kwargs): ) return EnrollmentTerm(self._requester, response.json()) - - def __str__(self): - return "{} ({})".format(self.name, self.id) diff --git a/canvasapi/exceptions.py b/canvasapi/exceptions.py index 3887c75a..20f6b820 100644 --- a/canvasapi/exceptions.py +++ b/canvasapi/exceptions.py @@ -1,8 +1,9 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import python_2_unicode_compatible, text_type +@python_2_unicode_compatible class CanvasException(Exception): # pragma: no cover """ Base class for all errors returned by the Canvas API. @@ -13,14 +14,14 @@ def __init__(self, message): errors = message.get('errors', False) if errors: - self.message = str(errors) + self.message = errors else: self.message = ('Something went wrong. ', message) else: self.message = message def __str__(self): - return self.message + return text_type(self.message) class BadRequest(CanvasException): diff --git a/canvasapi/external_feed.py b/canvasapi/external_feed.py index e2307d7d..c46a049b 100644 --- a/canvasapi/external_feed.py +++ b/canvasapi/external_feed.py @@ -1,11 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class ExternalFeed(CanvasObject): def __str__(self): - return str(self.display_name) + return "{}".format(self.display_name) diff --git a/canvasapi/external_tool.py b/canvasapi/external_tool.py index 4c61bc14..745e66c1 100644 --- a/canvasapi/external_tool.py +++ b/canvasapi/external_tool.py @@ -1,10 +1,13 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.exceptions import CanvasException from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class ExternalTool(CanvasObject): def __str__(self): diff --git a/canvasapi/file.py b/canvasapi/file.py index 0a9d7cca..cf606f06 100644 --- a/canvasapi/file.py +++ b/canvasapi/file.py @@ -1,14 +1,15 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class File(CanvasObject): def __str__(self): - return str(self.display_name) + return "{}".format(self.display_name) def delete(self): """ diff --git a/canvasapi/folder.py b/canvasapi/folder.py index 0baea1f3..4405dc96 100644 --- a/canvasapi/folder.py +++ b/canvasapi/folder.py @@ -1,16 +1,17 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.paginated_list import PaginatedList from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Folder(CanvasObject): def __str__(self): - return str(self.full_name) + return "{}".format(self.full_name) def list_files(self, **kwargs): """ diff --git a/canvasapi/group.py b/canvasapi/group.py index 1d62f839..bb3fa6a7 100644 --- a/canvasapi/group.py +++ b/canvasapi/group.py @@ -1,4 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.discussion_topic import DiscussionTopic @@ -9,6 +11,7 @@ from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Group(CanvasObject): def __str__(self): @@ -636,6 +639,7 @@ def list_tabs(self, **kwargs): ) +@python_2_unicode_compatible class GroupMembership(CanvasObject): def __str__(self): @@ -698,6 +702,7 @@ def remove_self(self): return response.json() +@python_2_unicode_compatible class GroupCategory(CanvasObject): def __str__(self): diff --git a/canvasapi/login.py b/canvasapi/login.py index 955b4c50..47f82d36 100644 --- a/canvasapi/login.py +++ b/canvasapi/login.py @@ -1,9 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Login(CanvasObject): def __str__(self): diff --git a/canvasapi/module.py b/canvasapi/module.py index 60a289ca..c771f830 100644 --- a/canvasapi/module.py +++ b/canvasapi/module.py @@ -1,4 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.exceptions import RequiredFieldMissing @@ -6,6 +8,7 @@ from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Module(CanvasObject): def __str__(self): @@ -139,6 +142,7 @@ def create_module_item(self, module_item, **kwargs): return ModuleItem(self._requester, module_item_json) +@python_2_unicode_compatible class ModuleItem(CanvasObject): def __str__(self): diff --git a/canvasapi/notification_preference.py b/canvasapi/notification_preference.py index 5983e7f6..177e4ff7 100644 --- a/canvasapi/notification_preference.py +++ b/canvasapi/notification_preference.py @@ -1,8 +1,11 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class NotificationPreference(CanvasObject): def __str__(self): diff --git a/canvasapi/page.py b/canvasapi/page.py index fd6c26f3..857e6b68 100644 --- a/canvasapi/page.py +++ b/canvasapi/page.py @@ -1,10 +1,13 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs from canvasapi.paginated_list import PaginatedList +@python_2_unicode_compatible class Page(CanvasObject): def __str__(self): @@ -188,6 +191,7 @@ def revert_to_revision(self, revision_id): return PageRevision(self._requester, pagerev_json) +@python_2_unicode_compatible class PageRevision(CanvasObject): def __str__(self): diff --git a/canvasapi/page_view.py b/canvasapi/page_view.py index f5848135..6ee8e437 100644 --- a/canvasapi/page_view.py +++ b/canvasapi/page_view.py @@ -1,8 +1,11 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class PageView(CanvasObject): def __str__(self): diff --git a/canvasapi/paginated_list.py b/canvasapi/paginated_list.py index fec05e15..430bbd60 100644 --- a/canvasapi/paginated_list.py +++ b/canvasapi/paginated_list.py @@ -1,8 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import re -from builtins import object - class PaginatedList(object): """ diff --git a/canvasapi/progress.py b/canvasapi/progress.py index 962951aa..82af0fda 100644 --- a/canvasapi/progress.py +++ b/canvasapi/progress.py @@ -1,8 +1,11 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class Progress(CanvasObject): def __str__(self): diff --git a/canvasapi/quiz.py b/canvasapi/quiz.py index 04f87449..e56ed93e 100644 --- a/canvasapi/quiz.py +++ b/canvasapi/quiz.py @@ -1,9 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Quiz(CanvasObject): def __str__(self): diff --git a/canvasapi/requester.py b/canvasapi/requester.py index 48ea06ce..620e21f9 100644 --- a/canvasapi/requester.py +++ b/canvasapi/requester.py @@ -1,6 +1,5 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import object import requests from canvasapi.exceptions import ( diff --git a/canvasapi/section.py b/canvasapi/section.py index 19dd63b7..17aba81f 100644 --- a/canvasapi/section.py +++ b/canvasapi/section.py @@ -1,4 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject from canvasapi.exceptions import RequiredFieldMissing @@ -7,6 +9,7 @@ from canvasapi.util import combine_kwargs +@python_2_unicode_compatible class Section(CanvasObject): def __str__(self): diff --git a/canvasapi/submission.py b/canvasapi/submission.py index 391c38be..f1afb73d 100644 --- a/canvasapi/submission.py +++ b/canvasapi/submission.py @@ -1,11 +1,12 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class Submission(CanvasObject): def __str__(self): - return str(self.id) + return "{}".format(self.id) diff --git a/canvasapi/tab.py b/canvasapi/tab.py index 9c22ac40..d345e40d 100644 --- a/canvasapi/tab.py +++ b/canvasapi/tab.py @@ -1,8 +1,11 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals + +from six import python_2_unicode_compatible from canvasapi.canvas_object import CanvasObject +@python_2_unicode_compatible class Tab(CanvasObject): def __str__(self): diff --git a/canvasapi/upload.py b/canvasapi/upload.py index f9b0ae6b..0f808ae9 100644 --- a/canvasapi/upload.py +++ b/canvasapi/upload.py @@ -1,7 +1,7 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import os -from builtins import object, str +from six import string_types from canvasapi.util import combine_kwargs @@ -20,7 +20,7 @@ def __init__(self, requester, url, file, **kwargs): :param file: A file handler or path of the file to upload. :type file: file or str """ - if isinstance(file, str): + if isinstance(file, string_types): if not os.path.exists(file): raise IOError('File ' + file + ' does not exist.') self._using_filename = True diff --git a/canvasapi/user.py b/canvasapi/user.py index 9576c025..43d08719 100644 --- a/canvasapi/user.py +++ b/canvasapi/user.py @@ -1,6 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import python_2_unicode_compatible from canvasapi.bookmark import Bookmark from canvasapi.calendar_event import CalendarEvent @@ -12,6 +12,7 @@ from canvasapi.util import combine_kwargs, obj_or_id +@python_2_unicode_compatible class User(CanvasObject): def __str__(self): @@ -611,7 +612,8 @@ def remove_observee(self, observee_id): return User(self._requester, response.json()) +@python_2_unicode_compatible class UserDisplay(CanvasObject): def __str__(self): - return str(self.display_name) + return "{}".format(self.display_name) diff --git a/canvasapi/util.py b/canvasapi/util.py index f9467c9e..d61280f6 100644 --- a/canvasapi/util.py +++ b/canvasapi/util.py @@ -1,6 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals -from builtins import str +from six import text_type def combine_kwargs(**kwargs): @@ -10,7 +10,7 @@ def combine_kwargs(**kwargs): :rtype: dict """ def flatten_dict(prefix, key, value): - new_prefix = prefix + '[' + str(key) + ']' + new_prefix = prefix + '[' + text_type(key) + ']' if isinstance(value, dict): d = {} for k, v in value.items(): @@ -26,9 +26,9 @@ def flatten_dict(prefix, key, value): if isinstance(arg, dict): # If the argument is a dictionary, flatten it. for key, value in arg.items(): - combined_kwargs.update(flatten_dict(str(kw), key, value)) + combined_kwargs.update(flatten_dict(text_type(kw), key, value)) else: - combined_kwargs.update({str(kw): arg}) + combined_kwargs.update({text_type(kw): arg}) return combined_kwargs diff --git a/dev_requirements.txt b/dev_requirements.txt index df946118..6d0eb712 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,13 +1,13 @@ -r tests_requirements.txt -alabaster==0.7.8 -Babel==2.3.4 -docutils==0.12 -imagesize==0.7.1 -Jinja2==2.8 -MarkupSafe==0.23 -Pygments==2.1.3 -pytz==2016.4 -snowballstemmer==1.2.1 -Sphinx==1.4.4 -sphinx-rtd-theme==0.1.9 +alabaster +Babel +docutils +imagesize +Jinja2 +MarkupSafe +Pygments +pytz +snowballstemmer +Sphinx +sphinx-rtd-theme diff --git a/requirements.txt b/requirements.txt index 1536591e..640e3d44 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ -future==0.16.0 -requests==2.10.0 -six==1.10.0 +requests +six diff --git a/setup.py b/setup.py index 69629b91..1db1015a 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import re from setuptools import setup @@ -23,7 +23,7 @@ license='MIT License', packages=['canvasapi'], include_package_data=True, - install_requires=['requests', 'future'], + install_requires=['requests', 'six'], zip_safe=False, classifiers=[ 'Development Status :: 3 - Alpha', diff --git a/tests/settings.py b/tests/settings.py index 71d0b142..789a25c5 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals BASE_URL = 'http://example.com/api/v1/' API_KEY = '123' diff --git a/tests/test_account.py b/tests/test_account.py index 58796bbe..e62d3fd5 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -1,8 +1,7 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import datetime import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_appointment_group.py b/tests/test_appointment_group.py index 81bf5c82..cb64556e 100644 --- a/tests/test_appointment_group.py +++ b/tests/test_appointment_group.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_assignment.py b/tests/test_assignment.py index f1158d65..b69cf867 100644 --- a/tests/test_assignment.py +++ b/tests/test_assignment.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_authentication_providers.py b/tests/test_authentication_providers.py index 368f313a..f16bfef5 100644 --- a/tests/test_authentication_providers.py +++ b/tests/test_authentication_providers.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_bookmark.py b/tests/test_bookmark.py index e923dfa2..69506058 100644 --- a/tests/test_bookmark.py +++ b/tests/test_bookmark.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_calendar_event.py b/tests/test_calendar_event.py index 0d10c38c..5c5ce8a8 100644 --- a/tests/test_calendar_event.py +++ b/tests/test_calendar_event.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_canvas.py b/tests/test_canvas.py index cb552a81..17cc8759 100644 --- a/tests/test_canvas.py +++ b/tests/test_canvas.py @@ -1,9 +1,9 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest from datetime import datetime -from builtins import str import requests_mock +from six import text_type from canvasapi import Canvas from canvasapi.account import Account @@ -88,7 +88,7 @@ def test_get_course_with_start_date(self, m): course = self.canvas.get_course(2) self.assertTrue(hasattr(course, 'start_at')) - self.assertIsInstance(course.start_at, str) + self.assertIsInstance(course.start_at, text_type) self.assertTrue(hasattr(course, 'start_at_date')) self.assertIsInstance(course.start_at_date, datetime) diff --git a/tests/test_canvas_object.py b/tests/test_canvas_object.py index 8bb48754..97cb3fea 100644 --- a/tests/test_canvas_object.py +++ b/tests/test_canvas_object.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest from canvasapi.canvas_object import CanvasObject diff --git a/tests/test_communication_channel.py b/tests/test_communication_channel.py index 20f54259..92197b25 100644 --- a/tests/test_communication_channel.py +++ b/tests/test_communication_channel.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_conversation.py b/tests/test_conversation.py index a579e305..633288ed 100644 --- a/tests/test_conversation.py +++ b/tests/test_conversation.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_course.py b/tests/test_course.py index cee7eb1a..09b5e4cb 100644 --- a/tests/test_course.py +++ b/tests/test_course.py @@ -1,10 +1,10 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest import uuid import os -from builtins import str import requests_mock +from six import text_type from canvasapi import Canvas from canvasapi.assignment import Assignment, AssignmentGroup @@ -136,7 +136,7 @@ def test_preview_html(self, m): html_str = "

hello

" prev_html = self.course.preview_html(html_str) - self.assertIsInstance(prev_html, str) + self.assertIsInstance(prev_html, text_type) self.assertEqual(prev_html, "

hello

") # get_settings() diff --git a/tests/test_discussion_topic.py b/tests/test_discussion_topic.py index 103831c3..e338200d 100644 --- a/tests/test_discussion_topic.py +++ b/tests/test_discussion_topic.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_enrollment.py b/tests/test_enrollment.py index 3fb5f2b1..c2eceb6c 100644 --- a/tests/test_enrollment.py +++ b/tests/test_enrollment.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi.canvas import Canvas diff --git a/tests/test_enrollment_term.py b/tests/test_enrollment_term.py index 1043fe19..fd4fda31 100644 --- a/tests/test_enrollment_term.py +++ b/tests/test_enrollment_term.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_external_feed.py b/tests/test_external_feed.py index bd68fda1..38baf88e 100644 --- a/tests/test_external_feed.py +++ b/tests/test_external_feed.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_external_tool.py b/tests/test_external_tool.py index 439286ea..a9e9b57e 100644 --- a/tests/test_external_tool.py +++ b/tests/test_external_tool.py @@ -1,8 +1,8 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock +from six import text_type from canvasapi import Canvas from canvasapi.account import Account @@ -94,7 +94,7 @@ def test_get_sessionless_launch_url(self, m): requires = {'external_tool': ['get_sessionless_launch_url_course']} register_uris(requires, m) - self.assertIsInstance(self.ext_tool_course.get_sessionless_launch_url(), str) + self.assertIsInstance(self.ext_tool_course.get_sessionless_launch_url(), text_type) def test_get_sessionless_launch_url_no_url(self, m): requires = { diff --git a/tests/test_file.py b/tests/test_file.py index f91c6f75..06bdcacb 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_folder.py b/tests/test_folder.py index 9bdc2e00..eb29e942 100644 --- a/tests/test_folder.py +++ b/tests/test_folder.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_group.py b/tests/test_group.py index eb171d57..4388ec21 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -1,9 +1,8 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import os import unittest import uuid -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_login.py b/tests/test_login.py index 98b09e63..8d2c0587 100644 --- a/tests/test_login.py +++ b/tests/test_login.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_module.py b/tests/test_module.py index fbe246bf..2f942687 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_notification_preference.py b/tests/test_notification_preference.py index 92de0692..1d383e59 100644 --- a/tests/test_notification_preference.py +++ b/tests/test_notification_preference.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_page.py b/tests/test_page.py index a979c641..dd739b44 100644 --- a/tests/test_page.py +++ b/tests/test_page.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi.canvas import Canvas diff --git a/tests/test_page_view.py b/tests/test_page_view.py index f3605e10..b8600ded 100644 --- a/tests/test_page_view.py +++ b/tests/test_page_view.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_paginated_list.py b/tests/test_paginated_list.py index 25c4124c..b7c2a1d2 100644 --- a/tests/test_paginated_list.py +++ b/tests/test_paginated_list.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest import requests_mock diff --git a/tests/test_progress.py b/tests/test_progress.py index 862f9ef2..8d16355f 100644 --- a/tests/test_progress.py +++ b/tests/test_progress.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi.canvas import Canvas diff --git a/tests/test_quiz.py b/tests/test_quiz.py index 83d133ff..e312c916 100644 --- a/tests/test_quiz.py +++ b/tests/test_quiz.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_requester.py b/tests/test_requester.py index 1193c337..0fabb9f0 100644 --- a/tests/test_requester.py +++ b/tests/test_requester.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest import requests_mock diff --git a/tests/test_section.py b/tests/test_section.py index 1378b9b7..c26ba21c 100644 --- a/tests/test_section.py +++ b/tests/test_section.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_submission.py b/tests/test_submission.py index bcd546d4..8f178c1b 100644 --- a/tests/test_submission.py +++ b/tests/test_submission.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_tab.py b/tests/test_tab.py index 80277166..91eaabc5 100644 --- a/tests/test_tab.py +++ b/tests/test_tab.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_uploader.py b/tests/test_uploader.py index a6d992ce..ad7a9642 100644 --- a/tests/test_uploader.py +++ b/tests/test_uploader.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import os import unittest import uuid diff --git a/tests/test_user.py b/tests/test_user.py index 8abc9263..1a4517e2 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -1,9 +1,8 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import os import unittest import uuid -from builtins import str import requests_mock from canvasapi import Canvas diff --git a/tests/test_util.py b/tests/test_util.py index f61b3ef5..9714ce47 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import unittest import requests_mock diff --git a/tests/util.py b/tests/util.py index 5dcb1f8a..c7d74ea8 100644 --- a/tests/util.py +++ b/tests/util.py @@ -1,4 +1,4 @@ -from __future__ import print_function, unicode_literals +from __future__ import absolute_import, division, print_function, unicode_literals import json import requests_mock diff --git a/tests_requirements.txt b/tests_requirements.txt index e87964d9..725b5860 100644 --- a/tests_requirements.txt +++ b/tests_requirements.txt @@ -1,6 +1,6 @@ -r requirements.txt -coverage==4.1 -pycodestyle==2.3.0 -pyflakes==1.5.0 -requests-mock==1.2.0 +coverage +pycodestyle +pyflakes +requests-mock