Index: DataLoader/loader.py
===================================================================
--- DataLoader/loader.py	(revision bb037397e81f6fff27c38198e299108d7d53424e)
+++ DataLoader/loader.py	(revision aa749ac6a2c4ea5ba4cc8b49129c811d24a69da0)
@@ -1,32 +1,122 @@
-from register import ExtensionRegistry
+# This program is public domain
+"""
+File extension registry.
 
-#import tiff_reader
-class Loader:
+This provides routines for opening files based on extension,
+and registers the built-in file extensions.
+"""
+import logging
+import os.path
+
+class Loader(object):
+    """
+    Associate a file loader with an extension.
+
+    Note that there may be multiple readers for the same extension.
+
+    Example:
+
+    registry = Loader()
+
+    # Add an association by setting an element
+    registry['.zip'] = unzip
+
+    # Multiple extensions for one loader
+    registry['.tgz'] = untar
+    registry['.tar.gz'] = untar
+
+    # Multiple readers for one extension
+    registry['.cx'] = cx1
+    registry['.cx'] = cx2
+    registry['.cx'] = cx3
+    
+    # Can also register a format name for explicit control from caller
+    registry['cx3'] = cx3
+
+    # Retrieve readers for a file name
+    registry.lookup('hello.cx') -> [cx3,cx2,cx1]
+
+    # Run loader on a filename
+    registry.load('hello.cx') ->
+        try:
+            return cx3('hello.cx')
+        except:
+            try:
+                return cx2('hello.cx')
+            except:
+                return cx1('hello.cx')
+
+    # Load in a specific format ignoring extension
+    registry.load('hello.cx',format='cx3') ->
+        return cx3('hello.cx')
+    """
     def __init__(self):
-        """ init method"""
-        self.reg=ExtensionRegistry()
-       
-    def setFormat(self,ext,reader):
-        """ 
-            Load the available reader with file extensions
-            @param ext:file extension
-            @param reader: instance of a reader
+        self.readers = {}
+        self.reading=None
+        
+        
+    def __setitem__(self, ext, reader):
+        if ext not in self.readers:
+            self.readers[ext] = []
+        self.readers[ext].insert(0,reader)
+        
+        
+    def __getitem__(self, ext):
+        return self.readers[ext]
+    
+    
+    def __contains__(self, ext):
+        return ext in self.readers
+    
+    
+    def formats(self, name=True, ext=False):
         """
