gitraze 0.1.0__tar.gz → 0.2.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.
- {gitraze-0.1.0 → gitraze-0.2.0}/PKG-INFO +5 -3
- {gitraze-0.1.0 → gitraze-0.2.0}/README.md +3 -2
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/cli.py +19 -4
- gitraze-0.2.0/gitraze/config.py +28 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/core/api_rest.py +27 -0
- gitraze-0.2.0/gitraze/modules/search.py +107 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/utils/helpers.py +9 -1
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze.egg-info/PKG-INFO +5 -3
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze.egg-info/requires.txt +1 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/pyproject.toml +2 -2
- gitraze-0.1.0/gitraze/config.py +0 -7
- gitraze-0.1.0/gitraze/modules/search.py +0 -1
- {gitraze-0.1.0 → gitraze-0.2.0}/LICENSE +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/__init__.py +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/core/__init__.py +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/core/api_graphql.py +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/modules/__init__.py +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/modules/analytics.py +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/modules/repo.py +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/modules/user.py +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze/utils/__init__.py +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze.egg-info/SOURCES.txt +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze.egg-info/dependency_links.txt +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze.egg-info/entry_points.txt +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/gitraze.egg-info/top_level.txt +0 -0
- {gitraze-0.1.0 → gitraze-0.2.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitraze
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A CLI and Python library for GitHub reconnaissance, search, and analysis
|
|
5
5
|
Author: AK Pandey
|
|
6
6
|
License: MIT
|
|
@@ -13,6 +13,7 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: requests
|
|
15
15
|
Requires-Dist: colorama
|
|
16
|
+
Requires-Dist: re
|
|
16
17
|
Dynamic: license-file
|
|
17
18
|
|
|
18
19
|
# Gitraze
|
|
@@ -64,8 +65,9 @@ Example:
|
|
|
64
65
|
```bash
|
|
65
66
|
gitraze --help
|
|
66
67
|
gitraze user octocat
|
|
67
|
-
gitraze repo torvalds/linux
|
|
68
|
-
gitraze search "machine learning"
|
|
68
|
+
gitraze repo torvalds/linux
|
|
69
|
+
gitraze search "machine learning"
|
|
70
|
+
gitraze analyze github # Coming soon!
|
|
69
71
|
```
|
|
70
72
|
|
|
71
73
|
Example output:
|
|
@@ -47,8 +47,9 @@ Example:
|
|
|
47
47
|
```bash
|
|
48
48
|
gitraze --help
|
|
49
49
|
gitraze user octocat
|
|
50
|
-
gitraze repo torvalds/linux
|
|
51
|
-
gitraze search "machine learning"
|
|
50
|
+
gitraze repo torvalds/linux
|
|
51
|
+
gitraze search "machine learning"
|
|
52
|
+
gitraze analyze github # Coming soon!
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
Example output:
|
|
@@ -2,6 +2,7 @@ import argparse
|
|
|
2
2
|
from gitraze.utils.helpers import pretty_print
|
|
3
3
|
from gitraze.modules.user import get_user_rest
|
|
4
4
|
from gitraze.modules.repo import get_repo_rest
|
|
5
|
+
from gitraze.modules.search import get_search_rest
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
def main():
|
|
@@ -14,7 +15,7 @@ def main():
|
|
|
14
15
|
parser.add_argument(
|
|
15
16
|
"--version",
|
|
16
17
|
action="version",
|
|
17
|
-
version="gitraze 0.
|
|
18
|
+
version="gitraze 0.2.0"
|
|
18
19
|
)
|
|
19
20
|
|
|
20
21
|
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
@@ -29,7 +30,9 @@ def main():
|
|
|
29
30
|
|
|
30
31
|
# --- SEARCH ---
|
|
31
32
|
search_parser = subparsers.add_parser("search", help="Search GitHub")
|
|
32
|
-
search_parser.add_argument("
|
|
33
|
+
search_parser.add_argument("category",choices=["repos", "users", "issues", "prs", "topics"],help="repos | users | issues | prs | topics")
|
|
34
|
+
search_parser.add_argument("query", nargs="+", help="Search category (repos, users, issues, topics)")
|
|
35
|
+
search_parser.add_argument("-n", "--limit", type=int, default=1, help="Number of results to show")
|
|
33
36
|
|
|
34
37
|
# --- ANALYZE ---
|
|
35
38
|
analyze_parser = subparsers.add_parser("analyze", help="Analyze target")
|
|
@@ -83,9 +86,21 @@ def handle_repo(args):
|
|
|
83
86
|
|
|
84
87
|
|
|
85
88
|
def handle_search(args):
|
|
89
|
+
category = args.category
|
|
86
90
|
query = " ".join(args.query)
|
|
87
|
-
print(f"[
|
|
88
|
-
|
|
91
|
+
print(f"[+] Searching {category} for '{query}'...")
|
|
92
|
+
|
|
93
|
+
data = get_search_rest(args.category, args.query, args.limit)
|
|
94
|
+
if "error" in data:
|
|
95
|
+
print(data["error"])
|
|
96
|
+
return
|
|
97
|
+
|
|
98
|
+
print("[✓] Done")
|
|
99
|
+
if isinstance(data, list):
|
|
100
|
+
for i, item in enumerate(data, 1):
|
|
101
|
+
pretty_print(item, title=f"{category} [{i}] -> {query}")
|
|
102
|
+
else:
|
|
103
|
+
pretty_print(data, title=f"Search: {category} -> {query}")
|
|
89
104
|
|
|
90
105
|
|
|
91
106
|
def handle_analysis(args):
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# config.py
|
|
2
|
+
|
|
3
|
+
'''=============REST=============='''
|
|
4
|
+
|
|
5
|
+
# --- BASE CONFIGS ---
|
|
6
|
+
REST_BASE_URL = "https://api.github.com"
|
|
7
|
+
GRAPHQL_URL = "https://api.github.com/graphql"
|
|
8
|
+
DEFAULT_TIMEOUT = 10
|
|
9
|
+
DEFAULT_HEADERS = {
|
|
10
|
+
"Accept": "application/vnd.github+json"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
# --- USER CONFIG ---
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# --- REPO CONFIG ---
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# --- SEARCH CONFIG ---
|
|
20
|
+
SEARCH_MAP = {
|
|
21
|
+
"repos": "repositories",
|
|
22
|
+
"users": "users",
|
|
23
|
+
"issues": "issues",
|
|
24
|
+
"topics": "topics",
|
|
25
|
+
"prs": "issues"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# api_rest.py
|
|
2
2
|
import requests
|
|
3
3
|
from gitraze.config import REST_BASE_URL, DEFAULT_HEADERS, DEFAULT_TIMEOUT
|
|
4
|
+
from gitraze.config import SEARCH_MAP
|
|
4
5
|
|
|
5
6
|
def get_user(username):
|
|
6
7
|
url = f"{REST_BASE_URL}/users/{username}"
|
|
@@ -35,5 +36,31 @@ def get_repo(owner, repo):
|
|
|
35
36
|
except requests.exceptions.Timeout:
|
|
36
37
|
return {"error": "Request timed out. Check your connection."}
|
|
37
38
|
|
|
39
|
+
except requests.exceptions.RequestException as e:
|
|
40
|
+
return {"error": f"Request failed: {str(e)}"}
|
|
41
|
+
|
|
42
|
+
def get_search(category, query):
|
|
43
|
+
url = f"{REST_BASE_URL}/search/{SEARCH_MAP.get(category)}"
|
|
44
|
+
if category == "issues":
|
|
45
|
+
query = query + " type:issue"
|
|
46
|
+
elif category == "prs":
|
|
47
|
+
query += " type:pr"
|
|
48
|
+
|
|
49
|
+
params = {
|
|
50
|
+
"q": query
|
|
51
|
+
}
|
|
52
|
+
try:
|
|
53
|
+
response = requests.get(
|
|
54
|
+
url,
|
|
55
|
+
headers=DEFAULT_HEADERS,
|
|
56
|
+
params=params,
|
|
57
|
+
timeout=DEFAULT_TIMEOUT
|
|
58
|
+
)
|
|
59
|
+
response.raise_for_status()
|
|
60
|
+
return response.json()
|
|
61
|
+
|
|
62
|
+
except requests.exceptions.Timeout:
|
|
63
|
+
return {"error": "Request timed out. Check your connection."}
|
|
64
|
+
|
|
38
65
|
except requests.exceptions.RequestException as e:
|
|
39
66
|
return {"error": f"Request failed: {str(e)}"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# search.py
|
|
2
|
+
from gitraze.utils.helpers import format_date
|
|
3
|
+
from gitraze.utils.helpers import clean_html
|
|
4
|
+
from gitraze.core.api_rest import get_search
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_search_rest(category, query, limit=1):
|
|
8
|
+
data = get_search(category, query)
|
|
9
|
+
if "error" in data:
|
|
10
|
+
return data
|
|
11
|
+
items = data.get("items", [])
|
|
12
|
+
|
|
13
|
+
if category == "issues":
|
|
14
|
+
items = [i for i in items if "pull_request" not in i]
|
|
15
|
+
elif category == "prs":
|
|
16
|
+
items = [i for i in items if "pull_request" in i]
|
|
17
|
+
|
|
18
|
+
if category not in ["repos", "users", "issues", "prs", "topics"]:
|
|
19
|
+
return {"error": "Invalid category"}
|
|
20
|
+
if not items:
|
|
21
|
+
return {"error": "No results found"}
|
|
22
|
+
items = items[:limit]
|
|
23
|
+
results = []
|
|
24
|
+
|
|
25
|
+
for item in items:
|
|
26
|
+
match(category):
|
|
27
|
+
case "repos":
|
|
28
|
+
results.append({
|
|
29
|
+
"full_name": item.get("full_name"),
|
|
30
|
+
"html_url": item.get("html_url"),
|
|
31
|
+
"description": clean_html(item.get("description")),
|
|
32
|
+
"stargazers_count": item.get("stargazers_count"),
|
|
33
|
+
"watchers_count": item.get("watchers_count"),
|
|
34
|
+
"forks_count": item.get("forks_count"),
|
|
35
|
+
"open_issues_count": item.get("open_issues_count"),
|
|
36
|
+
"archived": item.get("archived"),
|
|
37
|
+
"disabled": item.get("disabled"),
|
|
38
|
+
"updated_at": format_date(item.get("updated_at")),
|
|
39
|
+
"pushed_at": format_date(item.get("pushed_at")),
|
|
40
|
+
"language": item.get("language"),
|
|
41
|
+
"visibility": item.get("visibility"),
|
|
42
|
+
"default_branch": item.get("default_branch"),
|
|
43
|
+
"owner": item.get("owner", {}).get("login"),
|
|
44
|
+
"For More, use": "$ gitraze repo <owner/repo>"
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
case "users":
|
|
48
|
+
results.append({
|
|
49
|
+
"login": item.get("login"),
|
|
50
|
+
"html_url": item.get("html_url"),
|
|
51
|
+
"type": item.get("type"),
|
|
52
|
+
"score": item.get("score"),
|
|
53
|
+
"site_admin": item.get("site_admin"),
|
|
54
|
+
"repos_url": item.get("repos_url"),
|
|
55
|
+
"followers_url": item.get("followers_url"),
|
|
56
|
+
"following_url": item.get("following_url"),
|
|
57
|
+
"organizations_url": item.get("organizations_url"),
|
|
58
|
+
"For More, use": "$ gitraze user <username>"
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
case "issues":
|
|
62
|
+
results.append({
|
|
63
|
+
"title": item.get("title"),
|
|
64
|
+
"html_url": item.get("html_url"),
|
|
65
|
+
"state": item.get("state"),
|
|
66
|
+
"number": item.get("number"),
|
|
67
|
+
"comments": item.get("comments"),
|
|
68
|
+
"created_at": format_date(item.get("created_at")),
|
|
69
|
+
"updated_at": format_date(item.get("updated_at")),
|
|
70
|
+
"closed_at": format_date(item.get("closed_at")),
|
|
71
|
+
"user": item.get("user", {}).get("login"),
|
|
72
|
+
"repository_url": item.get("repository_url"),
|
|
73
|
+
"labels": [label.get("name") for label in item.get("labels", [])]
|
|
74
|
+
})
|
|
75
|
+
case "prs":
|
|
76
|
+
results.append({
|
|
77
|
+
"title": item.get("title"),
|
|
78
|
+
"html_url": item.get("html_url"),
|
|
79
|
+
"state": item.get("state"),
|
|
80
|
+
"number": item.get("number"),
|
|
81
|
+
"comments": item.get("comments"),
|
|
82
|
+
"created_at": format_date(item.get("created_at")),
|
|
83
|
+
"updated_at": format_date(item.get("updated_at")),
|
|
84
|
+
"closed_at": format_date(item.get("closed_at")),
|
|
85
|
+
"merged_at": format_date(item.get("pull_request", {}).get("merged_at")),
|
|
86
|
+
"user": item.get("user", {}).get("login"),
|
|
87
|
+
"repository_url": item.get("repository_url"),
|
|
88
|
+
"labels": [label.get("name") for label in item.get("labels", [])],
|
|
89
|
+
"draft": item.get("draft"),
|
|
90
|
+
"pr_url": item.get("pull_request", {}).get("html_url")
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
case "topics":
|
|
94
|
+
results.append({
|
|
95
|
+
"name": item.get("name"),
|
|
96
|
+
"display_name": item.get("display_name"),
|
|
97
|
+
"short_description": clean_html(item.get("short_description")),
|
|
98
|
+
"description": clean_html(item.get("description")),
|
|
99
|
+
"score": item.get("score"),
|
|
100
|
+
"created_by": item.get("created_by"),
|
|
101
|
+
"released": item.get("released"),
|
|
102
|
+
"created_at": format_date(item.get("created_at")),
|
|
103
|
+
"featured": item.get("featured")
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
return results
|
|
107
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# helpers.py
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from colorama import Fore, Style, init
|
|
4
|
+
import re
|
|
4
5
|
|
|
5
6
|
init(autoreset=True)
|
|
6
7
|
|
|
@@ -32,4 +33,11 @@ def pretty_print(data, title=None):
|
|
|
32
33
|
def format_date(date_str):
|
|
33
34
|
if not date_str:
|
|
34
35
|
return None
|
|
35
|
-
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
return datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%SZ").strftime("%d %b %Y")
|
|
39
|
+
except ValueError:
|
|
40
|
+
return date_str # fallback (don’t crash)
|
|
41
|
+
|
|
42
|
+
def clean_html(text):
|
|
43
|
+
return re.sub(r"<.*?>", "", text) if text else text
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitraze
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A CLI and Python library for GitHub reconnaissance, search, and analysis
|
|
5
5
|
Author: AK Pandey
|
|
6
6
|
License: MIT
|
|
@@ -13,6 +13,7 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: requests
|
|
15
15
|
Requires-Dist: colorama
|
|
16
|
+
Requires-Dist: re
|
|
16
17
|
Dynamic: license-file
|
|
17
18
|
|
|
18
19
|
# Gitraze
|
|
@@ -64,8 +65,9 @@ Example:
|
|
|
64
65
|
```bash
|
|
65
66
|
gitraze --help
|
|
66
67
|
gitraze user octocat
|
|
67
|
-
gitraze repo torvalds/linux
|
|
68
|
-
gitraze search "machine learning"
|
|
68
|
+
gitraze repo torvalds/linux
|
|
69
|
+
gitraze search "machine learning"
|
|
70
|
+
gitraze analyze github # Coming soon!
|
|
69
71
|
```
|
|
70
72
|
|
|
71
73
|
Example output:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "gitraze"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "A CLI and Python library for GitHub reconnaissance, search, and analysis"
|
|
5
5
|
authors = [{ name = "AK Pandey" }]
|
|
6
|
-
dependencies = ["requests", "colorama"]
|
|
6
|
+
dependencies = ["requests", "colorama", "re"]
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
requires-python = ">=3.8"
|
|
9
9
|
license = { text = "MIT" }
|
gitraze-0.1.0/gitraze/config.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# search.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|