Skip to content

Commit b37068a

Browse files
committed
Switch from import pathlib to from pathlib import Path
For alexwlchan/alexwlchan#20
1 parent 4c335fa commit b37068a

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

cog_helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
import os
11-
import pathlib
11+
from pathlib import Path
1212
import textwrap
1313
from typing import TypedDict
1414

@@ -49,7 +49,7 @@ def create_description_table(
4949
if ignore_files is None:
5050
ignore_files = set()
5151

52-
folder = pathlib.Path(folder_name)
52+
folder = Path(folder_name)
5353

5454
for f in ignore_files:
5555
if not (folder / f).exists():

images/save_xkcd.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
import json
1010
import os
11-
import pathlib
11+
from pathlib import Path
1212
import sys
1313
from urllib.request import urlretrieve
1414

1515
import httpx
1616

17-
BACKUP_ROOT = pathlib.Path("/Volumes/Media (Sapphire)/backups/xkcd")
17+
BACKUP_ROOT = Path("/Volumes/Media (Sapphire)/backups/xkcd")
1818

1919

2020
if __name__ == "__main__":

images/squarify.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
Creates a square crop of an image.
44
"""
55

6-
import pathlib
6+
from pathlib import Path
77
import sys
88

99
from PIL import Image
1010

1111

1212
if __name__ == '__main__':
1313
try:
14-
path = pathlib.Path(sys.argv[1])
14+
path = Path(sys.argv[1])
1515
except IndexError:
1616
sys.exit(f"Usage: {__file__} IMAGE_PATH")
1717

images/test_srgbify.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import filecmp
2-
import pathlib
2+
from pathlib import Path
33

44
from PIL import Image
55

@@ -66,7 +66,7 @@ def test_it_converts_images_with_a_grey_profile():
6666
assert new_im.mode == "RGB"
6767

6868

69-
def test_it_preserves_rotation_from_exif_orientation(tmp_path: pathlib.Path):
69+
def test_it_preserves_rotation_from_exif_orientation(tmp_path: Path):
7070
"""
7171
This is based on a photo exported from my Apple Photos Library
7272
which was rotated by 90 degrees upon transformation.

textexpander/get_mastodon_text.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
import datetime
88
import html
99
import os
10-
import pathlib
10+
from pathlib import Path
1111
import re
1212
import subprocess
1313

1414
import httpx
1515
import hyperlink
1616

1717

18-
ATTACHMENTS_DIR = pathlib.Path.home() / "textfiles" / "Attachments" / "mastodon"
18+
ATTACHMENTS_DIR = Path.home() / "textfiles" / "Attachments" / "mastodon"
1919

2020

2121
def download(url):

web/save_tumblr_likes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import functools
44
import json
55
import os
6-
import pathlib
6+
from pathlib import Path
77
import shutil
88
import subprocess
99
import sys
@@ -19,7 +19,7 @@
1919
import termcolor
2020

2121

22-
BACKUP_ROOT = pathlib.Path("/Volumes/Media (Sapphire)/backups/tumblr")
22+
BACKUP_ROOT = Path("/Volumes/Media (Sapphire)/backups/tumblr")
2323

2424

2525
def get_liked_posts(blog_identifier: str, days: int):
@@ -87,7 +87,7 @@ def wrapper(**kwargs):
8787
return decorator
8888

8989

90-
def get_saved_blog_name(*, post_id: str, blog_name: str, db_path: pathlib.Path) -> str:
90+
def get_saved_blog_name(*, post_id: str, blog_name: str, db_path: Path) -> str:
9191
"""
9292
Look up the blog name associated with this post ID.
9393
@@ -355,5 +355,5 @@ class CannotDownloadAsset(Exception):
355355
download_tumblr_post(
356356
post_url=post_data["post_url"],
357357
post_data=post_data,
358-
download_root=pathlib.Path(BACKUP_ROOT),
358+
download_root=Path(BACKUP_ROOT),
359359
)

web/save_youtube_videos.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import functools
77
import json
88
import os
9-
import pathlib
9+
from pathlib import Path
1010
import subprocess
1111
import sys
1212
import textwrap
@@ -18,7 +18,7 @@
1818
import termcolor
1919

2020

21-
BACKUP_ROOT = pathlib.Path("/Volumes/Media (Sapphire)/backups/youtube/videos")
21+
BACKUP_ROOT = Path("/Volumes/Media (Sapphire)/backups/youtube/videos")
2222

2323

2424
def youtube_dl(*args, **kwargs):
@@ -87,7 +87,7 @@ def wrapper(**kwargs):
8787

8888

8989
def classify_file_type(
90-
video_id: str, filename: pathlib.Path
90+
video_id: str, filename: Path
9191
) -> Literal["video", "info", "thumbnail", "subtitles"] | None:
9292
"""
9393
Given an already-downloaded file, work out what sort of file it is.
@@ -127,7 +127,7 @@ def classify_file_type(
127127
raise ValueError(f"Unrecognised filename: {filename}")
128128

129129

130-
def fix_info_json(path: pathlib.Path) -> None:
130+
def fix_info_json(path: Path) -> None:
131131
"""
132132
Tidy up the contents of the info.json fie.
133133
"""

0 commit comments

Comments
 (0)