wcp-library 1.1.8__py3-none-any.whl → 1.2.1__py3-none-any.whl
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.
- wcp_library/async_sql/oracle.py +11 -7
- wcp_library/async_sql/postgres.py +11 -7
- wcp_library/selenium_helper.py +77 -0
- wcp_library/sql/oracle.py +11 -7
- wcp_library/sql/postgres.py +11 -7
- {wcp_library-1.1.8.dist-info → wcp_library-1.2.1.dist-info}/METADATA +3 -1
- {wcp_library-1.1.8.dist-info → wcp_library-1.2.1.dist-info}/RECORD +8 -7
- {wcp_library-1.1.8.dist-info → wcp_library-1.2.1.dist-info}/WHEEL +0 -0
wcp_library/async_sql/oracle.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import logging
|
2
2
|
from typing import Optional
|
3
3
|
|
4
|
+
import numpy as np
|
4
5
|
import pandas as pd
|
5
6
|
import oracledb
|
6
7
|
from oracledb import AsyncConnectionPool
|
@@ -204,14 +205,17 @@ class AsyncOracleConnection(object):
|
|
204
205
|
bindList.append(':' + column)
|
205
206
|
bind = ', '.join(bindList)
|
206
207
|
|
207
|
-
main_dict = dfObj.to_dict('records')
|
208
208
|
if remove_nan:
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
209
|
+
dfObj = dfObj.replace({np.nan: None})
|
210
|
+
main_dict = dfObj.to_dict('records')
|
211
|
+
|
212
|
+
# if remove_nan:
|
213
|
+
# for val, item in enumerate(main_dict):
|
214
|
+
# for sub_item, value in item.items():
|
215
|
+
# if pd.isna(value):
|
216
|
+
# main_dict[val][sub_item] = None
|
217
|
+
# else:
|
218
|
+
# main_dict[val][sub_item] = value
|
215
219
|
|
216
220
|
query = """INSERT INTO {} ({}) VALUES ({})""".format(outputTableName, col, bind)
|
217
221
|
await self.execute_many(query, main_dict)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import logging
|
2
2
|
from typing import Optional
|
3
3
|
|
4
|
+
import numpy as np
|
4
5
|
import pandas as pd
|
5
6
|
from psycopg.sql import SQL
|
6
7
|
from psycopg_pool import AsyncConnectionPool
|
@@ -187,14 +188,17 @@ class AsyncPostgresConnection(object):
|
|
187
188
|
param_list.append(f"%({column})s")
|
188
189
|
params = ', '.join(param_list)
|
189
190
|
|
190
|
-
main_dict = dfObj.to_dict('records')
|
191
191
|
if remove_nan:
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
192
|
+
dfObj = dfObj.replace({np.nan: None})
|
193
|
+
main_dict = dfObj.to_dict('records')
|
194
|
+
|
195
|
+
# if remove_nan:
|
196
|
+
# for val, item in enumerate(main_dict):
|
197
|
+
# for sub_item, value in item.items():
|
198
|
+
# if pd.isna(value):
|
199
|
+
# main_dict[val][sub_item] = None
|
200
|
+
# else:
|
201
|
+
# main_dict[val][sub_item] = value
|
198
202
|
|
199
203
|
query = """INSERT INTO {} ({}) VALUES ({})""".format(outputTableName, col, params)
|
200
204
|
await self.execute_many(query, main_dict)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
from selenium import webdriver
|
5
|
+
from selenium.webdriver.common.by import By
|
6
|
+
from selenium.webdriver.chrome.service import Service
|
7
|
+
from selenium.webdriver.support import expected_conditions
|
8
|
+
from selenium.webdriver.support.wait import WebDriverWait
|
9
|
+
from selenium.webdriver.remote.webelement import WebElement
|
10
|
+
from webdriver_manager.chrome import ChromeDriverManager
|
11
|
+
|
12
|
+
|
13
|
+
class SeleniumHelper:
|
14
|
+
def __init__(self, headless: bool = False, download_path: Optional[Path] = None):
|
15
|
+
self._headless = headless
|
16
|
+
self._download_path = download_path
|
17
|
+
|
18
|
+
opt = webdriver.ChromeOptions()
|
19
|
+
opt.add_argument("--start-maximized")
|
20
|
+
if headless:
|
21
|
+
opt.add_argument('headless')
|
22
|
+
|
23
|
+
opt.page_load_strategy = 'eager'
|
24
|
+
|
25
|
+
experimental_options_dict = {"download.prompt_for_download": False,
|
26
|
+
"download.directory_upgrade": True,
|
27
|
+
"safebrowsing.enabled": True}
|
28
|
+
if download_path:
|
29
|
+
experimental_options_dict["download.default_directory"] = str(download_path)
|
30
|
+
|
31
|
+
opt.add_experimental_option("prefs", experimental_options_dict)
|
32
|
+
opt.timeouts = {'implicit': 5000}
|
33
|
+
|
34
|
+
self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=opt)
|
35
|
+
|
36
|
+
|
37
|
+
def find_button_by_text(self, text: str) -> WebElement:
|
38
|
+
"""
|
39
|
+
Find a button by its text
|
40
|
+
|
41
|
+
:param text:
|
42
|
+
:return button element:
|
43
|
+
"""
|
44
|
+
|
45
|
+
buttons = self.driver.find_elements(By.TAG_NAME, 'Button')
|
46
|
+
for b in buttons:
|
47
|
+
if b.text == text:
|
48
|
+
return b
|
49
|
+
|
50
|
+
# If there is something weird with the button text, this should find it
|
51
|
+
for b in buttons:
|
52
|
+
if text in b.text:
|
53
|
+
return b
|
54
|
+
|
55
|
+
def find_span_by_text(self, text: str) -> WebElement:
|
56
|
+
"""
|
57
|
+
Find a span by its text
|
58
|
+
|
59
|
+
:param text:
|
60
|
+
:return span element:
|
61
|
+
"""
|
62
|
+
|
63
|
+
buttons = self.driver.find_elements(By.TAG_NAME, 'Span')
|
64
|
+
for b in buttons:
|
65
|
+
if b.text == text:
|
66
|
+
return b
|
67
|
+
|
68
|
+
def wait_until_element_visible(self, css_element: str, timeout: int = 30) -> None:
|
69
|
+
"""
|
70
|
+
Wait until an element is visible
|
71
|
+
|
72
|
+
:param css_element:
|
73
|
+
:param timeout:
|
74
|
+
:return:
|
75
|
+
"""
|
76
|
+
|
77
|
+
WebDriverWait(self.driver, timeout).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, css_element)))
|
wcp_library/sql/oracle.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import logging
|
2
2
|
from typing import Optional
|
3
3
|
|
4
|
+
import numpy as np
|
4
5
|
import pandas as pd
|
5
6
|
import oracledb
|
6
7
|
from oracledb import ConnectionPool
|
@@ -208,14 +209,17 @@ class OracleConnection(object):
|
|
208
209
|
bindList.append(':' + column)
|
209
210
|
bind = ', '.join(bindList)
|
210
211
|
|
211
|
-
main_dict = dfObj.to_dict('records')
|
212
212
|
if remove_nan:
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
213
|
+
dfObj = dfObj.replace({np.nan: None})
|
214
|
+
main_dict = dfObj.to_dict('records')
|
215
|
+
|
216
|
+
# if remove_nan:
|
217
|
+
# for val, item in enumerate(main_dict):
|
218
|
+
# for sub_item, value in item.items():
|
219
|
+
# if pd.isna(value):
|
220
|
+
# main_dict[val][sub_item] = None
|
221
|
+
# else:
|
222
|
+
# main_dict[val][sub_item] = value
|
219
223
|
|
220
224
|
query = """INSERT INTO {} ({}) VALUES ({})""".format(outputTableName, col, bind)
|
221
225
|
self.execute_many(query, main_dict)
|
wcp_library/sql/postgres.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import logging
|
2
2
|
from typing import Optional
|
3
3
|
|
4
|
+
import numpy as np
|
4
5
|
import pandas as pd
|
5
6
|
from psycopg.sql import SQL
|
6
7
|
from psycopg_pool import ConnectionPool
|
@@ -187,14 +188,17 @@ class PostgresConnection(object):
|
|
187
188
|
param_list.append(f"%({column})s")
|
188
189
|
params = ', '.join(param_list)
|
189
190
|
|
190
|
-
main_dict = dfObj.to_dict('records')
|
191
191
|
if remove_nan:
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
192
|
+
dfObj = dfObj.replace({np.nan: None})
|
193
|
+
main_dict = dfObj.to_dict('records')
|
194
|
+
|
195
|
+
# if remove_nan:
|
196
|
+
# for val, item in enumerate(main_dict):
|
197
|
+
# for sub_item, value in item.items():
|
198
|
+
# if pd.isna(value):
|
199
|
+
# main_dict[val][sub_item] = None
|
200
|
+
# else:
|
201
|
+
# main_dict[val][sub_item] = value
|
198
202
|
|
199
203
|
query = """INSERT INTO {} ({}) VALUES ({})""".format(outputTableName, col, params)
|
200
204
|
self.execute_many(query, main_dict)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: wcp-library
|
3
|
-
Version: 1.1
|
3
|
+
Version: 1.2.1
|
4
4
|
Summary: Common utilites for internal development at WCP
|
5
5
|
Home-page: https://github.com/Whitecap-DNA/WCP-Library
|
6
6
|
Author: Mitch-Petersen
|
@@ -20,6 +20,8 @@ Requires-Dist: psycopg-binary (>=3.2.3,<4.0.0)
|
|
20
20
|
Requires-Dist: psycopg-pool (>=3.2.3,<4.0.0)
|
21
21
|
Requires-Dist: pycryptodome (>=3.21.0,<4.0.0)
|
22
22
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
23
|
+
Requires-Dist: selenium (>=4.27.1,<5.0.0)
|
24
|
+
Requires-Dist: webdriver-manager (>=4.0.2,<5.0.0)
|
23
25
|
Requires-Dist: yarl (>=1.17.1,<2.0.0)
|
24
26
|
Project-URL: Documentation, https://github.com/Whitecap-DNA/WCP-Library/wiki
|
25
27
|
Project-URL: Repository, https://github.com/Whitecap-DNA/WCP-Library
|
@@ -4,8 +4,8 @@ wcp_library/async_credentials/api.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
4
4
|
wcp_library/async_credentials/oracle.py,sha256=MvC7wsHnSyAyPGnRVlH0dvvW2xk5ap_IAByoHX4rUWY,5436
|
5
5
|
wcp_library/async_credentials/postgres.py,sha256=3wjqtLH0Nc-U80iscYnz5DV-9M2X4IjPW51C5MI2_tI,5297
|
6
6
|
wcp_library/async_sql/__init__.py,sha256=m4eWmUGYUEDomhhOp1ScB2uSIXFsNUNO589o5RwWdyM,1035
|
7
|
-
wcp_library/async_sql/oracle.py,sha256=
|
8
|
-
wcp_library/async_sql/postgres.py,sha256=
|
7
|
+
wcp_library/async_sql/oracle.py,sha256=W4_zXc3XxNnMZYXmyCCqx4dx1SQ6J8Tf_ifht_d8btI,7509
|
8
|
+
wcp_library/async_sql/postgres.py,sha256=gFkgSpJQ7Giwjtjbh-38szhtFHPAt8WbvtZEp7UZ3oM,6704
|
9
9
|
wcp_library/credentials/__init__.py,sha256=HRmg7mqcATeclIz3lZQjSR4nmK6aY6MK9-QXEYZoFrw,1857
|
10
10
|
wcp_library/credentials/ftp.py,sha256=FRxKVWifz7olQIrSjDgkTqk7rmc7Zdwmkfq7b62DQY8,4965
|
11
11
|
wcp_library/credentials/oracle.py,sha256=IJVGd10LH5LUNKUSFAbApi0sjR1AbloMJRHTuR9zFrQ,5095
|
@@ -16,9 +16,10 @@ wcp_library/ftp/ftp.py,sha256=EpyW0J2QIGxP8zVGD4VarA0hi4C2XAPDPF-0j2sRdpI,4350
|
|
16
16
|
wcp_library/ftp/sftp.py,sha256=hykXGLGdxe7DYAxFdTwjPjTEOYuIpSMyK3NOiTQNUK0,4176
|
17
17
|
wcp_library/informatica.py,sha256=IXZtk_9X1XLbOEwFrsyOwTgajQKvtXgANBHmuTOP3Kk,4064
|
18
18
|
wcp_library/logging.py,sha256=tpnEuet-V6SK68JWk5cpt4K51YO0AxaebXrwGDGabFs,2048
|
19
|
+
wcp_library/selenium_helper.py,sha256=rlphTXsUgnbaXZknY5nfQqxFhnc7UmrpzhV3hQ-cv7k,2509
|
19
20
|
wcp_library/sql/__init__.py,sha256=CLlBEBrWVAwE79bUxuQiwikSrYH8m9QRYSJ2l0-ofsY,1003
|
20
|
-
wcp_library/sql/oracle.py,sha256=
|
21
|
-
wcp_library/sql/postgres.py,sha256=
|
22
|
-
wcp_library-1.1.
|
23
|
-
wcp_library-1.1.
|
24
|
-
wcp_library-1.1.
|
21
|
+
wcp_library/sql/oracle.py,sha256=a0wc9zwBdzhZCZFRWxZlokDJEEt-HqhqmwRbtp2T8ZA,7342
|
22
|
+
wcp_library/sql/postgres.py,sha256=397Ii0ImjEo_e_QuWJRazfs0WpT9cGrnc6sBPyr4UyY,6596
|
23
|
+
wcp_library-1.2.1.dist-info/METADATA,sha256=OTbh7b1itfvVpO9ex6-yxz6MP9ZsjvKF_C9UFDdEcwk,1513
|
24
|
+
wcp_library-1.2.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
25
|
+
wcp_library-1.2.1.dist-info/RECORD,,
|
File without changes
|