bcpkgfox 0.18.1__tar.gz → 0.18.4__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: 2.4
2
2
  Name: bcpkgfox
3
- Version: 0.18.1
3
+ Version: 0.18.4
4
4
  Summary: Biblioteca BCFOX
5
5
  Home-page: https://github.com/robotsbcfox/PacotePythonBCFOX
6
6
  Author: BCFOX
@@ -225,7 +225,7 @@ def wait_for_element_disappear(object, type, timeout=10):
225
225
 
226
226
  return find_elements.backcode__dont_use__wait_for_d(driver, object, type, timeout=tempo)
227
227
 
228
- def selectfox(elemento, method, key, relative = None):
228
+ def selectfox(elemento, method, key, relative = None, unicode=False):
229
229
  """
230
230
  Seleciona uma opção em um elemento <select>.
231
231
 
@@ -262,22 +262,39 @@ def selectfox(elemento, method, key, relative = None):
262
262
  if method == "value":
263
263
  select.select_by_value(key)
264
264
 
265
- if method == "text":
266
- elements = select.options
267
- for elm in elements:
268
- if relative:
269
- if key.lower().strip() in elm.text.lower().strip():
270
- select.select_by_visible_text(elm.text)
271
- return
272
- else:
273
- if key == elm.text:
274
- select.select_by_visible_text(elm.text)
275
- return
276
-
277
- raise ModuleNotFoundError(f"Option {key} não encontrada")
265
+ elements = select.options
266
+ if method == "text" and not unicode:
267
+ for elm in elements:
268
+ if relative:
269
+ if key.lower().strip() in elm.text.lower().strip():
270
+ select.select_by_visible_text(elm.text)
271
+ return
272
+ else:
273
+ if key == elm.text:
274
+ select.select_by_visible_text(elm.text)
275
+ return
276
+
277
+ if method == "text" and unicode:
278
+ key_normalize = normalize(key.lower().strip())
279
+ for elm in elements:
280
+ text_normalize = normalize(elm.text.lower().strip())
281
+ if relative:
282
+ if key_normalize in text_normalize:
283
+ select.select_by_visible_text(elm.text)
284
+ return
285
+ else:
286
+ if key_normalize == text_normalize:
287
+ select.select_by_visible_text(elm.text)
288
+ return
289
+
290
+ raise ModuleNotFoundError(f"Option {key} não encontrada")
278
291
 
279
292
  if method == "index":
280
293
  select.select_by_index(key)
294
+ def normalize(text):
295
+ import unicodedata
296
+ return unicodedata.normalize("NFKD", text).encode("ASCII", "ignore").decode("ASCII").lower()
297
+
281
298
 
282
299
  def pop_up_extract(text: bool = False, accept: bool = False, timeout: int = 10, driver_instance: Optional[WebElement] = None):
283
300
  """ Identifica um pop-up simples extraindo o texto e aceitando ele também. \n
@@ -41,12 +41,12 @@ class Login2facmycena:
41
41
  time.sleep(5)
42
42
  return None
43
43
 
44
- def login_eproc(self, driver, url, tipo_login="mysena"):
44
+ def login_eproc(self, driver, url, tipo_login="mycena"):
45
45
  login = _LoginEproc(driver, self._api, url, self.uf, self.sistema, self.advogado, self.token, tipo_login, self.processar_codes)
46
46
  login.login()
47
47
  return True
48
48
 
49
- def login_pje(self, driver, url, tipo_login="mysena"):
49
+ def login_pje(self, driver, url, tipo_login="mycena"):
50
50
  login = _LoginPje(driver, self._api, url, self.uf, self.sistema, self.advogado, self.token, tipo_login,
51
51
  self.processar_codes)
52
52
  login.login()
@@ -119,14 +119,14 @@ class _ApiControll:
119
119
 
120
120
 
121
121
  class _LoginEproc:
122
- def __init__(self, driver, api, url_procurada, uf, sistema, advogado, token, tipo_login="mysena", processar_codes=None):
122
+ def __init__(self, driver, api, url_procurada, uf, sistema, advogado, token, tipo_login="mycena", processar_codes=None):
123
123
  self.driver = driver
124
124
  self.api = api
125
125
  self.uf = uf
126
126
  self.sistema = sistema
127
127
  self.advogado = advogado
128
128
  self.url_procurada = url_procurada
129
- self.tipo_login = tipo_login.lower if tipo_login else "mysena"
129
+ self.tipo_login = tipo_login.lower if tipo_login else "mycena"
130
130
  self._util = _Utils(driver, api, url_procurada, uf, sistema, advogado, token,tipo_login)
131
131
  self.processar_codes = processar_codes
132
132
 
@@ -544,14 +544,14 @@ class _LoginEproc:
544
544
  return
545
545
 
546
546
  class _LoginPje:
