Skip to content

Commit ce6eb06

Browse files
Use pathlib
1 parent ed6d81f commit ce6eb06

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

mopidy_spotify/backend.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import os
2-
31
import pykka
42
from mopidy import backend
53

@@ -42,14 +40,14 @@ def __init__(self, *args, **kwargs):
4240
self._data_location = Extension().get_data_dir(self.backend._config)
4341
self._config = self.backend._config["spotify"]
4442

43+
self._credentials_dir = self._data_location / "credentials-cache"
44+
if not self._credentials_dir.exists():
45+
self._credentials_dir.mkdir(mode=0o700)
46+
4547
def on_source_setup(self, source):
4648
for prop in ["username", "password", "bitrate"]:
4749
source.set_property(prop, str(self._config[prop]))
48-
credentials_dir = os.path.join(self._data_location, "credentials-cache")
49-
if not os.path.exists(credentials_dir):
50-
os.makedirs(self._data_location, exist_ok=True)
51-
os.mkdir(credentials_dir, 0o700)
52-
source.set_property("cache-credentials", credentials_dir)
50+
source.set_property("cache-credentials", self._credentials_dir)
5351
if self._config["allow_cache"]:
5452
source.set_property("cache-files", self._cache_location)
5553
source.set_property(

0 commit comments

Comments
 (0)