Merge lp:~stevanr/linaro-license-protection/combined-build-info-files into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Stevan Radaković
Status: Merged
Merged at revision: 182
Proposed branch: lp:~stevanr/linaro-license-protection/combined-build-info-files
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 238 lines (+166/-0)
8 files modified
license_protected_downloads/buildinfo.py (+15/-0)
license_protected_downloads/splice_build_infos.py (+49/-0)
license_protected_downloads/tests/__init__.py (+3/-0)
license_protected_downloads/tests/test_buildinfo.py (+9/-0)
license_protected_downloads/tests/test_splicebuildinfos.py (+35/-0)
license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-open/BUILD-INFO.txt (+6/-0)
license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-protected/BUILD-INFO.txt (+7/-0)
license_protected_downloads/tests/testserver_root/build-info/write-test/BUILD-INFO.txt (+42/-0)
To merge this branch: bzr merge lp:~stevanr/linaro-license-protection/combined-build-info-files
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Georgy Redkozubov Pending
Review via email: mp+159810@code.launchpad.net

Description of the change

Add combined BUILD-INFO support.

To post a comment you must log in.
Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks good.

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks good. Now with the approve tag :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'license_protected_downloads/buildinfo.py'
--- license_protected_downloads/buildinfo.py 2013-02-26 08:38:32 +0000
+++ license_protected_downloads/buildinfo.py 2013-04-19 12:21:29 +0000
@@ -173,6 +173,21 @@
173 for index in open_type:173 for index in open_type:
174 self.file_info_array.pop(index)174 self.file_info_array.pop(index)
175175
176 @classmethod
177 def write_from_array(cls, build_info_array, file_path):
178 with open(file_path, "w") as outfile:
179 outfile.write("Format-Version: 0.1\n\n")
180 for key in build_info_array[0]:
181 if key != "format-version":
182 outfile.write("Files-Pattern: %s\n" % key)
183 for item in build_info_array[0][key][0]:
184 text = build_info_array[0][key][0][item]
185 if item == "license-text":
186 text = text.replace("\n", "\n ")
187 outfile.write("%s: %s\n" % (item, text))
188 outfile.write("\n")
189
190
176if __name__ == "__main__":191if __name__ == "__main__":
177 import sys192 import sys
178 bi = BuildInfo(sys.argv[1])193 bi = BuildInfo(sys.argv[1])
179194
=== added file 'license_protected_downloads/splice_build_infos.py'
--- license_protected_downloads/splice_build_infos.py 1970-01-01 00:00:00 +0000
+++ license_protected_downloads/splice_build_infos.py 2013-04-19 12:21:29 +0000
@@ -0,0 +1,49 @@
1import os
2
3from buildinfo import BuildInfo
4
5IGNORED_FILES = ["BUILD-INFO.txt", "EULA.txt", "OPEN-EULA.txt"]
6
7
8class SpliceBuildInfos:
9
10 def __init__(self, build_info_paths):
11 """Initiates a splice build info object.
12
13 :param build_info_paths: list of dir paths containing
14 the BUILD-INFO.txt files.
15 """
16 self.build_infos = []
17 for build_info_path in build_info_paths:
18 for path, subdirs, files in os.walk(build_info_path):
19 for filename in files:
20 if path == build_info_path:
21 if filename not in IGNORED_FILES:
22 self.build_infos.append(
23 BuildInfo(os.path.join(path, filename)))
24
25 def splice(self, build_info_path):
26
27 build_info_res = {}
28 for build_info in self.build_infos:
29 build_info_res[build_info.fname] = build_info.file_info_array
30
31 build_info_res = self.merge_duplicates(build_info_res)
32 BuildInfo.write_from_array(build_info_res, build_info_path)
33
34 @classmethod
35 def merge_duplicates(cls, build_info_dict):
36 build_info_res = {}
37 for key in build_info_dict:
38 if build_info_dict[key] in build_info_res.values():
39 found_key = [name for name, value in
40 build_info_res.iteritems()
41 if value == build_info_dict[key]][0]
42 if key != found_key:
43 new_key = "%s, %s" % (found_key, key)
44 build_info_res[new_key] = build_info_dict[key]
45 del build_info_res[found_key]
46 else:
47 build_info_res[key] = build_info_dict[key]
48
49 return build_info_res
050
=== modified file 'license_protected_downloads/tests/__init__.py'
--- license_protected_downloads/tests/__init__.py 2012-11-28 12:30:30 +0000
+++ license_protected_downloads/tests/__init__.py 2013-04-19 12:21:29 +0000
@@ -2,6 +2,8 @@
2 BuildInfoTests,2 BuildInfoTests,
3 FileNameMatchingTests,3 FileNameMatchingTests,
4 )4 )
5from license_protected_downloads.tests.test_splicebuildinfos \
6 import SpliceBuildInfosTests
5from license_protected_downloads.tests.test_models import LicenseTestCase7from license_protected_downloads.tests.test_models import LicenseTestCase
6from license_protected_downloads.tests.test_pep8 import TestPep88from license_protected_downloads.tests.test_pep8 import TestPep8
7from license_protected_downloads.tests.test_pyflakes import TestPyflakes9from license_protected_downloads.tests.test_pyflakes import TestPyflakes
@@ -19,6 +21,7 @@
19#starts the test suite21#starts the test suite
20__test__ = {22__test__ = {
21 'BuildInfoTests': BuildInfoTests,23 'BuildInfoTests': BuildInfoTests,
24 'SpliceBuildInfosTests': SpliceBuildInfosTests,
22 'FileNameMatchingTests': FileNameMatchingTests,25 'FileNameMatchingTests': FileNameMatchingTests,
23 'FileViewTests': FileViewTests,26 'FileViewTests': FileViewTests,
24 'HowtoViewTests': HowtoViewTests,27 'HowtoViewTests': HowtoViewTests,
2528
=== modified file 'license_protected_downloads/tests/test_buildinfo.py'
--- license_protected_downloads/tests/test_buildinfo.py 2013-02-26 08:38:32 +0000
+++ license_protected_downloads/tests/test_buildinfo.py 2013-04-19 12:21:29 +0000
@@ -286,6 +286,15 @@
286286
287 self.assertEquals(build_info.file_info_array, [{}])287 self.assertEquals(build_info.file_info_array, [{}])
288288
289 def test_write_from_array(self):
290 build_info = BuildInfo(self.buildinfo_file_path)
291 file_path = THIS_DIRECTORY + \
292 '/testserver_root/build-info/write-test/BUILD-INFO.txt'
293 BuildInfo.write_from_array(build_info.build_info_array, file_path)
294 build_info_test = BuildInfo(file_path)
295 self.assertEquals(build_info_test.build_info_array,
296 build_info.build_info_array)
297
289298
290class FileNameMatchingTests(unittest.TestCase):299class FileNameMatchingTests(unittest.TestCase):
291 def test_buildinfo_simple_filename(self):300 def test_buildinfo_simple_filename(self):
292301
=== added file 'license_protected_downloads/tests/test_splicebuildinfos.py'
--- license_protected_downloads/tests/test_splicebuildinfos.py 1970-01-01 00:00:00 +0000
+++ license_protected_downloads/tests/test_splicebuildinfos.py 2013-04-19 12:21:29 +0000
@@ -0,0 +1,35 @@
1_author__ = 'stevanr'
2
3import os
4import unittest
5from license_protected_downloads.splice_build_infos import SpliceBuildInfos
6
7THIS_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
8
9
10class SpliceBuildInfosTests(unittest.TestCase):
11 def setUp(self):
12 dir_path1 = THIS_DIRECTORY + \
13 '/testserver_root/build-info/splice-build-info/build-info-open'
14 dir_path2 = THIS_DIRECTORY + \
15 '/testserver_root/build-info/splice-build-info/build-info-protected'
16 self.splice_build_infos = SpliceBuildInfos([dir_path1, dir_path2])
17
18 def test_merge_duplicates(self):
19 build_info_dict = {
20 'test-protected.txt':
21 [{'license-type': 'protected',
22 'build-name': 'landing-protected',
23 'openid-launchpad-teams': 'linaro'}],
24 'test-protected-2.txt':
25 [{'license-type': 'protected',
26 'build-name': 'landing-protected',
27 'openid-launchpad-teams': 'linaro'}]}
28
29 result = {'test-protected.txt, test-protected-2.txt':
30 [{'license-type': 'protected',
31 'build-name': 'landing-protected',
32 'openid-launchpad-teams': 'linaro'}]}
33
34 build_info_res = SpliceBuildInfos.merge_duplicates(build_info_dict)
35 self.assertEquals(build_info_res, result)
036
=== added directory 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info'
=== added directory 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-open'
=== added file 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-open/BUILD-INFO.txt'
--- license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-open/BUILD-INFO.txt 1970-01-01 00:00:00 +0000
+++ license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-open/BUILD-INFO.txt 2013-04-19 12:21:29 +0000
@@ -0,0 +1,6 @@
1Format-Version: 0.1
2
3
4Files-Pattern: *.txt
5Build-Name: landing-open
6License-Type: open
07
=== added file 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-open/testfile.txt'
=== added file 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-open/testfile2.txt'
=== added directory 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-protected'
=== added file 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-protected/BUILD-INFO.txt'
--- license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-protected/BUILD-INFO.txt 1970-01-01 00:00:00 +0000
+++ license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-protected/BUILD-INFO.txt 2013-04-19 12:21:29 +0000
@@ -0,0 +1,7 @@
1Format-Version: 0.1
2
3
4Files-Pattern: *, *.txt
5Build-Name: landing-protected
6License-Type: protected
7OpenID-Launchpad-Teams: linaro
08
=== added file 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-protected/test-protected-2.txt'
=== added file 'license_protected_downloads/tests/testserver_root/build-info/splice-build-info/build-info-protected/test-protected.txt'
=== added directory 'license_protected_downloads/tests/testserver_root/build-info/write-test'
=== added file 'license_protected_downloads/tests/testserver_root/build-info/write-test/BUILD-INFO.txt'
--- license_protected_downloads/tests/testserver_root/build-info/write-test/BUILD-INFO.txt 1970-01-01 00:00:00 +0000
+++ license_protected_downloads/tests/testserver_root/build-info/write-test/BUILD-INFO.txt 2013-04-19 12:21:29 +0000
@@ -0,0 +1,42 @@
1Format-Version: 0.1
2
3Files-Pattern: *openid*
4license-type: protected
5build-name: landing-protected
6openid-launchpad-teams: linaro
7
8Files-Pattern: *panda*
9license-type: open
10build-name: landing-panda
11
12Files-Pattern: *.txt
13license-type: protected
14build-name: landing-protected
15openid-launchpad-teams:
16theme: stericsson
17collect-user-data: yes
18license-text: <p>IMPORTANT — PLEASE READ THE FOLLOWING AGREEMENT CAREFULLY.</p>
19 <p>
20 THIS IS A LEGALLY BINDING AGREEMENT
21 </p>
22
23Files-Pattern: *origen*
24theme: samsung
25license-type: protected
26build-name: landing-origen
27license-text: <p>IMPORTANT — PLEASE READ THE FOLLOWING AGREEMENT CAREFULLY.</p>
28 <p>
29 THIS IS A LEGALLY BINDING AGREEMENT BETWEEN YOU, an individual or a
30 legal entity, (“LICENSEE”) AND HAL 1000.
31 </p>
32
33Files-Pattern: *snowball*
34theme: stericsson
35license-type: protected
36build-name: landing-snowball
37license-text: <p>IMPORTANT — PLEASE READ THE FOLLOWING AGREEMENT CAREFULLY.</p>
38 <p>
39 THIS IS A LEGALLY BINDING AGREEMENT BETWEEN YOU, an individual or a
40 legal entity, (“LICENSEE”) AND ME, THE TEST SERVER.
41 </p>
42

Subscribers

People subscribed via source and target branches