sparq 0.1.5__py3-none-any.whl → 0.2.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.
auth.py CHANGED
@@ -31,13 +31,21 @@ def register():
31
31
  )
32
32
 
33
33
  if response.status_code == 200:
34
- data = response.json()
35
- if data.get("status") == "pending_verification":
36
- print("Code already sent. Check your email.")
37
- else:
38
- print("Verification code sent to your email")
39
- elif response.status_code != 200:
40
- print(response.json()['detail'])
34
+ try:
35
+ data = response.json()
36
+ if data.get("status") == "pending_verification":
37
+ print("Code already sent. Check your email.")
38
+ else:
39
+ print("Verification code sent to your email. Check spam folder if not in Inbox.")
40
+ except Exception as e:
41
+ print(f"Error parsing response: {e}")
42
+ print(f"Response: {response.text}")
43
+ return
44
+ else:
45
+ try:
46
+ print(response.json()['detail'])
47
+ except Exception:
48
+ print(f"Error {response.status_code}: {response.text}")
41
49
  return
42
50
 
43
51
  code = input("Enter code: ").strip()
@@ -49,11 +57,18 @@ def register():
49
57
  )
50
58
 
51
59
  if response.status_code == 200:
52
- api_key = response.json()["api_key"]
53
- print(f"\nAPI Key: {api_key}")
54
- save_api_key(api_key, email)
60
+ try:
61
+ api_key = response.json()["api_key"]
62
+ print(f"\nAPI Key: {api_key}")
63
+ save_api_key(api_key, email)
64
+ except Exception as e:
65
+ print(f"Error parsing response: {e}")
66
+ print(f"Response: {response.text}")
55
67
  else:
56
- print(response.json()['detail'])
68
+ try:
69
+ print(response.json()['detail'])
70
+ except Exception:
71
+ print(f"Error {response.status_code}: {response.text}")
57
72
 
58
73
  if __name__ == "__main__":
59
74
  register()
