Esempio n. 1
0
    def __enter__(self):
        """
        Called when entering the with-block

        EXAMPLES::

            sage: libgap.set_global('FooBar', 1)
            sage: with libgap.global_context('FooBar', 2):
            ....:     print libgap.get_global('FooBar')
            2
            sage: libgap.get_global('FooBar')
            1
        """
        self._old_value = libgap.get_global(self._variable)
        libgap.set_global(self._variable, self._new_value)
Esempio n. 2
0
    def __enter__(self):
        """
        Called when entering the with-block

        EXAMPLES::

            sage: libgap.set_global('FooBar', 1)
            sage: with libgap.global_context('FooBar', 2):
            ....:     print libgap.get_global('FooBar')
            2
            sage: libgap.get_global('FooBar')
            1
        """
        self._old_value = libgap.get_global(self._variable)
        libgap.set_global(self._variable, self._new_value)
Esempio n. 3
0
def list_keywords():
    """
    Return the GAP reserved keywords

    OUTPUT:

    Tuple of strings.

    EXAMPLES::

        sage: from sage.libs.gap.assigned_names import KEYWORDS
        sage: 'fi' in KEYWORDS   # indirect doctest
        True
    """
    keywords = libgap.get_global('GAPInfo')['Keywords'].sage()
    return tuple(sorted(keywords))
Esempio n. 4
0
def list_keywords():
    """
    Return the GAP reserved keywords

    OUTPUT:

    Tuple of strings.

    EXAMPLES::

        sage: from sage.libs.gap.assigned_names import KEYWORDS
        sage: 'fi' in KEYWORDS   # indirect doctest
        True
    """
    keywords = libgap.get_global('GAPInfo')['Keywords'].sage()
    return tuple(sorted(keywords))
Esempio n. 5
0
is for inspecting GAP operations from Python. In particular, it can
list the operations that take a particular LibGAP element as first
argument. This is used in tab completion, where Python ``x.[TAB]``
lists all GAP operations for which ``Operation(x, ...)`` is defined.
"""

import re
import string
from sage.structure.sage_object import SageObject
from sage.libs.gap.libgap import libgap

Length = libgap.function_factory('Length')
FlagsType = libgap.function_factory('FlagsType')
TypeObj = libgap.function_factory('TypeObj')
IS_SUBSET_FLAGS = libgap.function_factory('IS_SUBSET_FLAGS')
OPERATIONS = libgap.get_global('OPERATIONS')
NameFunction = libgap.function_factory('NameFunction')

NAME_RE = re.compile(r'(Setter|Getter|Tester)\((.*)\)')


class OperationInspector(SageObject):
    def __init__(self, libgap_element):
        """
        Information about operations that can act on a given LibGAP element

        INPUT:

        - ``libgap_element`` -- libgap element.

        EXAMPLES::
Esempio n. 6
0
list the operations that take a particular LibGAP element as first
argument. This is used in tab completion, where Python ``x.[TAB]``
lists all GAP operations for which ``Operation(x, ...)`` is defined.
"""

import re
import string
from sage.structure.sage_object import SageObject
from sage.misc.cachefunc import cached_method
from sage.libs.gap.libgap import libgap

Length = libgap.function_factory('Length')
FlagsType = libgap.function_factory('FlagsType')
TypeObj = libgap.function_factory('TypeObj')
IS_SUBSET_FLAGS = libgap.function_factory('IS_SUBSET_FLAGS')
OPERATIONS = libgap.get_global('OPERATIONS')
NameFunction = libgap.function_factory('NameFunction')


NAME_RE = re.compile('(Setter|Getter|Tester)\((.*)\)')


class OperationInspector(SageObject):

    def __init__(self, libgap_element):
        """
        Information about operations that can act on a given LibGAP element

        INPUT:

        - ``libgap_element`` -- libgap element.