-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_line_endings.py
More file actions
35 lines (29 loc) · 932 Bytes
/
Copy pathfix_line_endings.py
File metadata and controls
35 lines (29 loc) · 932 Bytes
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
import os
def check_and_convert(file_path):
with open(file_path, 'rb') as f:
content = f.read()
if b'\r\n' in content:
print(f"Converting {file_path} to LF...")
new_content = content.replace(b'\r\n', b'\n')
with open(file_path, 'wb') as f:
f.write(new_content)
return True
return False
files_to_check = [
'arch/PKGBUILD',
'arch/.SRCINFO',
'Makefile',
]
# Add scripts and debian files
for root, dirs, files in os.walk('.'):
if '.git' in dirs:
dirs.remove('.git')
for file in files:
if root.startswith('./scripts') or root.startswith('./debian') or file.endswith('.sh'):
files_to_check.append(os.path.join(root, file))
converted_count = 0
for f in set(files_to_check):
if os.path.isfile(f):
if check_and_convert(f):
converted_count += 1
print(f"Total files converted: {converted_count}")