Skip to content

Commit

Permalink
Merge pull request #47 from secondlife/signal/rm-archive-attr
Browse files Browse the repository at this point in the history
Allow installables edit cmd to remove attributes
  • Loading branch information
nat-goodspeed authored May 9, 2024
2 parents e1e7a55 + 0eee1e4 commit f43ca67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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

0 comments on commit f43ca67

Please sign in to comment.