sideload 1.1.0__py3-none-any.whl → 1.3.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.

Potentially problematic release.


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

sideload/cli.py CHANGED
@@ -33,9 +33,19 @@ console = Console()
33
33
 
34
34
 
35
35
  class SideloadClient:
36
- def __init__(self, jsonbin_token: str, collection_id: str):
36
+ def __init__(
37
+ self,
38
+ jsonbin_token: str,
39
+ collection_id: str,
40
+ verify_ssl: bool = True,
41
+ key_type: str = "master"
42
+ ):
37
43
  self.collection_id = collection_id
38
- self.connector = JSONBinConnector(jsonbin_token)
44
+ self.connector = JSONBinConnector(
45
+ jsonbin_token,
46
+ verify_ssl=verify_ssl,
47
+ key_type=key_type
48
+ )
39
49
  self.manager = SideloadBinManager(self.connector)
40
50
 
41
51
  def __enter__(self):
@@ -117,7 +127,7 @@ class SideloadClient:
117
127
  return self.manager.get_sideload_data(bin_id)
118
128
 
119
129
  def download_packages(
120
- self, package_names: List[str], output_dir: Path
130
+ self, package_names: List[str], output_dir: Path, debug: bool = False
121
131
  ) -> List[Path]:
122
132
  """Download all packages to a temporary directory"""
123
133
  downloaded_files = []
@@ -128,6 +138,7 @@ class SideloadClient:
128
138
  BarColumn(),
129
139
  TaskProgressColumn(),
130
140
  console=console,
141
+ disable=debug, # Disable progress bar in debug mode
131
142
  ) as progress:
132
143
  download_task = progress.add_task(
133
144
  "Downloading packages...", total=len(package_names)
@@ -142,18 +153,23 @@ class SideloadClient:
142
153
 
143
154
  # Download using pip to temporary directory
144
155
  try:
156
+ cmd = [
157
+ sys.executable,
158
+ "-m",
159
+ "pip",
160
+ "download",
161
+ "--no-deps",
162
+ "--dest",
163
+ str(output_dir),
164
+ package_name,
165
+ ]
166
+
167
+ if debug:
168
+ console.print(f"[dim]Running: {' '.join(cmd)}[/dim]")
169
+
145
170
  subprocess.run(
146
- [
147
- sys.executable,
148
- "-m",
149
- "pip",
150
- "download",
151
- "--no-deps",
152
- "--dest",
153
- str(output_dir),
154
- package_name,
155
- ],
156
- capture_output=True,
171
+ cmd,
172
+ capture_output=not debug,
157
173
  text=True,
158
174
  check=True,
159
175
  )
@@ -162,10 +178,13 @@ class SideloadClient:
162
178
  wheel_files = list(output_dir.glob(f"{package_name}*.whl"))
163
179
  if wheel_files:
164
180
  downloaded_files.append(wheel_files[0])
181
+ if debug:
182
+ console.print(f"[green]✓ Downloaded: {wheel_files[0].name}[/green]")
165
183
 
166
184
  except subprocess.CalledProcessError as e:
185
+ error_msg = e.stderr if hasattr(e, 'stderr') and e.stderr else str(e)
167
186
  console.print(
168
- f"❌ Failed to download {package_name}: {e.stderr}", style="red"
187
+ f"❌ Failed to download {package_name}: {error_msg}", style="red"
169
188
  )
170
189
  continue
171
190
 
@@ -204,6 +223,7 @@ class SideloadClient:
204
223
  BarColumn(),
205
224
  TaskProgressColumn(),
206
225
  console=console,
226
+ disable=debug, # Disable progress bar in debug mode
207
227
  ) as progress:
208
228
  extract_task = progress.add_task(
209
229
  "Extracting packages...", total=len(wheel_files)
@@ -217,6 +237,9 @@ class SideloadClient:
217
237
  completed=i,
218
238
  )
219
239
 
240
+ if debug:
241
+ console.print(f"\n[cyan]Extracting package {i + 1}/{len(wheel_files)}: {package_name}[/cyan]")
242
+
220
243
  # Extract wheel file (it's just a zip)
221
244
  import zipfile
222
245
 
@@ -274,6 +297,7 @@ class SideloadClient:
274
297
  BarColumn(),
275
298
  TaskProgressColumn(),
276
299
  console=console,
300
+ disable=debug, # Disable progress bar in debug mode
277
301
  ) as progress:
278
302
  reassemble_task = progress.add_task(
279
303
  "Reassembling file...", total=len(part_files)
@@ -287,6 +311,9 @@ class SideloadClient:
287
311
  completed=i,
288
312
  )
289
313
 
314
+ if debug:
315
+ console.print(f"[dim]Reading part {i + 1}/{len(part_files)}: {part_file.name} ({part_file.stat().st_size:,} bytes)[/dim]")
316
+
290
317
  with open(part_file, "rb") as part:
291
318
  output_file.write(part.read())
292
319
 
@@ -363,6 +390,17 @@ Examples:
363
390
  type=Path,
