From 311d3a1965b308907ea3a7aeebee67fdccc7fa5f Mon Sep 17 00:00:00 2001 From: vgrem Date: Fri, 6 Dec 2024 13:52:40 +0200 Subject: [PATCH] a few examples and linter fixes --- examples/outlook/messages/search.py | 2 +- generator/generate_model.py | 2 - generator/metadata/SharePoint.xml | 216 +++++++++++++++++++++++----- office365/search/entity.py | 8 +- office365/search/request.py | 4 +- 5 files changed, 191 insertions(+), 41 deletions(-) diff --git a/examples/outlook/messages/search.py b/examples/outlook/messages/search.py index 195ef7fe..fa89ef13 100644 --- a/examples/outlook/messages/search.py +++ b/examples/outlook/messages/search.py @@ -13,4 +13,4 @@ result = client.search.query_messages("Meet for lunch?").execute_query() for item in result.value: for hit in item.hitsContainers[0].hits: - print(hit.resource.get("webLink")) + print(hit.resource.get_property("webLink")) diff --git a/generator/generate_model.py b/generator/generate_model.py index 37f1425b..d23127af 100644 --- a/generator/generate_model.py +++ b/generator/generate_model.py @@ -1,8 +1,6 @@ -from configparser import ConfigParser from generator import load_settings from generator.builders.type_builder import TypeBuilder -from office365.runtime.odata.model import ODataModel from office365.runtime.odata.v3.metadata_reader import ODataV3Reader from office365.runtime.odata.v4.metadata_reader import ODataV4Reader diff --git a/generator/metadata/SharePoint.xml b/generator/metadata/SharePoint.xml index a55a4d1a..e7fc00d9 100644 --- a/generator/metadata/SharePoint.xml +++ b/generator/metadata/SharePoint.xml @@ -903,6 +903,7 @@ + @@ -922,6 +923,7 @@ + @@ -1717,6 +1719,8 @@ + + @@ -1744,6 +1748,8 @@ + + @@ -2465,10 +2471,14 @@ + + + + @@ -8743,6 +8753,10 @@ + + + + @@ -8865,7 +8879,6 @@ - @@ -8965,6 +8978,10 @@ + + + + @@ -9211,6 +9228,10 @@ + + + + @@ -9427,6 +9448,10 @@ + + + + @@ -9628,6 +9653,10 @@ + + + + @@ -9859,6 +9888,10 @@ + + + + @@ -10592,10 +10625,29 @@ + + + + + + + + + + + + + + + + + + + @@ -10612,6 +10664,9 @@ + + + @@ -12025,6 +12080,9 @@ + + + @@ -12367,16 +12425,6 @@ - - - - - - - - - - @@ -13118,17 +13166,6 @@ - - - - - - - - - - - @@ -13830,6 +13867,10 @@ + + + + @@ -16956,6 +16997,9 @@ + + + @@ -17365,6 +17409,9 @@ + + + @@ -17937,12 +17984,14 @@ + + @@ -18134,6 +18183,13 @@ + + + + + + + @@ -21194,6 +21250,9 @@ + + + @@ -22661,6 +22720,12 @@ + + + + + + @@ -22856,6 +22921,12 @@ + + + + + + @@ -24012,6 +24083,12 @@ + + + + + + @@ -24021,6 +24098,12 @@ + + + + + + @@ -24297,6 +24380,9 @@ + + + @@ -25314,6 +25400,9 @@ + + + @@ -26004,6 +26093,9 @@ + + + @@ -26103,7 +26195,7 @@ - + @@ -26193,6 +26285,9 @@ + + + @@ -26334,6 +26429,9 @@ + + + @@ -26454,6 +26552,9 @@ + + + @@ -26613,6 +26714,9 @@ + + + @@ -26784,6 +26888,9 @@ + + + @@ -27696,9 +27803,6 @@ - - - @@ -27798,9 +27902,6 @@ - - - @@ -27981,7 +28082,7 @@ - + @@ -28887,6 +28988,9 @@ + + + @@ -28967,8 +29071,11 @@ + + + @@ -33067,6 +33174,7 @@ + @@ -34248,6 +34356,10 @@ + + + + @@ -34258,7 +34370,7 @@ - + @@ -36335,9 +36447,12 @@ + + + @@ -36793,17 +36908,21 @@ + + + + @@ -36866,12 +36985,14 @@ + + @@ -36894,8 +37015,10 @@ + + @@ -36905,6 +37028,7 @@ + @@ -36914,7 +37038,9 @@ + + @@ -36924,6 +37050,7 @@ + @@ -36988,6 +37115,10 @@ + + + + @@ -37353,6 +37484,14 @@ + + + + + + + + @@ -37478,6 +37617,7 @@ + @@ -38408,11 +38548,15 @@ + + + + @@ -38531,6 +38675,8 @@ + + @@ -38782,6 +38928,7 @@ + @@ -39064,8 +39211,8 @@ - - + + @@ -39107,6 +39254,7 @@ + @@ -39118,6 +39266,7 @@ + @@ -41230,6 +41379,7 @@ + diff --git a/office365/search/entity.py b/office365/search/entity.py index 395104d5..360d9649 100644 --- a/office365/search/entity.py +++ b/office365/search/entity.py @@ -36,7 +36,7 @@ def query( :param str query_string: Contains the query terms. :param list[str] entity_types: One or more types of resources expected in the response. Possible values are: list, site, listItem, message, event, drive, driveItem, externalItem. - :param int page_from: Specifies the offset for the search results. Offset 0 returns the very first result. Optional. + :param int page_from: Specifies the offset for the search results. Offset 0 returns the very first result. :param int size: The size of the page to be retrieved. The maximum value is 500. Optional. :param bool enable_top_results: This triggers hybrid sort for messages """ @@ -50,7 +50,9 @@ def query( def _patch_hit(search_hit): # type: (SearchHit) -> None - resource_type_name = search_hit.get_property("resource").get('@odata.type', None) + resource_type_name = search_hit.get_property("resource").get( + "@odata.type", None + ) resource_type = EntityType.resolve(resource_type_name) resource = resource_type(self.context, EntityPath()) self.context.pending_request().map_json(search_hit.resource, resource) @@ -73,7 +75,7 @@ def query_messages( ): """Searches Outlook messages. Alias to query method :param str query_string: Contains the query terms. - :param int page_from: Specifies the offset for the search results. Offset 0 returns the very first result. Optional. + :param int page_from: Specifies the offset for the search results. Offset 0 returns the very first result. :param int size: The size of the page to be retrieved. The maximum value is 500. Optional. :param bool enable_top_results: This triggers hybrid sort for messages """ diff --git a/office365/search/request.py b/office365/search/request.py index c179ca0b..cfa1f76e 100644 --- a/office365/search/request.py +++ b/office365/search/request.py @@ -1,4 +1,4 @@ -from typing import Optional, Dict +from typing import Dict, Optional from office365.runtime.client_value import ClientValue from office365.runtime.client_value_collection import ClientValueCollection @@ -70,5 +70,5 @@ def __init__( def to_json(self, json_format=None): # type: (Optional[ODataJsonFormat]) -> Dict json_value = super(SearchRequest, self).to_json(json_format) - json_value['from'] = json_value.pop('page_from', None) + json_value["from"] = json_value.pop("page_from", None) return json_value