Index: trunk/pxeconfig.in
===================================================================
--- trunk/pxeconfig.in	(revision 119)
+++ trunk/pxeconfig.in	(revision 120)
@@ -88,5 +88,5 @@
 INTERACTIVE='interactive'
 EQUALWIDTH='equalwidth'
-VERSION='1.1.0'
+VERSION='2.0.0'
 
 SHORTOPT_LIST='b:e:f:hin:s:rwvH:V'
@@ -98,5 +98,5 @@
 def verbose(str):
 	if VERBOSE:
-		print '%s'
+		print '%s' %str
 
 class PxeConfig(Exception):
@@ -239,5 +239,4 @@
 	         else it must be a valid number. 
 	"""
-
 	try:
 		n = int(number_str)
@@ -304,5 +303,5 @@
 	manage_links(binfo)
 
-def check_command_line(binfo, hostnames):
+def check_args(binfo, hostnames):
 	"""
 	Do you we have the right and propper values 
@@ -310,4 +309,6 @@
 	### check_filename 
 	#
+	str = 'check_args: '
+	verbose(str)	
 	try:
 		if not os.path.isfile(os.path.join(PXE_CONF_DIR, binfo[FILENAME])):
@@ -329,9 +330,10 @@
 
 	if binfo.has_key(BASENAME):
-		network_number = False
+		set_padding(binfo)
 		create_links =  base_2_net
 
 	elif binfo.has_key(NETWORK):
-		network_number = True
+		binfo[START] = check_number(binfo[START], True)
+		binfo[END] = check_number(binfo[END], True)
 		create_links = manage_links
 
@@ -340,7 +342,4 @@
 		raise PxeConfig, error
 
-	binfo[START] = check_number(binfo[START], network_number)
-	binfo[END] = check_number(binfo[END], network_number)
-
 	if DEBUG:
 		print binfo
@@ -348,18 +347,42 @@
 	create_links(binfo)
 
-def set_padding(binfo, start, end):
-	"""
-	find out th
-	"""
-	if len(start) > 1 and start[0] == '0':
-		binfo[EQUALWIDTH] = True
-	elif end[0] == '0':
-		binfo[EQUALWIDTH] = True
-
-	if len(start) == len(end):
-		a =1 	
-		
-
-def parse_hostrange(binfo, arg):
+def set_padding(binfo):
+	"""
+	binfo          : boot info
+	network_number : must we check if  start,end values are 
+	                 valid network numbers
+	return:
+		- if equal_width is requested then the length will be set to end value
+		- if start value length > 1 and start with a zero (0), width is set to
+		  the end value
+		- if end value starts with a zero (0), width will be set to the end 
+		  value
+	"""
+	start_str = binfo[START]
+	end_str = binfo[END]
+
+	print 'padding ', type(start_str), type(end_str)
+
+	start = check_number(start_str, False)
+	end = check_number(end_str, False)
+
+
+	print type(start_str), type(end_str)
+
+
+	if binfo[EQUALWIDTH][0] == True:
+		binfo[EQUALWIDTH][1] = len(end_str) 
+
+	elif len(start_str) > 1 and start_str[0] == '0':
+		binfo[EQUALWIDTH] = [ True, len(end_str) ]
+
+	elif end_str[0] == '0':
+		binfo[EQUALWIDTH] = [ True, len(end_str) ]
+
+	binfo[START] = start
+	binfo[END] = end
+
+
+def parse_host_range(binfo, arg):
 	"""
 	Parse if arg is of format <digit-digit>, if it starts 
@@ -374,12 +397,9 @@
 		raise PxeConfig, error
 
-	start = l[0]
-	end = l[1]
-
-
-	binfo[START] = check_number(start, False)
-	binfo[END] = check_number(end, False)
-	
-def check_args(argv, binfo):
+	binfo[START] = l[0]
+	binfo[END] = l[1]
+
+	
+def parse_args(argv, binfo):
 	"""
 	This function parses the command line options and returns the rest as
@@ -439,5 +459,5 @@
 
 		elif opt in ['-w', '--equal-width']:
-			binfo[EQUALWIDTH] = True 
+			binfo[EQUALWIDTH] = [True, 0]
 
 		elif opt in ['-v', '--verbose']:
@@ -445,5 +465,5 @@
 
 		elif opt in ['-H', '--host-range']:
-		 	parse_hostrange(binfo, value)
+		 	parse_host_range(binfo, value)
 			
 		elif opt in ['-V', '--version']:
@@ -451,5 +471,5 @@
 			sys.exit(0) 
 
-	check_command_line(binfo, args)
+	check_args(binfo, args)
 
 def host_2_net(hosts, binfo):
@@ -483,11 +503,8 @@
 		raise PxeConfig, error
 
-	if binfo[EQUALWIDTH]:
-		width = len(str(end))
-
 	hostnames = list()
 	for i in xrange(start, end + 1):
-		if binfo[EQUALWIDTH]:
-			hostname = '%s%0*d' %(binfo[BASENAME], width, i)
+		if binfo[EQUALWIDTH][0] == True:
+			hostname = '%s%0*d' %(binfo[BASENAME],  binfo[EQUALWIDTH][1], i)
 		else:
 			hostname = '%s%d' %(binfo[BASENAME], i)
@@ -507,5 +524,5 @@
 	bootinfo = {}
 	bootinfo[REMOVE] = False 
-	bootinfo[EQUALWIDTH] = False 
+	bootinfo[EQUALWIDTH] = [ False, 0 ]
 	
 	configfile = '@pxeconfig_conf@'
@@ -522,13 +539,13 @@
 	PXE_CONF_DIR = os.path.realpath(PXE_CONF_DIR)
 	if not os.path.isdir(PXE_CONF_DIR):
-		print 'pxeconfig directory: %s does not exists' %(PXE_CONF_DIR)
-		sys.exit(1)
-
+		error =  'pxeconfig directory: %s does not exists' %(PXE_CONF_DIR)
+		raise PxeConfig, error
+
+	parse_args(sys.argv, bootinfo) 
+	
+if __name__ == '__main__':
 	try:
-		check_args(sys.argv, bootinfo) 
+		main()
 	except PxeConfig, detail:
 		print detail
 		sys.exit(1)
-	
-if __name__ == '__main__':
-	main()
