t-office-365
Advanced tools
+2
-2
@@ -1,4 +0,4 @@ | ||
| Metadata-Version: 2.2 | ||
| Metadata-Version: 2.4 | ||
| Name: t_office_365 | ||
| Version: 0.1.24 | ||
| Version: 0.1.25 | ||
| Summary: An open-source Python package, t_office_365 providing easy-to-use classes and methods for interacting with Microsoft Office 365 services, including SharePoint, OneDrive, Outlook, and Excel, with features such as file management, email handling, and spreadsheet operations. | ||
@@ -5,0 +5,0 @@ Home-page: https://www.thoughtful.ai/ |
+1
-1
| [bumpversion] | ||
| current_version = 0.1.24 | ||
| current_version = 0.1.25 | ||
| commit = True | ||
@@ -4,0 +4,0 @@ tag = False |
+1
-1
@@ -31,5 +31,5 @@ #!/usr/bin/env python | ||
| url="https://www.thoughtful.ai/", | ||
| version="0.1.24", | ||
| version="0.1.25", | ||
| zip_safe=False, | ||
| install_requires=install_requirements, | ||
| ) |
@@ -1,4 +0,4 @@ | ||
| Metadata-Version: 2.2 | ||
| Metadata-Version: 2.4 | ||
| Name: t_office_365 | ||
| Version: 0.1.24 | ||
| Version: 0.1.25 | ||
| Summary: An open-source Python package, t_office_365 providing easy-to-use classes and methods for interacting with Microsoft Office 365 services, including SharePoint, OneDrive, Outlook, and Excel, with features such as file management, email handling, and spreadsheet operations. | ||
@@ -5,0 +5,0 @@ Home-page: https://www.thoughtful.ai/ |
@@ -5,3 +5,3 @@ """Top-level package for t-office-365.""" | ||
| __email__ = "support@thoughtful.ai" | ||
| __version__ = "0.1.24" | ||
| __version__ = "0.1.25" | ||
@@ -8,0 +8,0 @@ from .drive.excel import Excel |
@@ -5,2 +5,2 @@ """Top-level package for t_office_365/drive.""" | ||
| __email__ = "support@thoughtful.ai" | ||
| __version__ = "0.1.24" | ||
| __version__ = "0.1.25" |
@@ -27,2 +27,7 @@ """Drive class for managing OneDrive and Sharepoint API calls.""" | ||
| @abstractmethod | ||
| def root_site(self, *args, **kwargs): | ||
| """Get the drive ID for the root site.""" | ||
| raise NotImplementedError | ||
| def get_available_sites(self) -> list: | ||
@@ -29,0 +34,0 @@ """Get a list of existing sites. |
@@ -17,10 +17,12 @@ """SharePoint class.""" | ||
| def __init__(self, account: Account, site_name: str) -> None: | ||
| def __init__(self, account: Account, site_name: str, drive_name: str = None) -> None: | ||
| """Initializes instance of the SharepointService class. | ||
| :param: | ||
| - account: The account object containing the authentication information. | ||
| - site_name: The name of microsoft office site. | ||
| - account (Account): The account object containing the authentication information. | ||
| - site_name (str): The name of Microsoft Office site. | ||
| - drive_name (str): Optional. The name of the desired Drive inside the site. | ||
| """ | ||
| self.__site_name = site_name | ||
| self.__drive_name = drive_name | ||
| super().__init__(account) | ||
@@ -42,13 +44,51 @@ | ||
| check_result(result, url) | ||
| return result.json()["value"][0]["id"] | ||
| if not self.__drive_name: | ||
| return result.json()["value"][0]["id"] | ||
| return next((drive["id"] for drive in result.json()["value"] if drive["name"] == self.__drive_name), "") | ||
| class SharepointRootSite(DriveSite, ABC): | ||
| """Represents a SharePoint root site in Microsoft Office 365. | ||
| Provides access to SharePoint-specific services and Excel functionality. | ||
| """ | ||
| def __init__(self, account: Account, drive_name: str) -> None: | ||
| """Initializes instance of the SharepointRootSite class. | ||
| :param: | ||
| - account (Account): The account object containing the authentication information. | ||
| - drive_name (str): Optional. The name of the desired Drive inside the root site. | ||
| """ | ||
| self.__drive_name = drive_name | ||
| super().__init__(account) | ||
| def _get_drive_id(self) -> str: | ||
| """Get the Drive ID for SharePoint. | ||
| :return: | ||
| - str: The ID of the SharePoint Drive. | ||
| """ | ||
| site_id = self.account.sharepoint().get_root_site().object_id | ||
| url = self.get_url(f"/sites/{site_id}/drives") | ||
| result = requests.get(url, headers=self.headers()) | ||
| check_result(result, url) | ||
| return next((drive["id"] for drive in result.json()["value"] if drive["name"] == self.__drive_name), "") | ||
| class Sharepoint(Drive): | ||
| """SharePoint class is used for API calls to SharePoint.""" | ||
| def site(self, site_name: str) -> SharepointSite: | ||
| def site(self, site_name: str, drive_name: str = None) -> SharepointSite: | ||
| """Get a SharePoint site by its name. | ||
| Used to access Sharepoints that have different sites configured, usually their URL will follow the pattern: | ||
| - https://your_domain.sharepoint.com/sites/your_site/forms | ||
| For the given example, 'sites/your_site' would be the site name. | ||
| :param: | ||
| - site_name: The name of the SharePoint site. | ||
| - site_name (str): The name of the SharePoint site. | ||
| - drive_name (str): Optional. The name of the desired Drive inside the site. | ||
@@ -58,2 +98,17 @@ :return: | ||
| """ | ||
| return SharepointSite(self.account, site_name) | ||
| return SharepointSite(self.account, site_name, drive_name) | ||
| def root_site(self, drive_name: str) -> SharepointRootSite: | ||
| """Get a SharePoint site by its root site drive name. | ||
| Some Sharepoints are not configured to use different sites. | ||
| Instead, all drives are listed for the root site. Bellow is an example URL of how you can identify that: | ||
| - https://your_domain.sharepoint.com/drive_name/forms | ||
| :param: | ||
| - drive_name (str): The name of the drive available for the root site. | ||
| :return: | ||
| - A SharepointRootSite object representing the specified SharePoint root site. | ||
| """ | ||
| return SharepointRootSite(self.account, drive_name) |
@@ -5,3 +5,3 @@ """This module for t_office_365 package api endpoints.""" | ||
| __email__ = "support@thoughtful.ai" | ||
| __version__ = "0.1.24" | ||
| __version__ = "0.1.25" | ||
@@ -8,0 +8,0 @@ from t_office_365.endpoints import drive_api, mail_api, workbook_api |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
69197
3.89%1371
3.39%