simplex 1.2.53__tar.gz → 1.2.55__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.

Potentially problematic release.


This version of simplex might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.53
3
+ Version: 1.2.55
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -22,7 +22,7 @@ class PostInstallCommand(install):
22
22
 
23
23
  setup(
24
24
  name="simplex",
25
- version="1.2.53",
25
+ version="1.2.55",
26
26
  packages=find_packages(),
27
27
  package_data={
28
28
  "simplex": ["browser_agent/dom/*.js"], # Include JS files in the dom directory
@@ -1,6 +1,6 @@
1
1
  import requests
2
2
  import atexit
3
- from typing import Optional
3
+ from typing import Optional, Union
4
4
  import os
5
5
  import json
6
6
  import warnings
@@ -555,20 +555,33 @@ class Simplex:
555
555
  else:
556
556
  raise ValueError(f"Failed to restore login session: {response.json()['error']}")
557
557
 
558
- def click_and_upload(self, element_description: str, file_path: str):
558
+ def click_and_upload(self, element_description: str, file_path_or_callable: Union[str, callable]):
559
+ """
560
+ Args:
561
+ element_description: Description of the element to click and upload to
562
+ file_path_or_callable: Either a path to the file to be uploaded or a callable that returns a file-like object in 'rb' mode
563
+ """
559
564
  if not self.session_id:
560
565
  raise ValueError(f"Must call create_session before calling action click_and_upload with element_description='{element_description}'")
561
-
562
- files = {
563
- 'file': open(file_path, 'rb')
564
- }
565
566
 
567
+ if not isinstance(file_path_or_callable, str) and not callable(file_path_or_callable):
568
+ raise TypeError("file_path_or_callable must be either a string or a callable, not a " + type(file_path_or_callable).__name__)
569
+
570
+ if isinstance(file_path_or_callable, str):
571
+ files = {
572
+ 'file': open(file_path_or_callable, 'rb')
573
+ }
574
+ elif callable(file_path_or_callable):
575
+ files = {
576
+ 'file': file_path_or_callable()
577
+ }
578
+ else:
579
+ raise ValueError("You must provide either a valid file path or a callable that returns a file-like object.")
566
580
  data = {
567
- 'element_description': element_description
581
+ 'element_description': element_description,
582
+ 'session_id': self.session_id
568
583
  }
569
584
 
570
- data['session_id'] = self.session_id
571
-
572
585
  response = requests.post(
573
586
  f"{BASE_URL}/click_and_upload",
574
587
  headers={
@@ -583,7 +596,7 @@ class Simplex:
583
596
  return
584
597
  else:
585
598
  raise ValueError(f"Failed to click and upload: {response.json()['error']}")
586
-
599
+
587
600
  def click_and_download(self, element_description: str):
588
601
  if not self.session_id:
589
602
  raise ValueError(f"Must call create_session before calling action click_and_download with element_description='{element_description}'")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.53
3
+ Version: 1.2.55
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -3,7 +3,6 @@ README.md
3
3
  setup.py
4
4
  simplex/__init__.py
5
5
  simplex/cli.py
6
- simplex/setup.py
7
6
  simplex/simplex.py
8
7
  simplex.egg-info/PKG-INFO
9
8
  simplex.egg-info/SOURCES.txt
@@ -1 +0,0 @@
1
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes