示例#1
0
def _tdFilePathCallback(theS, attrs, k, v):
    """Callback function for the file reference table.

    :param theS: HTML stream.
    :type theS: :py:class:`cpip.util.XmlWrite.XhtmlStream`

    :param attrs: Element attributes.
    :type attrs: ``dict({str : [str]})``

    :param k: Keys.
    :type k: ``list([str])``

    :param v: Values.
    :type v: ``list([tuple([str, str])])``

    :returns: ``NoneType``
    """
    attrs['class'] = 'filetable'
    with XmlWrite.Element(theS, 'td', attrs):
        theS.characters('%s:' % k[-1])
        # Get the href/navtext from the value
        for h, n in v:
            theS.characters(' ')
            with XmlWrite.Element(theS, 'a', {'href': h}):
                # Write the nav text
                theS.characters('%s' % n)
示例#2
0
def _writeMacroDependencies(theS, theEnv, theMacro, theMacroAdjList, theItu):
    """Writes out the macro dependencies.

    :param theS: HTML stream.
    :type theS: :py:class:`cpip.util.XmlWrite.XhtmlStream`

    :param theEnv: The macro environment.
    :type theEnv: :py:class:`cpip.core.MacroEnv.MacroEnv`

    :param theMacro: The macro definition.
    :type theMacro: :py:class:`cpip.core.PpDefine.PpDefine`

    :param theMacroAdjList: Dependency adjacency list.
    :type theMacroAdjList: ``cpip.util.Tree.DuplexAdjacencyList``

    :param theItu: The Initial Translation Unit (ITU).
    :type theItu: ``str``

    :returns: ``NoneType``
    """
    pcTree, cpTree = _getMacroDependencyTrees(theMacroAdjList, theMacro)
    if pcTree is not None:
        with XmlWrite.Element(theS, 'p', {}):
            theS.characters('I depend on these macros:')
        _writeMacroDependenciesTable(theS, theEnv, pcTree, theItu)
    if cpTree is not None:
        with XmlWrite.Element(theS, 'p', {}):
            theS.characters('These macros depend on me:')
        _writeMacroDependenciesTable(theS, theEnv, cpTree, theItu)
示例#3
0
    def test_08(self):
        """TestXmlWrite.test_08(): raise during write."""
        myF = io.StringIO()
        try:
            with XmlWrite.XmlStream(myF) as xS:
                with XmlWrite.Element(xS, 'Root', {'version': '12.0'}):
                    self.assertRaises(XmlWrite.ExceptionXmlEndElement,
                                      xS.endElement, 'NotRoot')
                    with XmlWrite.Element(xS, 'E', {'attr_1': '1'}):
                        xS._elemStk.pop()
                        xS._elemStk.append('F')
                        raise Exception('Some exception')
        except Exception as e:
            print(e)
        else:
            print('No exception raised')


