mbu-dev-shared-components 0.0.50__tar.gz → 0.0.51.post3__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.
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/PKG-INFO +2 -3
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/README.md +0 -1
- {mbu_dev_shared_components-0.0.50/mbu_dev_shared_components/office365 → mbu_dev_shared_components-0.0.51.post3/mbu_dev_shared_components/msoffice365}/sharepoint_api/files.py +83 -29
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components.egg-info/PKG-INFO +2 -3
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components.egg-info/SOURCES.txt +5 -5
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components.egg-info/requires.txt +1 -1
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/pyproject.toml +2 -2
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/.github/workflows/pylint.yml +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/.gitignore +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/.pylintrc +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/LICENSE +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/getorganized/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/getorganized/auth.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/getorganized/cases.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/getorganized/contacts.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/getorganized/documents.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/getorganized/objects.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/google/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/google/api/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/google/api/auth.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/google/workspace/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/google/workspace/alerts.py +0 -0
- {mbu_dev_shared_components-0.0.50/mbu_dev_shared_components/office365 → mbu_dev_shared_components-0.0.51.post3/mbu_dev_shared_components/msoffice365}/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50/mbu_dev_shared_components/office365 → mbu_dev_shared_components-0.0.51.post3/mbu_dev_shared_components/msoffice365}/excel/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50/mbu_dev_shared_components/office365 → mbu_dev_shared_components-0.0.51.post3/mbu_dev_shared_components/msoffice365}/excel/excel_reader.py +0 -0
- {mbu_dev_shared_components-0.0.50/mbu_dev_shared_components/office365 → mbu_dev_shared_components-0.0.51.post3/mbu_dev_shared_components/msoffice365}/sharepoint_api/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/os2forms/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/os2forms/documents.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/os2forms/forms.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/sap/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/sap/create_invoice.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/utils/__init__.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/utils/db_stored_procedure_executor.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/utils/fernet_encryptor.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components/utils/json_handler.py +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components.egg-info/dependency_links.txt +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/mbu_dev_shared_components.egg-info/top_level.txt +0 -0
- {mbu_dev_shared_components-0.0.50 → mbu_dev_shared_components-0.0.51.post3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mbu_dev_shared_components
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.51.post3
|
|
4
4
|
Summary: Shared components to use in RPA projects
|
|
5
5
|
Author-email: MBU <rpa@mbu.aarhus.dk>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -9,12 +9,12 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
9
9
|
Requires-Python: >=3.7
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
|
-
Requires-Dist: shareplum
|
|
13
12
|
Requires-Dist: openpyxl>=3.1.2
|
|
14
13
|
Requires-Dist: pyodbc>=5.1.0
|
|
15
14
|
Requires-Dist: requests_ntlm>=1.2.0
|
|
16
15
|
Requires-Dist: python-dateutil==2.9.*
|
|
17
16
|
Requires-Dist: cryptography>=43.0.0
|
|
17
|
+
Requires-Dist: office365-rest-python-client
|
|
18
18
|
|
|
19
19
|
# mbu-dev-shared-components
|
|
20
20
|
|
|
@@ -60,7 +60,6 @@ Additionally, it provides functionalities to count the total number of rows and
|
|
|
60
60
|
#### - Invoices
|
|
61
61
|
|
|
62
62
|
This module provides the InvoiceCreator class to create invoices in SAP.
|
|
63
|
-
|
|
64
63
|
The InvoiceCreator class offers methods to open a specified business partner, and creat an invoice.
|
|
65
64
|
|
|
66
65
|
- Open business partner
|
|
@@ -42,7 +42,6 @@ Additionally, it provides functionalities to count the total number of rows and
|
|
|
42
42
|
#### - Invoices
|
|
43
43
|
|
|
44
44
|
This module provides the InvoiceCreator class to create invoices in SAP.
|
|
45
|
-
|
|
46
45
|
The InvoiceCreator class offers methods to open a specified business partner, and creat an invoice.
|
|
47
46
|
|
|
48
47
|
- Open business partner
|
|
@@ -30,15 +30,16 @@ Example:
|
|
|
30
30
|
"""
|
|
31
31
|
|
|
32
32
|
from pathlib import PurePath
|
|
33
|
-
from typing import Optional
|
|
34
|
-
|
|
35
|
-
from
|
|
33
|
+
from typing import Optional, List
|
|
34
|
+
import os
|
|
35
|
+
from office365.runtime.auth.user_credential import UserCredential
|
|
36
|
+
from office365.sharepoint.client_context import ClientContext
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
class Sharepoint:
|
|
39
40
|
"""
|
|
40
41
|
A class to interact with a SharePoint site, enabling authentication, file listing,
|
|
41
|
-
downloading, and saving functionalities within a specified SharePoint document library.
|
|
42
|
+
downloading, uploading, and saving functionalities within a specified SharePoint document library.
|
|
42
43
|
|
|
43
44
|
Attributes:
|
|
44
45
|
username (str): Username for authentication.
|
|
@@ -48,32 +49,36 @@ class Sharepoint:
|
|
|
48
49
|
document_library (str): Document library path.
|
|
49
50
|
"""
|
|
50
51
|
|
|
51
|
-
def __init__(
|
|
52
|
+
def __init__(
|
|
53
|
+
self, username: str, password: str, site_url: str, site_name: str, document_library: str
|
|
54
|
+
):
|
|
52
55
|
"""Initializes the Sharepoint class with credentials and site details."""
|
|
53
56
|
self.username = username
|
|
54
57
|
self.password = password
|
|
55
58
|
self.site_url = site_url
|
|
56
59
|
self.site_name = site_name
|
|
57
60
|
self.document_library = document_library
|
|
58
|
-
self.
|
|
61
|
+
self.ctx = self._auth()
|
|
59
62
|
|
|
60
|
-
def _auth(self) -> Optional[
|
|
63
|
+
def _auth(self) -> Optional[ClientContext]:
|
|
61
64
|
"""
|
|
62
|
-
Authenticates to the SharePoint site and returns the
|
|
65
|
+
Authenticates to the SharePoint site and returns the client context.
|
|
63
66
|
|
|
64
67
|
Returns:
|
|
65
|
-
Optional[
|
|
68
|
+
Optional[ClientContext]: A ClientContext object for interacting with the SharePoint site if authentication is successful,
|
|
66
69
|
otherwise None.
|
|
67
70
|
"""
|
|
68
71
|
try:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
site_full_url = f"{self.site_url}/teams/{self.site_name}"
|
|
73
|
+
ctx = ClientContext(site_full_url).with_credentials(
|
|
74
|
+
UserCredential(self.username, self.password)
|
|
75
|
+
)
|
|
76
|
+
return ctx
|
|
72
77
|
except Exception as e:
|
|
73
78
|
print(f"Failed to authenticate: {e}")
|
|
74
79
|
return None
|
|
75
80
|
|
|
76
|
-
def fetch_files_list(self, folder_name: str) -> Optional[
|
|
81
|
+
def fetch_files_list(self, folder_name: str) -> Optional[List[dict]]:
|
|
77
82
|
"""
|
|
78
83
|
Retrieves a list of files from a specified folder within the document library.
|
|
79
84
|
|
|
@@ -81,13 +86,17 @@ class Sharepoint:
|
|
|
81
86
|
folder_name (str): The name of the folder within the document library.
|
|
82
87
|
|
|
83
88
|
Returns:
|
|
84
|
-
list: A list of file dictionaries in the specified folder, or
|
|
89
|
+
list: A list of file dictionaries in the specified folder, or None if an error occurs or if the site is not authenticated.
|
|
85
90
|
"""
|
|
86
|
-
if self.
|
|
91
|
+
if self.ctx:
|
|
87
92
|
try:
|
|
88
|
-
|
|
93
|
+
folder_url = f"/teams/{self.site_name}/{self.document_library}/{folder_name}"
|
|
94
|
+
folder = self.ctx.web.get_folder_by_server_relative_url(folder_url)
|
|
89
95
|
files = folder.files
|
|
90
|
-
|
|
96
|
+
self.ctx.load(files)
|
|
97
|
+
self.ctx.execute_query()
|
|
98
|
+
files_list = [{"Name": file.name} for file in files]
|
|
99
|
+
return files_list
|
|
91
100
|
except Exception as e:
|
|
92
101
|
print(f"Error retrieving files: {e}")
|
|
93
102
|
return None
|
|
@@ -102,13 +111,14 @@ class Sharepoint:
|
|
|
102
111
|
folder_name (str): The name of the folder where the file is located.
|
|
103
112
|
|
|
104
113
|
Returns:
|
|
105
|
-
bytes
|
|
114
|
+
Optional[bytes]: The binary content of the file if successful, otherwise None.
|
|
106
115
|
"""
|
|
107
|
-
if self.
|
|
116
|
+
if self.ctx:
|
|
108
117
|
try:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
file_url = f"/teams/{self.site_name}/{self.document_library}/{folder_name}/{file_name}"
|
|
119
|
+
file = self.ctx.web.get_file_by_server_relative_url(file_url)
|
|
120
|
+
file_content = file.read().execute_query()
|
|
121
|
+
return file_content.value
|
|
112
122
|
except Exception as e:
|
|
113
123
|
print(f"Failed to download file: {e}")
|
|
114
124
|
return None
|
|
@@ -124,7 +134,7 @@ class Sharepoint:
|
|
|
124
134
|
file_content (bytes): The binary content of the file.
|
|
125
135
|
"""
|
|
126
136
|
file_directory_path = PurePath(folder_destination, file_name)
|
|
127
|
-
with open(file_directory_path,
|
|
137
|
+
with open(file_directory_path, "wb") as file:
|
|
128
138
|
file.write(file_content)
|
|
129
139
|
|
|
130
140
|
def download_file(self, folder: str, filename: str, folder_destination: str):
|
|
@@ -151,9 +161,53 @@ class Sharepoint:
|
|
|
151
161
|
folder_destination (str): The local folder path where the downloaded files will be saved.
|
|
152
162
|
"""
|
|
153
163
|
files_list = self.fetch_files_list(folder)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
if files_list:
|
|
165
|
+
for file in files_list:
|
|
166
|
+
file_content = self.fetch_file_content(file["Name"], folder)
|
|
167
|
+
if file_content:
|
|
168
|
+
self._write_file(folder_destination, file["Name"], file_content)
|
|
169
|
+
else:
|
|
170
|
+
print(f"Failed to download {file['Name']}")
|
|
171
|
+
else:
|
|
172
|
+
print(f"No files found in folder {folder}")
|
|
173
|
+
|
|
174
|
+
def upload_file(self, folder_name: str, file_path: str, file_name: Optional[str] = None):
|
|
175
|
+
"""
|
|
176
|
+
Uploads a single file to a specified folder within the document library.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
folder_name (str): The name of the folder within the document library.
|
|
180
|
+
file_path (str): The local path to the file to be uploaded.
|
|
181
|
+
file_name (Optional[str]): The name to give the file in SharePoint. If not provided, uses the name from file_path.
|
|
182
|
+
"""
|
|
183
|
+
if self.ctx:
|
|
184
|
+
try:
|
|
185
|
+
if file_name is None:
|
|
186
|
+
file_name = os.path.basename(file_path)
|
|
187
|
+
|
|
188
|
+
folder_url = f"/teams/{self.site_name}/{self.document_library}/{folder_name}"
|
|
189
|
+
target_folder = self.ctx.web.get_folder_by_server_relative_url(folder_url)
|
|
190
|
+
|
|
191
|
+
with open(file_path, 'rb') as content_file:
|
|
192
|
+
file_content = content_file.read()
|
|
193
|
+
|
|
194
|
+
target_folder.upload_file(file_name, file_content).execute_query()
|
|
195
|
+
print(f"File '{file_name}' uploaded successfully to '{folder_url}'.")
|
|
196
|
+
except Exception as e:
|
|
197
|
+
print(f"Failed to upload file '{file_name}': {e}")
|
|
198
|
+
|
|
199
|
+
def upload_files(self, folder_name: str, files: List[str]):
|
|
200
|
+
"""
|
|
201
|
+
Uploads multiple files to a specified folder within the document library.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
folder_name (str): The name of the folder within the document library.
|
|
205
|
+
files (List[str]): A list of local file paths to be uploaded.
|
|
206
|
+
"""
|
|
207
|
+
if self.ctx:
|
|
208
|
+
for file_path in files:
|
|
209
|
+
try:
|
|
210
|
+
file_name = os.path.basename(file_path)
|
|
211
|
+
self.upload_file(folder_name, file_path, file_name)
|
|
212
|
+
except Exception as e:
|
|
213
|
+
print(f"Failed to upload file '{file_path}': {e}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mbu_dev_shared_components
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.51.post3
|
|
4
4
|
Summary: Shared components to use in RPA projects
|
|
5
5
|
Author-email: MBU <rpa@mbu.aarhus.dk>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -9,12 +9,12 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
9
9
|
Requires-Python: >=3.7
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
|
-
Requires-Dist: shareplum
|
|
13
12
|
Requires-Dist: openpyxl>=3.1.2
|
|
14
13
|
Requires-Dist: pyodbc>=5.1.0
|
|
15
14
|
Requires-Dist: requests_ntlm>=1.2.0
|
|
16
15
|
Requires-Dist: python-dateutil==2.9.*
|
|
17
16
|
Requires-Dist: cryptography>=43.0.0
|
|
17
|
+
Requires-Dist: office365-rest-python-client
|
|
18
18
|
|
|
19
19
|
# mbu-dev-shared-components
|
|
20
20
|
|
|
@@ -60,7 +60,6 @@ Additionally, it provides functionalities to count the total number of rows and
|
|
|
60
60
|
#### - Invoices
|
|
61
61
|
|
|
62
62
|
This module provides the InvoiceCreator class to create invoices in SAP.
|
|
63
|
-
|
|
64
63
|
The InvoiceCreator class offers methods to open a specified business partner, and creat an invoice.
|
|
65
64
|
|
|
66
65
|
- Open business partner
|
|
@@ -20,11 +20,11 @@ mbu_dev_shared_components/google/api/__init__.py
|
|
|
20
20
|
mbu_dev_shared_components/google/api/auth.py
|
|
21
21
|
mbu_dev_shared_components/google/workspace/__init__.py
|
|
22
22
|
mbu_dev_shared_components/google/workspace/alerts.py
|
|
23
|
-
mbu_dev_shared_components/
|
|
24
|
-
mbu_dev_shared_components/
|
|
25
|
-
mbu_dev_shared_components/
|
|
26
|
-
mbu_dev_shared_components/
|
|
27
|
-
mbu_dev_shared_components/
|
|
23
|
+
mbu_dev_shared_components/msoffice365/__init__.py
|
|
24
|
+
mbu_dev_shared_components/msoffice365/excel/__init__.py
|
|
25
|
+
mbu_dev_shared_components/msoffice365/excel/excel_reader.py
|
|
26
|
+
mbu_dev_shared_components/msoffice365/sharepoint_api/__init__.py
|
|
27
|
+
mbu_dev_shared_components/msoffice365/sharepoint_api/files.py
|
|
28
28
|
mbu_dev_shared_components/os2forms/__init__.py
|
|
29
29
|
mbu_dev_shared_components/os2forms/documents.py
|
|
30
30
|
mbu_dev_shared_components/os2forms/forms.py
|
|
@@ -17,12 +17,12 @@ classifiers = [
|
|
|
17
17
|
"Operating System :: Microsoft :: Windows",
|
|
18
18
|
]
|
|
19
19
|
dependencies = [
|
|
20
|
-
"shareplum",
|
|
21
20
|
"openpyxl >= 3.1.2",
|
|
22
21
|
"pyodbc >= 5.1.0",
|
|
23
22
|
"requests_ntlm >= 1.2.0",
|
|
24
23
|
"python-dateutil == 2.9.*",
|
|
25
|
-
"cryptography >= 43.0.0"
|
|
24
|
+
"cryptography >= 43.0.0",
|
|
25
|
+
"office365-rest-python-client",
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
[tool.setuptools_scm]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|