Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cf8eb6d

Browse files
feat: module for utility functions
1 parent 72e9edf commit cf8eb6d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

‎Github-Automation/utils.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
def getMaxSpaces(file):
2+
max = float('-inf')
3+
for ele in file:
4+
ele = ele.strip()
5+
if(len(ele) > max):
6+
max = len(ele)
7+
return max
8+
9+
def getNestedFiles(rootDir,ignoredirs):
10+
from os import walk
11+
from os.path import join
12+
nestfiles = []
13+
for path, subdirs, files in walk(rootDir):
14+
if(all(ele not in path for ele in ignoredirs)):
15+
for name in files:
16+
nestfiles.append(join(path, name))
17+
return nestfiles
18+
19+
20+
def read_file(onlyfiles):
21+
filecontent = []
22+
for file in onlyfiles:
23+
with open(onlyfiles[onlyfiles.index(file)], "r") as f:
24+
filecontent.append(f.readlines())
25+
return filecontent
26+
27+
def initCommands(info):
28+
import gitcommands as git
29+
import filechange
30+
url,branch = info
31+
info.remove('n')
32+
git.init()
33+
git.createReadme()
34+
git.add(['.'])
35+
git.commit(['README.md'])
36+
git.setBranch(branch)
37+
git.setremote(url)
38+
git.push(url, branch)
39+
print('initial setup done :)')
40+
filechange.ischanged(url, branch)
41+
42+
def commitAndUpdate(changedfile,diffarr,url,branch):
43+
from gitcommands import commit,push,add
44+
from logger import updatedata
45+
from colors import logcolors
46+
add(changedfile)
47+
if(commit(changedfile,diffarr) == False):
48+
print(f'{logcolors.ERROR}Reverting Push{logcolors.ENDC}')
49+
# updatedata(changedfile, diffarr)
50+
else:
51+
print(f'{logcolors.SUCCESS}Updating Logs{logcolors.ENDC}')
52+
updatedata(changedfile, diffarr)
53+
if(len(changedfile) == 0):
54+
push(url, branch)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /