Author: bugman Date: Thu May 3 19:38:18 2012 New Revision: 15913 URL: http://svn.gna.org/viewcvs/relax?rev=15913&view=rev Log: Shifted the Uf_info singleton into the new user_functions.data module. This will avoid a lot of circular imports. Added: branches/uf_redesign/user_functions/data.py - copied, changed from r15911, branches/uf_redesign/user_functions/__init__.py Modified: branches/uf_redesign/user_functions/__init__.py Modified: branches/uf_redesign/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/__init__.py?rev=15913&r1=15912&r2=15913&view=diff ============================================================================== --- branches/uf_redesign/user_functions/__init__.py (original) +++ branches/uf_redesign/user_functions/__init__.py Thu May 3 19:38:18 2012 @@ -28,79 +28,3 @@ # The __all__ package list. __all__ = [''] - - -# Python module imports. -from re import search -from string import split - -# relax module imports. -from relax_errors import RelaxError -from user_functions.objects import Class_container, Uf_container - - -class Uf_info(object): - """The user function data singleton class.""" - - # Class variable for storing the class instance (for the singleton). - _instance = None - - def __new__(self, *args, **kargs): - """Replacement method for implementing the singleton design pattern.""" - - # First instantiation. - if self._instance is None: - # Instantiate. - self._instance = object.__new__(self, *args, **kargs) - - # Initialise a number of class variables. - self._uf_names = [] - self._uf = [] - self._class_names = [] - self._classes = [] - - # Already instantiated, so return the instance. - return self._instance - - - def add_class(self, name): - """Add a new user function class. - - @param name: The name of the user function class. - @type name: str - @return: The user function class data object. - @rtype: user_functions.objects.Class_container instance - """ - - # Store the name and initialise a new object. - self._class_names.append(name) - self._classes.append(Class_container()) - - # Return the object. - return self._classes[-1] - - - def add_uf(self, name): - """Add the user function to the object. - - @param name: The name of the user function. - @type name: str - @return: The user function data object. - @rtype: user_functions.objects.Uf_container instance - """ - - # First check if the user function class has been set up. - if search('.', name): - # Split up the name. - class_name, fn_name = split(name, '.') - - # Check for the class name. - if class_name not in self._class_names: - raise RelaxError("The user function class '%s' has not been set up yet." % class_name) - - # Store the name and initialise a new object. - self._uf_names.append(name) - self._uf.append(Uf_container()) - - # Return the object. - return self._uf[-1] Copied: branches/uf_redesign/user_functions/data.py (from r15911, branches/uf_redesign/user_functions/__init__.py) URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/data.py?p2=branches/uf_redesign/user_functions/data.py&p1=branches/uf_redesign/user_functions/__init__.py&r1=15911&r2=15913&rev=15913&view=diff ============================================================================== --- branches/uf_redesign/user_functions/__init__.py (original) +++ branches/uf_redesign/user_functions/data.py Thu May 3 19:38:18 2012 @@ -20,15 +20,8 @@ # # ############################################################################### -# Package docstring. -"""Package containing all of the user function details. - -This package contains all information and details about user functions, from documentation to icons to be used in the GUI. This package contains a special data structure which will be used by the different UIs to automatically generate their interfaces to the user functions. -""" - -# The __all__ package list. -__all__ = [''] - +# Module docstring. +"""Module containing the user function data singleton which stores all of the data.""" # Python module imports. from re import search