Ejemplo n.º 1
0
 def xml_terms(self):
     ta = stf.newNode("term")
     b = stf.newNode(self.tag)
     stf.setText(b, self.name+'()')
     stf.appendNode(ta, b)
     tb = stf.newNode("term")
     b = stf.newNode(self.tag)
     stf.setText(b, 'env.'+self.name+'()')
     stf.appendNode(tb, b)
     return [ta, tb]
Ejemplo n.º 2
0
 def xml_terms(self):
     ta = stf.newNode("term")
     b = stf.newNode(self.tag)
     stf.setText(b, self.name + '()')
     stf.appendNode(ta, b)
     tb = stf.newNode("term")
     b = stf.newNode(self.tag)
     stf.setText(b, 'env.' + self.name + '()')
     stf.appendNode(tb, b)
     return [ta, tb]
Ejemplo n.º 3
0
    def write_gen(self, filename):
        if not filename:
            return
        # Try to split off .gen filename
        if filename.count(','):
            fl = filename.split(',')
            filename = fl[0]

        # Start new XML file
        root = stf.newXmlTree("variablelist")

        for v in self.values:

            ve = stf.newNode("varlistentry")
            stf.setAttribute(ve, 'id', '%s%s' % (v.prefix, v.idfunc()))
            for t in v.xml_terms():
                stf.appendNode(ve, t)
            vl = stf.newNode("listitem")
            added = False
            if v.summary is not None:
                for s in v.summary:
                    added = True
                    stf.appendNode(vl, stf.copyNode(s))

            if v.sets:
                added = True
                vp = stf.newNode("para")
                stf.setText(vp, 'Sets: ')
                for x in v.sets[:-1]:
                    stf.appendCvLink(vp, x, ', ')
                stf.appendCvLink(vp, v.sets[-1], '.')
                stf.appendNode(vl, vp)

            if v.uses:
                added = True
                vp = stf.newNode("para")
                stf.setText(vp, 'Uses: ')
                for x in v.uses[:-1]:
                    stf.appendCvLink(vp, x, ', ')
                stf.appendCvLink(vp, v.uses[-1], '.')
                stf.appendNode(vl, vp)

            # Still nothing added to this list item?
            if not added:
                # Append an empty para
                vp = stf.newNode("para")
                stf.appendNode(vl, vp)

            stf.appendNode(ve, vl)
            stf.appendNode(root, ve)

        # Write file
        f = self.fopen(filename)
        stf.writeGenTree(root, f)
        f.close()
Ejemplo n.º 4
0
    def xml_terms(self):
        """emit xml for an scons function

        The signature attribute controls whether to emit the
        global function, the environment method, or both.
        """
        if self.arguments is None:
            a = stf.newNode("arguments")
            stf.setText(a, '()')
            arguments = [a]
        else:
            arguments = self.arguments
        tlist = []
        for arg in arguments:
            signature = 'both'
            if stf.hasAttribute(arg, 'signature'):
                signature = stf.getAttribute(arg, 'signature')
            sig = stf.getText(arg).strip()[1:-1]  # strip (), temporarily
            if signature in ('both', 'global'):
                # build term for global function
                gterm = stf.newNode("term")
                func = stf.newSubNode(gterm, Function.tag)
                stf.setText(func, self.name)
                if sig:
                    # if there are parameters, use that entity
                    stf.setTail(func, "(")
                    s = stf.newSubNode(gterm, "parameter")
                    stf.setText(s, sig)
                    stf.setTail(s, ")")
                else:
                    stf.setTail(func, "()")
                tlist.append(gterm)
            if signature in ('both', 'env'):
                # build term for env. method
                mterm = stf.newNode("term")
                inst = stf.newSubNode(mterm, "replaceable")
                stf.setText(inst, "env")
                stf.setTail(inst, ".")
                # we could use <function> here, but it's a "method"
                meth = stf.newSubNode(mterm, "methodname")
                stf.setText(meth, self.name)
                if sig:
                    # if there are parameters, use that entity
                    stf.setTail(meth, "(")
                    s = stf.newSubNode(mterm, "parameter")
                    stf.setText(s, sig)
                    stf.setTail(s, ")")
                else:
                    stf.setTail(meth, "()")
                tlist.append(mterm)

        if not tlist:
            tlist.append(stf.newNode("term"))
        return tlist
Ejemplo n.º 5
0
 def write_gen(self, filename):
     if not filename:
         return
     # Try to split off .gen filename
     if filename.count(','):
         fl = filename.split(',')
         filename = fl[0]
         
     # Start new XML file
     root = stf.newXmlTree("variablelist")
     
     for v in self.values:
         
         ve = stf.newNode("varlistentry")
         stf.setAttribute(ve, 'id', '%s%s' % (v.prefix, v.idfunc()))
         for t in v.xml_terms():
             stf.appendNode(ve, t)
         vl = stf.newNode("listitem")
         added = False
         if v.summary is not None:
             for s in v.summary:
                 added = True
                 stf.appendNode(vl, stf.copyNode(s))
         
         if len(v.sets):
             added = True
             vp = stf.newNode("para")
             s = ['&cv-link-%s;' % x for x in v.sets]
             stf.setText(vp, 'Sets:  ' + ', '.join(s) + '.')
             stf.appendNode(vl, vp)
         if len(v.uses):
             added = True
             vp = stf.newNode("para")
             u = ['&cv-link-%s;' % x for x in v.uses]
             stf.setText(vp, 'Uses:  ' + ', '.join(u) + '.')
             stf.appendNode(vl, vp)
             
         # Still nothing added to this list item?
         if not added:
             # Append an empty para
             vp = stf.newNode("para")
             stf.appendNode(vl, vp)
             
         stf.appendNode(ve, vl)
         stf.appendNode(root, ve)
         
     # Write file        
     f = self.fopen(filename)
     stf.writeGenTree(root, f)
