brynq-sdk-sharepoint 1.0.1__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_sharepoint
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: Sharepoint wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -96,8 +96,10 @@ class Sharepoint(BrynQ):
96
96
  headers_upload = {'Content-Type': 'application/json',
97
97
  'Content-Length': f'{file_bytes}',
98
98
  'Content-Range': f'bytes 0-{file_bytes - 1}/{file_bytes}'}
99
- response_upload = requests.put(url=upload_url, headers=headers_upload, data=file_input)
100
- response_upload.raise_for_status()
99
+ response_upload = requests.put(url=upload_url, headers=headers_upload, data=file_input)
100
+ response_upload.raise_for_status()
101
+
102
+ return response_upload
101
103
 
102
104
  def open_file(self, remote_file_path: str) -> bytes:
103
105
  """
@@ -137,6 +139,8 @@ class Sharepoint(BrynQ):
137
139
  with open(file=f'{local_file_path}', mode='wb') as f:
138
140
  f.write(BytesIO(response_download.content).read())
139
141
 
142
+ return response_download
143
+
140
144
  def download_files(self, local_folder_path: str, remote_folder_path: str):
141
145
  """
142
146
  This method downloads a file from sharepoint to the local machine.
@@ -150,6 +154,8 @@ class Sharepoint(BrynQ):
150
154
  if self.debug:
151
155
  print(f"folder_content: {folder_content}")
152
156
  filecount = 0
157
+
158
+ responses = []
153
159
  for file in folder_content:
154
160
  url = f'https://graph.microsoft.com/v1.0/sites/{self.site_id}/drives/{driveid}/root:/{remote_folder_path}{file["name"]}'
155
161
  if self.debug:
@@ -162,8 +168,11 @@ class Sharepoint(BrynQ):
162
168
  with open(file=f'{local_folder_path}{file["name"]}', mode='wb') as f:
163
169
  f.write(BytesIO(response_download.content).read())
164
170
  filecount += 1
171
+ responses.append(response_download)
165
172
  print(f'{filecount} files downloaded')
166
173
 
174
+ return responses
175
+
167
176
  def list_dir(self, remote_folder_path: str, get_files_from_nested_folders: bool = False) -> [json, typing.Generator]:
168
177
  """
169
178
  Fetch the contents of the API and return the "children"
@@ -205,6 +214,8 @@ class Sharepoint(BrynQ):
205
214
  response = requests.delete(url=url, headers=self._get_sharepoint_headers())
206
215
  response.raise_for_status()
207
216
 
217
+ return response
218
+
208
219
  def remove_files(self, remote_folder_path: str):
209
220
  """
210
221
  Remove a file from Sharepoint
@@ -212,12 +223,16 @@ class Sharepoint(BrynQ):
212
223
  """
213
224
  drive_id = self.get_driveid()
214
225
  folder_content = self.list_dir(remote_folder_path=remote_folder_path)
226
+ responses = []
215
227
  for file in folder_content:
216
228
  url = f'https://graph.microsoft.com/v1.0/sites/{self.site_id}/drives/{drive_id}/root:/{remote_folder_path}{file["name"]}'
217
229
  if self.debug:
218
230
  print(f"url: {url}")
219
231
  response = requests.delete(url=url, headers=self._get_sharepoint_headers())
220
232
  response.raise_for_status()
233
+ responses.append(response)
234
+
235
+ return responses
221
236
 
222
237
  def remove_folder(self, folder_id: str):
223
238
  """
@@ -229,4 +244,6 @@ class Sharepoint(BrynQ):
229
244
  if self.debug:
230
245
  print(f"url: {url}")
231
246
  response = requests.delete(url=url, headers=self._get_sharepoint_headers())
232
- response.raise_for_status()
247
+ response.raise_for_status()
248
+
249
+ return response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-sharepoint
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: Sharepoint wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
 
4
4
  setup(
5
5
  name='brynq_sdk_sharepoint',
6
- version='1.0.1',
6
+ version='1.1.0',
7
7
  description='Sharepoint wrapper from BrynQ',
8
8
  long_description='Sharepoint wrapper from BrynQ',
9
9
  author='BrynQ',