def parseDestinationDescription(self, parse_string):
     tmp_descr = re.split(string = parse_string, pattern = "#")
     if len(tmp_descr) != 2 or not tmp_descr[1].isdigit():
         rospy.logerr("Provided destination description >%s< is invalid.", parse_string)
         rospy.logerr("It should be 2 strings. A description and an id.")
         return False
     self.parameters['destination_description'] = du.getO(tmp_descr[0], tmp_descr[1])
     return True
 def parseDestinationDescription(self, parse_string):
     tmp_descr = re.split(string=parse_string, pattern="#")
     if len(tmp_descr) != 2 or not tmp_descr[1].isdigit():
         rospy.logerr("Provided destination description >%s< is invalid.",
                      parse_string)
         rospy.logerr("It should be 2 strings. A description and an id.")
         return False
     self.parameters['destination_description'] = du.getO(
         tmp_descr[0], tmp_descr[1])
     return True
    def parse(self):

        parser = OptionParser()
        parser.add_option("-d", "--description", dest="description",
                          help="description string", default = "")
        parser.add_option("-i", "--id", type="int", dest="id",
                          help="description id", default = -1)
        parser.add_option("-t", "--trial", type="int", dest="trial",
                          help="trial index", default = -1)
        parser.add_option("-r", "--remove", action="store_true", dest="remove",
                          help="remove the recording matching the description, id, and trial", default = "")
        parser.add_option("-c", "--copy", dest="copy",
                          help="copy the recording matching the description to <description#id>", default = "")
        parser.add_option("-m", "--move", dest="move",
                          help="move the recording matching the description to <description#id>", default = "")
        
        (options, args) = parser.parse_args()

        if not self.requireDescriptionAndId(options):
            parser.print_help()
            return False
        self.parameters['source_description'] = du.getO(options.description, options.id, options.trial)

        if options.copy != "" and options.remove != "" or options.copy != "" and options.move != "" or options.remove != "" and options.move != "":
            rospy.logerr("Can't copy/remove/move at the same time...")
            return False
        elif options.copy != "":
            if not self.parseDestinationDescription(options.copy):
                return False
            return self.copy(self.parameters['source_description'], self.parameters['destination_description'])
        elif options.remove != "":
            return self.remove(self.parameters['source_description'])
        elif options.move != "":
            if not self.parseDestinationDescription(options.move):
                return False
            if not self.copy(self.parameters['source_description'], self.parameters['destination_description']):
                rospy.logerr("Problems when copying... not moving >%s< to >%s<.", du.getN(self.parameters['source_description']), du.getN(self.parameters['destination_description']))
                return False
            return self.remove(self.parameters['source_description'])
            
        return True 
    def parse(self):

        parser = OptionParser()
        parser.add_option("-d",
                          "--description",
                          dest="description",
                          help="description string",
                          default="")
        parser.add_option("-i",
                          "--id",
                          type="int",
                          dest="id",
                          help="description id",
                          default=-1)
        parser.add_option("-t",
                          "--trial",
                          type="int",
                          dest="trial",
                          help="trial index",
                          default=-1)
        parser.add_option(
            "-r",
            "--remove",
            action="store_true",
            dest="remove",
            help="remove the recording matching the description, id, and trial",
            default="")
        parser.add_option(
            "-c",
            "--copy",
            dest="copy",
            help=
            "copy the recording matching the description to <description#id>",
            default="")
        parser.add_option(
            "-m",
            "--move",
            dest="move",
            help=
            "move the recording matching the description to <description#id>",
            default="")

        (options, args) = parser.parse_args()

        if not self.requireDescriptionAndId(options):
            parser.print_help()
            return False
        self.parameters['source_description'] = du.getO(
            options.description, options.id, options.trial)

        if options.copy != "" and options.remove != "" or options.copy != "" and options.move != "" or options.remove != "" and options.move != "":
            rospy.logerr("Can't copy/remove/move at the same time...")
            return False
        elif options.copy != "":
            if not self.parseDestinationDescription(options.copy):
                return False
            return self.copy(self.parameters['source_description'],
                             self.parameters['destination_description'])
        elif options.remove != "":
            return self.remove(self.parameters['source_description'])
        elif options.move != "":
            if not self.parseDestinationDescription(options.move):
                return False
            if not self.copy(self.parameters['source_description'],
                             self.parameters['destination_description']):
                rospy.logerr(
                    "Problems when copying... not moving >%s< to >%s<.",
                    du.getN(self.parameters['source_description']),
                    du.getN(self.parameters['destination_description']))
                return False
            return self.remove(self.parameters['source_description'])

        return True