mirror of
https://github.com/ThomasKing2014/android-firmware-qti-sdm660
synced 2025-11-05 15:28:11 +08:00
35 lines
1.1 KiB
Python
Executable File
35 lines
1.1 KiB
Python
Executable File
#! /usr/bin/env python
|
|
### Replace CRLF with LF in files with extensions given in the below list under the folder given as argument to the script.
|
|
### Print names of changed files.
|
|
### This script expects dos2unix being installed on the host machine
|
|
|
|
import os, sys
|
|
import subprocess
|
|
|
|
def dos2unix_script(input, output, convert_eol_cmd):
|
|
content = ''
|
|
outsize = 0
|
|
with open(input, 'rb') as infile:
|
|
content = infile.read()
|
|
with open(output, 'wb') as output:
|
|
for line in content.splitlines():
|
|
outsize += len(line) + 1
|
|
output.write(line + '\n')
|
|
|
|
print convert_eol_cmd + ' :Done.'
|
|
|
|
|
|
extensions = ['.py', '.sh', '.scons', 'scons', 'SConstruct', 'SConscript', '.template', '.dblite', 'txt']
|
|
folder = str(sys.argv[1])
|
|
print folder
|
|
for root, dirs, files in os.walk(folder):
|
|
for file in files:
|
|
if file.endswith(tuple(extensions)):
|
|
filepath = os.path.join(root, file)
|
|
convert_eol_cmd = 'dos2unix '+filepath
|
|
#print convert_eol_cmd
|
|
dos2unix_script(filepath, filepath, convert_eol_cmd)
|
|
|
|
|
|
|