#        print()
#        print(myF.getvalue())
        self.assertEqual(
            myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<Root version="12.0">
  <E attr_1="1" />
</Root>
""")
示例#4
0
def _writeMacroDefinitionAndAnchor(theS, theDef, theIntOccurence):
    """Writes a definition of the macro with an anchor that can be linked to.
    This also writes an anchor based on the first character of the macro name so
    that alphabetic links can reference it.
    """
    macroAnchorName = _retMacroId(theDef, theIntOccurence)
    if len(theDef.strReplacements()):
        rStr = splitLine(' '.join(
            [theDef.strIdentPlusParam(),
             theDef.strReplacements()]),
                         splitLen=80,
                         splitLenHard=132)
        myReplStr = rStr[len(theDef.strIdentPlusParam()):]
    else:
        myReplStr = ''
    # Write the enclosing <span> element depending on the macro properties
    spanClass = 'macro'
    if theDef.isCurrentlyDefined:
        spanClass += '_s_t'
    else:
        spanClass += '_s_f'
    if theDef.refCount > 0:
        spanClass += '_r_t'
    else:
        spanClass += '_r_f'
    # Now definition and replacement list
    with XmlWrite.Element(theS, 'span', {'class': spanClass + '_name'}):
        theS.characters('#define ')
        theS.characters(theDef.strIdentPlusParam())
    if myReplStr:
        with XmlWrite.Element(theS, 'span', {'class': spanClass + '_repl'}):
            theS.charactersWithBr(myReplStr)
    return macroAnchorName
示例#5
0
文件: ItuToHtml.py 项目: cybort/cpip
    def _writeTextWithNewlines(self, theS, theText, spanClass):
        """Splits text by newlines and writes it out.

        :param theS: The HTML stream.
        :type theS: :py:class:`cpip.util.XmlWrite.XhtmlStream`

        :param theText: The text to write.
        :type theText: ``str``

        :param spanClass: CSS class.
        :type spanClass: ``NoneType, str``

        :returns: ``NoneType``
        """
        # Whitespace, line breaks
        myL = theText.split('\n')
        if len(myL) > 1:
            # Do all up to the last
            for s in myL[:-1]:
                if spanClass is not None:
                    with XmlWrite.Element(theS, 'span', {'class': spanClass}):
                        theS.characters(s.replace('\t', '    '))
                else:
                    theS.characters(s.replace('\t', '    '))
                theS.characters('\n')
                self._incAndWriteLine(theS)
        # Now the last
        if spanClass is not None:
            with XmlWrite.Element(theS, 'span', {'class': spanClass}):
                theS.characters(myL[-1].replace('\t', '    '))
        else:
            theS.characters(myL[-1].replace('\t', '    '))
示例#6
0
def _writeMacrosTestedButNotDefined(theS, theMacroId, theEnv):
    """Writes out the macro history for macros tested but not defined.

    :param theS: The HTML stream.
    :type theS: :py:class:`cpip.util.XmlWrite.XhtmlStream`

    :param theMacroId: Macro name.
    :type theMacroId: ``str``

    :param theEnv: Macro environment.
    :type theEnv: :py:class:`cpip.core.MacroEnv.MacroEnv`

    :returns: ``NoneType``
    """
    anchorName = XmlWrite.nameFromString(
        _macroIdTestedWhenNotDefined(theMacroId))
    # This is a list of [class FileLineColumn, ...]
    myRefS = theEnv.macroNotDefinedDependencyReferences(theMacroId)
    # Write out the macro title
    with XmlWrite.Element(theS, 'h3'):
        with XmlWrite.Element(theS, 'a', {'name': anchorName}):
            theS.characters('%s [References: %d]' \
                % (
                   theMacroId,
                   len(myRefS),
                )
            )
    _writeMacroReferencesTable(theS, myRefS)
示例#7
0
 def test_06(self):
     """TestXmlWrite.test_06(): encoded text in 'latin-1'."""
     myF = io.StringIO()
     with XmlWrite.XmlStream(myF, 'latin-1') as xS:
         with XmlWrite.Element(xS, 'Root'):
             with XmlWrite.Element(xS, 'A'):
                 xS.characters("""<&>"'""")
示例#8
0
def _writeTrMacro(theS, theHtmlPath, theMacro, theIntOccurence, theStartLetter,
                  retMap):
    """Write the macro as a row in the general table.
    theMacro is a PpDefine object.
    theStartLetter is the current letter we are writing ['A', 'B', ...] which
    writes an anchor at the beginning of each letter section."""
    with XmlWrite.Element(theS, 'tr'):
        if theMacro.identifier[0] != theStartLetter:
            theStartLetter = theMacro.identifier[0]
            _writeTdMacro(theS, theMacro, theStartLetter, theIntOccurence)
        else:
            _writeTdMacro(theS, theMacro, '', theIntOccurence)
        if theMacro.identifier not in retMap:
            # Add to the return value
            retMap[theMacro.identifier] = '%s#%s' \
                % (
                    os.path.basename(theHtmlPath),
                    _retMacroId(theMacro, theIntOccurence),
                )
        with XmlWrite.Element(theS, 'td'):
            HtmlUtils.writeHtmlFileLink(
                theS, theMacro.fileId, theMacro.line,
                '%s#%d' % (theMacro.fileId, theMacro.line), 'file_decl')
        _writeTdRefCount(theS, theMacro)
        _writeTdMonospace(theS, str(theMacro.isCurrentlyDefined))
    return theStartLetter
