Skip to content

Commit

Permalink
autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
purarue committed Sep 12, 2024
1 parent 80efc05 commit 887ab1f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion google_takeout_parser/parse_html/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _parse_html_activity(p: Path) -> Iterator[Res[Activity]]:
data = p.read_text()

def soup_filter(tag: str, data: Dict[str, Any]) -> bool:
return tag == 'div' and 'outer-cell' in data.get('class', '')
return tag == "div" and "outer-cell" in data.get("class", "")

soup = bs4.BeautifulSoup(data, "lxml", parse_only=bs4.SoupStrainer(soup_filter)) # type: ignore[arg-type] # this overload is missing from stubs

Expand Down
4 changes: 3 additions & 1 deletion google_takeout_parser/parse_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def _read_json_data(p: Path) -> Any:
try:
import orjson
except ModuleNotFoundError:
warnings.warn("orjson not found, it can significantly speed up json parsing. Consider installing via 'pip install orjson'. Falling back onto stdlib json")
warnings.warn(
"orjson not found, it can significantly speed up json parsing. Consider installing via 'pip install orjson'. Falling back onto stdlib json"
)
return json.loads(p.read_text())
else:
return orjson.loads(p.read_bytes())
Expand Down
5 changes: 4 additions & 1 deletion google_takeout_parser/time_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def parse_datetime_millis(d: Union[str, float, int]) -> datetime:
# from 3.11, it supports parsing strings ending with Z
parse_json_utc_date = datetime.fromisoformat
else:

def parse_json_utc_date(ds: str) -> datetime:
utc_naive = datetime.fromisoformat(ds.rstrip("Z"))
return utc_naive.replace(tzinfo=timezone.utc)
Expand All @@ -24,4 +25,6 @@ def test_parse_utc_date() -> None:
expected = datetime(2021, 9, 30, 1, 44, 33, tzinfo=timezone.utc)
assert parse_json_utc_date("2021-09-30T01:44:33.000Z") == expected

assert parse_json_utc_date("2023-01-27T22:46:47.389352Z") == datetime(2023, 1, 27, 22, 46, 47, 389352, tzinfo=timezone.utc)
assert parse_json_utc_date("2023-01-27T22:46:47.389352Z") == datetime(
2023, 1, 27, 22, 46, 47, 389352, tzinfo=timezone.utc
)

0 comments on commit 887ab1f

Please sign in to comment.