Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installables edit cmd to remove attributes #47

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions autobuild/autobuild_tool_installables.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


# Match key=value arguments.
_key_value_regexp = re.compile(r'(\w+)\s*=\s*(\S+)')
_key_value_regexp = re.compile(r'(\w+)\s*=\s*(\S+)?')


class InstallablesError(common.AutobuildError):
Expand Down Expand Up @@ -219,9 +219,12 @@ def edit(config, args_name, args_archive, arguments):
installed_package_description.platforms[platform_name] = platform_description.copy()

for element in _ARCHIVE_ATTRIBUTES:
if element in metadata.archive \
and metadata.archive[element] is not None:
installed_package_description.platforms[platform_name].archive[element] = metadata.archive[element]
if element in metadata.archive:
if metadata.archive[element] is None:
# Allow installables edit to remove archive elements, such as creds, by passing "creds="
del installed_package_description.platforms[platform_name].archive[element]
else:
installed_package_description.platforms[platform_name].archive[element] = metadata.archive[element]



Expand Down
7 changes: 5 additions & 2 deletions tests/test_installables.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setUp(self):
def test_add_edit_remove(self):
local_archive=os.path.join(self.datadir,'bogus-0.1-common-111.tar.bz2')
data = ('license=tut', 'license_file=LICENSES/bogus.txt', 'platform=darwin',
'url='+local_archive)
'url='+local_archive, 'creds=github')
installables.add(self.config, 'bogus', None, data)
self.assertEqual(len(self.config.installables), 1)
package_description = self.config.installables['bogus']
Expand All @@ -27,10 +27,13 @@ def test_add_edit_remove(self):
platform_description = package_description.platforms['darwin']
assert platform_description.archive is not None
assert platform_description.archive.url.endswith(local_archive)
edit_data = ('license=Apache', 'platform=darwin', 'hash_algorithm=sha-1')
self.assertEqual(platform_description.archive.creds, 'github')
edit_data = ('license=Apache', 'platform=darwin', 'hash_algorithm=sha-1', 'creds=')
installables.edit(self.config, 'bogus', None, edit_data)
self.assertEqual(package_description.license, 'Apache')
self.assertEqual(platform_description.archive.hash_algorithm, 'sha-1')
platform_description = package_description.platforms['darwin']
self.assertNotIn('creds', platform_description.archive)
installables.remove(self.config, 'bogus')
self.assertEqual(len(self.config.installables), 0)

Expand Down
Loading