Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def search_items(bus, attributes):
"""Returns a generator of items in all collections with the given
attributes. `attributes` should be a dictionary."""
service_obj = bus_get_object(bus, SS_PATH)
service_iface = dbus.Interface(service_obj, SERVICE_IFACE)
locked, unlocked = service_iface.SearchItems(attributes,
signature='a{ss}')
for item_path in locked + unlocked:
yield Item(bus, item_path)
def get_all_items(self) -> Iterator[Item]:
"""Returns a generator of all items in the collection."""
for item_path in self._collection.get_property('Items'):
yield Item(self.connection, item_path, self.session)
def search_items(connection: DBusConnection,
attributes: Dict[str, str]) -> Iterator[Item]:
"""Returns a generator of items in all collections with the given
attributes. `attributes` should be a dictionary."""
service = DBusAddressWrapper(SS_PATH, SERVICE_IFACE, connection)
locked, unlocked = service.call('SearchItems', 'a{ss}', attributes)
for item_path in locked + unlocked:
yield Item(connection, item_path)
(bytestring). If `replace` is :const:`True`, replaces the existing
item with the same attributes. If `content_type` is given, also
sets the content type of the secret (``text/plain`` by default).
Returns the created item."""
self.ensure_not_locked()
if not self.session:
self.session = open_session(self.bus)
secret = format_secret(self.session, secret, content_type)
attributes = dbus.Dictionary(attributes, signature='ss')
properties = {
SS_PREFIX+'Item.Label': label,
SS_PREFIX+'Item.Attributes': attributes
}
new_item, prompt = self.collection_iface.CreateItem(properties,
secret, replace, signature='a{sv}(oayays)b')
return Item(self.bus, new_item, self.session)
def get_all_items(self):
"""Returns a generator of all items in the collection."""
for item_path in self.collection_props_iface.Get(
COLLECTION_IFACE, 'Items', signature='ss'):
yield Item(self.bus, item_path, self.session)
def search_items(self, attributes: Dict[str, str]) -> Iterator[Item]:
"""Returns a generator of items with the given attributes.
`attributes` should be a dictionary."""
result, = self._collection.call('SearchItems', 'a{ss}', attributes)
for item_path in result:
yield Item(self.connection, item_path, self.session)
def search_items(self, attributes):
"""Returns a generator of items with the given attributes.
`attributes` should be a dictionary."""
result = self.collection_iface.SearchItems(attributes,
signature='a{ss}')
for item_path in result:
yield Item(self.bus, item_path, self.session)
`label` (unicode string), `attributes` (dictionary) and `secret`
(bytestring). If `replace` is :const:`True`, replaces the existing
item with the same attributes. If `content_type` is given, also
sets the content type of the secret (``text/plain`` by default).
Returns the created item."""
self.ensure_not_locked()
if not self.session:
self.session = open_session(self.connection)
_secret = format_secret(self.session, secret, content_type)
properties = {
SS_PREFIX + 'Item.Label': ('s', label),
SS_PREFIX + 'Item.Attributes': ('a{ss}', attributes),
}
new_item, prompt = self._collection.call('CreateItem', 'a{sv}(oayays)b',
properties, _secret, replace)
return Item(self.connection, new_item, self.session)