summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xupdate-sha1sums.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/update-sha1sums.py b/update-sha1sums.py
index da37b04..52429be 100755
--- a/update-sha1sums.py
+++ b/update-sha1sums.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# Copyright (C) 2016 The CyanogenMod Project
-# Copyright (C) 2017-2018 The LineageOS Project
+# Copyright (C) 2017-2020 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -22,16 +22,14 @@ import sys
device = 'sdm660-common'
vendor = 'xiaomi'
-lines = [line for line in open('proprietary-files.txt', 'r')]
+with open('proprietary-files.txt', 'r') as f:
+ lines = f.read().splitlines()
vendorPath = '../../../vendor/' + vendor + '/' + device + '/proprietary'
needSHA1 = False
def cleanup():
for index, line in enumerate(lines):
- # Remove '\n' character
- line = line[:-1]
-
# Skip empty or commented lines
if len(line) == 0 or line[0] == '#':
continue
@@ -39,14 +37,11 @@ def cleanup():
# Drop SHA1 hash, if existing
if '|' in line:
line = line.split('|')[0]
- lines[index] = '%s\n' % (line)
+ lines[index] = '%s' % (line)
def update():
for index, line in enumerate(lines):
- # Remove '\n' character
- line = line[:-1]
-
# Skip empty lines
if len(line) == 0:
continue
@@ -68,7 +63,7 @@ def update():
file = open('%s/%s' % (vendorPath, filePath), 'rb').read()
hash = sha1(file).hexdigest()
- lines[index] = '%s|%s\n' % (line, hash)
+ lines[index] = '%s|%s' % (line, hash)
if len(sys.argv) == 2 and sys.argv[1] == '-c':
@@ -77,7 +72,4 @@ else:
update()
with open('proprietary-files.txt', 'w') as file:
- for line in lines:
- file.write(line)
-
- file.close()
+ file.write('\n'.join(lines) + '\n')