Esempio n. 1
0
    def t_doublequote(self, s, m, parent):
        r'" [^"\\\n]* ( ( ((\\(.|\n)|\n)[\s?]*) | "" ) [^"\\\n]* )* "'
        if parent.current[-1] == _COMMAND_MODE:
            parent.addToken(type=parent.argsep)
            parent.argsep = ","

        nline = _countNewlines(s)

        # Recognize and remove any embedded comments
        s = comment_pat.sub("", s)

        s = irafutils.removeEscapes(irafutils.stripQuotes(s), quoted=1)
        parent.addToken(type="QSTRING", attr=s)
        parent.lineno = parent.lineno + nline
Esempio n. 2
0
def sigStrToKwArgsDict(checkFuncSig):
    """ Take a check function signature (string), and parse it to get a dict
        of the keyword args and their values. """
    p1 = checkFuncSig.find('(')
    p2 = checkFuncSig.rfind(')')
    assert p1 > 0 and p2 > 0 and p2 > p1, "Invalid signature: "+checkFuncSig
    argParts = irafutils.csvSplit(checkFuncSig[p1+1:p2], ',', True)
    argParts = [x.strip() for x in argParts]
    retval = {}
    for argPair in argParts:
        argSpl = argPair.split('=', 1)
        if len(argSpl) > 1:
            if argSpl[0] in retval:
                if isinstance(retval[argSpl[0]], (list,tuple)):
                    retval[argSpl[0]]+=(irafutils.stripQuotes(argSpl[1]),) # 3rd
                else: # 2nd in, so convert to tuple
                    retval[argSpl[0]] = (retval[argSpl[0]],
                                         irafutils.stripQuotes(argSpl[1]),)
            else:
                retval[argSpl[0]] = irafutils.stripQuotes(argSpl[1]) # 1st in
        else:
            retval[argSpl[0]] = None #  eg. found "triggers=, max=6, ..."
    return retval
Esempio n. 3
0
    def t_singlequote(self, s, m, parent):
        r"' [^'\\\n]* ( ( ((\\(.|\n)|\n)[\s?]*) | '' ) [^'\\\n]* )*'"
        # this pattern allows both escaped embedded quotes and
        # embedded double quotes ('embedded''quotes')
        # it also allows escaped newlines
        if parent.current[-1] == _COMMAND_MODE:
            parent.addToken(type=parent.argsep)
            parent.argsep = ","

        nline = _countNewlines(s)
        # Recognize and remove any embedded comments
        s = comment_pat.sub("", s)

        s = irafutils.removeEscapes(irafutils.stripQuotes(s), quoted=1)
        # We use a different type for quoted strings to protect them
        # against conversion to other token types by enterComputeEqnMode
        parent.addToken(type="QSTRING", attr=s)
        parent.lineno = parent.lineno + nline