Index: /trunk/src/AdvancedParser.py
===================================================================
--- /trunk/src/AdvancedParser.py	(revision 180)
+++ /trunk/src/AdvancedParser.py	(revision 181)
@@ -13,4 +13,7 @@
 import re
 import types
+
+__author__  = "Dennis Stam"
+__version__ = ( 1, 1, 0 )
 
 class AdvancedParser(OptionParser):
@@ -36,4 +39,23 @@
         """
 
+        def parse_letters( self, chars ):
+            
+            if type( chars ) is not types.ListType and len( chars ) != 2:
+                self.error( 'Could not parse range' )
+
+            start   = ord( chars[ 0 ] )
+            end     = ord( chars[ 1 ] )
+            out     = list()
+
+            if start > 96 and start < 122 and end > 97 and end < 123:
+                lrange = range( start, end + 1 )
+
+                for ichar in lrange:
+                    out.append( chr( ichar ) )
+                
+                return out
+            else:
+                self.error( 'AdvanedParser module only handles letters from a to z ( lower cased )' )
+
         def return_range(self, string):
                 """
@@ -45,46 +67,35 @@
                 The ranges will be return as lists
                 """
-                parts = string.split( ',' )
                 numbers_chars = list()
                 equal_width_length = 0
 
-                for part in parts:
-                        part_range = part.split( '-' )
-                        if len( part_range ) == 2:
-                                try:
-                                        if part_range[0][0] == '0' or part_range[1][0] == '0':
-                                                if len( part_range[0] ) > len( part_range[1] ):
-                                                        equal_width_length = len( part_range[0] )
-                                                else:
-                                                        equal_width_length = len( part_range[1] )
+                if string.find( ',' ) >= 0 and string.find( ',' ) < 1:
+                    self.error( 'You cannot start a range with \',\'. Given range: %s' % string )
 
-                                        numbers_chars += range( int( part_range[0] ), int( part_range[1] ) + 1 )
-                                except ValueError:
-                                        begin = ord( part_range[0] )
-                                        end = ord( part_range[1] )
-                                        tmplist = list()
+                if string.find( '-' ) >= 0 and string.find( '-' ) < 1:
+                    self.error( 'You cannot start a range with \'-\'. Given range: %s' % string )
 
-                                        if begin > 96 and end < 123:
-                                                tmplist = range( begin, end + 1)
+                for section in string.split( ',' ):
+                    if section.find( '-' ) > 0:
+                        if len( section.split( '-' ) ) != 2:
+                            self.error( 'A range must be consisted of two values' )
+                        
+                        chars = section.split( '-' )
 
-                                                for letter in tmplist:
-                                                        numbers_chars.append( chr( letter ) )
-                        else:
-                                if equal_width_length != 0 and len( part ) > equal_width_length:
-                                        equal_width_length = len( part )
+                        try:
+                            if chars[ 0 ][ 0 ] == '0' or chars[ 1 ][ 0 ]:
+                                if len( chars[ 0 ] ) > len( chars[ 1 ] ):
+                                    equal_width_length = len( chars[ 0 ] )
+                                else:
+                                    equal_width_lenght = len( chars[ 1 ] )
 
-                                numbers_chars.append( part )
+                            numbers_chars += range( int( chars[ 0 ] ), int( chars[ 1 ] ) + 1 )
+                        except ValueError:
+                            numbers_chars += self.parse_letters( chars )
 
-                if equal_width_length > 0:
-                        tmplist = list()
-
-                        for number_char in numbers_chars:
-                                try:
-                                        nnum = int( number_char )
-                                        tmplist.append( '%0*d' % (equal_width_length, nnum) )
-                                except ValueError:
-                                        tmplist.append( number_char )
-                        
-                        numbers_chars = tmplist
+                    else:
+                        if equal_width_length != 0 and len( section ) > equal_width_lenght:
+                            equal_width_lenght = len( section )
+                        numbers_chars.append( section )
 
                 return numbers_chars
@@ -152,4 +163,3 @@
 if __name__ == "__main__":
         import doctest
-        print 'Starting doctest'
         doctest.testmod()
