github-streak 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.
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: github-streak
3
+ Version: 0.1.0
4
+ Summary: CLI tool to track your GitHub contribution streaks
5
+ Author: Deven Mistry
6
+ Project-URL: Homepage, https://github.com/deven367/github-streak
7
+ Project-URL: Repository, https://github.com/deven367/github-streak
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.7
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.25.0
19
+ Requires-Dist: python-dotenv>=0.19.0
20
+
21
+ # ghstreak
22
+
23
+ A simple CLI tool to track your GitHub contribution streaks.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install ghstreak
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```bash
34
+ ghstreak <github_username>
35
+ ```
36
+
37
+ Example:
38
+
39
+ ```bash
40
+ ghstreak deven367
41
+ ```
42
+
43
+ ## Authentication
44
+
45
+ For higher API rate limits, set your GitHub token as an environment variable:
46
+
47
+ ```bash
48
+ export GITHUB_TOKEN=your_token_here
49
+ ```
50
+
51
+ You can create a personal access token at: <https://github.com/settings/tokens>
52
+
53
+ ## Output
54
+
55
+ The tool displays:
56
+
57
+ - Your current contribution streak (consecutive days with contributions)
58
+ - Your previous streak (if applicable) and when it ended
59
+
60
+ ## Requirements
61
+
62
+ - Python >= 3.7
63
+ - requests >= 2.25.0
64
+ - python-dotenv >= 0.19.0
@@ -0,0 +1,44 @@
1
+ # ghstreak
2
+
3
+ A simple CLI tool to track your GitHub contribution streaks.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install ghstreak
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ ghstreak <github_username>
15
+ ```
16
+
17
+ Example:
18
+
19
+ ```bash
20
+ ghstreak deven367
21
+ ```
22
+
23
+ ## Authentication
24
+
25
+ For higher API rate limits, set your GitHub token as an environment variable:
26
+
27
+ ```bash
28
+ export GITHUB_TOKEN=your_token_here
29
+ ```
30
+
31
+ You can create a personal access token at: <https://github.com/settings/tokens>
32
+
33
+ ## Output
34
+
35
+ The tool displays:
36
+
37
+ - Your current contribution streak (consecutive days with contributions)
38
+ - Your previous streak (if applicable) and when it ended
39
+
40
+ ## Requirements
41
+
42
+ - Python >= 3.7
43
+ - requests >= 2.25.0
44
+ - python-dotenv >= 0.19.0
File without changes
@@ -0,0 +1,111 @@
1
+ from datetime import date, timedelta
2
+ import os
3
+ import requests
4
+ from dotenv import load_dotenv
5
+
6
+ # Load environment variables from .env file
7
+ load_dotenv()
8
+
9
+ def get_contributions(username, days=365):
10
+ # GitHub GraphQL API to get contribution calendar
11
+ token = os.getenv('GITHUB_TOKEN')
12
+
13
+ if not token:
14
+ print("Warning: No GITHUB_TOKEN found. API rate limits will be very restrictive.")
15
+ print("To fix this, set your token: export GITHUB_TOKEN=your_token_here")
16
+ print("You can create a token at: https://github.com/settings/tokens")
17
+ print()
18
+
19
+ from_date = (date.today() - timedelta(days=days)).isoformat() + "T00:00:00Z"
20
+ to_date = date.today().isoformat() + "T23:59:59Z"
21
+
22
+ query = f"""
23
+ query {{
24
+ user(login: "{username}") {{
25
+ contributionsCollection(from: "{from_date}", to: "{to_date}") {{
26
+ contributionCalendar {{
27
+ weeks {{
28
+ contributionDays {{
29
+ date
30
+ contributionCount
31
+ }}
32
+ }}
33
+ }}
34
+ }}
35
+ }}
36
+ }}
37
+ """
38
+
39
+ headers = {
40
+ "Authorization": f"Bearer {token}",
41
+ "Content-Type": "application/json"
42
+ } if token else {"Content-Type": "application/json"}
43
+
44
+ try:
45
+ response = requests.post(
46
+ "https://api.github.com/graphql",
47
+ json={"query": query},
48
+ headers=headers
49
+ )
50
+ response.raise_for_status()
51
+ result = response.json()
52
+
53
+ if 'errors' in result:
54
+ raise Exception(f"GraphQL Error: {result['errors']}")
55
+
56
+ days_data = []
57
+ for week in result['data']['user']['contributionsCollection']['contributionCalendar']['weeks']:
58
+ for day in week['contributionDays']:
59
+ days_data.append({
60
+ "date": day["date"],
61
+ "count": day["contributionCount"]
62
+ })
63
+ return sorted(days_data, key=lambda x: x["date"], reverse=True)
64
+
65
+ except requests.exceptions.HTTPError as e:
66
+ if e.response.status_code == 403:
67
+ raise Exception("GitHub API rate limit exceeded. Please set GITHUB_TOKEN environment variable.")
68
+ raise
69
+
70
+ def analyze_streaks(days_data):
71
+ current_streak = 0
72
+ previous_streak = 0
73
+ gap_found = False
74
+ last_active_day = None
75
+
76
+ for i, day in enumerate(days_data):
77
+ if day['count'] > 0:
78
+ if not gap_found:
79
+ current_streak += 1
80
+ else:
81
+ previous_streak += 1
82
+ else:
83
+ if not gap_found:
84
+ gap_found = True
85
+ last_active_day = days_data[i-1]["date"] if i > 0 else None
86
+ elif previous_streak > 0:
87
+ break
88
+
89
+ return {
90
+ "current_streak": current_streak,
91
+ "previous_streak": previous_streak,
92
+ "last_active_day": last_active_day
93
+ }
94
+
95
+ def main():
96
+ import sys
97
+ if len(sys.argv) != 2:
98
+ print("Usage: ghstreak <github_username>")
99
+ sys.exit(1)
100
+
101
+ username = sys.argv[1]
102
+ data = get_contributions(username)
103
+ result = analyze_streaks(data)
104
+ print(f"Current streak: {result['current_streak']} days")
105
+ if result['previous_streak'] > 0:
106
+ print(f"Previous streak: {result['previous_streak']} days, ended on {result['last_active_day']}")
107
+ else:
108
+ print("No previous streak found")
109
+
110
+ if __name__ == "__main__":
111
+ main()
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: github-streak
3
+ Version: 0.1.0
4
+ Summary: CLI tool to track your GitHub contribution streaks
5
+ Author: Deven Mistry
6
+ Project-URL: Homepage, https://github.com/deven367/github-streak
7
+ Project-URL: Repository, https://github.com/deven367/github-streak
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.7
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.25.0
19
+ Requires-Dist: python-dotenv>=0.19.0
20
+
21
+ # ghstreak
22
+
23
+ A simple CLI tool to track your GitHub contribution streaks.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install ghstreak
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```bash
34
+ ghstreak <github_username>
35
+ ```
36
+
37
+ Example:
38
+
39
+ ```bash
40
+ ghstreak deven367
41
+ ```
42
+
43
+ ## Authentication
44
+
45
+ For higher API rate limits, set your GitHub token as an environment variable:
46
+
47
+ ```bash
48
+ export GITHUB_TOKEN=your_token_here
49
+ ```
50
+
51
+ You can create a personal access token at: <https://github.com/settings/tokens>
52
+
53
+ ## Output
54
+
55
+ The tool displays:
56
+
57
+ - Your current contribution streak (consecutive days with contributions)
58
+ - Your previous streak (if applicable) and when it ended
59
+
60
+ ## Requirements
61
+
62
+ - Python >= 3.7
63
+ - requests >= 2.25.0
64
+ - python-dotenv >= 0.19.0
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ ghstreak/__init__.py
4
+ ghstreak/streak.py
5
+ github_streak.egg-info/PKG-INFO
6
+ github_streak.egg-info/SOURCES.txt
7
+ github_streak.egg-info/dependency_links.txt
8
+ github_streak.egg-info/entry_points.txt
9
+ github_streak.egg-info/requires.txt
10
+ github_streak.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ghstreak = ghstreak.streak:main
@@ -0,0 +1,2 @@
1
+ requests>=2.25.0
2
+ python-dotenv>=0.19.0
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "github-streak"
7
+ version = "0.1.0"
8
+ description = "CLI tool to track your GitHub contribution streaks"
9
+ readme = "README.md"
10
+ authors = [{name = "Deven Mistry"}]
11
+ requires-python = ">=3.7"
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3.7",
15
+ "Programming Language :: Python :: 3.8",
16
+ "Programming Language :: Python :: 3.9",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Operating System :: OS Independent",
20
+ "License :: OSI Approved :: MIT License",
21
+ ]
22
+ dependencies = [
23
+ "requests>=2.25.0",
24
+ "python-dotenv>=0.19.0",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/deven367/github-streak"
29
+ Repository = "https://github.com/deven367/github-streak"
30
+
31
+ [project.scripts]
32
+ ghstreak = "ghstreak.streak:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+