-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d36aedd
commit 586e9e5
Showing
7 changed files
with
9 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "0.3.1dev2" | ||
__version__ = "0.4.0" | ||
|
||
import logging | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,4 @@ | ||
"""OneDrive instance constructor classes. | ||
"""OneDrive Class and Context Manager. | ||
""" | ||
from __future__ import annotations | ||
|
||
import warnings | ||
from pathlib import Path | ||
|
||
from graph_onedrive._manager import OneDriveManager | ||
from graph_onedrive._onedrive import OneDrive | ||
|
||
# The following functions are depreciated and will be removed completely in a future release. | ||
|
||
|
||
def create( | ||
client_id: str, | ||
client_secret: str, | ||
tenant: str = "common", | ||
redirect_url: str = "http://localhost:8080", | ||
refresh_token: str | None = None, | ||
) -> OneDrive: | ||
"""DEPRECIATED: use OneDrive() instead. | ||
Create an instance of the OneDrive class from arguments. | ||
Positional arguments: | ||
client_id (str) -- Azure app client id | ||
client_secret (str) -- Azure app client secret | ||
Keyword arguments: | ||
tenant (str) -- Azure app org tentent id number, use default if multi-tenant (default = "common") | ||
redirect_url (str) -- Authentication redirection url (default = "http://localhost:8080") | ||
refresh_token (str) -- optional token from previous session (default = None) | ||
Returns: | ||
onedrive_instance (OneDrive) -- OneDrive object instance | ||
""" | ||
# Warn to use class directly | ||
warnings.warn( | ||
"create() depreciated, use OneDrive()", | ||
category=DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
# Return the OneDrive object instance | ||
return OneDrive( | ||
client_id=client_id, | ||
client_secret=client_secret, | ||
tenant=tenant, | ||
redirect_url=redirect_url, | ||
refresh_token=refresh_token, | ||
) | ||
|
||
|
||
def create_from_config_file( | ||
config_path: str | Path, config_key: str = "onedrive" | ||
) -> OneDrive: | ||
"""DEPRECIATED: use OneDrive.from_json() instead. | ||
Create an instance of the OneDrive class from a config file. | ||
Positional arguments: | ||
config_path (str|Path) -- path to configuration json file | ||
Keyword arguments: | ||
config_key (str) -- key of the json item storing the configuration (default = "onedrive") | ||
Returns: | ||
onedrive_instance (OneDrive) -- OneDrive object instance | ||
""" | ||
# Warn to use class directly | ||
warnings.warn( | ||
"create_from_config_file() depreciated, use OneDrive.from_json()", | ||
category=DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
# Return the OneDrive instance | ||
return OneDrive.from_file(config_path, config_key) | ||
|
||
|
||
def save_to_config_file( | ||
onedrive_instance: OneDrive, | ||
config_path: str | Path, | ||
config_key: str = "onedrive", | ||
) -> None: | ||
"""DEPRECIATED: use OneDrive.to_json() instead. | ||
Save the configuration to a json config file. | ||
Positional arguments: | ||
onedrive_instance (OneDrive) -- instance with the config to save | ||
config_path (str|Path) -- path to configuration json file | ||
Keyword arguments: | ||
config_key (str) -- key of the json item storing the configuration (default = "onedrive") | ||
""" | ||
# Check types | ||
if not isinstance(onedrive_instance, OneDrive): | ||
raise TypeError( | ||
f"onedrive_instance expected 'OneDrive', got {type(onedrive_instance).__name__!r}" | ||
) | ||
# Warn to use class directly | ||
warnings.warn( | ||
"save_to_config_file() depreciated, use OneDrive.to_json()", | ||
category=DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
# Save to json | ||
onedrive_instance.to_file(config_path, config_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.