code: def versions_installed(pkg):
      '''
      Query which version(s) of the specified snap package are installed.
      Returns a list of 0 or more dictionaries.
  
      pkg
          The package name
      '''
  
      try:
          # Try to run it, merging stderr into output
          output = subprocess.check_output([SNAP_BINARY_NAME, 'list', pkg], stderr=subprocess.STDOUT)
      except subprocess.CalledProcessError:
          return []
  
      lines = output.splitlines()[1:]
      ret = []
      for item in lines:
          # If fields contain spaces this will break.
          i = item.split()
          # Ignore 'Notes' field
          ret.append({
              'name':         i[0],
              'version':      i[1],
              'rev':          i[2],
              'tracking':     i[3],
              'publisher':    i[4]
              })
  
      return ref versions_installed(pkg):
      '''
      Query which version(s) of the specified snap package are installed.
      Returns a list of 0 or more dictionaries.
  
      pkg
          The package name
      '''
  
      try:
          # Try to run it, merging stderr into output
          output = subprocess.check_output([SNAP_BINARY_NAME, 'list', pkg], stderr=subprocess.STDOUT)
      except subprocess.CalledProcessError:
          return []
  
      lines = output.splitlines()[1:]
      ret = []
      for item in lines:
          # If fields contain spaces this will break.
          i = item.split()
          # Ignore 'Notes' field
          ret.append({
              'name':         i[0],
              'version':      i[1],
              'rev':          i[2],
              'tracking':     i[3],
              'publisher':    i[4]
              })
  
      return ret
docs: Query which version(s) of the specified snap package are installed.
      Returns a list of 0 or more dictionaries.
  
      pkg
          The package name