Skip to content

Commit c29c20d

Browse files
Merge pull request avinashkranjan#838 from Sukriti-sood/Feature
Added Script for Scripts.json
2 parents a4381f0 + c70cbed commit c29c20d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

script_updater.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
# imports
3+
import sys
4+
import json
5+
from github import Github
6+
7+
if(len(sys.argv) > 1):
8+
# access token
9+
token = sys.argv[1]
10+
repo_name = 'avinashkranjan/Amazing-Python-Scripts'
11+
files_to_be_excluded = sys.argv[2:]
12+
repo_contents = {}
13+
14+
try:
15+
gitHub=Github(token)
16+
repo=gitHub.get_repo(repo_name)
17+
18+
contents=repo.get_contents("")
19+
for content in contents:
20+
script=content
21+
if((script.type=="dir") and (script.name not in files_to_be_excluded)):
22+
repo_contents[script.name]=script.html_url
23+
24+
with open('Scripts.json','w') as jsonfile:
25+
json.dump(repo_contents,jsonfile,indent=4)
26+
27+
28+
29+
except:
30+
print('Either wrong token entered or poor internet connection..!')
31+
32+
33+
else:
34+
print('Please pass the token (and the files to be excluded if any).')
35+
36+

0 commit comments

Comments
 (0)