cli.py ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ sparq CLI - Command-line interface for the sparq API
4
+ """
5
+
6
+ import sys
7
+ import argparse
8
+ from auth import register
9
+ from recover import recover_key
10
+ from usage import show_usage
11
+
12
+
13
+ def main():
14
+ """Main CLI entry point."""
15
+ parser = argparse.ArgumentParser(
16
+ description="sparq - Automated degree planning for SJSU students",
17
+ formatter_class=argparse.RawDescriptionHelpFormatter,
18
+ epilog="""
19
+ Commands:
20
+ auth Register and get your API key
21
+ recover Recover your existing API key
22
+ usage View your API usage statistics
23
+
24
+ Examples:
25
+ sparq auth # Register and get API key
26
+ sparq recover # Recover existing API key
27
+ sparq usage # View usage statistics
28
+ """
29
+ )
30
+
31
+ parser.add_argument(
32
+ 'command',
33
+ nargs='?',
34
+ choices=['auth', 'recover', 'usage'],
35
+ help='Command to execute'
36
+ )
37
+
38
+ args = parser.parse_args()
39
+
40
+ if not args.command:
41
+ parser.print_help()
42
+ sys.exit(1)
43
+
44
+ try:
45
+ if args.command == 'auth':
46
+ register()
47
+ elif args.command == 'recover':
48
+ recover_key()
49
+ elif args.command == 'usage':
50
+ show_usage()
51
+ except KeyboardInterrupt:
52
+ print("\n\nOperation cancelled.")
53
+ sys.exit(0)
54
+ except Exception as e:
55
+ print(f"\nError: {e}")
56
+ sys.exit(1)
57
+
58
+
59
+ if __name__ == "__main__":
60
+ main()
recover.py CHANGED
@@ -16,7 +16,7 @@ def save_api_key(api_key, email):
16
16
 
17
17
  print(f"\nAPI key saved to {config_file}")
18
18
 
19
- def recover():
19
+ def recover_key():
20
20
  email = input("Email: ").strip()
21
21
 
22
22
  if not email or "@" not in email:
@@ -34,7 +34,7 @@ def recover():
34
34
  print(f"Error: {response.json().get('detail', 'Unknown error')}")
35
35
  return
36
36
 
37
- print("Verification code sent to your email")
37
+ print("Verification code sent to your email. Check spam folder if not in Inbox.")
38
38
  except Exception as e:
39
39
  print(f"Error connecting to API: {e}")
40
40
  return
@@ -58,4 +58,4 @@ def recover():
58
58
  print(f"Error connecting to API: {e}")
59
59
 
60
60
  if __name__ == "__main__":
61
- recover()
61
+ recover_key()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sparq
3
- Version: 0.1.5
3
+ Version: 0.2.0
4
4
  Summary: Python client for the sparq api - automated degree planning for SJSU students + more
5
5
  Author-email: Shiven Sheth <shivsbots@gmail.com>
6
6
  License-Expression: MIT
@@ -27,10 +27,10 @@ pip install sparq
27
27
 
28
28
  ### 1. Get Your API Key
29
29
 
30
- First, run the authentication script to register and get your API key:
30
+ First, register and get your API key:
31
31
 
32
32
  ```bash
33
- python auth.py
33
+ sparq auth
34
34
  ```
35
35
 
36
36
  This will:
@@ -76,7 +76,7 @@ print(plan)
76
76
  View your API usage statistics:
77
77
 
78
78
  ```bash
79
- python usage.py
79
+ sparq usage
80
80
  ```
81
81
 
82
82
  ### 4. Recover Lost API Key
@@ -84,9 +84,15 @@ python usage.py
84
84
  If you lose your API key:
85
85
 
86
86
  ```bash
87
- python recover.py
87
+ sparq recover
88
88
  ```
89
89
 
90
+ ## CLI Commands
91
+
92
+ - `sparq auth` - Register and get your API key
93
+ - `sparq usage` - View API usage statistics
94
+ - `sparq recover` - Recover your API key via email
95
+
90
96
  ## Features
91
97
 
92
98
  - **Degree Planning**: Generate semester-by-semester plans for SJSU majors
@@ -0,0 +1,11 @@
1
+ auth.py,sha256=Napt9UXU3tCtB59-weX0Xz-PzFcT-OH7f6UU2kwxS1I,2141
2
+ cli.py,sha256=NFvTsTfBV9eOzj5-_OZ_hHSsYUQFlrsZYeQt4lYs-OA,1419
3
+ client.py,sha256=V-2lY3-Bqf3OS57uDvld1pCJ0GgOAQCNQathZoAJbVI,2003
4
+ recover.py,sha256=grNf8EVe3lKmRSHxcf9bhUdJg-97LuOJzWCEsgsBZms,1745
5
+ usage.py,sha256=YO2UmKk227L3y3t-TYX-RGdcGgcllLJC5CzFKCx9mn0,1845
6
+ sparq-0.2.0.dist-info/licenses/LICENSE,sha256=u3S2yd9hZVIlnAs1I1u7Dh7yvkF5UOD2ioaXRzuPqhQ,1068
7
+ sparq-0.2.0.dist-info/METADATA,sha256=GKIsxvgbtgiw4m1DfCya4D2JB3MrGekjUomzypSdeS0,2158
8
+ sparq-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ sparq-0.2.0.dist-info/entry_points.txt,sha256=NPijFObGVd6A5OFVzfNWBmL21CvHtlOMxcDmJNsV1gM,35
10
+ sparq-0.2.0.dist-info/top_level.txt,sha256=PhPB7i3dPGHDDbifd2SoSSfGoecXpMjNhXmzRk4Jn14,30
11
+ sparq-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sparq = cli:main
@@ -1,4 +1,5 @@
1
1
  auth
2
+ cli
2
3
  client
3
4
  recover
4
5
  usage
usage.py CHANGED
@@ -13,7 +13,7 @@ def load_api_key():
13
13
  return line.strip().split("=", 1)[1]
14
14
  return None
15
15
 
16
- def view_usage(api_key=None):
16
+ def show_usage(api_key=None):
17
17
  if not api_key:
18
18
  api_key = load_api_key()
19
19
  if not api_key:
@@ -52,4 +52,4 @@ def view_usage(api_key=None):
52
52
  print(f"Error: {e}")
53
53
 
54
54
  if __name__ == "__main__":
55
- view_usage()
55
+ show_usage()
@@ -1,9 +0,0 @@
1
- auth.py,sha256=MK1cCKnhkPru6DTp8rSG4G4cTuxydRC-FJQV2Ua4zqc,1576
2
- client.py,sha256=V-2lY3-Bqf3OS57uDvld1pCJ0GgOAQCNQathZoAJbVI,2003
3
- recover.py,sha256=wTisYzw-B_xpciqep1bwEOQcNoVpsdQKzCaxIli3dL8,1701
4
- usage.py,sha256=-iaXr_CZGlY7qNxJCzkU0P1eZ-cZDHJYjLPbpKDBqq8,1845
5
- sparq-0.1.5.dist-info/licenses/LICENSE,sha256=u3S2yd9hZVIlnAs1I1u7Dh7yvkF5UOD2ioaXRzuPqhQ,1068
6
- sparq-0.1.5.dist-info/METADATA,sha256=qiS_e9UOLPTc5fCHj26RVn9Z3dCcv0VjV_YD1a-z0IM,2043
7
- sparq-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- sparq-0.1.5.dist-info/top_level.txt,sha256=BC13SQ_ChSPIgV2PKOkVEiZ7xvZH7PocWm29AQN_2NU,26
9
- sparq-0.1.5.dist-info/RECORD,,
File without changes