Index: DataLoader/docs/todo.txt
===================================================================
--- DataLoader/docs/todo.txt	(revision f8de7deba50a8c7d2cd5c662682568b3735fd0f5)
+++ DataLoader/docs/todo.txt	(revision 8bd8ea439767ebb5cd5480a4da37e8e080d4f3df)
@@ -24,4 +24,9 @@
  - All data loaded from a file should be stored in a common class object.  
  
+ - Avoid use of __setitem__ from outside a class.
+ - Bug: Loading blah.my.txt won't work. Is fixed in reflectivity registry.py
+ - Bug: The extension recognition is case sensitive and shouldn't be.
+ - BUG: if a reader raises an exception other than ValueError, the loader doesn't catch it.
+ 
  * Error conditions
  - Trying to load a file with an unknown extension should raise a RuntimeException.
Index: taLoader/readers/TXT2_Reader.py
===================================================================
--- DataLoader/readers/TXT2_Reader.py	(revision 16d8e5fb43348001cacbc6967a6922266e68fe6e)
+++ 	(revision )
@@ -1,83 +1,0 @@
-# class Loader  to load any king of file
-import wx
-import string,numpy,logging
-class Reader:
-    """
-        This class is loading values from given file or value giving by the user
-        should be able to read only 2 columns of data
-    """
-    ext=['.txt','.dat'] 
-    def _init_(self,x=None,y=None,dx=None,dy=None):
-        # variable to store loaded values
-        self.x = x
-        self.y = y
-        self.dx = dx
-        self.dy = dy
-        
-    def read(self,path, format=None):
-        """ Store the values loaded from file in local variables """
-        if not path == None:
-            read_it = False
-             
-            for item in self.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:
-                try:
-                    input_f =  open(path,'r')
-                except :
-                    raise  RuntimeError,"TXT2_Reader cannot open %s"%(path)
-                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 %s"%path
-                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
-                    from readInfo import ReaderInfo   
-                    output = ReaderInfo()
-                    output.x=self.x
-                    output.y=self.y
-                    
-                    logging.info("TXT2_Reader reading  %s\n" %path)
-                    return output
-        return None
-   
-       
-    
-if __name__ == "__main__": 
-    read= Reader()
-    read.load("testdata_line.txt")
-    
-            
Index: taLoader/readers/TXT3_Reader.py
===================================================================
--- DataLoader/readers/TXT3_Reader.py	(revision 16d8e5fb43348001cacbc6967a6922266e68fe6e)
+++ 	(revision )
@@ -1,87 +1,0 @@
-# class Loader  to load any king of file
-import wx
-import string,numpy,logging
-class Reader:
-    """
-        This class is loading values from given file or value giving by the user
-    """
-    ext=['.txt','.dat']  
-    def _init_(self,filename=None,x=None,y=None,dx=None,dy=None):
-        # variable to store loaded values
-        self.x = x
-        self.y = y
-        self.dx = dx
-        self.dy = dy
-        self.filename = filename
-        
-        
-    def read(self,path, format=None):
-        """ Store the values loaded from file in local variables 
-            can read 3 columns of data
-        """
-        
-        if not path == None:
-            read_it = False
-            
-            for item in self.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:
-                try:
-                    input_f =  open(path,'r')
-                except :
-                    raise  RuntimeError,"TXT3_Reader cannot open %s"%(path)
-                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])
-                        y = float(toks[1]) 
-                        dy = float(toks[2])
-                       
-                        self.x.append(x)
-                        self.y.append(y)
-                        self.dy.append(dy)
-                   
-                    except:
-                        pass
-                        #print "READ ERROR", line
-            
-                    self.dx = numpy.zeros(len(self.x))
-                    # Sanity check
-                    if not len(self.x) == len(self.dx):
-                        raise ValueError, "x and dx have different length"
-                    if not len(self.y) == len(self.dy):
-                        raise ValueError, "y and dy have different length"
-               
-                if (self.x==[] or self.y==[])and (self.dy==[]):
-                    raise ValueError, "TXT3_Reader can't read %s"%path
-                else:
-                    #msg="txtReader  Reading:\n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n"
-                    #return msg
-                    logging.info("TXT3_Reader reading %s \n" %path)
-                    from readInfo import ReaderInfo   
-                    output = ReaderInfo()
-                    output.x    = self.x
-                    output.y    = self.y
-                    output.dy   = self.dy
-                    output.type = "1D"
-                    
-                    return output
-                
-        return None
-if __name__ == "__main__": 
-    read= Reader()
-    #read= Reader(filename="testdata_line.txt")
-    print read.load("test.dat")
-    
-    
-            
Index: DataLoader/readers/abs_reader.py
===================================================================
--- DataLoader/readers/abs_reader.py	(revision d8a5f12377326958efea5affdd5ff78963a17fd0)
+++ DataLoader/readers/abs_reader.py	(revision 8bd8ea439767ebb5cd5480a4da37e8e080d4f3df)
@@ -18,5 +18,5 @@
     """
     ## List of allowed extensions
-    ext=['.abs']  
+    ext=['.abs', '.ABS']  
     
     def read(self, path):
@@ -131,4 +131,9 @@
                 if not len(y) == len(dy):
                     raise ValueError, "abs_reader: y and dy have different length"
+
+                # If the data length is zero, consider this as
+                # though we were not able to read the file.
+                if len(x)==0:
+                    raise ValueError, "ascii_reader: could not load file"
                
                 output.x = x
@@ -136,5 +141,5 @@
                 output.dy = dy
                 output.xaxis("\\rm{Q}", 'A^{-1}')
-                output.yaxis("\\rm{I(Q)} ","cm^{-1}")
+                output.yaxis("\\rm{I(Q)}","cm^{-1}")
                 
                 return output
Index: DataLoader/readers/ascii_reader.py
===================================================================
--- DataLoader/readers/ascii_reader.py	(revision 8bd8ea439767ebb5cd5480a4da37e8e080d4f3df)
+++ DataLoader/readers/ascii_reader.py	(revision 8bd8ea439767ebb5cd5480a4da37e8e080d4f3df)
@@ -0,0 +1,110 @@
+"""
+This software was developed by the University of Tennessee as part of the
+Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+project funded by the US National Science Foundation. 
+
+See the license text in license.txt
+
+copyright 2008, University of Tennessee
+"""
+
+import numpy
+import os
+from DataLoader.data_info import Data1D
+
+class Reader:
+    """
+        Class to load ascii files (2 or 3 columns)
+    """
+    ## List of allowed extensions
+    ext=['.txt', '.TXT', '.dat', '.DAT']  
+    
+    def read(self, path):
+        """ 
+            Load data file
+            
+            @param path: file path
+            @return: Data1D object, or None
+            @raise RuntimeError: when the file can't be opened
+            @raise ValueError: when the length of the data vectors are inconsistent
+        """
+        if os.path.isfile(path):
+            basename  = os.path.basename(path)
+            root, extension = os.path.splitext(basename)
+            if extension.lower() in self.ext:
+                try:
+                    input_f =  open(path,'r')
+                except :
+                    raise  RuntimeError, "ascii_reader: cannot open %s" % path
+                buff = input_f.read()
+                lines = buff.split('\n')
+                x  = numpy.zeros(0)
+                y  = numpy.zeros(0)
+                dy = numpy.zeros(0)
+                output = Data1D(x, y, dy=dy)
+                self.filename = output.filename = basename
+                
+                # The first good line of data will define whether
+                # we have 2-column or 3-column ascii
+                has_error = None
+                
+                for line in lines:
+                    toks = line.split()
+                    try:
+                        _x = float(toks[0])
+                        _y = float(toks[1])
+                        
+                        # If we have an extra token, check
+                        # whether it can be interpreted as a
+                        # third column.
+                        _dy = None
+                        if len(toks)>2:
+                            try:
+                                _dy = float(toks[2])
+                            except:
+                                # The third column is not a float, skip it.
+                                pass
+                            
+                        # If we haven't set the 3rd column
+                        # flag, set it now.
+                        if has_error == None:
+                            has_error = False if _dy == None else True
+
+                        x  = numpy.append(x,   _x) 
+                        y  = numpy.append(y,   _y)
+                        if has_error == True:
+                            dy = numpy.append(dy, _dy)
+                        
+                    except:
+                        # Couldn't parse this line, skip it 
+                        pass
+                         
+                     
+                # Sanity check
+                if has_error == True and not len(y) == len(dy):
+                    raise ValueError, "ascii_reader: y and dy have different length"
+
+                # If the data length is zero, consider this as
+                # though we were not able to read the file.
+                if len(x)==0:
+                    raise ValueError, "ascii_reader: could not load file"
+               
+                output.x = x
+                output.y = y
+                output.dy = dy
+                output.xaxis("\\rm{Q}", 'A^{-1}')
+                output.yaxis("\\rm{I(Q)}","cm^{-1}")
+                
+                
+                return output
+        else:
+            raise RuntimeError, "%s is not a file" % path
+        return None
+    
+if __name__ == "__main__": 
+    reader = Reader()
+    #print reader.read("../test/test_3_columns.txt")
+    print reader.read("../test/empty.txt")
+    
+    
+                        
Index: DataLoader/readers/tiff_reader.py
===================================================================
--- DataLoader/readers/tiff_reader.py	(revision 68f6ae249434566dbc018908720451e6f12c11ca)
+++ DataLoader/readers/tiff_reader.py	(revision 8bd8ea439767ebb5cd5480a4da37e8e080d4f3df)
@@ -1,4 +1,3 @@
 
-import Image
 import math,logging
 
@@ -14,4 +13,5 @@
         
     def read(self, filename=None):
+        import Image
         print "in tiff"
         """