示例#9
0
 def test_nameFromString(self):
     self.assertEqual(XmlWrite.nameFromString('foo'), 'ZZm9v')
     self.assertEqual(
         XmlWrite.nameFromString(
             'http://www.w3.org/TR/1999/REC-html401-19991224/types.html#type-cdata'
         ),
         'ZaHR0cDovL3d3dy53My5vcmcvVFIvMTk5OS9SRUMtaHRtbDQwMS0xOTk5MTIyNC90eXBlcy5odG1sI3R5cGUtY2RhdGE_'
     )
示例#10
0
def _writeMacroDependencies(theS, theEnv, theMacro, theMacroAdjList, theItu):
    pcTree, cpTree = _getMacroDependencyTrees(theMacroAdjList, theMacro)
    if pcTree is not None:
        with XmlWrite.Element(theS, 'p', {}):
            theS.characters('I depend on these macros:')
        _writeMacroDependenciesTable(theS, theEnv, pcTree, theItu)
    if cpTree is not None:
        with XmlWrite.Element(theS, 'p', {}):
            theS.characters('These macros depend on me:')
        _writeMacroDependenciesTable(theS, theEnv, cpTree, theItu)
示例#11
0
def _tdFilePathCallback(theS, attrs, k, v):
    """Callback function for the file reference table."""
    attrs['class'] = 'filetable'
    with XmlWrite.Element(theS, 'td', attrs):
        theS.characters('%s:' % k[-1])
        # Get the href/navtext from the value
        for h, n in v:
            theS.characters(' ')
            with XmlWrite.Element(theS, 'a', {'href': h}):
                # Write the nav text
                theS.characters('%s' % n)
示例#12
0
def _writeTdRefCount(theS, theMacro):
    with XmlWrite.Element(theS, 'td'):
        with XmlWrite.Element(theS, 'span', {'class': 'monospace'}):
            if theMacro.refCount > 0:
                # Write a link to the history
                with XmlWrite.Element(theS, 'a', {
                        'href':
                        '#%s' % XmlWrite.nameFromString(_macroId(theMacro))
                }):
                    theS.characters(str(theMacro.refCount))
            else:
                theS.characters(str(theMacro.refCount))
示例#13
0
    def test_09(self):
        """TestXmlWrite.test_09(): literal."""
        myF = io.StringIO()
        with XmlWrite.XmlStream(myF) as xS:
            with XmlWrite.Element(xS, 'Root', {'version': '12.0'}):
                xS.literal(u'literal&nbsp;text')
        # print()
        # print(myF.getvalue())
        self.assertEqual(
            myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<Root version="12.0">literal&nbsp;text</Root>
""")
示例#14
0
    def test_07(self):
        """TestXmlWrite.test_07(): comments."""
        myF = io.StringIO()
        with XmlWrite.XmlStream(myF) as xS:
            with XmlWrite.Element(xS, 'Root', {'version': '12.0'}):
                xS.comment(u' a comment ')
        #print
        #print myF.getvalue()
        self.assertEqual(
            myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<Root version="12.0"><!-- a comment -->
</Root>
""")
示例#15
0
def writeIncludeGraphAsText(theOutDir, theItu, theLexer):
    def _linkToIndex(theS, theItu):
        with XmlWrite.Element(theS, 'p'):
            theS.characters('Return to ')
            with XmlWrite.Element(theS, 'a',
                                  {'href': tuIndexFileName(theItu)}):
                theS.characters('Index')

    outPath = os.path.join(theOutDir, includeGraphFileNameText(theItu))
    with XmlWrite.XhtmlStream(outPath, mustIndent=INDENT_ML) as myS:
        with XmlWrite.Element(myS, 'head'):
            with XmlWrite.Element(
                    myS, 'link', {
                        'href': TokenCss.TT_CSS_FILE,
                        'type': "text/css",
                        'rel': "stylesheet",
                    }):
                pass
            with XmlWrite.Element(myS, 'title'):
                myS.characters('Included graph for %s' % theItu)
        with XmlWrite.Element(myS, 'body'):
            with XmlWrite.Element(myS, 'h1'):
                myS.characters('File include graph for: %s' % theItu)
            with XmlWrite.Element(myS, 'p'):
                myS.characters('A text dump of the include graph.')
            _linkToIndex(myS, theItu)
            with XmlWrite.Element(myS, 'pre'):
                myS.characters(str(theLexer.fileIncludeGraphRoot))
            _linkToIndex(myS, theItu)
