Skip to content

Commit

Permalink
Merge pull request #42 from ucfopen/develop
Browse files Browse the repository at this point in the history
Release v0.5.0
Resolves #41
  • Loading branch information
Thetwam authored Jul 10, 2017
2 parents a98338c + 2a617b1 commit ac78bf2
Show file tree
Hide file tree
Showing 83 changed files with 525 additions and 191 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
install:
- pip install -r tests_requirements.txt
- pip install coveralls
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## [0.5.0] - 2017-07-10
### New Endpoint Coverage

- Files (Get file from Canvas, Course, Group, or User)

### General

- Added support for Python 3.3, 3.4, 3.5, and 3.6 while maintaining 2.7 compatibility.

### Bugfixes

- Fixed an issue where non-ASCII characters in CanvasObject data would throw UnicodeEncodeError exceptions.

## [0.4.0] - 2017-06-16
### New Endpoint Coverage

Expand Down
19 changes: 14 additions & 5 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
canvasapi Deploy Procedures
==========================
CanvasAPI Deploy Procedures
===========================

Pre-Flight Checklist
--------------------

- On branch `master` and up-to-date
- On branch `develop` and up-to-date
- All tests pass
- 100% coverage
- No linter errors
- `CHANGELOG` is accurate

Packaging
Expand All @@ -16,20 +17,28 @@ Update version number in `__init__.py`.

Run `python setup.py sdist`. This should create a file in the `dist` directory called something like `canvasapi-0.0.0.tar.gz`.


Generate Documentation
----------------------

In the `docs` directory, run `make clean html`.

**TODO:** how to publish documentation.
This will create all the documentation files in the `_build/html` directory


Deploy
------

Commit the new files and the changes to `__init__.py` and push.

Create a merge request from `master` to `stable`, and merge.
Create a merge request from `develop` to `master`, and merge.

Tag the merge commit with the version number: `git tag -s v0.0.0 -m "Release version 0.0.0" abc1234`

Push the tag: `git push origin v0.0.0`

Run `twine upload dist/canvasapi-0.0.0.tar.gz` to upload to PyPI.