547
- def __init__(self, driver, api, url_procurada, uf, sistema, advogado, token, tipo_login="mysena", processar_codes=None):
547
+ def __init__(self, driver, api, url_procurada, uf, sistema, advogado, token, tipo_login="mycena", processar_codes=None):
548
548
  self.driver = driver
549
549
  self.api = api
550
550
  self.uf = uf
551
551
  self.sistema = sistema
552
552
  self.advogado = advogado
553
553
  self.url_procurada = url_procurada
554
- self.tipo_login = tipo_login.lower if tipo_login else "mysena"
554
+ self.tipo_login = tipo_login.lower if tipo_login else "mycena"
555
555
  self._util = _Utils(driver, api, url_procurada, uf, sistema, advogado, token,tipo_login)
556
556
  self.processar_codes = processar_codes
557
557
 
@@ -571,6 +571,17 @@ class _LoginPje:
571
571
  self.driver.get(f"{self.url_procurada}")
572
572
  time.sleep(2)
573
573
 
574
+
575
+ if self._verica_captcha():
576
+ if self._util.deve_usar_whom():
577
+ self._util.login_via_whom()
578
+ if self._verificar_ja_logado():
579
+ print(" ✓ Login via WHOM realizado com sucesso!")
580
+ return True
581
+ else:
582
+ print("⚠ Login via WHOM falhou. Não há fallback disponível para este estado.")
583
+ raise Exception("Falha no login via WHOM")
584
+
574
585
  # ══════════════════════════════════════════════════════════════
575
586
  # PRIORIDADE 1: Verifica se já está logado
576
587
  # ══════════════════════════════════════════════════════════════
@@ -578,7 +589,6 @@ class _LoginPje:
578
589
  return True
579
590
 
580
591
  print(f"{self.url_procurada}")
581
- self.driver.get(f"{self.url_procurada}")
582
592
  self.driver.execute_script("document.body.style.zoom='90%'")
583
593
 
584
594
 
@@ -693,7 +703,15 @@ class _LoginPje:
693
703
  self.driver.execute_script("arguments[0].click();", click_certification)
694
704
  except Exception:
695
705
  click_certification.click()
706
+
707
+ code = self._obter_codigo_2fa()
708
+ if code:
709
+ self._insert_codigo_2fa(code)
710
+ else:
711
+ self.login()
712
+
696
713
  self._util.loading()
714
+
697
715
  time.sleep(2)
698
716
  except NoSuchElementException:
699
717
  pass
@@ -828,6 +846,11 @@ class _LoginPje:
828
846
  return True
829
847
  else:
830
848
  return False
849
+ def _verica_captcha(self):
850
+ if 'Vamos confirmar que você é humano' in self.driver.page_source:
851
+ return True
852
+ else:
853
+ return False
831
854
 
832
855
  def _fechar_popup_certificado(self):
833
856
  if "Certificado próximo de expirar" in self.driver.page_source:
@@ -899,7 +922,7 @@ class _LoginPje:
899
922
  pass
900
923
 
901
924
  class _Utils:
902
- def __init__(self, driver, api, url_procurada, uf, sistema, advogado, token, tipo='mysena'):
925
+ def __init__(self, driver, api, url_procurada, uf, sistema, advogado, token, tipo='mycena'):
903
926
  self.driver = driver
904
927
  self.tipo_login = tipo
905
928
  self.sistema = sistema
@@ -929,9 +952,9 @@ class _Utils:
929
952
  Determina se deve usar o login via WHOM baseado no estado (UF).
930
953
  Estados que usam WHOM: RJ, TO
931
954
  """
932
- if self.tipo_login.lower() == "mysena" or "my" in self.tipo_login.lower():
955
+ if self.tipo_login.lower() == "mycena" or "my" in self.tipo_login.lower() or "mysena" in self.tipo_login.lower():
933
956
  return False
934
- elif 'whoom' in self.tipo_login.lower() or self.tipo_login.lower() == 'whoom' or self.tipo_login.lower() == 'whom' or self.tipo_login.lower() == 'wh' or 'wh' in self.tipo_login.lower() :
957
+ elif 'whoom' in self.tipo_login.lower() or 'whoon' in self.tipo_login.lower() or self.tipo_login.lower() == 'whoom' or self.tipo_login.lower() == 'whom' or self.tipo_login.lower() == 'wh' or 'wh' in self.tipo_login.lower() :
935
958
  return True
936
959
  else:
937
960
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcpkgfox
3
- Version: 0.18.1
3
+ Version: 0.18.4
4
4
  Summary: Biblioteca BCFOX
5
5
  Home-page: https://github.com/robotsbcfox/PacotePythonBCFOX
6
6
  Author: BCFOX
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="bcpkgfox",
5
- version="0.18.1",
5
+ version="0.18.4",
6
6
  author="BCFOX",
7
7
  author_email="bcfox@bcfox.com.br",
8
8
  description="Biblioteca BCFOX",
File without changes
File without changes
File without changes
File without changes
File without changes