-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_ext-git.py
executable file
·41 lines (33 loc) · 1.01 KB
/
get_ext-git.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
37
38
39
40
41
#!/usr/bin/env python3
# Imports
import os
import sys
import git
import pathlib
from prettytable import PrettyTable
# Vars
path = sys.argv[-1] # dir to work in (scan)
g = git.Git(path)
# Check if any path has been given:
if len(sys.argv) == 1:
sys.exit("You need to give path to dir!!!")
files = g.execute(["git", "ls-files"]).split("\n")
# GET THIS FROM HELPER FILE!
os.system("cls" if os.name == "nt" else "clear")
table = PrettyTable(
["Num", "Rel path", "Filename", "Ext (suffix)", "Ext (suffixes)", "Ext (splitext)"]
)
table.align = "l"
for i in range(0, len(files)):
# print(f"{i + 1}. {files[i]} = {pathlib.Path(files[i]).suffix} / {pathlib.Path(files[i]).suffixes} / {os.path.splitext(files[i])[1]}") # <- joing the suffixes? / use suffix?
table.add_row(
[
i + 1,
files[i],
os.path.basename(files[i]),
pathlib.Path(files[i]).suffix,
pathlib.Path(files[i]).suffixes,
os.path.splitext(files[i])[1],
]
)
print(table)