Skip to content

Commit c467c3e

Browse files
Merge branch 'dev' into zhiwei/obj-quotas
2 parents b8bb6e0 + 34fbbab commit c467c3e

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
# If extensions (or modules to document with autodoc) are in another directory,
1212
# add these directories to sys.path here. If the directory is relative to the
13-
# documentation root, use os.path.abspath to make it absolute, like shown here.
13+
# documentation root, use Path(...).absolute() to make it absolute, like shown here.
1414
#
15-
import os
1615
import sys
17-
sys.path.insert(0, os.path.abspath('..'))
16+
from pathlib import Path
17+
sys.path.insert(0, str(Path('..').absolute()))
1818

1919

2020
# -- Project information -----------------------------------------------------

linode_api4/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import os
21
from dataclasses import dataclass
2+
from pathlib import Path
33

44
from linode_api4.objects import JSONObject
55

@@ -47,9 +47,9 @@ def load_and_validate_keys(authorized_keys):
4747
ret.append(k)
4848
else:
4949
# it doesn't appear to be a key.. is it a path to the key?
50-
k = os.path.expanduser(k)
51-
if os.path.isfile(k):
52-
with open(k) as f:
50+
k_path = Path(k).expanduser()
51+
if k_path.is_file():
52+
with open(k_path) as f:
5353
ret.append(f.read().rstrip())
5454
else:
5555
raise ValueError(

linode_api4/groups/linode.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import base64
2-
import os
2+
from pathlib import Path
33
from typing import Any, Dict, List, Optional, Union
44

55
from linode_api4.common import load_and_validate_keys
@@ -457,8 +457,9 @@ def stackscript_create(
457457
script_body = script
458458
if not script.startswith("#!"):
459459
# it doesn't look like a stackscript body, let's see if it's a file
460-
if os.path.isfile(script):
461-
with open(script) as f:
460+
script_path = Path(script)
461+
if script_path.is_file():
462+
with open(script_path) as f:
462463
script_body = f.read()
463464
else:
464465
raise ValueError(

linode_api4/groups/profile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import os
21
from datetime import datetime
2+
from pathlib import Path
33

44
from linode_api4 import UnexpectedResponseError
55
from linode_api4.common import SSH_KEY_TYPES
@@ -322,9 +322,9 @@ def ssh_key_upload(self, key, label):
322322
"""
323323
if not key.startswith(SSH_KEY_TYPES):
324324
# this might be a file path - look for it
325-
path = os.path.expanduser(key)
326-
if os.path.isfile(path):
327-
with open(path) as f:
325+
key_path = Path(key).expanduser()
326+
if key_path.is_file():
327+
with open(key_path) as f:
328328
key = f.read().strip()
329329
if not key.startswith(SSH_KEY_TYPES):
330330
raise ValueError("Invalid SSH Public Key")

linode_api4/objects/nodebalancer.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os
1+
from pathlib import Path
22
from urllib import parse
33

44
from linode_api4.common import Price, RegionPrice
@@ -220,12 +220,14 @@ def load_ssl_data(self, cert_file, key_file):
220220

221221
# we're disabling warnings here because these attributes are defined dynamically
222222
# through linode.objects.Base, and pylint isn't privy
223-
if os.path.isfile(os.path.expanduser(cert_file)):
224-
with open(os.path.expanduser(cert_file)) as f:
223+
cert_path = Path(cert_file).expanduser()
224+
if cert_path.is_file():
225+
with open(cert_path) as f:
225226
self.ssl_cert = f.read()
226227

227-
if os.path.isfile(os.path.expanduser(key_file)):
228-
with open(os.path.expanduser(key_file)) as f:
228+
key_path = Path(key_file).expanduser()
229+
if key_path.is_file():
230+
with open(key_path) as f:
229231
self.ssl_key = f.read()
230232

231233

0 commit comments

Comments
 (0)