-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_manager.py
36 lines (29 loc) · 1.07 KB
/
config_manager.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
from typing import Iterable
import configparser
import os
import argparse
class config_manager:
def __init__(self):
self.config = configparser.ConfigParser()
self.config.read("profiles.cfg")
def is_profile(self, profile_name: str) -> bool:
return profile_name in self.config
def get_properties(self, profile_name: str) -> Iterable:
return self.config[profile_name]
def set_profile(self, profile_name):
for k in self.config[profile_name]:
cmd = "git config --global --unset %s" % k
print(cmd)
os.system(cmd)
target = self.config[profile_name][k]
if target != "UNSET":
cmd = "git config --global %s %s" % (k, target)
print(cmd)
os.system(cmd)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("profile_name", help="Enter the name of profile you"
" want to apply")
args = parser.parse_args()
cfmgr = config_manager()
cfmgr.set_profile(args.profile_name)