mirror of
https://github.com/thecyberlearn/chat-backend.git
synced 2026-08-18 13:12:52 +00:00
Features: - Django REST API backend - Multi-strategy web scraping system (Beautiful Soup, Playwright, Firecrawl) - Anti-detection features (proxy rotation, user-agent rotation) - Data export functionality (JSON, CSV, TXT) - Business and CrawledPage models - Enhanced crawling service with fallback mechanisms 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
738 B
Python
27 lines
738 B
Python
from collections.abc import Iterable
|
|
|
|
|
|
def make_hashable(value):
|
|
"""
|
|
Attempt to make value hashable or raise a TypeError if it fails.
|
|
|
|
The returned value should generate the same hash for equal values.
|
|
"""
|
|
if isinstance(value, dict):
|
|
return tuple(
|
|
[
|
|
(key, make_hashable(nested_value))
|
|
for key, nested_value in sorted(value.items())
|
|
]
|
|
)
|
|
# Try hash to avoid converting a hashable iterable (e.g. string, frozenset)
|
|
# to a tuple.
|
|
try:
|
|
hash(value)
|
|
except TypeError:
|
|
if isinstance(value, Iterable):
|
|
return tuple(map(make_hashable, value))
|
|
# Non-hashable, non-iterable.
|
|
raise
|
|
return value
|