--- /dev/null
+#==============================================================
+#
+#==============================================================
+def get_help_info() :
+ return "\tUsage : \n\tpython install.py [-gui|tui] [-f <xmlfile>] [-t taget_dir] [-tmp tmp_dir]\n"
+
+#==============================================================
+#
+#==============================================================
+def error_exit (str = ""):
+ import sys
+ if len(str): res = "\n" + str + "\n"
+ else : res = ""
+ print res + \
+ get_help_info() + \
+ "\nWrong parameters\n\n";
+ sys.exit(1);
+
+
+#==============================================================
+# Cheks whether the passed parameter is a key.
+#==============================================================
+def is_key ( val ):
+ import re
+ if val is not None :
+ return re.match(r'^-[a-zA-Z]', val)
+ return 0
+
+#==============================================================
+#
+#==============================================================
+def extract_parameter ( key, args ) :
+ import sys
+ length = len(args);
+ if ( length == 0 ) : return None
+
+ found = 0;
+
+ for i in range(0, length-1):
+ if args[i] == key :
+ if ( is_key ( args[i+1]) ) :
+ print " No value after key ", key
+ sys.exit(1);
+
+ value = args[i+1]
+ if ( i < length - 2 and is_key ( args[i+2] ) == 0 ) : #control that only one value follows key
+ #(not a list). In this case params are correct.
+ print "Too much values after key ", key
+ sys.exit(1);
+
+ found = 1; break;
+
+ if (found) :
+ return value
+
+ return None
+
+
+#===============================================================
+# extracts list of values following specified 'key' from 'args[]'
+#===============================================================
+def extract_list (key, args) :
+
+ lenght = len(args)
+ if ( args is None or lenght == 0 ):
+ error_exit()
+
+ list=[]
+ found = 0
+
+ for i in range(0, length) :
+ if args[i] == key :
+ if (is_key ( args[i+1])) :
+ error_exit();
+
+ for i in range (i+1, lenght):
+ if is_key(args[i]) : break
+ list.append(args[i])
+ found =1; break
+
+ return list; #empty list is returned if no values after key
+
+
+#==============================================================
+# Method find the $key in the list and return 1 if success
+# and 0 otherwise.
+#==============================================================
+def find_key (key, argv) :
+
+ if (not is_key(key)) : return 0
+
+ for simbol in argv :
+ if simbol == key:
+ return 1
+ return 0
+
+#==============================================================
+#
+#==============================================================
+def parse_parameters (args) :
+
+ if find_key('-h', args) :
+ print get_help_info();
+ import sys
+ sys.exit(0)
+
+ xmlfile = extract_parameter("-f", args)
+ target_dir = extract_parameter("-t", args)
+ tmp_dir = extract_parameter("-tmp", args)
+ if find_key('-tui', args):
+ is_gui = 0
+ else : is_gui = 1
+ return [xmlfile, target_dir, tmp_dir, is_gui]