-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
38 lines (25 loc) · 819 Bytes
/
config.py
File metadata and controls
38 lines (25 loc) · 819 Bytes
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
def gitUserConfig():
import configparser
import os
import sys
name = input("Enter Username: ")
email = input("Enter Useremail: ")
section_name = 'user'
cwd = os.getcwd()
config = configparser.ConfigParser()
path = os.path.join(cwd, '.git', 'config')
try:
if not os.path.exists(os.path.join(cwd, '.git')):
os.system("git init")
config.read(path)
if not config.has_section(section_name):
config.add_section(section_name)
config.set(section_name, 'name', name)
config.set(section_name, 'email', email)
with open(path, 'w') as configfile:
config.write(configfile)
except Exception as e:
print(e)
sys.exit()
if __name__ == "__main__":
gitUserConfig()