diff --git a/src/pcloud/oauth2.py b/src/pcloud/oauth2.py index db2dd70..babae18 100644 --- a/src/pcloud/oauth2.py +++ b/src/pcloud/oauth2.py @@ -11,6 +11,7 @@ PORT = 65432 REDIRECT_URL = f"http://localhost:{PORT}/" +AUTHORIZE_URL = f"https://my.pcloud.com/oauth2/authorize" class HTTPServerHandler(BaseHTTPRequestHandler): @@ -47,7 +48,7 @@ class TokenHandler(object): def __init__(self, client_id): self._id = client_id - self.auth_url = f"https://my.pcloud.com/oauth2/authorize?response_type=code&redirect_uri={self.redirect_url}&client_id={self._id}" + self.auth_url = f"{AUTHORIZE_URL}?response_type=code&redirect_uri={self.redirect_url}&client_id={self._id}" def open_browser(self): """Hook which is called before request is handled.""" diff --git a/src/pcloud/pcloudfs.py b/src/pcloud/pcloudfs.py index 37c146f..d9e5b6d 100644 --- a/src/pcloud/pcloudfs.py +++ b/src/pcloud/pcloudfs.py @@ -3,19 +3,18 @@ import os import tempfile +from contextlib import closing +from datetime import datetime +from fs import errors +from fs.enums import ResourceType from fs.base import FS from fs.info import Info from fs.opener import Opener -from fs import errors -from fs.enums import ResourceType -from fs.path import abspath, dirname +from fs.path import abspath +from fs.path import dirname from fs.mode import Mode from fs.subfs import SubFS from pcloud import api -from fs.enums import ResourceType -from contextlib import closing - -from datetime import datetime DT_FORMAT_STRING = "%a, %d %b %Y %H:%M:%S %z" @@ -359,7 +358,7 @@ def remove(self, path): _path = self.validatepath(path) if not self.exists(_path): raise errors.ResourceNotFound(path=_path) - if self.getinfo(_path).is_dir == True: + if self.getinfo(_path).is_dir: raise errors.FileExpected(_path) with self._lock: resp = self.pcloud.deletefile(path=_path) @@ -371,7 +370,7 @@ def removedir(self, path): if not self.exists(_path): raise errors.ResourceNotFound(path=_path) info = self.getinfo(_path) - if info.is_dir == False: + if not info.is_dir: raise errors.DirectoryExpected(_path) if not self.isempty(_path): raise errors.DirectoryNotEmpty(_path) @@ -384,7 +383,7 @@ def removetree(self, dir_path): _path = self.validatepath(dir_path) if not self.exists(_path): raise errors.ResourceNotFound(path=_path) - if self.getinfo(_path).is_dir == False: + if not self.getinfo(_path).is_dir: raise errors.DirectoryExpected(_path) with self._lock: resp = self.pcloud.deletefolderrecursive(path=_path) diff --git a/src/pcloud/tests/test_integration.py b/src/pcloud/tests/test_integration.py index 8d4490e..f41872d 100644 --- a/src/pcloud/tests/test_integration.py +++ b/src/pcloud/tests/test_integration.py @@ -3,12 +3,10 @@ import time import zipfile -from fs import opener from io import BytesIO from pathlib import Path from pcloud.api import PyCloud from pcloud.api import O_CREAT -from urllib.parse import quote @pytest.fixture