-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprev_comp.py
executable file
·35 lines (27 loc) · 1.02 KB
/
prev_comp.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
from pathlib import Path
import platform
# removes old aliases, especially doubled ones and bad leftovers from ~/.bashrc file
def aliases_clean(start, end, file_name, *words):
if platform.system() == "Linux":
write_lines = []
skipping = False
with open(file_name, 'r') as read_obj:
for line in read_obj:
if start in line:
skipping = True
if not skipping:
write_lines.append(line)
if end in line:
skipping = False
for word in words:
if word in line:
write_lines.remove(line)
with open(file_name, 'w') as write_obj:
write_obj.write("".join(write_lines))
return False
def main():
home_dir = str(Path.home())
Path(f"{home_dir}/.ota_markers").mkdir(exist_ok=True)
aliases_clean('Shortcut', 'After', f'{home_dir}/.bashrc', 'uu', 'updateupdater', '# #')
if __name__ == "__main__":
main()