curlyshed 0.1.0__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.
curlyshed/__init__.py ADDED
@@ -0,0 +1,54 @@
1
+ """curlyshed: Python on libcurl.
2
+
3
+ libcurl does the protocol work; curlyshed gives it a Python API per protocol:
4
+
5
+ from curlyshed import http
6
+ with http.Client() as client:
7
+ r = client.get("https://example.org/", params={"q": "x"})
8
+
9
+ from curlyshed import WebSocket
10
+ with WebSocket("wss://example.org/feed") as ws:
11
+ ws.send("hello")
12
+
13
+ curlyshed.http has Client and AsyncClient, curlyshed.requests is a
14
+ compatibility layer with the API of requests, WebSocket and AsyncWebSocket
15
+ speak ws:// and wss://. Shared by all: URL (libcurl's URL API),
16
+ ClientConfig, the exceptions, trace_logger (curl's verbose trace) and
17
+ libcurl_info(); `python -m curlyshed` prints what the libcurl in use brings.
18
+ """
19
+
20
+ from importlib import import_module
21
+ from types import ModuleType
22
+ from typing import TYPE_CHECKING
23
+
24
+ from curlyshed import exceptions, http
25
+ from curlyshed._curl import MIN_LIBCURL, ClientConfig, __version__, libcurl_info, trace_logger
26
+ from curlyshed._url import URL
27
+ from curlyshed.exceptions import Error, MissingFeature
28
+ from curlyshed.websocket import AsyncWebSocket, WebSocket
29
+
30
+ if TYPE_CHECKING:
31
+ from curlyshed import requests
32
+
33
+
34
+ def __getattr__(name: str) -> ModuleType:
35
+ if name == "requests":
36
+ return import_module("curlyshed.requests")
37
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
38
+
39
+
40
+ __all__ = [
41
+ "MIN_LIBCURL",
42
+ "URL",
43
+ "AsyncWebSocket",
44
+ "ClientConfig",
45
+ "Error",
46
+ "MissingFeature",
47
+ "WebSocket",
48
+ "__version__",
49
+ "exceptions",
50
+ "http",
51
+ "libcurl_info",
52
+ "requests",
53
+ "trace_logger",
54
+ ]
curlyshed/__main__.py ADDED
@@ -0,0 +1,7 @@
1
+ """python -m curlyshed: what libcurl curlyshed runs on, as JSON."""
2
+
3
+ import json
4
+
5
+ from curlyshed import libcurl_info
6
+
7
+ print(json.dumps(libcurl_info(), indent=2))