summaryrefslogtreecommitdiff
path: root/update-sha1sums.py
diff options
context:
space:
mode:
authordianlujitao <dianlujitao@lineageos.org>2020-01-31 12:19:35 +0800
committerMichael Bestas <mkbestas@lineageos.org>2020-04-30 00:48:54 +0300
commita38b083458f6fce17a58c984551196d843453e2b (patch)
tree02138722068ff2035f05a0a3ac3ece23a880182c /update-sha1sums.py
parent5c950f6070a74614c072b09270806b33dce8d05f (diff)
sdm660-common: update-sha1sums: Better handle line breaks
Change-Id: I15cfda82a5bc6f05c0d7b9db209064ba498dac11
Diffstat (limited to 'update-sha1sums.py')
-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')