-        #self.reg[ext]=reader
-        self.reg.__setitem__(ext, reader)
-    def getReader(self,ext):
-        return self.reg.__getitem__( ext)
+        Return a list of the registered formats.  If name=True then
+        named formats are returned.  If ext=True then extensions
+        are returned.
+        """
+        names = [a for a in self.readers.keys() if not a.startswith('.')]
+        exts = [a for a in self.readers.keys() if a.startswith('.')]
+        names.sort()
+        exts.sort()
+        ret = []
+        if name: ret += names
+        if ext: ret += exts
+        return ret
         
+    def lookup(self, path):
+        """
+        Return the loader associated with the file type of path.
+        """        
+        file = os.path.basename(path)
+        idx = file.find('.')
+        ext = file[idx:] if idx >= 0 else ''
+        try:
+            return self.readers[ext]
+        except:
+            #raise ValueError, "Unknown file type '%s'"%ext
+            print  "Unknown file type '%s'"%ext
+ 
+                
+    def getAcTReader(self,path):
+        return self.reading
     
-    def loadData(self,path,format=None):
-        """ Read a file and save values"""
-        self.reg.lookup(path)
-        try:  
-            return self.reg.load(path,format)
-        except ValueError,msg:
-            print msg
-    def getActiveReader(self,path):
-        return self.reg.getAcTReader(path)
-    def getextension(self,name=False,ext=True):
-        """ return list of readers"""
-        return self.reg.formats(name,ext) 
+    def load(self, path, format=None):
+        """
+        Call the loader for the file type of path.
+
+        Raises ValueError if no loader is available.
+        May raise a loader-defined exception if loader fails.
+        """
+        if format is None:
+            readers = self.lookup(path)
+        else:
+            readers = self.readers[format]
+        if readers!=None:
+            for fn in readers:
+                try:
+                    value=fn.read(path)
+                    self.reading= fn.__class__
+                    return value
+                except ValueError,msg:
+                    print str(msg)
Index: DataLoader/readers/TXT2_Reader.py
===================================================================
--- DataLoader/readers/TXT2_Reader.py	(revision 11a0319ff1d484c300ed9c17d720b8bae9e27810)
+++ DataLoader/readers/TXT2_Reader.py	(revision aa749ac6a2c4ea5ba4cc8b49129c811d24a69da0)
@@ -18,41 +18,52 @@
         """ Store the values loaded from file in local variables """
         if not path == None:
-            input_f =  open(path,'r')
-            buff = input_f.read()
-            lines = buff.split('\n')
-            self.x=[]
-            self.y=[]
-            self.dx = [] 
-            self.dy=[]
-            value="can't read" 
-            for line in lines:
-                toks = line.split()
-                try:
-                    x = float(toks[0])
-                    self.x.append(x)
-                except:
-                    print "READ ERROR", line
-                try:
-                    y = float(toks[1])
-                    self.y.append(y)
-                except:
-                    print "READ ERROR", line
-                try:
-                    dy=float(toks[2])
-                    self.dy.append(dy)
-
-                except:
-                    print "READ ERROR", line
-
-            if(( self.x==[])or (self.y==[])) or (self.dy !=[]):
-                print "went here"
-                #return value
-                raise ValueError, "Reader1 can't read"
+            read_it = False
+            ext=['.txt','.dat']  
+            for item in ext:
+                if path.lower().find(item)>=0:
+                    read_it = True
+            #print "this is the flag",read_it, path.lower()
+            if read_it==False:
+                return None
             else:
-                #msg="R1 reading: \n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n"
-                #return msg
-                print "TXT2_Reader reading: \n"
-                return self.x,self.y,self.dy
-                
+                input_f =  open(path,'r')
+                buff = input_f.read()
+                lines = buff.split('\n')
+                self.x=[]
+                self.y=[]
+                self.dx = [] 
+                self.dy=[]
+                for line in lines:
+                    toks = line.split()
+                    try:
+                        x = float(toks[0])
+                        self.x.append(x)
+                    except:
+                        pass
+                        #print "READ ERROR", line
+                    try:
+                        y = float(toks[1])
+                        self.y.append(y)
+                    except:
+                        pass
+                        #print "READ ERROR", line
+                    try:
+                        dy=float(toks[2])
+                        self.dy.append(dy)
+    
+                    except:
+                        pass
+                        #print "READ ERROR", line
+    
+                if(( self.x==[])or (self.y==[])) or (self.dy !=[]):
+                    #print "went here"
+                    #return value
+                    raise ValueError, "TXT2_Reader can't read"
+                else:
+                    #msg="R1 reading: \n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n"
+                    #return msg
+                    print "TXT2_Reader reading \n"
+                    return self.x,self.y,self.dy
+        return None
    
        
Index: DataLoader/readers/TXT3_Reader.py
===================================================================
--- DataLoader/readers/TXT3_Reader.py	(revision bb037397e81f6fff27c38198e299108d7d53424e)
+++ DataLoader/readers/TXT3_Reader.py	(revision aa749ac6a2c4ea5ba4cc8b49129c811d24a69da0)
@@ -27,7 +27,7 @@
                 if path.lower().find(item)>=0:
                     read_it = True
-            print "this is the flag",read_it, path.lower()
+            #print "this is the flag",read_it, path.lower()
             if read_it==False:
-                raise ValueError, "txtReader can't read"
+                return None
             else:
                 input_f =  open(path,'r')
@@ -38,5 +38,4 @@
                 self.dx = [] 
                 self.dy=[]
-                value="can't read" 
                 for line in lines:
                     toks = line.split()
@@ -51,5 +50,6 @@
                    
                     except:
-                        print "READ ERROR", line
+                        pass
+                        #print "READ ERROR", line
             
                     self.dx = numpy.zeros(len(self.x))
@@ -61,5 +61,5 @@
                
                 if (self.x==[] or self.y==[])and (self.dy==[]):
-                    raise ValueError, "txtReader can't read"
+                    raise ValueError, "TXT3_Reader can't read"
                 else:
                     #msg="txtReader  Reading:\n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n"
@@ -68,5 +68,5 @@
                     return self.x,self.y,self.dy
                 
-  
+        return None
 if __name__ == "__main__": 
     read= Reader()
Index: DataLoader/register.py
===================================================================
--- DataLoader/register.py	(revision bb037397e81f6fff27c38198e299108d7d53424e)
+++ 	(revision )
@@ -1,135 +1,0 @@
-# This program is public domain
-"""
-File extension registry.
-
-This provides routines for opening files based on extension,
-and registers the built-in file extensions.
-"""
-import logging
-import os.path
-
-class ExtensionRegistry(object):
-    """
-    Associate a file loader with an extension.
-
-    Note that there may be multiple loaders for the same extension.
-
-    Example:
-
-    registry = ExtensionRegistry()
-
-    # Add an association by setting an element
-    registry['.zip'] = unzip
-
-    # Multiple extensions for one loader
-    registry['.tgz'] = untar
-    registry['.tar.gz'] = untar
-
-    # Multiple loaders for one extension
-    registry['.cx'] = cx1
-    registry['.cx'] = cx2
-    registry['.cx'] = cx3
-    
-    # Can also register a format name for explicit control from caller
-    registry['cx3'] = cx3
-
-    # Retrieve loaders for a file name
-    registry.lookup('hello.cx') -> [cx3,cx2,cx1]
-
-    # Run loader on a filename
-    registry.load('hello.cx') ->
-        try:
-            return cx3('hello.cx')
-        except:
-            try:
-                return cx2('hello.cx')
-            except:
-                return cx1('hello.cx')
-
-    # Load in a specific format ignoring extension
-    registry.load('hello.cx',format='cx3') ->
-        return cx3('hello.cx')
-    """
-    def __init__(self):
-        self.loaders = {}
-        self.reader=None
-    def __setitem__(self, ext, loader):
-        if ext not in self.loaders:
-            self.loaders[ext] = []
-        self.loaders[ext].insert(0,loader)
-    def __getitem__(self, ext):
-        return self.loaders[ext]
-    def __contains__(self, ext):
-        return ext in self.loaders
-    def formats(self, name=True, ext=False):
-        """
-        Return a list of the registered formats.  If name=True then
-        named formats are returned.  If ext=True then extensions
-        are returned.
-        """
-        names = [a for a in self.loaders.keys() if not a.startswith('.')]
-        exts = [a for a in self.loaders.keys() if a.startswith('.')]
-        names.sort()
-        exts.sort()
-        ret = []
-        if name: ret += names
-        if ext: ret += exts
-        return ret
-        
-    def lookup(self, path):
-        """
-        Return the loader associated with the file type of path.
-        """        
-        file = os.path.basename(path)
-        idx = file.find('.')
-        ext = file[idx:] if idx >= 0 else ''
-        try:
-            return self.loaders[ext]
-        except:
-            #raise ValueError, "Unknown file type '%s'"%ext
-            print  "Unknown file type '%s'"%ext
-        
-    def loads(self, path, format=None):
-        """
-        Call the loader for the file type of path.
-
-        Raises ValueError if no loader is available.
-        May raise a loader-defined exception if loader fails.
-        """
-        if format is None:
-            loaders = self.lookup(path)
-        else:
-            loaders = self.loaders[format]
-        for fn in loaders:
-            print fn
-            try:
-                value=fn.read(path)
-                self.reader= fn
-                return value 
-            except ValueError,msg:
-                #pass
-                print str(msg)
-    def getAcTReader(self,path):
-        return self.reader
-    def load(self, path, format=None):
-        """
-        Call the loader for the file type of path.
-
-        Raises ValueError if no loader is available.
-        May raise a loader-defined exception if loader fails.
-        """
-        if format is None:
-            loaders = self.lookup(path)
-        else:
-            loaders = self.loaders[format]
-        if loaders!=None:
-            for fn in loaders:
-                try:
-                    value=fn.read(path)
-                    self.reader= fn.__class__
-                    return value
-                    #value=fn.read(path)
-                    #return value 
-                except ValueError,msg:
-                    #pass
-                    print str(msg)
Index: DataLoader/test/testLoad.py
===================================================================
--- DataLoader/test/testLoad.py	(revision aa749ac6a2c4ea5ba4cc8b49129c811d24a69da0)
+++ DataLoader/test/testLoad.py	(revision aa749ac6a2c4ea5ba4cc8b49129c811d24a69da0)
@@ -0,0 +1,57 @@
+"""
+    Unit tests for DataLoader module 
+"""
+
+import unittest
+import math
+import DataLoader
+from DataLoader.loader import  Loader
+from DataLoader.readers import TXT3_Reader,TXT2_Reader
+from DataLoader.readers import DataReader,danse_reader,tiff_reader
+
+class testLoader(unittest.TestCase):
+    """ test fitting """
+    def testLoad(self):
+        """ 
+            test module Load
+        """
+        #Creating a loader
+        L=Loader()
+        
+        #creating readers
+        read1=TXT2_Reader.Reader()
+        read2=TXT3_Reader.Reader()
+        read3=DataReader.Reader()
+        read4=danse_reader.Reader()
+        read5=tiff_reader.Reader()
+        #for each readers set an extensions inside the loader
+        L.__setitem__('.txt',read1)
+        L.__setitem__('.dat',read1)
+        L.__setitem__('.txt',read2)
+        L.__setitem__('.dat',read2)
+        L.__setitem__('.ASC',read3)
+        L.__setitem__('.sans',read4)
+        L.__setitem__('.tif',read5)
+        L.__setitem__('.jpg',read5)
+        L.__setitem__('.png',read5)
+        L.__setitem__('.jpeg',read5)
+        L.__setitem__('.gif',read5)
+        L.__setitem__('.bmp',read5)
+        
+        #test reading empty file
+        self.assertEqual(L.load('empty.txt'),None)
+         
+        #print L.loadData('test_2_columns.txt') 
+        xload,yload,dyload=L.load('test_2_columns.txt') 
+        x=[.83954,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449,1.42857,1.63265]
+        y=[0.6,3.44938, 5.82026,5.27591,5.2781,5.22531,7.47487,7.85852,10.2278]
+        dx=[]
+        dy=[]
+        self.assertEqual(len(xload),len(x))
+        self.assertEqual(len(yload),len(y))
+        self.assertEqual( L.getAcTReader('test_2_columns.txt'),DataLoader.readers.TXT2_Reader.Reader)
+        
+        
+        
+        
+        
