Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mocking #23

Merged
merged 8 commits into from
Oct 8, 2014
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Don't complain if non-runnable code isn't run:
pass
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage*
.cache
nosetests.xml
coverage.xml
Expand Down
63 changes: 4 additions & 59 deletions pymal/anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,14 @@ class Anime(Media):
"""
Object that keeps all the anime data in MAL.

:ivar title: :class:`str`
:ivar image_url: :class:`str`
:ivar english: :class:`str`
:ivar synonyms: :class:`str`
:ivar japanese: :class:`str`
:ivar type: :class:`str`
:ivar status: :class:`int`
:ivar start_time: :class:`int`
:ivar end_time: :class:`int`
:ivar creators: :class:`dict`
:ivar genres: :class:`dict`
:ivar duration: :class:`int`
:ivar score: :class:`float`
:ivar rank: :class:`int`
:ivar popularity: :class:`int`
:ivar rating: :class:`str`
:ivar episodes: :class:`int`
:ivar synopsis: :class:`str`

:ivar adaptations: :class:`frozenset`
:ivar characters: :class:`frozenset`
:ivar sequels: :class:`frozenset`
:ivar prequels: :class:`frozenset`
:ivar spin_offs: :class:`frozenset`
:ivar alternative_versions: :class:`frozenset`
:ivar side_stories: :class:`frozenset`
:ivar summaries: :class:`frozenset`
:ivar others: :class:`frozenset`
:ivar parent_stories: :class:`frozenset`
:ivar alternative_settings: :class:`frozenset`
:ivar full_stories: :class:`frozenset`
"""

_NAME = 'anime'
_TIMING_HEADER = 'Aired'
_CREATORS_HEADER = 'Producers'

def __init__(self, mal_id: int):
"""
Expand All @@ -79,8 +53,8 @@ def __init__(self, mal_id: int):
self._type_parse,
self._episodes_parse,
self._status_parse,
self._aired_parse,
self._producers_parse,
self._timing_parse,
self._creators_parse,
self._genres_parse,
self._duration_parse,
self._rating_parse,
Expand All @@ -94,11 +68,6 @@ def __init__(self, mal_id: int):
def duration(self) -> int:
return self.__duration

@property
@load()
def full_stories(self) -> frozenset:
return frozenset(self._full_stories)

@property
@load()
def rating(self) -> int:
Expand All @@ -121,30 +90,6 @@ def _episodes_parse(self, episodes_div: bs4.element.Tag):
self.__episodes = global_functions.make_counter(self_episodes.strip())
return 1

def _aired_parse(self, aired_div: bs4.element.Tag):
"""
:param aired_div: Aired <div>
:type aired_div: bs4.element.Tag
:return: 1.
"""
if not global_functions.check_side_content_div('Aired', aired_div):
raise exceptions.FailedToReloadError(aired_div)
aired_span, aired = aired_div.contents
self._start_time, self._end_time = global_functions.make_start_and_end_time(aired)
return 1

def _producers_parse(self, producers_div: bs4.element.Tag):
"""
:param producers_div: Aired <div>
:type producers_div: bs4.element.Tag
:return: 1.
"""
if not global_functions.check_side_content_div('Producers', producers_div):
raise exceptions.FailedToReloadError(producers_div)
for producer_link in producers_div.findAll(name='a'):
self._creators[producer_link.text.strip()] = producer_link['href']
return 1

def _duration_parse(self, duration_div: bs4.element.Tag):
"""
:param duration_div: Duration <div>
Expand Down
5 changes: 1 addition & 4 deletions pymal/global_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import time

import requests
try:
import httpcache
except ImportError:
httpcache = None
import httpcache
import bs4

from pymal import consts
Expand Down