示例#16
0
def linkToIndex(theS, theIdxPath):
    """Write a link to the index.

    :param theS: HTML stream.
    :type theS: :py:class:`cpip.util.XmlWrite.XhtmlStream`

    :param theIdxPath: Path to the index.
    :type theIdxPath: ``str``

    :returns: ``NoneType``
    """
    with XmlWrite.Element(theS, 'p'):
        theS.characters('Return to ')
        with XmlWrite.Element(theS, 'a', {'href': theIdxPath}):
            theS.characters('Index')
示例#17
0
    def test_03(self):
        """TestXmlWrite.test_03(): processing instruction."""
        myF = io.StringIO()
        with XmlWrite.XmlStream(myF) as xS:
            with XmlWrite.Element(xS, 'Root', {'version': '12.0'}):
                with XmlWrite.Element(xS, 'A', {'attr_1': '1'}):
                    xS.pI('Do <&> this')
        #print
        #print myF.getvalue()
        self.assertEqual(
            myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<Root version="12.0">
  <A attr_1="1"><?Do &lt;&amp;&gt; this?></A>
</Root>
""")
示例#18
0
    def test_02(self):
        """TestXmlWrite.test_02(): mixed content."""
        myF = io.StringIO()
        with XmlWrite.XmlStream(myF) as xS:
            with XmlWrite.Element(xS, 'Root', {'version': '12.0'}):
                with XmlWrite.Element(xS, 'A', {'attr_1': '1'}):
                    xS.characters(u'<&>')
        #print
        #print myF.getvalue()
        self.assertEqual(
            myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<Root version="12.0">
  <A attr_1="1">&lt;&amp;&gt;</A>
</Root>
""")
示例#19
0
    def test_01(self):
        """TestXmlWrite.test_01(): simple elements."""
        myF = io.StringIO()
        with XmlWrite.XmlStream(myF) as xS:
            with XmlWrite.Element(xS, 'Root', {'version': '12.0'}):
                with XmlWrite.Element(xS, 'A', {'attr_1': '1'}):
                    pass
        #print
        #print myF.getvalue()
        self.assertEqual(
            myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<Root version="12.0">
  <A attr_1="1" />
</Root>
""")
示例#20
0
def _tdCallback(theS, attrs, k, v):
    """Callback function for the file count table."""
    attrs['class'] = 'filetable'
    href, navText, count = v
    with XmlWrite.Element(theS, 'td', attrs):
        with XmlWrite.Element(theS, 'a', {'href': href}):
            # Write the nav text
            theS.characters(navText)
    with XmlWrite.Element(theS, 'td', {
            'width': "36px",
            'class': 'filetable',
            'align': "right",
    }):
        # Write the nav text
        theS.characters('%d' % count)
示例#21
0
def linkToIndex(theS, theIdxPath):
    """Write a back link to the index page.

    :param theS: The HTML stream.
    :type theS: :py:class:`cpip.util.XmlWrite.XhtmlStream`

    :param theIdxPath: <insert documentation for argument>
    :type theIdxPath: ``str``

    :returns: ``NoneType``
    """
    with XmlWrite.Element(theS, 'p'):
        theS.characters('Return to ')
        with XmlWrite.Element(theS, 'a', {'href': theIdxPath}):
            theS.characters('Index')
示例#22
0
 def visitPre(self, theCcgNode, theDepth):
     """Pre-traversal call with a CppCondGraphNode and the integer depth in
     the tree."""
     self._hs.characters(self.PAD_STR * theDepth)
     if theCcgNode.state:
         myCssClass = 'CcgNodeTrue'
     else:
         myCssClass = 'CcgNodeFalse'
     with XmlWrite.Element(self._hs, 'span', {'class' : myCssClass}):
         self._hs.characters('#%s' % theCcgNode.cppDirective)
         if theCcgNode.constExpr is not None:
             self._hs.characters(' %s' % theCcgNode.constExpr)
     self._hs.characters(' ')
     self._hs.characters(' /* ')
     HtmlUtils.writeHtmlFileLink(
             self._hs,
             theCcgNode.fileId,
             theCcgNode.lineNum,
             os.path.basename(theCcgNode.fileId),
             theClass=None,
         )
     self._hs.characters(' */')
     #with XmlWrite.Element(self._hs, 'span', {'class' : 'file'}):
     #    self._hs.characters(' [%s]' % theCcgNode.fileId)
     self._hs.characters('\n')
示例#23
0
def _writeParagraphWithBreaks(theS, theParas):
    for i, p in enumerate(theParas):
        #         if i > 0:
        #             with XmlWrite.Element(theS, 'br'):
        #                 pass
        with XmlWrite.Element(theS, 'p'):
            theS.characters(p)
示例#24
0
    def test_01(self):
        """Test_writeFileListTrippleAsTable.test_01(): writeFileListTrippleAsTable() - Single file list"""
        myFileNameS = [
            '0eggs.lis',
            '1chips.lis',
            '2beans.lis',
        ]
        myFileLinkS = [(f, HtmlUtils.retHtmlFileName(f), 'Link text {:d}'.format(i)) for i, f in enumerate(myFileNameS)]
        myF = io.StringIO()
        with XmlWrite.XhtmlStream(myF) as myS:
            HtmlUtils.writeFileListTrippleAsTable(myS, myFileLinkS, {}, False)
#         print()
#         print(myF.getvalue())
#         self.maxDiff = None
#        print(myFileLinkS)
        self.assertEqual(myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <table>
    <tr>
      <td> <a href="0eggs.lis_4656d29aa36ca0c168a10dd3ffe2c9fa.html">Link text 0</a></td>
    </tr>
    <tr>
      <td> <a href="1chips.lis_6cb5a1758e21dad3dba0cc4a53d91c31.html">Link text 1</a></td>
    </tr>
    <tr>
      <td> <a href="2beans.lis_961d8a2ab0ecf325e12f11c8bdbbf817.html">Link text 2</a></td>
    </tr>
  </table>
</html>
""")
示例#25
0
    def test_02(self):
        """Test_writeFileListTrippleAsTable.test_02(): writeFileListTrippleAsTable() - Single directory list"""
        myFileNameS = [
            'spam/beans.lis',
            'spam/chips.lis',
            'spam/eggs.lis',
        ]
        myFileLinkS = [(f, HtmlUtils.retHtmlFileName(f), 'Link text {:d}'.format(i)) for i, f in enumerate(myFileNameS)]
        myF = io.StringIO()
        with XmlWrite.XhtmlStream(myF) as myS:
            HtmlUtils.writeFileListTrippleAsTable(myS, myFileLinkS, {}, False)
