Skip to content

Commit

Permalink
Package for PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyWayUp committed Jan 27, 2024
1 parent 2be53c9 commit 45c5861
Show file tree
Hide file tree
Showing 16 changed files with 897 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
__pycache__
venv
*venv
.env
.vscode
*.ipynb
*json
dist
*info
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
aiohttp==3.9.1
aiohttp-client-cache==0.10.0
aiosignal==1.3.1
annotated-types==0.6.0
async-timeout==4.0.3
attrs==23.2.0
frozenlist==1.4.1
idna==3.6
itsdangerous==2.1.2
multidict==6.0.4
pydantic==2.5.3
pydantic_core==2.14.6
six==1.16.0
typing_extensions==4.9.0
url-normalize==1.4.3
yarl==1.9.4
52 changes: 52 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[metadata]
name = wattpad
version = 0.0.2
description = High-performance Wattpad SDK. Supports Caching and Async. Memory-Efficient.
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/TheOnlyWayUp/Wattpad-Py
author = TheOnlyWayUp
author_email = "TheOnlyWayUp" <[email protected]>
license_files = LICENSE
classifiers =
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Typing :: Typed


[options]
packages = find:
python_requires = >=3.8
package_dir = =src
install_requires =
aiohttp==3.9.1
aiohttp-client-cache==0.10.0
aiosignal==1.3.1
annotated-types==0.6.0
async-timeout==4.0.3
attrs==23.2.0
frozenlist==1.4.1
idna==3.6
itsdangerous==2.1.2
multidict==6.0.4
pydantic==2.5.3
pydantic_core==2.14.6
six==1.16.0
typing_extensions==4.9.0
url-normalize==1.4.3
yarl==1.9.4


[options.packages.find]
where = ./src

[options.package_data]
dunderhell =
py.typed
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()
36 changes: 36 additions & 0 deletions src/wattpad.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Metadata-Version: 2.1
Name: wattpad
Version: 0.0.1
Summary: High-performance Wattpad SDK. Caching, Async, Memory-Efficiency.
Home-page: https://github.com/TheOnlyWayUp/Wattpad-Py
Author: TheOnlyWayUp
Author-email: "TheOnlyWayUp" <[email protected]>
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp==3.9.1
Requires-Dist: aiohttp-client-cache==0.10.0
Requires-Dist: aiosignal==1.3.1
Requires-Dist: annotated-types==0.6.0
Requires-Dist: async-timeout==4.0.3
Requires-Dist: attrs==23.2.0
Requires-Dist: frozenlist==1.4.1
Requires-Dist: idna==3.6
Requires-Dist: itsdangerous==2.1.2
Requires-Dist: multidict==6.0.4
Requires-Dist: pydantic==2.5.3
Requires-Dist: pydantic_core==2.14.6
Requires-Dist: six==1.16.0
Requires-Dist: typing_extensions==4.9.0
Requires-Dist: url-normalize==1.4.3
Requires-Dist: yarl==1.9.4
15 changes: 15 additions & 0 deletions src/wattpad.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
LICENSE
README.md
setup.cfg
setup.py
src/wattpad/__init__.py
src/wattpad/model_types.py
src/wattpad/models.py
src/wattpad/py.typed
src/wattpad/utils.py
src/wattpad/wattpad.py
src/wattpad.egg-info/PKG-INFO
src/wattpad.egg-info/SOURCES.txt
src/wattpad.egg-info/dependency_links.txt
src/wattpad.egg-info/requires.txt
src/wattpad.egg-info/top_level.txt
1 change: 1 addition & 0 deletions src/wattpad.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

16 changes: 16 additions & 0 deletions src/wattpad.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
aiohttp==3.9.1
aiohttp-client-cache==0.10.0
aiosignal==1.3.1
annotated-types==0.6.0
async-timeout==4.0.3
attrs==23.2.0
frozenlist==1.4.1
idna==3.6
itsdangerous==2.1.2
multidict==6.0.4
pydantic==2.5.3
pydantic_core==2.14.6
six==1.16.0
typing_extensions==4.9.0
url-normalize==1.4.3
yarl==1.9.4
1 change: 1 addition & 0 deletions src/wattpad.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wattpad
13 changes: 13 additions & 0 deletions src/wattpad/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Copyright (C) 2024 TheOnlyWayUp
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
---
Entrypoint."""

from wattpad.wattpad import User, Story, List
12 changes: 12 additions & 0 deletions src/model_types.py → src/wattpad/model_types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
"""Copyright (C) 2024 TheOnlyWayUp
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
---
Typehints for the models in `./models.py`. These types are used to specify what fields to request in API-Interfacing methods."""

from __future__ import annotations

from typing import TypedDict
Expand Down
14 changes: 13 additions & 1 deletion src/models.py → src/wattpad/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
"""Pydantic Models representing Wattpad API Responses. Thanks https://jsontopydantic.com. Thanks to Tushar Sadhwani (https://sadh.life) for helping me understand the Literal type (used in an earlier version of this code)."""
"""Copyright (C) 2024 TheOnlyWayUp
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
---
Pydantic Models representing Wattpad API Responses. Thanks https://jsontopydantic.com."""

from __future__ import annotations


from typing import List, Optional
from pydantic import BaseModel, Field

Expand Down
1 change: 1 addition & 0 deletions src/wattpad/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Marker file for PEP 561. This package uses inline types.
23 changes: 22 additions & 1 deletion src/utils.py → src/wattpad/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
"""Copyright (C) 2024 TheOnlyWayUp
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
---
Utility functions for the wattpad package."""

from typing import Optional

import aiohttp
from aiohttp_client_cache import CachedSession
from pydantic import BaseModel
from os import environ

base_headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 OPR/105.0.0.0"
Expand Down Expand Up @@ -71,10 +86,16 @@ def build_url(


async def fetch_url(url: str, headers: dict = {}) -> dict | list:
"""Perform a GET Request to the provided URL. Using the headers provided, merged with base_headers."""
use_headers = base_headers.copy()
use_headers.update(headers)

async with aiohttp.ClientSession(headers=use_headers) as session:
if environ["WPPY_SKIP_CACHE"]:
session = aiohttp.ClientSession
else:
session = CachedSession

async with session(headers=use_headers) as session:
async with session.get(url) as response:
response.raise_for_status()
return await response.json()
Expand Down
19 changes: 19 additions & 0 deletions src/wattpad_py.py → src/wattpad/wattpad.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
"""Copyright (C) 2024 TheOnlyWayUp
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
---
The main module for the wattpad package. This contains the User, Story, and List classes.
>>> u = User("<username>")
>>> await u.fetch()
>>> print(u.data)
Use `help(User)` for information. Refer to the documentation for more.
"""

from __future__ import annotations
from typing import Optional, cast
from models import (
Expand Down

0 comments on commit 45c5861

Please sign in to comment.