예제 #1
0
    def render(self, convfunc):
        assert self.switchuse is not None, "Switch 'switchuse' has not been set"
        assert type(self.switchuse) is str or type(self.switchuse) is unicode, "Switch 'switchuse' is wrong type"

        # lets list the previous job files

        return self.switchuse % {'switch': self.flag, 'value': quote_argument(convfunc(self.value))}
예제 #2
0
 def render(self, filenames):
     assert self.switchuse is not None, "Switch 'switchuse' has not been set"
     assert type(self.switchuse) is str or type(
         self.switchuse) is unicode, "Switch 'switchuse' is wrong type"
     return self.switchuse % {
         'switch': self.flag,
         'value': " ".join([quote_argument(X) for X in filenames])
     }
예제 #3
0
 def render(self, filenames):
     assert self.switchuse is not None, "Switch 'switchuse' has not been set"
     assert type(self.switchuse) is str or type(
         self.switchuse) is unicode, "Switch 'switchuse' is wrong type"
     assert len(
         filenames) == 1, "BatchSwitch can only take single filenames"
     return self.switchuse % {
         'switch': self.flag,
         'value': quote_argument(filenames[0])
     }
예제 #4
0
    def render(self, convfunc):
        assert self.switchuse is not None, "Switch 'switchuse' has not been set"
        assert type(self.switchuse) is str or type(
            self.switchuse) is unicode, "Switch 'switchuse' is wrong type"

        # lets list the previous job files

        return self.switchuse % {
            'switch': self.flag,
            'value': quote_argument(convfunc(self.value))
        }
예제 #5
0
 def __str__(self):
     """This is the render function that renders the filename"""
     return quote_argument(self.template(self.filename, self.extension))
예제 #6
0
    def parse_parameter_description(self):
        """Parse the json parameter description"""
        for tp in self.tool.desc.toolparameter_set.order_by('rank').all():
            # check the tool switch against the incoming params
            if tp.switch not in self.params:
                logger.debug("Switch ignored [%s]" % tp.switch)
                continue

            logger.debug("TP->%s" % tp.switch)
            logger.debug("self.params[%s]=%s" % (tp.switch, self.params[tp.switch]))

            # check to see if the param description refers to a filesystem
            params = self.params[tp.switch]
            if params['valid']:
                details = params['value']
                logger.debug("details = %s" % details)
                for value in details:
                    logger.debug("value = %s" % value)

                    if type(value) is dict and 'type' in value and (value['type'] == 'file' or value['type'] == 'directory'):
                        # param refers to a file
                        assert tp.file_assignment == "batch" or tp.file_assignment == "all", "File parameter passed in on switch '%s' where file_assignment is neither 'batch' nor 'all'" % (tp.switch)

                        self.files.append(value)

                        filename = value['filename']
                        if value['type'] == 'directory':
                            if not filename.endswith('/'):
                                filename += '/'

                        value = SwitchInputFilename(filename)

                        self.arguments.append(Switch(tp.switch, value, switchuse=tp.switch_use.formatstring))
                    else:
                        # switch has single parameter
                        if tp.batch_bundle_files:
                            logger.debug("[%s] tool.batch_bundle_files" % (tp.switch))
                        if tp.input_file:
                            logger.debug("[%s] tp.input_file" % (tp.switch))
                        if tp.output_file:
                            logger.debug("[%s] tp.output_file" % (tp.switch))
                        if tp.use_output_filename:
                            logger.debug("[%s] tp.use_output_filename = %s" % (tp.switch, tp.use_output_filename))
                        if tp.extension_param:
                            logger.debug("[%s] tp.extension_param" % (tp.switch))

                        if type(value) is dict:
                            assert "type" in value and (value['type'] == 'job' or value['type'] == 'jobfile'), "Unknown param value type for switch '%s', type is '%s'" % (tp.switch, value['type'])

                            # annotate extra info
                            value['extensions'] = tp.input_filetype_patterns()
                            value['bundle_files'] = tp.batch_bundle_files
                            value['file_assignment'] = tp.file_assignment

                            # annotate with the switch we are processing
                            value['switch'] = tp.switch

                            # save the param
                            self.backrefs.append(value)
                            if tp.file_assignment == "batch":                 # tp.batch_param:
                                # this is a batch parameter, so it needs the special batch switch
                                self.arguments.append(BatchSwitch(tp.switch, switchuse=tp.switch_use.formatstring))
                                self.batch_switches.append(tp.switch)

                            elif tp.file_assignment == "all":
                                # this is a consume parameter. so it needs the consumer switch
                                self.arguments.append(ConsumerSwitch(tp.switch, switchuse=tp.switch_use.formatstring))
                                self.consume_switches.append(tp.switch)

                            else:
                                if 'filename' in value:
                                    # this is just an input file that will be staged along. lets add the filename statically now as it wont change, then we use the uri conversion later to make it full path
                                    self.arguments.append(Switch(tp.switch, SwitchInputFilename(value['filename']), switchuse=tp.switch_use.formatstring))
                                else:
                                    assert value['type'] == 'job' and 'jobId' in value, "non previous job switch input filename. value is: %s" % (str(value))
                                    self.arguments.append(UnknownFileSwitch(tp.switch, value, switchuse=tp.switch_use.formatstring))

                        elif type(value) is str or type(value) is unicode:
                            value = quote_argument(value)

                            if tp.output_file:
                                if tp.use_output_filename:
                                    # this means output filename has to be named after the filename associated with the switch this parameter is pointing to
                                    if tp.extension_param:
                                        value = SwitchFilename(default=value, template=make_fname, source_switch=tp.use_output_filename.switch, extension=tp.extension_param.extension())
                                    else:
                                        value = SwitchFilename(default=value, template=make_fname, source_switch=tp.use_output_filename.switch)

                            self.arguments.append(Switch(tp.switch, value, switchuse=tp.switch_use.formatstring))
예제 #7
0
 def render(self, filenames):
     assert self.switchuse is not None, "Switch 'switchuse' has not been set"
     assert type(self.switchuse) is str or type(self.switchuse) is unicode, "Switch 'switchuse' is wrong type"
     return self.switchuse % {'switch': self.flag, 'value': " ".join([quote_argument(X) for X in filenames])}
예제 #8
0
 def render(self, filenames):
     assert self.switchuse is not None, "Switch 'switchuse' has not been set"
     assert type(self.switchuse) is str or type(self.switchuse) is unicode, "Switch 'switchuse' is wrong type"
     assert len(filenames) == 1, "BatchSwitch can only take single filenames"
     return self.switchuse % {'switch': self.flag, 'value': quote_argument(filenames[0])}
예제 #9
0
 def __str__(self):
     """Convert the filename using the conversion routine"""
     if self.convfunc:
         return quote_argument(self.convfunc(self.filename))
     else:
         return quote_argument(self.filename)
예제 #10
0
 def __str__(self):
     """This is the render function that renders the filename"""
     return quote_argument(self.template(self.filename, self.extension))
예제 #11
0
    def parse_parameter_description(self):
        """Parse the json parameter description"""
        for tp in self.tool.desc.toolparameter_set.order_by('rank').all():
            # check the tool switch against the incoming params
            if tp.switch not in self.params:
                logger.debug("Switch ignored [%s]" % tp.switch)
                continue

            logger.debug("TP->%s" % tp.switch)
            logger.debug("self.params[%s]=%s" %
                         (tp.switch, self.params[tp.switch]))

            # check to see if the param description refers to a filesystem
            params = self.params[tp.switch]
            if params['valid']:
                details = params['value']
                logger.debug("details = %s" % details)
                for value in details:
                    logger.debug("value = %s" % value)

                    if type(value) is dict and 'type' in value and (
                            value['type'] == 'file'
                            or value['type'] == 'directory'):
                        # param refers to a file
                        assert tp.file_assignment == "batch" or tp.file_assignment == "all", "File parameter passed in on switch '%s' where file_assignment is neither 'batch' nor 'all'" % (
                            tp.switch)

                        self.files.append(value)

                        filename = value['filename']
                        if value['type'] == 'directory':
                            if not filename.endswith('/'):
                                filename += '/'

                        value = SwitchInputFilename(filename)

                        self.arguments.append(
                            Switch(tp.switch,
                                   value,
                                   switchuse=tp.switch_use.formatstring))
                    else:
                        # switch has single parameter
                        if tp.batch_bundle_files:
                            logger.debug("[%s] tool.batch_bundle_files" %
                                         (tp.switch))
                        if tp.input_file:
                            logger.debug("[%s] tp.input_file" % (tp.switch))
                        if tp.output_file:
                            logger.debug("[%s] tp.output_file" % (tp.switch))
                        if tp.use_output_filename:
                            logger.debug("[%s] tp.use_output_filename = %s" %
                                         (tp.switch, tp.use_output_filename))
                        if tp.extension_param:
                            logger.debug("[%s] tp.extension_param" %
                                         (tp.switch))

                        if type(value) is dict:
                            assert "type" in value and (
                                value['type'] == 'job'
                                or value['type'] == 'jobfile'
                            ), "Unknown param value type for switch '%s', type is '%s'" % (
                                tp.switch, value['type'])

                            # annotate extra info
                            value['extensions'] = tp.input_filetype_patterns()
                            value['bundle_files'] = tp.batch_bundle_files
                            value['file_assignment'] = tp.file_assignment

                            # annotate with the switch we are processing
                            value['switch'] = tp.switch

                            # save the param
                            self.backrefs.append(value)
                            if tp.file_assignment == "batch":  # tp.batch_param:
                                # this is a batch parameter, so it needs the special batch switch
                                self.arguments.append(
                                    BatchSwitch(
                                        tp.switch,
                                        switchuse=tp.switch_use.formatstring))
                                self.batch_switches.append(tp.switch)

                            elif tp.file_assignment == "all":
                                # this is a consume parameter. so it needs the consumer switch
                                self.arguments.append(
                                    ConsumerSwitch(
                                        tp.switch,
                                        switchuse=tp.switch_use.formatstring))
                                self.consume_switches.append(tp.switch)

                            else:
                                if 'filename' in value:
                                    # this is just an input file that will be staged along. lets add the filename statically now as it wont change, then we use the uri conversion later to make it full path
                                    self.arguments.append(
                                        Switch(tp.switch,
                                               SwitchInputFilename(
                                                   value['filename']),
                                               switchuse=tp.switch_use.
                                               formatstring))
                                else:
                                    assert value[
                                        'type'] == 'job' and 'jobId' in value, "non previous job switch input filename. value is: %s" % (
                                            str(value))
                                    self.arguments.append(
                                        UnknownFileSwitch(
                                            tp.switch,
                                            value,
                                            switchuse=tp.switch_use.
                                            formatstring))

                        elif type(value) is str or type(value) is unicode:
                            value = quote_argument(value)

                            if tp.output_file:
                                if tp.use_output_filename:
                                    # this means output filename has to be named after the filename associated with the switch this parameter is pointing to
                                    if tp.extension_param:
                                        value = SwitchFilename(
                                            default=value,
                                            template=make_fname,
                                            source_switch=tp.
                                            use_output_filename.switch,
                                            extension=tp.extension_param.
                                            extension())
                                    else:
                                        value = SwitchFilename(
                                            default=value,
                                            template=make_fname,
                                            source_switch=tp.
                                            use_output_filename.switch)

                            self.arguments.append(
                                Switch(tp.switch,
                                       value,
                                       switchuse=tp.switch_use.formatstring))
예제 #12
0
 def __str__(self):
     """Convert the filename using the conversion routine"""
     if self.convfunc:
         return quote_argument(self.convfunc(self.filename))
     else:
         return quote_argument(self.filename)