Example #1
0
    def _update_optionstring(self):
        slist = []
        for arg in self._pargs:
            slist.append(butils.quotearg(arg))
            
        # iterate fopts arguments to preserve that ordering
        done_args = []
        for arg in self._fopts.filterOptions():
            v = self._kwargs.get(arg.argname,None)
            if (v is not None):
                soptarg = self._fopts.getSOptNameFromArg(arg.argname)
                if (arg.argtypename == 'bool'):
                    slist.append('-d'+soptarg+('' if v else '=False'))
                else:
                    slist.append('-s'+soptarg+'='+butils.quotearg(unicode(v)))
                    
            done_args.append(arg.argname)

        # and add any extra args
        for (k,v) in self._kwargs.iteritems():
            if (k in done_args):
                continue
            slist.append('-s' + k + '=' + butils.quotearg(unicode(v)))

        self._optionstring = " ".join(slist)

        logger.debug("option string is now %r", self._optionstring)
Example #2
0
    def on_sourceListEditor_sourceListChanged(self, sourcelist):

        sourcelist = [unicode(x) for x in list(sourcelist)]

        cmdtext = "src: " + ("\n     ".join([butils.quotearg(x) for x in sourcelist])) + "\n"

        self._replace_current_cmd(cmdtext, 'src')
    def _update_optionstring(self):
        if not self._fopts:
            return None

        slist = []
        for arg in self._pargs:
            slist.append(butils.quotearg(arg))
            
        # iterate fopts arguments to preserve that ordering
        done_args = []
        for arg in self._fopts.filterOptions():
            v0 = self._kwargs.get(arg.argname,None)

            v = v0
            if hasattr(v0, 'type_arg_input') and hasattr(v0.type_arg_input, 'option_val_repr'):
                v = v0.type_arg_input.option_val_repr(v0)

            logger.debug("formatting options, %r -> %r (-> %r)", arg.argname, v0, v)
            if v is not None:
                soptarg = self._fopts.getSOptNameFromArg(arg.argname)
                if (arg.argtypename == 'bool' or isinstance(v, bool)):
                    slist.append('-d'+soptarg+('' if v else '=False'))
                else:
                    slist.append('-s'+soptarg+'='+butils.quotearg(str(v)))
                    
            done_args.append(arg.argname)

        # and add any extra args
        for (k,v) in self._kwargs.items():
            if (k in done_args):
                continue
            slist.append('-s' + k + '=' + butils.quotearg(str(v)))

        optstring = " ".join(slist)
        if len(optstring) > 80:
            # long option string, so keep each option on a separate line
            indentstr = " "*(len("filter: ") + len(self._filtername) + 1)
            optstring = ("\n" + indentstr).join(slist)

        self._optionstring = optstring

        logger.debug("option string is now %r", self._optionstring)