#         print()
#         print(myF.getvalue())
#         self.maxDiff = None
        self.assertEqual(myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <table>
    <tr>
      <td rowspan="3">spam/</td>
      <td> <a href="beans.lis_2cd7aad2a1a03013720d9cc5d83b860c.html">Link text 0</a></td>
    </tr>
    <tr>
      <td> <a href="chips.lis_78c24a9e68057387b3f7c7de7f57385d.html">Link text 1</a></td>
    </tr>
    <tr>
      <td> <a href="eggs.lis_afc193e8de9a2e06454b4bf92d5fefd8.html">Link text 2</a></td>
    </tr>
  </table>
</html>
""")
示例#26
0
def _writeMacrosTestedButNotDefined(theS, theMacroId, theEnv):
    """Writes out the macro history for macros tested but not defined."""
    anchorName = XmlWrite.nameFromString(
        _macroIdTestedWhenNotDefined(theMacroId))
    # This is a list of [class FileLineColumn, ...]
    myRefS = theEnv.macroNotDefinedDependencyReferences(theMacroId)
    # Write out the macro title
    with XmlWrite.Element(theS, 'h3'):
        with XmlWrite.Element(theS, 'a', {'name': anchorName}):
            theS.characters('%s [References: %d]' \
                % (
                   theMacroId,
                   len(myRefS),
                )
            )
    _writeMacroReferencesTable(theS, myRefS)
示例#27
0
    def test_07(self):
        """TestSVGlWriter.test_07(): text.
        Based on http://www.w3.org/TR/2003/REC-SVG11-20030114/text.html#TextElement"""
        myF = io.StringIO()
        myViewPort = Coord.Box(
            Coord.Dim(12, 'cm'),
            Coord.Dim(4, 'cm'),
        )
        with SVGWriter.SVGWriter(myF, myViewPort,
                                 {'viewBox': "0 0 1000 300"}) as xS:
            with XmlWrite.Element(xS, 'desc'):
                xS.characters("Example text01 - 'Hello, out there' in blue")
            myPt = Coord.Pt(Coord.baseUnitsDim(250), Coord.baseUnitsDim(150))
            with SVGWriter.SVGText(xS, myPt, "Verdans", 55, {'fill': "blue"}):
                xS.characters('Hello, out there')
            #xS.comment(" Show outline of canvas using 'rect' element ")
            myPt = Coord.Pt(Coord.baseUnitsDim(1), Coord.baseUnitsDim(1))
            myBx = Coord.Box(Coord.baseUnitsDim(998), Coord.baseUnitsDim(298))
            with SVGWriter.SVGRect(xS, myPt, myBx, {
                    'fill': "none",
                    'stroke': "blue",
                    'stroke-width': "2"
            }):
                pass
        #print
        #print myF.getvalue()
        self.assertEqual(
            myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="4.00cm" version="1.1" viewBox="0 0 1000 300" width="12.00cm" xmlns="http://www.w3.org/2000/svg">
  <desc>Example text01 - &apos;Hello, out there&apos; in blue</desc>
  <text fill="blue" font-family="Verdans" font-size="55" x="250px" y="150px">Hello, out there</text>
  <rect fill="none" height="298px" stroke="blue" stroke-width="2" width="998px" x="1px" y="1px" />
</svg>
""")
示例#28
0
    def test_01(self):
        """Test_writeFileListTrippleAsTable.test_01(): writeFileListTrippleAsTable() - Single file list"""
        myFileNameS = [
            '0eggs.lis',
            '1chips.lis',
            '2beans.lis',
        ]
        myFileLinkS = [(f, HtmlUtils.retHtmlFileName(f),
                        'Link text {:d}'.format(i))
                       for i, f in enumerate(myFileNameS)]
        myF = io.StringIO()
        with XmlWrite.XhtmlStream(myF) as myS:
            HtmlUtils.writeFileListTrippleAsTable(myS, myFileLinkS, {}, False)
#         print()
#         print(myF.getvalue())
#         self.maxDiff = None
#         print(myFileLinkS)
        self.assertEqual(
            myF.getvalue(), """<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <table>
    <tr>
      <td> <a href="0eggs.lis_55d1c28c70fa11242791f484339eb1be.html">Link text 0</a></td>
    </tr>
    <tr>
      <td> <a href="1chips.lis_9d8f17f73fd3f595dcdc0d6cb43efee2.html">Link text 1</a></td>
    </tr>
    <tr>
      <td> <a href="2beans.lis_c191c76d1f99127750d4f05f0d47e101.html">Link text 2</a></td>
    </tr>
  </table>
</html>
""")
示例#29
0
文件: IncGraphXML.py 项目: csarn/cpip
 def _writeTokenCounter(self, theS, theCntr, isAll):
     for aType in PpToken.LEX_PPTOKEN_TYPES:
         myAttrs = {
             'type': aType,
             'count': '%d' % theCntr.tokenCount(aType, isAll),
         }
         with XmlWrite.Element(theS, 'Tokens', myAttrs):
             pass
示例#30
0
def _writeTocLetterLinks(theS, theSet):
    if len(theSet) > 0:
        letterList = list(theSet)
        letterList.sort()
        for aL in letterList:
            theS.literal(' &nbsp; ')
            with XmlWrite.Element(
                    theS,
                    'a',
                    {
                        'href' : '#%s.%s' \
                            % (ANCHOR_MACRO_ALPHA, aL),
                    }
                ):
                with XmlWrite.Element(theS, 'tt'):
                    theS.characters('%s' % aL)
                theS.characters('...')