-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathglobalize.py
More file actions
41 lines (34 loc) · 1.2 KB
/
globalize.py
File metadata and controls
41 lines (34 loc) · 1.2 KB
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
import git
import datetime
import glob
import os
r = git.Repo('.')
remote_parts = r.remotes.origin.url[:-4].split('/')
uname = remote_parts[3]
def modify():
"""
'ssn.py' currently scrapes the intranet and sets the base path to the current
directory. 'modify', reads all the html files and replaces the base path (curr)
with that of the repository's GH page URL (newpath).
"""
curr = 'file://' + os.getcwd()
newpath = 'https://' + uname + '.github.io/SSN-Intranet-Downloader'
allhtmls = glob.glob('*/*/*.html') + glob.glob('*/*.html')
for f in allhtmls:
fl = open(f)
content = fl.read()
content = content.replace(curr, newpath)
open(f, 'w').write(content)
def gitops(ghpagesbranch='master'):
"""
Stages and commits all the changes inside CseElearnThirdYear to local repo.
Pushes them to branch used to serve ghpages. (master, in my case)
Make sure you set up GH Pages for your repo.
"""
r.index.add(['CseElearnFourthYear/*'])
r.index.commit('Added files - ' + str(datetime.datetime.now()))
org = r.remotes.origin
org.push(ghpagesbranch)
if __name__ == "__main__":
modify()
gitops()