-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcat.py
46 lines (34 loc) · 992 Bytes
/
cat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import sys
from github import Github
from github import Auth
from github.GithubException import UnknownObjectException, GithubException
reponaming = " Listing contents of "
countrepolen = " Listing repos of "
warninglen = " Warning!: Repository not found! "
maindir = os.path.dirname(os.path.abspath(__file__))
# Read the token from the file
try:
with open(f"{maindir}/mykey.txt", "r") as file:
key = file.read().strip()
except FileNotFoundError:
print(
"\033[93mError: Token file 'mykey.txt' not found.\033[0m"
) # Yellow text for error
sys.exit(1)
auth = Auth.Token(key)
g = Github(auth=auth)
user = g.get_user()
# Color codes
GREEN = "\033[92m"
YELLOW = "\033[93m"
RESET = "\033[0m"
BLUE = "\033[94m"
lsts = sys.argv[1:]
print(lsts)
repo = g.get_repo(f"{user.login}/Auto-Git")
# Fetch the file content
file_content = repo.get_contents("install.sh")
content = file_content.decoded_content.decode()
print(content)
# Main logic