def add_arguments(self, arg): """ has to be called whenever th script is used from within the JTShell environment, adds the parameters, which would normally be provided directly by the system variable. ### arg - (string) the string passed onto the shell ### RETURNS (void) """ # dividing the given string into the the list of arguments and the given # values of these parameters, by breaking the string by every appearance # of the '-' key and making an exception at the "" separation # the toggle wether inside an separated string in_separation = False # the temporary key, value pair of the current argument temp_argument_tuples = [] # the actual temporary string temp_string = "" # first step: dividing the string into strings of key/value pairs with whitespaces for character in arg: # toggeling the separation condition if character == '"': if in_separation: in_separation = False else: in_separation = True # breaking the temporary string in case the keycharacter "-" appears if character == "-" and not (in_separation): temp_argument_tuples.append(temp_string) temp_string = "" # adding the character to the temporary string temp_string += character temp_argument_tuples.append(temp_string) temp_argument_tuples.remove("") # second step: itering through the tempory list and then appending the # argiuments to the arguments dictionary of the class for string in temp_argument_tuples: temp_string = jtstr.divide_by_custom(string, " ")[0] if '"' in string: self.args[temp_string] = string.replace(temp_string + " ", "").replace('"', "") else: self.args[temp_string] = string.replace(temp_string + " ", "")