示例#1
0
 def is_present_in_agent_config(self, package_id: PackageId) -> bool:
     """Check item is in agent config."""
     current_item = get_item_public_id_by_author_name(
         self._agent_config,
         str(package_id.package_type),
         package_id.public_id.author,
         package_id.public_id.name,
     )
     return bool(current_item)
示例#2
0
 def get_current_item(self) -> PublicId:
     """Return public id of the item already presents in agent config."""
     current_item = get_item_public_id_by_author_name(
         self.ctx.agent_config,
         self.item_type,
         self.item_id.author,
         self.item_id.name,
     )
     if not current_item:  # pragma: nocover # actually checked in check_item_present
         raise click.ClickException("The {} '{}' is not supported.".format(
             self.item_type, self.item_id))
     return current_item
示例#3
0
 def get_current_item(self) -> PublicId:
     """Return public id of the item already presents in agent config."""
     self.check_item_present()
     current_item = get_item_public_id_by_author_name(
         self.ctx.agent_config,
         self.item_type,
         self.item_public_id.author,
         self.item_public_id.name,
     )
     if not current_item:  # pragma: nocover # actually checked in check_item_present
         raise ValueError("Item not found!")
     return current_item