diff options
author | crupest <crupest@outlook.com> | 2020-10-27 19:21:35 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-10-27 19:21:35 +0800 |
commit | ac769e656b122ff569c3f1534701b71e00fed586 (patch) | |
tree | 72966645ff1e25139d3995262e1c4349f2c14733 /BackEnd/tools/convert-eol.py | |
parent | 14e5848c23c643cea9b5d709770747d98c3d75e2 (diff) | |
download | timeline-ac769e656b122ff569c3f1534701b71e00fed586.tar.gz timeline-ac769e656b122ff569c3f1534701b71e00fed586.tar.bz2 timeline-ac769e656b122ff569c3f1534701b71e00fed586.zip |
Split front and back end.
Diffstat (limited to 'BackEnd/tools/convert-eol.py')
-rw-r--r-- | BackEnd/tools/convert-eol.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/BackEnd/tools/convert-eol.py b/BackEnd/tools/convert-eol.py new file mode 100644 index 00000000..3ea8ed7c --- /dev/null +++ b/BackEnd/tools/convert-eol.py @@ -0,0 +1,35 @@ +# This is a python script that converts all text source codes into
+# CRLF (Windows line ending) eol format and UTF-8 with NO BOM encoding.
+
+import glob
+import os.path
+
+project_root = os.path.relpath(os.path.join(os.path.dirname(__file__), '..'))
+
+
+def convert(file_path):
+ with open(file_path, 'r', encoding='utf-8') as open_file:
+ content = open_file.read()
+
+ #if there is BOM, remove BOM
+ if content[0] == '\ufeff':
+ content = content[1:]
+
+ with open(file_path, 'w', encoding='utf-8', newline='\r\n') as open_file:
+ open_file.write(content)
+
+
+glob_list = [
+ './nuget.config',
+ '**/*.sln',
+ '**/*.cs',
+ '**/*.csproj',
+ '**/appsettings*.json'
+]
+
+for glob_pattern in glob_list:
+ for f in glob.glob(glob_pattern, recursive=True):
+ print('Converting {}'.format(f))
+ convert(f)
+
+print('Done!!!')
|