Exemple #1
0
    def intern_atom(self, name, only_if_exists=True):
        """
        Create a new X11 atom with the given ``name``.

        ``name`` is a byte or unicode string with the name of the atom.  If
        ``only_if_exists`` is ``True``, the atom is only created, if it already
        exists.  If it does not exist, ``None`` is returned.

        Return an :class:`Atom` with the given ``name``, or ``None``, if the
        ``only_if_exists`` was ``True`` and the atom did not exist.
        """
        name = ensure_byte_string(name)
        atom = self._atom_cache.get(name)
        if atom:
            return atom
        atom = xlib.intern_atom(self, ensure_byte_string(name), only_if_exists)
        if atom == xlib.NONE:
            return None
        return self._atom_cache.setdefault(name, Atom(self, atom))
Exemple #2
0
    def intern_atom(self, name, only_if_exists=True):
        """
        Create a new X11 atom with the given ``name``.

        ``name`` is a byte or unicode string with the name of the atom.  If
        ``only_if_exists`` is ``True``, the atom is only created, if it already
        exists.  If it does not exist, ``None`` is returned.

        Return an :class:`Atom` with the given ``name``, or ``None``, if the
        ``only_if_exists`` was ``True`` and the atom did not exist.
        """
        name = ensure_byte_string(name)
        atom = self._atom_cache.get(name)
        if atom:
            return atom
        atom = xlib.intern_atom(self, ensure_byte_string(name), only_if_exists)
        if atom == xlib.NONE:
            return None
        return self._atom_cache.setdefault(name, Atom(self, atom))
Exemple #3
0
def test_intern_atom_non_existing(display):
    atom = xlib.intern_atom(display, 'this-atom-certainly-not-exists', True)
    assert atom == xlib.NONE
Exemple #4
0
def test_intern_atom_existing(display):
    int_atom = xlib.intern_atom(display, 'INTEGER', True)
    assert int_atom == xlib.INTEGER
    float_atom = xlib.intern_atom(display, 'FLOAT', True)
    assert float_atom != xlib.NONE