Ejemplo n.º 1
0
    def join_answer_and_menu_prefix(self, x, y):

        for g in x:

            if y == str(g['keycode']):
                n = g

                if not self.back_door_segment:
                    n['userInput'] = raw_input("\n" + g['inputQuestion'] + "> ")
                else:
                    n['userInput'] = self.back_door_segment

        n['segmentPath'] = folderValidation("tmpTest").convertUserInput(n['userInput'])

        '''
            Need to add a validation to the type of answer that was given.
            1) numerical
            2) yes or no
            3) file or folder path
            
        '''
        if self.validation(n['expected_type'], n['userInput']):
            rule.pause("Validation passed")
            # if self.validateAllNumbers(n['scanOutput'], n['userInput']):
            #
            # We need to simplify the returned list...not everything is needed
            output_filter = ['scanOutput', 'userInput', 'keycode', 'segmentPath']

            return rule.funnel_white_list(output_filter, self.return_first_key_in_List(n))

        else:
            rule.pause("Validation failed")
Ejemplo n.º 2
0
    def convertUserInput(self, user_input):

        set_path = self.dir + "/" + user_input.replace(".", "_") + "/" + rule.DT_stamp(1)

        if not os.path.exists(set_path):

            os.makedirs(set_path)

            return set_path

        else:
            rule.pause("Error creating directory...make sure it has write permissions :: %s" % set_path)