Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tools-webrtc/ios/generate_licenses.py

Issue 2812273002: Fix lint errors to enable stricter PyLint rules (Closed)
Patch Set: Rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools-webrtc/gtest-parallel-wrapper.py ('k') | tools-webrtc/vim/webrtc.ycm_extra_conf.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 # Copyright 2016 The WebRTC project authors. All Rights Reserved.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license 5 # Use of this source code is governed by a BSD-style license
6 # that can be found in the LICENSE file in the root of the source 6 # that can be found in the LICENSE file in the root of the source
7 # tree. An additional intellectual property rights grant can be found 7 # tree. An additional intellectual property rights grant can be found
8 # in the file PATENTS. All contributing project authors may 8 # in the file PATENTS. All contributing project authors may
9 # be found in the AUTHORS file in the root of the source tree. 9 # be found in the AUTHORS file in the root of the source tree.
10 10
(...skipping 19 matching lines...) Expand all
30 'usrsctp': ['third_party/usrsctp/LICENSE'], 30 'usrsctp': ['third_party/usrsctp/LICENSE'],
31 'webrtc': ['webrtc/LICENSE', 'webrtc/LICENSE_THIRD_PARTY'], 31 'webrtc': ['webrtc/LICENSE', 'webrtc/LICENSE_THIRD_PARTY'],
32 'libvpx': ['third_party/libvpx/source/libvpx/LICENSE'], 32 'libvpx': ['third_party/libvpx/source/libvpx/LICENSE'],
33 'libyuv': ['third_party/libyuv/LICENSE'], 33 'libyuv': ['third_party/libyuv/LICENSE'],
34 } 34 }
35 35
36 SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0])) 36 SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
37 CHECKOUT_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir)) 37 CHECKOUT_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
38 WEBRTC_ROOT = os.path.join(CHECKOUT_ROOT, 'webrtc') 38 WEBRTC_ROOT = os.path.join(CHECKOUT_ROOT, 'webrtc')
39 39
40
40 def GetThirdPartyLibraries(buildfile_dir, target_name): 41 def GetThirdPartyLibraries(buildfile_dir, target_name):
41 def extractLibName(s): 42 def ExtractLibName(string_list):
42 # Sample input: 43 # Sample input:
43 # [" //third_party/usrsctp:usrsctp", " //webrtc:webrtc_common"] 44 # [" //third_party/usrsctp:usrsctp", " //webrtc:webrtc_common"]
44 # Sample output: 45 # Sample output:
45 # ["usrsctp"] 46 # ["usrsctp"]
46 return re.sub(r'\(.*\)', '', s).strip().split(os.path.sep)[-1].split(':')[0] 47 return re.sub(r'\(.*\)', '', string_list).strip().split(
48 os.path.sep)[-1].split(':')[0]
47 output = subprocess.check_output( 49 output = subprocess.check_output(
48 ["gn", "desc", buildfile_dir, target_name, '--all']) .split(os.linesep) 50 ["gn", "desc", buildfile_dir, target_name, '--all']) .split(os.linesep)
49 return [extractLibName(x) for x in output if re.search(r'third_party', x)] 51 return [ExtractLibName(x) for x in output if re.search(r'third_party', x)]
50 52
51 53
52 class LicenseBuilder(object): 54 class LicenseBuilder(object):
53 55
54 def __init__(self, buildfile_dirs, target_name): 56 def __init__(self, buildfile_dirs, target_name):
55 self.buildfile_dirs = buildfile_dirs 57 self.buildfile_dirs = buildfile_dirs
56 self.target_name = target_name 58 self.target_name = target_name
57 59
58 def GenerateLicenseText(self, output_dir): 60 def GenerateLicenseText(self, output_dir):
59 # Get a list of third_party libs from gn. For fat libraries we must consider 61 # Get a list of third_party libs from gn. For fat libraries we must consider
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 output_license_file.write(license_text) 107 output_license_file.write(license_text)
106 output_license_file.write('\n') 108 output_license_file.write('\n')
107 output_license_file.write('</pre>\n') 109 output_license_file.write('</pre>\n')
108 110
109 output_license_file.write('</body>\n') 111 output_license_file.write('</body>\n')
110 output_license_file.write('</html>') 112 output_license_file.write('</html>')
111 output_license_file.close() 113 output_license_file.close()
112 return 0 114 return 0
113 115
114 116
115 if __name__ == '__main__': 117 def main():
116 parser = argparse.ArgumentParser(description='Generate WebRTC LICENSE.html') 118 parser = argparse.ArgumentParser(description='Generate WebRTC LICENSE.html')
117 parser.add_argument('target_name', 119 parser.add_argument('target_name',
118 help='Name of the GN target to generate a license for') 120 help='Name of the GN target to generate a license for')
119 parser.add_argument('output_dir', 121 parser.add_argument('output_dir',
120 help='Directory to output LICENSE.html to.') 122 help='Directory to output LICENSE.html to.')
121 parser.add_argument('buildfile_dirs', nargs="+", 123 parser.add_argument('buildfile_dirs', nargs="+",
122 help='Directories containing gn generated ninja files') 124 help='Directories containing gn generated ninja files')
123 args = parser.parse_args() 125 args = parser.parse_args()
124 builder = LicenseBuilder(args.buildfile_dirs, args.target_name) 126 builder = LicenseBuilder(args.buildfile_dirs, args.target_name)
125 sys.exit(builder.GenerateLicenseText(args.output_dir)) 127 sys.exit(builder.GenerateLicenseText(args.output_dir))
128
129
130 if __name__ == '__main__':
131 main()
OLDNEW
« no previous file with comments | « tools-webrtc/gtest-parallel-wrapper.py ('k') | tools-webrtc/vim/webrtc.ycm_extra_conf.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698