Compress all files in the `docs/_build/html` directory into a `.zip` file. Upload this file to PyPI to update the [documentation](https://pythonhosted.org/canvasapi/).

Create release on GitHub for the new tag. Use the text from the changelog for content.
6 changes: 4 additions & 2 deletions canvasapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-

from canvas import Canvas
from __future__ import unicode_literals

from canvasapi.canvas import Canvas

__all__ = ["Canvas"]

__version__ = '0.4.0'
__version__ = '0.5.0'
16 changes: 10 additions & 6 deletions canvasapi/account.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import unicode_literals

from builtins import str

from canvasapi.canvas_object import CanvasObject
from canvasapi.exceptions import RequiredFieldMissing
from canvasapi.paginated_list import PaginatedList
Expand Down Expand Up @@ -495,7 +499,7 @@ def list_groups(self, **kwargs):
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of :class:`canvasapi.group.Group`
"""
from group import Group
from canvasapi.group import Group
return PaginatedList(
Group,
self._requester,
Expand All @@ -515,7 +519,7 @@ def create_group_category(self, name, **kwargs):
:type name: str
:rtype: :class:`canvasapi.group.GroupCategory`
"""
from group import GroupCategory
from canvasapi.group import GroupCategory

response = self._requester.request(
'POST',
Expand All @@ -535,7 +539,7 @@ def list_group_categories(self):
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.group.GroupCategory`
"""
from group import GroupCategory
from canvasapi.group import GroupCategory

return PaginatedList(
GroupCategory,
Expand Down Expand Up @@ -605,7 +609,7 @@ def list_enrollment_terms(self, **kwargs):
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.enrollment_term.EnrollmentTerm`
"""
from enrollment_term import EnrollmentTerm
from canvasapi.enrollment_term import EnrollmentTerm

return PaginatedList(
EnrollmentTerm,
Expand All @@ -626,7 +630,7 @@ def list_user_logins(self, **kwargs):
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.login.Login`
"""
from login import Login
from canvasapi.login import Login

return PaginatedList(
Login,
Expand All @@ -649,7 +653,7 @@ def create_user_login(self, user, login, **kwargs):
:type login: `dict`
:rtype: :class:`canvasapi.login.Login`
"""
from login import Login
from canvasapi.login import Login

if isinstance(user, dict) and 'id' in user:
kwargs['user'] = user
Expand Down
2 changes: 2 additions & 0 deletions canvasapi/appointment_group.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.exceptions import RequiredFieldMissing
from canvasapi.util import combine_kwargs
Expand Down
2 changes: 2 additions & 0 deletions canvasapi/assignment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.util import combine_kwargs

Expand Down
2 changes: 2 additions & 0 deletions canvasapi/authentication_provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.util import combine_kwargs

Expand Down
4 changes: 4 additions & 0 deletions canvasapi/avatar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import unicode_literals

from builtins import str

from canvasapi.canvas_object import CanvasObject


Expand Down
2 changes: 2 additions & 0 deletions canvasapi/bookmark.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.util import combine_kwargs

Expand Down
2 changes: 2 additions & 0 deletions canvasapi/calendar_event.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.util import combine_kwargs

Expand Down
25 changes: 24 additions & 1 deletion canvasapi/canvas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from __future__ import unicode_literals

from builtins import object

from canvasapi.account import Account
from canvasapi.course import Course
from canvasapi.exceptions import RequiredFieldMissing
from canvasapi.file import File
from canvasapi.folder import Folder
from canvasapi.group import Group, GroupCategory
from canvasapi.paginated_list import PaginatedList
Expand Down Expand Up @@ -757,9 +762,27 @@ def list_group_participants(self, appointment_group_id, **kwargs):
**combine_kwargs(**kwargs)
)

def get_file(self, file_id, **kwargs):
"""
Return the standard attachment json object for a file.
:calls: `GET /api/v1/files/:id \
<https://canvas.instructure.com/doc/api/files.html#method.files.api_show>`_
:param file_id: The ID of the file to retrieve.
:type file_id: int
:rtype: :class:`canvasapi.file.File`
"""
response = self.__requester.request(
'GET',
'files/{}'.format(file_id),
**combine_kwargs(**kwargs)
)
return File(self.__requester, response.json())

def get_folder(self, folder_id):
"""
Returns the details for a folder
Return the details for a folder
:calls: `GET /api/v1/folders/:id \
<https://canvas.instructure.com/doc/api/files.html#method.folders.show>`_
Expand Down
19 changes: 9 additions & 10 deletions canvasapi/canvas_object.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import unicode_literals
from datetime import datetime
import json
import re

from builtins import str, object

DATE_PATTERN = re.compile('[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z')


Expand All @@ -25,7 +28,7 @@ def __init__(self, requester, attributes):

def __repr__(self): # pragma: no cover
classname = self.__class__.__name__
attrs = ', '.join(['%s=%s' % (attr, val) for attr, val in self.__dict__.iteritems() if attr != 'attributes']) # noqa
attrs = ', '.join(['%s=%s' % (attr, val) for attr, val in self.__dict__.items() if attr != 'attributes']) # noqa
return '%s(%s)' % (classname, attrs)

def to_json(self):
Expand Down Expand Up @@ -61,14 +64,10 @@ def set_attributes(self, attributes):
"""
self.attributes = attributes

for attribute, value in attributes.iteritems():
for attribute, value in attributes.items():
self.__setattr__(attribute, value)

try:
# datetime field
if DATE_PATTERN.match(str(value)):
date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ')
self.__setattr__(attribute + '_date', date)
# Non-unicode character. We can skip over this attribute.
except UnicodeEncodeError:
continue
# datetime field
if DATE_PATTERN.match(str(value)):
date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ')
self.__setattr__(attribute + '_date', date)
2 changes: 2 additions & 0 deletions canvasapi/communication_channel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.notification_preference import NotificationPreference

Expand Down
2 changes: 2 additions & 0 deletions canvasapi/conversation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.util import combine_kwargs

Expand Down
23 changes: 22 additions & 1 deletion canvasapi/course.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.discussion_topic import DiscussionTopic
from canvasapi.exceptions import RequiredFieldMissing
Expand Down Expand Up @@ -694,7 +696,7 @@ def list_groups(self, **kwargs):
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.course.Course`
"""
from group import Group
from canvasapi.group import Group
return PaginatedList(
Group,
self._requester,
Expand Down Expand Up @@ -765,6 +767,25 @@ def get_discussion_topic(self, topic_id):

return DiscussionTopic(self._requester, response_json)

def get_file(self, file_id, **kwargs):
"""
Return the standard attachment json object for a file.
:calls: `GET /api/v1/courses/:course_id/files/:id \
<https://canvas.instructure.com/doc/api/files.html#method.files.api_show>`_
:param file_id: The ID of the file to retrieve.
:type file_id: int
:rtype: :class:`canvasapi.file.File`
"""
from canvasapi.file import File
response = self._requester.request(
'GET',
'courses/{}/files/{}'.format(self.id, file_id),
**combine_kwargs(**kwargs)
)
return File(self._requester, response.json())

def get_full_discussion_topic(self, topic_id):
"""
Return a cached structure of the discussion topic.
Expand Down
2 changes: 2 additions & 0 deletions canvasapi/discussion_topic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.paginated_list import PaginatedList
from canvasapi.util import combine_kwargs
Expand Down
2 changes: 2 additions & 0 deletions canvasapi/enrollment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject


Expand Down
2 changes: 2 additions & 0 deletions canvasapi/enrollment_term.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.util import combine_kwargs

Expand Down
5 changes: 5 additions & 0 deletions canvasapi/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from __future__ import unicode_literals

from builtins import str


class CanvasException(Exception): # pragma: no cover
"""
Base class for all errors returned by the Canvas API.
Expand Down
4 changes: 4 additions & 0 deletions canvasapi/external_feed.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import unicode_literals

from builtins import str

from canvasapi.canvas_object import CanvasObject


Expand Down
2 changes: 2 additions & 0 deletions canvasapi/external_tool.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from canvasapi.canvas_object import CanvasObject
from canvasapi.exceptions import CanvasException
from canvasapi.util import combine_kwargs
Expand Down
4 changes: 4 additions & 0 deletions canvasapi/file.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import unicode_literals

from builtins import str

from canvasapi.canvas_object import CanvasObject


Expand Down
4 changes: 4 additions & 0 deletions canvasapi/folder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import unicode_literals

from builtins import str

from canvasapi.canvas_object import CanvasObject
from canvasapi.paginated_list import PaginatedList
from canvasapi.util import combine_kwargs
Expand Down
Loading

0 comments on commit ac78bf2

Please sign in to comment.