mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-29 10:26:12 +01:00
Update new config
This commit is contained in:
parent
857a03c14f
commit
c28dc02fff
1 changed files with 29 additions and 14 deletions
|
@ -42,8 +42,7 @@ class NewConfig(object):
|
||||||
if self.meta.use_colors in ["off", "OFF"]:
|
if self.meta.use_colors in ["off", "OFF"]:
|
||||||
self.br = ")"
|
self.br = ")"
|
||||||
# self.etc = "/etc/"
|
# self.etc = "/etc/"
|
||||||
self.etc = "/etc/slpkg/"
|
self.etc = "/home/dslackw/Downloads/test/"
|
||||||
# self.etc = "/home/dslackw/Downloads/test/"
|
|
||||||
self.news = []
|
self.news = []
|
||||||
|
|
||||||
def find_new(self):
|
def find_new(self):
|
||||||
|
@ -83,17 +82,17 @@ class NewConfig(object):
|
||||||
self.red, self.endc, self.br))
|
self.red, self.endc, self.br))
|
||||||
Msg().template(78)
|
Msg().template(78)
|
||||||
try:
|
try:
|
||||||
choose = raw_input("\nWhat would you like to do [O/R/P]? ")
|
choose = raw_input("\nWhat would you like to do [K/O/R/P]? ")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("")
|
print("")
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
if choose == "O":
|
if choose in ("K", "k"):
|
||||||
self.overwrite_all()
|
|
||||||
elif choose == "R":
|
|
||||||
self.remove_all()
|
|
||||||
elif choose == "K":
|
|
||||||
self.keep
|
self.keep
|
||||||
elif choose == "P":
|
elif choose in ("O", "o"):
|
||||||
|
self.overwrite_all()
|
||||||
|
elif choose in ("R", "r"):
|
||||||
|
self.remove_all()
|
||||||
|
elif choose in ("P", "p"):
|
||||||
self.prompt()
|
self.prompt()
|
||||||
|
|
||||||
def overwrite_all(self):
|
def overwrite_all(self):
|
||||||
|
@ -122,6 +121,7 @@ class NewConfig(object):
|
||||||
self.red, self.endc, self.br, self.red, self.endc, self.br,
|
self.red, self.endc, self.br, self.red, self.endc, self.br,
|
||||||
self.red, self.endc, self.br))
|
self.red, self.endc, self.br))
|
||||||
Msg().template(78)
|
Msg().template(78)
|
||||||
|
print("")
|
||||||
self.i = 0
|
self.i = 0
|
||||||
try:
|
try:
|
||||||
while self.i < len(self.news):
|
while self.i < len(self.news):
|
||||||
|
@ -135,15 +135,18 @@ class NewConfig(object):
|
||||||
"""Choose what do to file by file
|
"""Choose what do to file by file
|
||||||
"""
|
"""
|
||||||
prompt_ask = raw_input("{0} [K/O/R/D/M]? ".format(n))
|
prompt_ask = raw_input("{0} [K/O/R/D/M]? ".format(n))
|
||||||
if prompt_ask == "K":
|
print("")
|
||||||
|
if prompt_ask in ("K", "k"):
|
||||||
self.keep()
|
self.keep()
|
||||||
elif prompt_ask == "O":
|
elif prompt_ask in ("O", "o"):
|
||||||
self._overwrite(n)
|
self._overwrite(n)
|
||||||
elif prompt_ask == "R":
|
elif prompt_ask in ("R", "r"):
|
||||||
self._remove(n)
|
self._remove(n)
|
||||||
elif prompt_ask == "D":
|
elif prompt_ask in ("D", "d"):
|
||||||
self.diff(n)
|
self.diff(n)
|
||||||
self.i -= 1
|
self.i -= 1
|
||||||
|
elif prompt_ask in ("M", "m"):
|
||||||
|
self.merge(n)
|
||||||
|
|
||||||
def _remove(self, n):
|
def _remove(self, n):
|
||||||
"""Remove one single file
|
"""Remove one single file
|
||||||
|
@ -173,7 +176,7 @@ class NewConfig(object):
|
||||||
for a, b in itertools.izip_longest(diff1, diff2):
|
for a, b in itertools.izip_longest(diff1, diff2):
|
||||||
l += 1
|
l += 1
|
||||||
if a != b:
|
if a != b:
|
||||||
for s1, s2 in itertools.izip_longest(a, b):
|
for s1, s2 in itertools.izip_longest(str(a), str(b)):
|
||||||
c += 1
|
c += 1
|
||||||
if s1 != s2:
|
if s1 != s2:
|
||||||
break
|
break
|
||||||
|
@ -188,6 +191,18 @@ class NewConfig(object):
|
||||||
c = 0
|
c = 0
|
||||||
else:
|
else:
|
||||||
lines.append(a)
|
lines.append(a)
|
||||||
|
print("")
|
||||||
|
|
||||||
|
def merge(self, n):
|
||||||
|
old = Utils().read_file(n[:-4]).splitlines()
|
||||||
|
new = Utils().read_file(n).splitlines()
|
||||||
|
with open(n[:-4], "w") as out:
|
||||||
|
for l1, l2 in itertools.izip_longest(old, new):
|
||||||
|
if l1 != l2:
|
||||||
|
out.write(l2 + "\n")
|
||||||
|
else:
|
||||||
|
out.write(l1 + "\n")
|
||||||
|
print("The file {0} merged in file {1}".format(n, n[:-4]))
|
||||||
|
|
||||||
|
|
||||||
NewConfig().view_new()
|
NewConfig().view_new()
|
||||||
|
|
Loading…
Reference in a new issue