From 7ec72f77023167078d7c3e49a57e256000d39403 Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Thu, 30 Dec 2021 12:11:24 +0000 Subject: [PATCH 1/2] add `async` info to the docs --- README.md | 5 +++-- docs/imdb.md | 5 +++-- docs/index.md | 3 ++- docs/mtc.md | 3 ++- docs/phylm.md | 9 +++++---- docs/rt.md | 3 ++- mkdocs.yml | 4 ++++ src/phylm/sources/mtc.py | 2 +- src/phylm/sources/rt.py | 2 +- 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2a8682b..5f97594 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![codecov](https://codecov.io/gh/dbatten5/phylm/branch/master/graph/badge.svg?token=P233M48EA6)](https://codecov.io/gh/dbatten5/phylm) [![PyPI version](https://badge.fury.io/py/phylm.svg)](https://badge.fury.io/py/phylm) -Film data aggregation. +Film data aggregation with async support. ## Motivation @@ -23,9 +23,10 @@ pip install phylm ## Usage ```python +>>> import asyncio >>> from phylm import Phylm >>> p = Phylm("The Matrix") ->>> p.load_source("imdb") +>>> asyncio.run(p.load_source("imdb")) >>> p.imdb.year 1999 >>> p.imdb.rating diff --git a/docs/imdb.md b/docs/imdb.md index 95d3a99..94976a2 100644 --- a/docs/imdb.md +++ b/docs/imdb.md @@ -4,7 +4,7 @@ To access IMDb data points, first ensure you have loaded the IMDb source through: ```python -phylm.load_source("imdb") +await phylm.load_source("imdb") ``` Alternatively you can instantiate the IMDb source class directly through: @@ -13,6 +13,7 @@ Alternatively you can instantiate the IMDb source class directly through: from phylm.sources import Imdb imdb = Imdb(raw_title="The Matrix", raw_year=1999)  # raw_year is optional +await imdb.load_source() ``` ## Movie ID @@ -33,7 +34,7 @@ to a title search. Alternatively, you can pass it to `load_source` with `"imdb"` as the first argument: ```python -phylm.load_source("imdb", imdb_id="0133093") +await phylm.load_source("imdb", imdb_id="0133093") ``` Or instantiate the IMDb source class with the ID: diff --git a/docs/index.md b/docs/index.md index f36690a..5e0a9d9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,9 +16,10 @@ pip install phylm # Example ```python +>>> import asyncio >>> from phylm import Phylm >>> p = Phylm("The Matrix") ->>> p.load_source("imdb") +>>> asyncio.run(p.load_source("imdb")) >>> p.imdb.rating 8.7 ``` diff --git a/docs/mtc.md b/docs/mtc.md index af234dd..b963e4e 100644 --- a/docs/mtc.md +++ b/docs/mtc.md @@ -4,7 +4,7 @@ To access Metacritic data points, first ensure you have loaded the Metacritic so through: ```python -phylm.load_source("mtc") +await phylm.load_source("mtc") ``` Alternatively you can instantiate the Metacritic source class directly through: @@ -13,6 +13,7 @@ Alternatively you can instantiate the Metacritic source class directly through: from phylm.sources import Mtc mtc = Mtc(raw_title="The Matrix", raw_year=1999)  # raw_year is optional +await mtc.load_source() ``` # Reference diff --git a/docs/phylm.md b/docs/phylm.md index 70fdf05..22a8cde 100644 --- a/docs/phylm.md +++ b/docs/phylm.md @@ -18,11 +18,12 @@ from phylm import Phylm p = Phylm(title="The Matrix", year=1999) ``` -Next load a source through either `load_sources` or `load_source`: +Next, asynchronously load a source through either `load_sources` or +`load_source`: ```python -p.load_sources(["imdb", "rt"]) -p.load_source("mtc") +await p.load_sources(["imdb", "rt"]) +await p.load_source("mtc") ``` The available sources are: @@ -54,7 +55,7 @@ one: ```python from phylm import Phylm p = Phylm("Ambiguous Movie") # suppose this movie was released in 1999 -p.load_source("imdb") +await p.load_source("imdb") if p.imdb.low_confidence and p.imdb.year != 1999: # it's unlikely we're dealing with the right "Ambigous Movie" ``` diff --git a/docs/rt.md b/docs/rt.md index e989699..5ca5450 100644 --- a/docs/rt.md +++ b/docs/rt.md @@ -4,7 +4,7 @@ To access Rotten Tomatoes data points, first ensure you have loaded the Rotten T through: ```python -phylm.load_source("rt") +await phylm.load_source("rt") ``` Alternatively you can instantiate the Rotten Tomatoes source class directly through: @@ -13,6 +13,7 @@ Alternatively you can instantiate the Rotten Tomatoes source class directly thro from phylm.sources import Rt rot_tom = Rt(raw_title="The Matrix", raw_year=1999)  # raw_year is optional +await rot_tom.load_source() ``` # Reference diff --git a/mkdocs.yml b/mkdocs.yml index cb54a20..b8216b0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -31,6 +31,10 @@ plugins: show_root_heading: true heading_level: 1 show_source: false + selection: + filters: + - "!^_" + - "^__init__$" watch: - src - autolinks diff --git a/src/phylm/sources/mtc.py b/src/phylm/sources/mtc.py index 8f85d9b..d5550cd 100644 --- a/src/phylm/sources/mtc.py +++ b/src/phylm/sources/mtc.py @@ -57,7 +57,7 @@ async def _scrape_data( return await async_soupify(search_url, session) async def load_source(self, session: Optional[ClientSession] = None) -> None: - """Asynchronously load the data for from the source. + """Asynchronously load the data from the source. Args: session: an optional instance of `aiohttp.ClientSession` in which to run the diff --git a/src/phylm/sources/rt.py b/src/phylm/sources/rt.py index fda046a..4624076 100644 --- a/src/phylm/sources/rt.py +++ b/src/phylm/sources/rt.py @@ -56,7 +56,7 @@ async def _scrape_data( return await async_soupify(search_url, session) async def load_source(self, session: Optional[ClientSession] = None) -> None: - """Asynchronously load the data for from the source. + """Asynchronously load the data from the source. Args: session: an optional instance of `aiohttp.ClientSession` in which to run the From 105dc146b10005bdb5fb2d8ba9a1ed715c3b8b31 Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Thu, 30 Dec 2021 12:11:49 +0000 Subject: [PATCH 2/2] bump version to `5.0.0` --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 87afe5e..5539fa3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "phylm" -version = "4.3.1" +version = "5.0.0" description = "Phylm" authors = ["Dom Batten "] license = "MIT"