Ejemplo n.º 6
0
    def xml_terms(self):
        if self.arguments is None:
            a = stf.newNode("arguments")
            stf.setText(a, '()')
            arguments = [a]
        else:
            arguments = self.arguments
        tlist = []
        for arg in arguments:
            signature = 'both'
            if stf.hasAttribute(arg, 'signature'):
                signature = stf.getAttribute(arg, 'signature')
            s = stf.getText(arg).strip()
            if signature in ('both', 'global'):
                t = stf.newNode("term")
                syn = stf.newNode("literal")
                stf.setText(syn, '%s%s' % (self.name, s))
                stf.appendNode(t, syn)
                tlist.append(t)
            if signature in ('both', 'env'):
                t = stf.newNode("term")
                syn = stf.newNode("literal")
                stf.setText(syn, 'env.%s%s' % (self.name, s))
                stf.appendNode(t, syn)
                tlist.append(t)

        if not tlist:
            tlist.append(stf.newNode("term"))
        return tlist
Ejemplo n.º 7
0
    def xml_terms(self):
        if self.arguments is None:
            a = stf.newNode("arguments")
            stf.setText(a, '()')
            arguments = [a]
        else:
            arguments = self.arguments
        tlist = []
        for arg in arguments:
            signature = 'both'
            if stf.hasAttribute(arg, 'signature'):
                signature = stf.getAttribute(arg, 'signature')
            s = stf.getText(arg).strip()
            if signature in ('both', 'global'):
                t = stf.newNode("term")
                syn = stf.newNode("literal")
                stf.setText(syn, '%s%s' % (self.name, s))
                stf.appendNode(t, syn)
                tlist.append(t)
            if signature in ('both', 'env'):
                t = stf.newNode("term")
                syn = stf.newNode("literal")
                stf.setText(syn, 'env.%s%s' % (self.name, s))
                stf.appendNode(t, syn)
                tlist.append(t)

        if not tlist:
            tlist.append(stf.newNode("term"))
        return tlist
Ejemplo n.º 8
0
    def xml_terms(self):
        """emit xml for an scons builder

        builders don't show a full signature, just func()
        """
        # build term for global function
        gterm = stf.newNode("term")
        func = stf.newSubNode(gterm, Builder.tag)
        stf.setText(func, self.name)
        stf.setTail(func, '()')

        # build term for env. method
        mterm = stf.newNode("term")
        inst = stf.newSubNode(mterm, "replaceable")
        stf.setText(inst, "env")
        stf.setTail(inst, ".")
        # we could use <function> here, but it's a "method"
        meth = stf.newSubNode(mterm, "methodname")
        stf.setText(meth, self.name)
        stf.setTail(meth, '()')

        return [gterm, mterm]
Ejemplo n.º 9
0
 def xml_terms(self):
     term = stf.newNode("term")
     var = stf.newSubNode(term, Variable.tag)
     stf.setText(var, self.name)
     return [term]
Ejemplo n.º 10
0
 def xml_terms(self):
     e = stf.newNode("term")
     stf.setText(e, self.name)
     return [e]
Ejemplo n.º 11
0
    def write_gen(self, filename):
        if not filename:
            return
        # Try to split off .gen filename
        if filename.count(','):
            fl = filename.split(',')
            filename = fl[0]

        # Start new XML file
        root = stf.newXmlTree("variablelist")

        for v in self.values:

            ve = stf.newNode("varlistentry")
            stf.setAttribute(ve, 'id', '%s%s' % (v.prefix, v.idfunc()))
            for t in v.xml_terms():
                stf.appendNode(ve, t)
            vl = stf.newNode("listitem")
            added = False
            if v.summary is not None:
                for s in v.summary:
                    added = True
                    stf.appendNode(vl, stf.copyNode(s))

            # Generate the text for sets/uses lists of construction vars.
            # This used to include an entity reference which would be replaced
            # by the link to the cvar, but with lxml, dumping out the tree
            # with tostring() will encode the & introducing the entity,
            # breaking it. Instead generate the actual link. (issue #3580)
            if v.sets:
                added = True
                vp = stf.newNode("para")
                stf.setText(vp, "Sets: ")
                for setv in v.sets:
                    link = stf.newSubNode(vp, "link", linkend="cv-%s" % setv)
                    linktgt = stf.newSubNode(link, "varname")
                    stf.setText(linktgt, "$" + setv)
                    stf.setTail(link, " ")
                stf.appendNode(vl, vp)

            if v.uses:
                added = True
                vp = stf.newNode("para")
                stf.setText(vp, "Uses: ")
                for use in v.uses:
                    link = stf.newSubNode(vp, "link", linkend="cv-%s" % use)
                    linktgt = stf.newSubNode(link, "varname")
                    stf.setText(linktgt, "$" + use)
                    stf.setTail(link, " ")
                stf.appendNode(vl, vp)

            # Still nothing added to this list item?
            if not added:
                # Append an empty para
                vp = stf.newNode("para")
                stf.appendNode(vl, vp)

            stf.appendNode(ve, vl)
            stf.appendNode(root, ve)

        # Write file
        f = self.fopen(filename)
        stf.writeGenTree(root, f)
        f.close()
Ejemplo n.º 12
0
 def xml_terms(self):
     e = stf.newNode("term")
     stf.setText(e, self.name)
     return [e]