fetchly 0.1.0__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.
fetchly-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: fetchly
3
+ Version: 0.1.0
4
+ Summary: A lightweight Python HTTP library with retries, timeouts, and automatic headers
5
+ Author: Sudhamsh Kalaonda
6
+ Author-email: sudhamshguptha14@gmail.com
7
+ Requires-Python: >=3.6
8
+ Requires-Dist: requests
9
+ Dynamic: author
10
+ Dynamic: author-email
11
+ Dynamic: requires-dist
12
+ Dynamic: requires-python
13
+ Dynamic: summary
@@ -0,0 +1,39 @@
1
+ # Fetchly
2
+
3
+ A lightweight Python HTTP library with automatic retries, timeouts, and headers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install fetchly
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ import fetchly
15
+
16
+ # Set headers once
17
+ fetchly.set_headers({"Authorization": "Bearer your_api_key"})
18
+
19
+ # GET request
20
+ response = fetchly.get("https://api.example.com/data")
21
+ print(response.json())
22
+
23
+ # POST request
24
+ response = fetchly.post("https://api.example.com/data", json={"name": "John"})
25
+ print(response.json())
26
+
27
+ # PUT request
28
+ response = fetchly.put("https://api.example.com/data/1", json={"name": "Jane"})
29
+
30
+ # DELETE request
31
+ response = fetchly.delete("https://api.example.com/data/1")
32
+ ```
33
+
34
+ ## Features
35
+
36
+ - Automatic retries (default: 3)
37
+ - Timeout protection (default: 10 seconds)
38
+ - Clean error messages
39
+ - Set headers once, works everywhere
@@ -0,0 +1,88 @@
1
+ import requests
2
+ import time
3
+
4
+ default_headers={}
5
+
6
+ def set_headers(key):
7
+ default_headers .update(key)
8
+
9
+
10
+
11
+
12
+
13
+ def get(url, timeout=10, retries=3, **kwargs):
14
+ kwargs.setdefault("headers", {}).update(default_headers)
15
+ for attempt in range(1, retries + 1):
16
+ try:
17
+ response = requests.get(url, timeout=timeout, **kwargs)
18
+ response.raise_for_status()
19
+ return response
20
+ except requests.exceptions.Timeout:
21
+ print(f"Attempt {attempt} timed out...")
22
+ except requests.exceptions.HTTPError as e:
23
+ raise Exception(f"HTTP error: {e}")
24
+ except requests.exceptions.ConnectionError:
25
+ print(f"Attempt {attempt} failed. Retrying...")
26
+
27
+ if attempt < retries:
28
+ time.sleep(2)
29
+
30
+ raise Exception(f"All {retries} attempts failed for {url}")
31
+
32
+
33
+ def post(url, timeout=10, retries=3, **kwargs):
34
+ kwargs.setdefault("headers", {}).update(default_headers)
35
+ for attempt in range(1, retries + 1):
36
+ try:
37
+ response = requests.post(url, timeout=timeout, **kwargs)
38
+ response.raise_for_status()
39
+ return response
40
+ except requests.exceptions.Timeout:
41
+ print(f"Attempt {attempt} timed out...")
42
+ except requests.exceptions.HTTPError as e:
43
+ raise Exception(f"HTTP error: {e}")
44
+ except requests.exceptions.ConnectionError:
45
+ print(f"Attempt {attempt} failed. Retrying...")
46
+
47
+ if attempt < retries:
48
+ time.sleep(2)
49
+
50
+ raise Exception(f"All {retries} attempts failed for {url}")
51
+
52
+ def put(url, timeout=10, retries=3, **kwargs):
53
+ kwargs.setdefault("headers", {}).update(default_headers)
54
+ for attempt in range(1, retries + 1):
55
+ try:
56
+ response = requests.put(url, timeout=timeout, **kwargs)
57
+ response.raise_for_status()
58
+ return response
59
+ except requests.exceptions.Timeout:
60
+ print(f"Attempt {attempt} timed out...")
61
+ except requests.exceptions.HTTPError as e:
62
+ raise Exception(f"HTTP error: {e}")
63
+ except requests.exceptions.ConnectionError:
64
+ print(f"Attempt {attempt} failed. Retrying...")
65
+
66
+ if attempt < retries:
67
+ time.sleep(2)
68
+
69
+ raise Exception(f"All {retries} attempts failed for {url}")
70
+
71
+ def delete(url, timeout=10, retries=3, **kwargs):
72
+ kwargs.setdefault("headers", {}).update(default_headers)
73
+ for attempt in range(1, retries + 1):
74
+ try:
75
+ response = requests.delete(url, timeout=timeout, **kwargs)
76
+ response.raise_for_status()
77
+ return response
78
+ except requests.exceptions.Timeout:
79
+ print(f"Attempt {attempt} timed out...")
80
+ except requests.exceptions.HTTPError as e:
81
+ raise Exception(f"HTTP error: {e}")
82
+ except requests.exceptions.ConnectionError:
83
+ print(f"Attempt {attempt} failed. Retrying...")
84
+
85
+ if attempt < retries:
86
+ time.sleep(2)
87
+
88
+ raise Exception(f"All {retries} attempts failed for {url}")
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: fetchly
3
+ Version: 0.1.0
4
+ Summary: A lightweight Python HTTP library with retries, timeouts, and automatic headers
5
+ Author: Sudhamsh Kalaonda
6
+ Author-email: sudhamshguptha14@gmail.com
7
+ Requires-Python: >=3.6
8
+ Requires-Dist: requests
9
+ Dynamic: author
10
+ Dynamic: author-email
11
+ Dynamic: requires-dist
12
+ Dynamic: requires-python
13
+ Dynamic: summary
@@ -0,0 +1,8 @@
1
+ README.md
2
+ setup.py
3
+ fetchly/__init__.py
4
+ fetchly.egg-info/PKG-INFO
5
+ fetchly.egg-info/SOURCES.txt
6
+ fetchly.egg-info/dependency_links.txt
7
+ fetchly.egg-info/requires.txt
8
+ fetchly.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests
@@ -0,0 +1 @@
1
+ fetchly
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
fetchly-0.1.0/setup.py ADDED
@@ -0,0 +1,14 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="fetchly",
5
+ version="0.1.0",
6
+ author="Sudhamsh Kalaonda",
7
+ author_email="sudhamshguptha14@gmail.com",
8
+ description="A lightweight Python HTTP library with retries, timeouts, and automatic headers",
9
+ packages=find_packages(),
10
+ install_requires=[
11
+ "requests",
12
+ ],
13
+ python_requires=">=3.6",
14
+ )