Skip to content

Commit cc46b1f

Browse files
lfs-ext: allow variable lenght for type and extension
1 parent b1d67e9 commit cc46b1f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

git-find-lfs-extensions.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333

3434
CWD = os.getcwd()
3535
CHUNKSIZE = 1024
36+
MAX_TYPE_LEN = len("Type")
37+
MAX_EXT_LEN = len("Extension")
3638
result = {}
37-
max_ext_len = len("Extension")
3839

3940
def is_binary(filename):
4041
"""Return true if the given filename is binary.
@@ -55,6 +56,10 @@ def is_binary(filename):
5556
return False
5657

5758
def add_file(ext, type, size_mb):
59+
global MAX_EXT_LEN
60+
MAX_EXT_LEN = max(MAX_EXT_LEN, len(ext))
61+
global MAX_TYPE_LEN
62+
MAX_TYPE_LEN = max(MAX_TYPE_LEN, len(type))
5863
if ext not in result:
5964
result[ext] = {
6065
'ext' : ext,
@@ -76,8 +81,8 @@ def add_file(ext, type, size_mb):
7681

7782
def print_line(type, ext, share_large, count_large, count_all, size_all, min, max):
7883
print('{}{}{}{}{}{}{}{}'.format(
79-
type.ljust(10),
80-
ext.ljust(3+max_ext_len),
84+
type.ljust(3+MAX_TYPE_LEN),
85+
ext.ljust(3+MAX_EXT_LEN),
8186
str(share_large).rjust(10),
8287
str(count_large).rjust(10),
8388
str(count_all).rjust(10),
@@ -102,7 +107,6 @@ def print_line(type, ext, share_large, count_large, count_all, size_all, min, ma
102107
ext = ext[ext.find('.')+1:]
103108
if ext.find('.') <= 0:
104109
add_file(ext, file_type, size_mb)
105-
max_ext_len = max(max_ext_len, len(ext))
106110
except Exception as e:
107111
print(e)
108112

0 commit comments

Comments
 (0)