364
391
  help="Working directory for extraction (for debugging, defaults to temp directory)",
365
392
  )
393
+ download_parser.add_argument(
394
+ "--no-verify-ssl",
395
+ action="store_true",
396
+ help="Disable SSL certificate verification for JSONBin API",
397
+ )
398
+ download_parser.add_argument(
399
+ "--jsonbin-key-type",
400
+ choices=["master", "access"],
401
+ default=None,
402
+ help="JSONBin key type to use (default: from JSONBIN_KEY_TYPE env or 'master')",
403
+ )
366
404
 
367
405
  args = parser.parse_args()
368
406
 
@@ -377,6 +415,19 @@ Examples:
377
415
  jsonbin_token = args.token or os.environ.get("JSONBIN_TOKEN")
378
416
  collection_id = args.collection or os.environ.get("SIDELOAD_COLLECTION_ID")
379
417
 
418
+ # Get SSL verification setting (CLI flag overrides env var)
419
+ verify_ssl = not args.no_verify_ssl
420
+ if args.no_verify_ssl:
421
+ # If CLI flag is set, disable SSL verification
422
+ verify_ssl = False
423
+ else:
424
+ # Otherwise check environment variable (default to True)
425
+ env_verify = os.environ.get("JSONBIN_VERIFY_SSL", "true").lower()
426
+ verify_ssl = env_verify in ("true", "1", "yes")
427
+
428
+ # Get key type (CLI arg > env var > default)
429
+ key_type = args.jsonbin_key_type or os.environ.get("JSONBIN_KEY_TYPE", "master").lower()
430
+
380
431
  if not jsonbin_token:
