Modify python formatting
[termux-packages] / scripts / lint-packages.py
1 #!/usr/bin/env python3
2
3 import os
4 import sys
5
6 def main():
7 package_dir = 'packages'
8 for pkgdir_name in sorted(os.listdir(package_dir)):
9 dir_path = package_dir + '/' + pkgdir_name
10 build_sh_path = dir_path + '/build.sh'
11 if not os.path.isfile(build_sh_path):
12 sys.exit('No build.sh file in: ' + pkgdir_name)
13 with open(build_sh_path) as build_sh:
14 lines = build_sh.readlines()
15 validate_package(pkgdir_name, lines)
16
17 def validate_package(package_name, lines):
18 if len(lines) < 3:
19 print('Too few lines in package: ' + package_name)
20 return
21 if not lines[0].startswith('TERMUX_PKG_HOMEPAGE='):
22 print('The first line is not TERMUX_PKG_HOMEPAGE: ' + package_name)
23 if not lines[1].startswith('TERMUX_PKG_DESCRIPTION='):
24 print('The second line is not TERMUX_PKG_DESCRIPTION: ' + package_name)
25
26 line_number = 1
27 for line in lines:
28 if line.endswith(' \n'):
29 print('Line ' + str(line_number) + ' has trailing whitespace: ' + package_name)
30 line_number += 1
31
32 if __name__ == '__main__':
33 main()