MCPcopy
hub / github.com/saltstack/salt / contains

Function contains

salt/cache/mysql_cache.py:331–349  ·  view source on GitHub ↗

Checks if the specified bank contains the specified key.

(bank, key)

Source from the content-addressed store, hash-verified

329
330
331def contains(bank, key):
332 """
333 Checks if the specified bank contains the specified key.
334 """
335 _init_client()
336 if key is None:
337 data = (bank,)
338 query = "SELECT COUNT(data) FROM {} WHERE bank=%s".format(
339 __context__["mysql_table_name"]
340 )
341 else:
342 data = (bank, key)
343 query = "SELECT COUNT(data) FROM {} WHERE bank=%s AND etcd_key=%s".format(
344 __context__["mysql_table_name"]
345 )
346 cur, _ = run_query(__context__.get("mysql_client"), query, args=data)
347 r = cur.fetchone()
348 cur.close()
349 return r[0] == 1
350
351
352def updated(bank, key):

Callers

nothing calls this directly

Calls 5

formatMethod · 0.80
_init_clientFunction · 0.70
run_queryFunction · 0.70
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected