Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
Update copy.py
Marco Vinciguerradcef172e03da
diff --git a/scrapegraphai/utils/copy.py b/scrapegraphai/utils/copy.pyindex 99cf8419..838f3c05 100644--- a/scrapegraphai/utils/copy.py+++ b/scrapegraphai/utils/copy.py@@ -3,27 +3,27 @@ from typing import Anyclass DeepCopyError(Exception):- """Custom exception raised when an object cannot be deep-copied."""+ """+ Custom exception raised when an object cannot be deep-copied.+ """passdef is_boto3_client(obj):+ """+ Function for understanding if the script is using boto3 or not+ """import sys- # check boto3 module imprortboto3_module = sys.modules.get("boto3")if boto3_module:- # boto3 use botocore client so here we import botocore- # if boto3 was imported the botocore will be import automatically normallytry:from botocore.client import BaseClientreturn isinstance(obj, BaseClient)except (AttributeError, ImportError):- # if the module is not imported, or the BaseClient class does not exist, return False- # if custome module name is boto3, the BaseClient class does not exist,return Falsereturn False@@ -47,12 +47,9 @@ def safe_deepcopy(obj: Any) -> Any:try:- # Try to use copy.deepcopy firstreturn copy.deepcopy(obj)except (TypeError, AttributeError) as e:- # If deepcopy fails, handle specific types manually- # Handle dictionariesif isinstance(obj, dict):new_obj = {}@@ -60,7 +57,6 @@ def safe_deepcopy(obj: Any) -> Any:new_obj[k] = safe_deepcopy(v)return new_obj- # Handle listselif isinstance(obj, list):new_obj = []@@ -68,13 +64,11 @@ def safe_deepcopy(obj: Any) -> Any:new_obj.append(safe_deepcopy(v))return new_obj- # Handle tuples (immutable, but might contain mutable objects)elif isinstance(obj, tuple):new_obj = tuple(safe_deepcopy(v) for v in obj)return new_obj- # Handle frozensets (immutable, but might contain mutable objects)elif isinstance(obj, frozenset):new_obj = frozenset(safe_deepcopy(v) for v in obj)return new_obj@@ -82,10 +76,7 @@ def safe_deepcopy(obj: Any) -> Any:elif is_boto3_client(obj):return obj- # Handle objects with attributeselse:- # If an object cannot be deep copied, then the sub-properties of \- # the object will not be analyzed and shallow copy will be used directly.try:return copy.copy(obj)except (TypeError, AttributeError):