Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #24 from thejessleigh/develop
Browse files Browse the repository at this point in the history
Version 0.4.2 release
  • Loading branch information
thejessleigh authored Apr 26, 2019
2 parents b0b5482 + a837102 commit f11595a
Show file tree
Hide file tree
Showing 37 changed files with 446 additions and 284 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
*pyc
.coverage
venv/
venv*
docs/_*
.idea/
htmlcov/
build/
dist/
docs/make.bat
.python-version
28 changes: 19 additions & 9 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ contribution!
Fork the Repo and Create a Branch
---------------------------------

To contribute to this project, first make a fork of the repo. Then create a branch on your local fork. If your change
corresponds to an issue your branch name should start with to that issue number. Your name branch should be descriptive.
To contribute to this project, first make a fork of the repo.

Then create a branch on your local fork. This branch should be based off of the ``develop`` branch, NOT the ``master``
branch. Active development is merged into the ``develop`` branch and ``develop`` is merged into ``master`` when
there is a new release or a hotfix to be released on PyPi.

If your change corresponds to an issue your branch name should start with to that issue number.
Your name branch should be descriptive.

Example: ``13-add-delete-to-owned-book``

Once you've made your changes
Once you've made your changes and the unit test suite is passing, create a pull request. Make sure that your pull
request is pointing to ``develop`` and not ``master``.


Pre-Commit
Expand All @@ -37,20 +44,23 @@ Running Tests
-------------

You will not need your own developer keys to run the unit tests. However, you will need developer keys for the
Goodreads API in order to run the integration test suite. Any changes you make likely shouldn't impact the integration
tests, but if for some reason you do need to adjust them and run them, set your developer keys as ``GOODREADS_KEY``
and ``GOODREADS_SECRET`` environment variables.
Goodreads API in order to run the integration test suite.

Any changes you make likely shouldn't impact the integration tests, but if for some reason you do need to adjust them
and run them, set your developer keys as ``GOODREADS_KEY`` and ``GOODREADS_SECRET`` environment variables.

You can obtain a Goodreads developer key `here <https://www.goodreads.com/api/keys>`__.

To run the test suite, make sure you've installed the packages listed in ``requirements.txt`` and
``requirements-dev.txt``. Then run ``pytest --cov=betterreads``

Pull requests that cause the repository's overall test coverage to drop below 85% or cause a decrease in coverage of
over 5% will be rejected. Please make sure to update tests in accordance with your changes.
Pull requests that cause the repository's overall test coverage to drop below 85% or cause a decrease in coverage of %5
or more will be rejected. Please make sure to update tests in accordance with your changes.

Community Standards
-------------------

In general, PRs will be acknowledged within one week of receipt. I wish I could say that they would all be
reviewed and merge in in this timeframe, but sometimes life gets the better of us. I'll do my best.
reviewed and merge in in this time frame, but sometimes life gets the better of us. I'll do my best.

All contributions and discussions in this repo should abide by the `Code of Conduct <CODE_OF_CONDUCT.md>`__.
15 changes: 12 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
betterreads
BetterReads
===========

|Build Status| |Coverage Status| |Documentation Status| |Primary Code Style| |Secondary Code Style|

.. image:: http://s.gr-assets.com/assets/icons/goodreads_icon_50x50-823139ec9dc84278d3863007486ae0ac.png
:width: 100
:target: https://goodreads.com
:width: 100px

This package provides a Python interface for the `Goodreads
API <http://goodreads.com/api>`__. Using it, you can do pretty much
Expand Down Expand Up @@ -36,6 +37,7 @@ This package depends on the following packages:
- xmltodict
- requests
- rauth
- backports-datetime-fromisoformat

They can be installed using ``pip``.

Expand All @@ -44,7 +46,7 @@ They can be installed using ``pip``.
sudo pip install -r requirements.txt

If you want to contribute to this package, you will need to install the packages
in ``requirements-dev.txt` as well.
in ``requirements-dev.txt`` as well.

Installation
------------
Expand All @@ -56,6 +58,13 @@ directory.

sudo python setup.py install

You can also install BetterReads using pip. The current version on PyPi is 0.4.1.

::

pip install betterreads


Getting Started
---------------

Expand Down
20 changes: 15 additions & 5 deletions betterreads.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Metadata-Version: 2.1
Name: betterreads
Version: 0.4.1
Version: 0.4.2
Summary: Python 3 wrapper for Goodreads API
Home-page: https://github.com/thejessleigh/betterreads
Author: Jess Unrein
Author-email: j.l.unrein@gmail.com
License: MIT
Description: betterreads
Description: BetterReads
===========

|Build Status| |Coverage Status| |Documentation Status| |Primary Code Style| |Secondary Code Style|

.. image:: http://s.gr-assets.com/assets/icons/goodreads_icon_50x50-823139ec9dc84278d3863007486ae0ac.png
:width: 100
:target: https://goodreads.com
:width: 100px

This package provides a Python interface for the `Goodreads
API <http://goodreads.com/api>`__. Using it, you can do pretty much
Expand Down Expand Up @@ -44,6 +45,7 @@ Description: betterreads
- xmltodict
- requests
- rauth
- backports-datetime-fromisoformat

They can be installed using ``pip``.

Expand All @@ -52,7 +54,7 @@ Description: betterreads
sudo pip install -r requirements.txt

If you want to contribute to this package, you will need to install the packages
in ``requirements-dev.txt` as well.
in ``requirements-dev.txt`` as well.

Installation
------------
Expand All @@ -64,6 +66,13 @@ Description: betterreads

sudo python setup.py install

You can also install BetterReads using pip. The current version on PyPi is 0.4.1.

::

pip install betterreads


Getting Started
---------------

Expand Down Expand Up @@ -226,6 +235,7 @@ Description: betterreads
.. |Secondary Code Style| image:: https://img.shields.io/badge/code_style-prettier-ff69b4.svg
:target: https://github.com/prettier/prettier
:alt: Secondary Code Style - Prettier

Keywords: goodreads API
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Expand All @@ -234,4 +244,4 @@ Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Description-Content-Type: text/markdown
Description-Content-Type: text/x-rst
6 changes: 3 additions & 3 deletions betterreads.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nose
xmltodict
requests
backports-datetime-fromisoformat
rauth
requests
xmltodict
17 changes: 11 additions & 6 deletions betterreads/author.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from datetime import datetime


class GoodreadsAuthor:
def __init__(self, author_dict, client):
self._author_dict = author_dict
Expand All @@ -9,7 +12,7 @@ def __repr__(self):
@property
def gid(self):
"""Goodreads id of the author"""
return self._author_dict["id"]
return int(self._author_dict["id"])

@property
def name(self):
Expand Down Expand Up @@ -39,17 +42,19 @@ def books(self):
@property
def born_at(self):
"""Author date of birth"""
return self._author_dict["born_at"]
born_date = self._author_dict["born_at"]
return datetime.strptime(born_date, "%Y/%m/%d")

@property
def died_at(self):
"""Author date of death"""
return self._author_dict["died_at"]
died_date = self._author_dict["died_at"]
return datetime.strptime(died_date, "%Y/%m/%d")

@property
def fans_count(self):
"""Number of fans"""
return self._author_dict["fans_count"]["#text"]
return int(self._author_dict["fans_count"]["#text"])

@property
def gender(self):
Expand Down Expand Up @@ -84,7 +89,7 @@ def influences(self):
@property
def user(self):
"""Goodreads user profile of the author"""
from .user import GoodreadsUser
from betterreads.user import GoodreadsUser

goodreads_user = None
if "user" in self._author_dict:
Expand All @@ -96,4 +101,4 @@ def user(self):
@property
def works_count(self):
"""Author number of works"""
return self._author_dict["works_count"]
return int(self._author_dict["works_count"])
23 changes: 12 additions & 11 deletions betterreads/book.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Goodreads book class"""
from datetime import datetime

from betterreads.author import GoodreadsAuthor


Expand All @@ -13,7 +14,7 @@ def __repr__(self):
@property
def gid(self):
"""Goodreads id of the book"""
return self._book_dict["id"]
return int(self._book_dict["id"])

@property
def title(self):
Expand Down Expand Up @@ -41,7 +42,7 @@ def description(self):
@property
def average_rating(self):
"""Average rating of the book"""
return self._book_dict["average_rating"]
return float(self._book_dict["average_rating"])

@property
def rating_dist(self):
Expand All @@ -51,17 +52,17 @@ def rating_dist(self):
@property
def ratings_count(self):
"""Number of ratings for the book"""
return self._book_dict["ratings_count"]
return int(self._book_dict["ratings_count"])

@property
def text_reviews_count(self):
"""Number of text reviews for the book"""
return self._book_dict["text_reviews_count"]
return int(self._book_dict["text_reviews_count"])

@property
def num_pages(self):
"""Number of pages of the book"""
return self._book_dict["num_pages"]
return int(self._book_dict["num_pages"])

@property
def popular_shelves(self):
Expand All @@ -83,10 +84,10 @@ def series_works(self):
@property
def publication_date(self):
"""Publication month/day/year for the book"""
return (
self._book_dict["publication_month"],
self._book_dict["publication_day"],
self._book_dict["publication_year"],
return datetime(
int(self._book_dict["publication_year"]),
int(self._book_dict["publication_month"]),
int(self._book_dict["publication_day"]),
)

@property
Expand Down Expand Up @@ -117,7 +118,7 @@ def small_image_url(self):
@property
def is_ebook(self):
"""Is this book an e-book?"""
return self._book_dict["is_ebook"]
return False if self._book_dict["is_ebook"] == "false" else True

@property
def format(self):
Expand Down
13 changes: 9 additions & 4 deletions betterreads/comment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Class for Goodreads comments"""
from datetime import datetime

from betterreads.user import GoodreadsUser


Expand All @@ -11,7 +12,7 @@ def __init__(self, comment_dict):
@property
def gid(self):
"""Goodreads id of the comment"""
return self._comment_dict["id"]
return int(self._comment_dict["id"])

@property
def body(self):
Expand All @@ -26,9 +27,13 @@ def user(self):
@property
def created_at(self):
"""Comment created at"""
return self._comment_dict["created_at"]
return datetime.strptime(
self._comment_dict["created_at"], "%a %b %d %H:%M:%S %z %Y"
)

@property
def updated_at(self):
"""Comment updated at"""
return self._comment_dict["updated_at"]
return datetime.strptime(
self._comment_dict["updated_at"], "%a %b %d %H:%M:%S %z %Y"
)
Loading

0 comments on commit f11595a

Please sign in to comment.