381
432
  console.print(
382
433
  "❌ JSONBin token required. Set JSONBIN_TOKEN environment variable or use --token",
@@ -394,8 +445,19 @@ Examples:
394
445
  # Ensure output directory exists
395
446
  args.output.mkdir(parents=True, exist_ok=True)
396
447
 
448
+ # Show debug flags if enabled
449
+ if args.debug:
450
+ console.print("\n[bold cyan]Debug Mode Enabled[/bold cyan]")
451
+ console.print(f" [dim]URL:[/dim] {args.url}")
452
+ console.print(f" [dim]Output:[/dim] {args.output}")
453
+ console.print(f" [dim]Work Directory:[/dim] {args.work_dir or 'temp (auto-cleanup)'}")
454
+ console.print(f" [dim]Collection ID:[/dim] {collection_id}")
455
+ console.print(f" [dim]SSL Verification:[/dim] {verify_ssl}")
456
+ console.print(f" [dim]JSONBin Key Type:[/dim] {key_type}")
457
+ console.print()
458
+
397
459
  try:
398
- with SideloadClient(jsonbin_token, collection_id) as client:
460
+ with SideloadClient(jsonbin_token, collection_id, verify_ssl, key_type) as client:
399
461
  # Create the request
400
462
  console.print(
401
463
  f"🌐 Requesting download for: [bold blue]{args.url}[/bold blue]"
@@ -425,7 +487,7 @@ Examples:
425
487
 
426
488
  with tempfile.TemporaryDirectory() as temp_dir:
427
489
  temp_path = Path(temp_dir)
428
- wheel_files = client.download_packages(package_names, temp_path)
490
+ wheel_files = client.download_packages(package_names, temp_path, args.debug)
429
491
 
430
492
  if not wheel_files:
431
493
  console.print(
@@ -2,13 +2,26 @@ import os
2
2
  import httpx
3
3
 
4
4
  JSONBIN_TOKEN = os.environ["JSONBIN_TOKEN"]
5
+ JSONBIN_VERIFY_SSL = os.environ.get("JSONBIN_VERIFY_SSL", "true").lower() in ("true", "1", "yes")
6
+ JSONBIN_KEY_TYPE = os.environ.get("JSONBIN_KEY_TYPE", "master").lower() # "master" or "access"
5
7
 
6
8
 
7
9
  class JSONBinConnector:
8
- def __init__(self):
10
+ def __init__(self, verify_ssl: bool = None, key_type: str = None):
11
+ # Use provided values or fall back to environment variables
12
+ verify = JSONBIN_VERIFY_SSL if verify_ssl is None else verify_ssl
13
+ key_type = key_type or JSONBIN_KEY_TYPE
14
+
15
+ # Determine the key header to use
16
+ if key_type == "access":
17
+ key_header = "X-Access-Key"
18
+ else:
19
+ key_header = "X-Master-Key"
20
+
9
21
  self.client = httpx.Client(
10
22
  base_url="https://api.jsonbin.io/v3",
11
- headers={"X-Master-Key": JSONBIN_TOKEN, "Content-Type": "application/json"},
23
+ headers={key_header: JSONBIN_TOKEN, "Content-Type": "application/json"},
24
+ verify=verify,
12
25
  )
13
26
 
14
27
  def get_collections(self) -> list:
sideload/jsonbin_old.py CHANGED
@@ -11,19 +11,35 @@ from typing import Dict, List, Optional, Any
11
11
  class JSONBinConnector:
12
12
  """A connector for JSONBin.io API with httpx"""
13
13
 
14
- def __init__(self, api_token: str, base_url: str = "https://api.jsonbin.io/v3"):
14
+ def __init__(
15
+ self,
16
+ api_token: str,
17
+ base_url: str = "https://api.jsonbin.io/v3",
18
+ verify_ssl: bool = True,
19
+ key_type: str = "master"
20
+ ):
15
21
  """
16
22
  Initialize the JSONBin connector
17
23
 
18
24
  Args:
19
25
  api_token: JSONBin API token
20
26
  base_url: JSONBin API base URL
27
+ verify_ssl: Whether to verify SSL certificates (default: True)
28
+ key_type: Type of key to use - "master" or "access" (default: "master")
21
29
  """
22
30
  self.api_token = api_token
23
31
  self.base_url = base_url
32
+
33
+ # Determine the key header to use
34
+ if key_type == "access":
35
+ key_header = "X-Access-Key"
36
+ else:
37
+ key_header = "X-Master-Key"
38
+
24
39
  self.client = httpx.Client(
25
40
  base_url=base_url,
26
- headers={"X-Master-Key": api_token, "Content-Type": "application/json"},
41
+ headers={key_header: api_token, "Content-Type": "application/json"},
42
+ verify=verify_ssl,
27
43
  )
28
44
 
29
45
  def __enter__(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sideload
3
- Version: 1.1.0
3
+ Version: 1.3.0
4
4
  Summary: Download large files via PyPI packages
5
5
  Author: Sygmei
6
6
  Author-email: Sygmei <3835355+Sygmei@users.noreply.github.com>
@@ -0,0 +1,11 @@
1
+ sideload/__init__.py,sha256=Y3rHLtR7n0sjLXrn-BEcrbIHx-9uE1tPZkooavo7xcA,222
2
+ sideload/cli.py,sha256=8CcoZf9_7XHzlFA9XBBZn19RRNAbrFfRshVIWWSaFhQ,20186
3
+ sideload/jsonbin.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ sideload/jsonbin_connector.py,sha256=IS7YdSBZeZMoTwOyA1I0T7aw36-KERYNnD324dRRI5A,2305
5
+ sideload/jsonbin_old.py,sha256=Rs657F3dTtdoxVYolByuyINABCIQx_VLxwxgdne1mws,8865
6
+ sideload/main.py,sha256=EiZguc4-ug8RM6vXkZuXW_ps8jFWoAfeKBBNy7FX-F0,7600
7
+ sideload/scripts/cleanup_pypi.py,sha256=CouuOhnbpSbrFc1KhlOeZAuajVVpGF9d4qwFpIKkEvY,5906
8
+ sideload-1.3.0.dist-info/WHEEL,sha256=-neZj6nU9KAMg2CnCY6T3w8J53nx1kFGw_9HfoSzM60,79
9
+ sideload-1.3.0.dist-info/entry_points.txt,sha256=7ULrIjaVhrxMhuddTeoPjeIrqmIvVc9cSU3lZU2_YqE,44
10
+ sideload-1.3.0.dist-info/METADATA,sha256=r0lod7DO3pFy-v0M9HQQFHKTiPih1jCApRnwZWVRZ8o,4281
11
+ sideload-1.3.0.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- sideload/__init__.py,sha256=Y3rHLtR7n0sjLXrn-BEcrbIHx-9uE1tPZkooavo7xcA,222
2
- sideload/cli.py,sha256=zGcpAJ_j4ZrqWln3lQfZ2kO8TD_AW2PjAfVo3BvRIwM,17465
3
- sideload/jsonbin.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- sideload/jsonbin_connector.py,sha256=HtR1Pwnpm5jfYcmnvcug9HaKxFpsyJBXYYlLuzWPiTE,1680
5
- sideload/jsonbin_old.py,sha256=ve21WsV7Ay60moFfrR4lSM_JRZNqo4z5v69cNw0Iqo0,8411
6
- sideload/main.py,sha256=EiZguc4-ug8RM6vXkZuXW_ps8jFWoAfeKBBNy7FX-F0,7600
7
- sideload/scripts/cleanup_pypi.py,sha256=CouuOhnbpSbrFc1KhlOeZAuajVVpGF9d4qwFpIKkEvY,5906
8
- sideload-1.1.0.dist-info/WHEEL,sha256=-neZj6nU9KAMg2CnCY6T3w8J53nx1kFGw_9HfoSzM60,79
9
- sideload-1.1.0.dist-info/entry_points.txt,sha256=7ULrIjaVhrxMhuddTeoPjeIrqmIvVc9cSU3lZU2_YqE,44
10
- sideload-1.1.0.dist-info/METADATA,sha256=AGrmSEXpybApWqfbA3uv9MHaGY2wUXo_poyPHWVRvd8,4281
11
- sideload-1.1.0.dist-info/RECORD,,