Skip to content

Commit

Permalink
v0.4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
dariobauer committed Feb 24, 2022
1 parent d36aedd commit 586e9e5
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 529 deletions.
9 changes: 7 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

## Unreleased

* Add destination argument to download_file method (Issue [#30](https://github.com/dariobauer/graph-onedrive/issues/30))
* Fixed bug in download_file method when verbose was set to false (Issue [#29](https://github.com/dariobauer/graph-onedrive/issues/29))


## Released

### Version 0.4.0

* Add destination argument to download_file method (Issue [#30](https://github.com/dariobauer/graph-onedrive/issues/30))
* Fixed bug in download_file method when verbose was set to false (Issue [#29](https://github.com/dariobauer/graph-onedrive/issues/29))
* Removed depreciated class constructors & deconstructors `graph_onedrive.create()`, `graph_onedrive.create_from_config_file()`, `graph_onedrive.save_to_config_file()`, `OneDrive.from_json()`, `OneDrive.to_json()`, `OneDrive.from_yaml()`, `OneDrive.to_yaml()`, `OneDrive.from_toml()`, `OneDrive.to_toml()`. Alternative methods are available, refer to the documentation

### Version 0.3.0

Released 2022-01-08
Expand Down
4 changes: 0 additions & 4 deletions docs/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ Returns:

Create an instance of the OneDrive class from a configuration file.

Note `from_json`, `from_yaml`, and `from_toml` are alias of `from_file` and are pending depreciation.

To use yaml and toml config files the corresponding [optional dependencies](#dependencies) are required.

```python
Expand All @@ -371,8 +369,6 @@ Returns:

Save the configuration to a configuration file.

Note `to_json`, `to_yaml`, and `to_toml` are alias of `to_file` and are pending depreciation.

To use yaml or toml config files the corresponding [optional dependencies](#dependencies) are required.

```python
Expand Down
2 changes: 1 addition & 1 deletion src/graph_onedrive/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.3.1dev2"
__version__ = "0.4.0"

import logging

Expand Down
94 changes: 1 addition & 93 deletions src/graph_onedrive/_main.py
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)
127 changes: 0 additions & 127 deletions src/graph_onedrive/_onedrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,133 +239,6 @@ def to_file(
dump_config(config, file_path, config_key)
logger.info(f"saved config to '{file_path}' with key '{config_key}'")

@classmethod
def from_json(
cls,
file_path: str | Path = "config.json",
config_key: str = "onedrive",
save_refresh_token: bool = False,
) -> OneDrive:
"""Create an instance of the OneDrive class from a config json file.
WARNING: from_json will be depreciated in the future, use from_file.
Keyword arguments:
file_path (str|Path) -- path to configuration json file (default = "config.json")
config_key (str) -- key of the json item storing the configuration (default = "onedrive")
save_refresh_token (bool) -- save the refresh token back to the config file during instance initiation (default = False)
Returns:
onedrive_instance (OneDrive) -- OneDrive object instance
"""
warnings.warn(
"from_json will be depreciated in the future, use from_file",
PendingDeprecationWarning,
stacklevel=2,
)
# Pass to generic constructor
return cls.from_file(file_path, config_key, save_refresh_token)

def to_json(
self, file_path: str | Path = "config.json", config_key: str = "onedrive"
) -> None:
"""Save the configuration to a json config file.
WARNING: to_json will be depreciated in the future, use to_file.
Keyword arguments:
file_path (str|Path) -- path to configuration json file (default = "config.json")
config_key (str) -- key of the json item storing the configuration (default = "onedrive")
"""
warnings.warn(
"to_json will be depreciated in the future, use to_file",
PendingDeprecationWarning,
stacklevel=2,
)
# Pass to generic exporter
return self.to_file(file_path, config_key)

@classmethod
def from_yaml(
cls,
file_path: str | Path = "config.yaml",
config_key: str = "onedrive",
save_refresh_token: bool = False,
) -> OneDrive:
"""Create an instance of the OneDrive class from a config yaml file.
WARNING: from_yaml will be depreciated in the future, use from_file.
Note this requires the yaml optional (pip install graph-onedrive[yaml]).
Keyword arguments:
file_path (str|Path) -- path to configuration yaml file (default = "config.yaml")
config_key (str) -- key of the yaml item storing the configuration (default = "onedrive")
save_refresh_token (bool) -- save the refresh token back to the config file during instance initiation (default = False)
Returns:
onedrive_instance (OneDrive) -- OneDrive object instance
"""
warnings.warn(
"from_yaml will be depreciated in the future, use from_file",
PendingDeprecationWarning,
stacklevel=2,
)
# Pass to generic constructor
return cls.from_file(file_path, config_key, save_refresh_token)

def to_yaml(
self, file_path: str | Path = "config.yaml", config_key: str = "onedrive"
) -> None:
"""Save the configuration to a yaml config file.
WARNING: to_yaml will be depreciated in the future, use to_file.
Note this requires the yaml optional (pip install graph-onedrive[yaml]).
Keyword arguments:
file_path (str|Path) -- path to configuration yaml file (default = "config.yaml")
config_key (str) -- key of the yaml item storing the configuration (default = "onedrive")
"""
warnings.warn(
"to_yaml will be depreciated in the future, use to_file",
PendingDeprecationWarning,
stacklevel=2,
)
# Pass to generic exporter
return self.to_file(file_path, config_key)

@classmethod
def from_toml(
cls,
file_path: str | Path = "config.toml",
config_key: str = "onedrive",
save_refresh_token: bool = False,
) -> OneDrive:
"""Create an instance of the OneDrive class from a config toml file.
WARNING: from_toml will be depreciated in the future, use from_file.
Note this requires the toml optional (pip install graph-onedrive[toml]).
Keyword arguments:
file_path (str|Path) -- path to configuration toml file (default = "config.toml")
config_key (str) -- key of the toml item storing the configuration (default = "onedrive")
save_refresh_token (bool) -- save the refresh token back to the config file during instance initiation (default = False)
Returns:
onedrive_instance (OneDrive) -- OneDrive object instance
"""
warnings.warn(
"from_toml will be depreciated in the future, use from_file",
PendingDeprecationWarning,
stacklevel=2,
)
# Pass to generic constructor
return cls.from_file(file_path, config_key, save_refresh_token)

def to_toml(
self, file_path: str | Path = "config.toml", config_key: str = "onedrive"
) -> None:
"""Save the configuration to a toml config file.
WARNING: to_toml will be depreciated in the future, use to_file.
Note this requires the toml optional (pip install graph-onedrive[toml]).
Keyword arguments:
file_path (str|Path) -- path to configuration toml file (default = "config.toml")
config_key (str) -- key of the toml item storing the configuration (default = "onedrive")
"""
warnings.warn(
"to_toml will be depreciated in the future, use to_file",
PendingDeprecationWarning,
stacklevel=2,
)
# Pass to generic exporter
return self.to_file(file_path, config_key)

@staticmethod
def _raise_unexpected_response(
response: httpx.Response,
Expand Down
Loading

0 comments on commit 586e9e5

Please sign in to comment.