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

Replace maya with arrow #283

Merged
merged 1 commit into from
Nov 28, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions aiopinboard/bookmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from collections.abc import Awaitable, Callable
from dataclasses import dataclass
from datetime import date, datetime
from typing import Any, cast
from typing import Any

import maya
import arrow
from defusedxml import ElementTree

DEFAULT_RECENT_BOOKMARKS_COUNT: int = 15
Expand Down Expand Up @@ -40,7 +40,7 @@ def async_create_bookmark_from_xml(tree: ElementTree) -> Bookmark:
tree.attrib["href"],
tree.attrib["description"],
tree.attrib["extended"],
maya.parse(tree.attrib["time"]).datetime(),
arrow.get(tree.attrib["time"]).datetime,
tree.attrib["tag"].split(),
tree.attrib.get("toread") == "yes",
tree.attrib.get("shared") != "no",
Expand Down Expand Up @@ -195,7 +195,7 @@ async def async_get_dates(
resp = await self._async_request("get", "posts/dates")

return {
maya.parse(row.attrib["date"]).datetime().date(): int(row.attrib["count"])
arrow.get(row.attrib["date"]).datetime.date(): int(row.attrib["count"])
for row in resp
}

Expand All @@ -206,8 +206,8 @@ async def async_get_last_change_datetime(self) -> datetime:
A datetime object.
"""
resp = await self._async_request("get", "posts/update")
maya_dt = maya.parse(resp.attrib["time"])
return cast(datetime, maya_dt.datetime())
parsed = arrow.get(resp.attrib["time"])
return parsed.datetime

async def async_get_recent_bookmarks(
self,
Expand Down
6 changes: 3 additions & 3 deletions aiopinboard/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from datetime import datetime

import maya
import arrow
from defusedxml import ElementTree


Expand Down Expand Up @@ -34,8 +34,8 @@ def async_create_note_from_xml(tree: ElementTree) -> Note:
tree.attrib["id"],
tree[0].text,
tree[1].text,
maya.parse(tree[2].text).datetime(),
maya.parse(tree[3].text).datetime(),
arrow.get(tree[2].text).datetime,
arrow.get(tree[3].text).datetime,
int(tree[4].text),
)

Expand Down
284 changes: 32 additions & 252 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ include = [

[tool.poetry.dependencies]
aiohttp = ">=3.8.0"
arrow = "^1.3.0"
certifi = ">=2023.07.22"
defusedxml = "^0.7.0"
maya = "^0.6.1"
python = "^3.9.0"

[tool.poetry.group.dev.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/posts_all_response.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<posts user="auser" dt="2020-09-02T03:43:26Z">
<post href="https://mylink.com" time="2020-09-02t03:59:55z" description="A really neat website!" extended="I saved this bookmark to Pinboard" tag="tag1 tag2" hash="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" shared="no" toread="yes" />
<post href="https://mylink.com" time="2020-09-02T03:59:55Z" description="A really neat website!" extended="I saved this bookmark to Pinboard" tag="tag1 tag2" hash="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" shared="no" toread="yes" />
</posts>
2 changes: 1 addition & 1 deletion tests/fixtures/posts_recent_response.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<posts user="auser" dt="2020-09-02T03:43:26Z">
<post href="https://mylink.com" time="2020-09-02t03:59:55z" description="A really neat website!" extended="I saved this bookmark to Pinboard" tag="tag1 tag2" hash="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" shared="no" toread="yes" />
<post href="https://mylink.com" time="2020-09-02T03:59:55Z" description="A really neat website!" extended="I saved this bookmark to Pinboard" tag="tag1 tag2" hash="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" shared="no" toread="yes" />
</posts>
8 changes: 4 additions & 4 deletions tests/test_bookmark_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test the API."""
from datetime import datetime, timedelta, timezone

import maya
import arrow
import pytest
from aiohttp import ClientSession
from aresponses import ResponsesMockServer
Expand Down Expand Up @@ -214,9 +214,9 @@ async def test_get_dates(aresponses: ResponsesMockServer) -> None:

dates = await api.bookmark.async_get_dates(tags=["tag1", "tag2"])
assert dates == {
maya.parse("2020-09-05").datetime().date(): 1,
maya.parse("2020-09-04").datetime().date(): 1,
maya.parse("2020-09-03").datetime().date(): 3,
arrow.get("2020-09-05").datetime.date(): 1,
arrow.get("2020-09-04").datetime.date(): 1,
arrow.get("2020-09-03").datetime.date(): 3,
}


Expand Down