Path: blob/master/sage/libs/singular/function_factory.py
4037 views
"""1libSingular: Function Factory.23AUTHORS:45- Martin Albrecht (2010-01): initial version67"""8#*****************************************************************************9# Copyright (C) 2010 Martin Albrecht <[email protected]>10#11# Distributed under the terms of the GNU General Public License (GPL)12# http://www.gnu.org/licenses/13#*****************************************************************************1415from sage.libs.singular.function import singular_function, lib, list_of_functions1617class SingularFunctionFactory(object):18"""19A convenient interface to libsingular functions.20"""21def __getattr__(self, name):22"""23EXAMPLE::2425sage: groebner = sage.libs.singular.ff.groebner26sage: groebner27groebner (singular function)2829sage: primdecSY = sage.libs.singular.ff.primdec__lib.primdecSY30sage: primdecSY31primdecSY (singular function)32"""33if name.startswith("_"):34raise AttributeError("Singular Function Factory has no attribute '%s'"%name)3536try:37return singular_function(name)38except NameError:39if name.endswith("__lib"):40name = name[:-5]41lib(name+".lib")42return SingularFunctionFactory()43else:44raise NameError("function or package '%s' unknown."%(name))4546def trait_names(self):47"""48EXAMPLE::4950sage: "groebner" in sage.libs.singular.ff.trait_names()51True52"""53return list_of_functions()545556