Index: DataLoader/test/testLoad.py
===================================================================
--- DataLoader/test/testLoad.py	(revision 5f0f3d2b73729b4cc2b92ad9acf3ae24e3281418)
+++ DataLoader/test/testLoad.py	(revision 8bd8ea439767ebb5cd5480a4da37e8e080d4f3df)
@@ -16,6 +16,4 @@
 import DataLoader
 from DataLoader.loader import  Loader
-from DataLoader.readers import TXT3_Reader,TXT2_Reader
-from DataLoader.readers import IgorReader,danse_reader,tiff_reader
  
 import os.path
Index: DataLoader/test/test_log.txt
===================================================================
--- DataLoader/test/test_log.txt	(revision 8bd8ea439767ebb5cd5480a4da37e8e080d4f3df)
+++ DataLoader/test/test_log.txt	(revision 8bd8ea439767ebb5cd5480a4da37e8e080d4f3df)
@@ -0,0 +1,14 @@
+2008-07-28 14:22:51,773 DEBUG Inside testLoad module
+2008-07-28 14:22:52,273 ERROR ascii_reader: could not load file
+2008-07-28 14:22:52,273 ERROR ascii_reader: could not load file
+2008-07-28 14:22:52,509 INFO IgorReader reading MAR07232_rest.ASC
+2008-07-28 14:22:52,509 ERROR IgorReader: can't read this file, missing distance
+2008-07-28 14:22:52,509 ERROR IgorReader: can't read this file, missing distance
+2008-07-28 14:22:52,648 INFO Danse_reader Reading MP_New.sans 
+
+2008-07-28 14:22:52,773 INFO Danse_reader Reading P_New.sans 
+
+2008-07-28 14:22:52,789 WARNING Unknown file type '.missing'
+2008-07-28 14:22:52,789 WARNING Unknown file type '.missing'
+2008-07-28 14:22:52,789 ERROR ascii_reader: could not load file
+2008-07-28 14:22:52,789 ERROR ascii_reader: could not load file
