Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > dd7a95aabe1c049ac9f84beede8143d3 > files > 1769

synopsis-doc-0.12-4.fc14.i686.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<!-- Source/Synopsis/Formatters/HTML/Fragments/ClassHierarchyGraph.py.html -->
<!-- this view was generated by Source -->
<head>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"/>
<title >Synopsis - Synopsis/Formatters/HTML/Fragments/ClassHierarchyGraph.py</title>
<link href="../../../../../style.css" type="text/css" rel="stylesheet" />
</head>
<body class="Source">
<div class="navigation">
<span class="normal"><a href="../../../../../Scopes/Synopsis.html" >Global Package</a></span>
<span class="normal"><a href="../../../../../InheritanceTree.html" >Inheritance Tree</a></span>
<span class="normal"><a href="../../../../../InheritanceGraph.html" >Inheritance Graph</a></span>
<span class="normal"><a href="../../../../../NameIndex.html" >Name Index</a></span>
</div>
File: <b >Synopsis/Formatters/HTML/Fragments/ClassHierarchyGraph.py</b><pre class="sxr"><a id="line1"></a><span class="lineno"> 1</span><span class="line"><span class="py-comment">#</span></span>
<a id="line2"></a><span class="lineno"> 2</span><span class="line"><span class="py-comment"># Copyright (C) 2000 Stephen Davies</span></span>
<a id="line3"></a><span class="lineno"> 3</span><span class="line"><span class="py-comment"># Copyright (C) 2000 Stefan Seefeld</span></span>
<a id="line4"></a><span class="lineno"> 4</span><span class="line"><span class="py-comment"># All rights reserved.</span></span>
<a id="line5"></a><span class="lineno"> 5</span><span class="line"><span class="py-comment"># Licensed to the public under the terms of the GNU LGPL (&gt;= 2),</span></span>
<a id="line6"></a><span class="lineno"> 6</span><span class="line"><span class="py-comment"># see the file COPYING for details.</span></span>
<a id="line7"></a><span class="lineno"> 7</span><span class="line"><span class="py-comment">#</span></span>
<a id="line8"></a><span class="lineno"> 8</span>
<a id="line9"></a><span class="lineno"> 9</span><span class="line"><span class="py-keyword">from</span> Synopsis <span class="py-keyword">import</span> IR</span>
<a id="line10"></a><span class="lineno">10</span><span class="line"><span class="py-keyword">from</span> Synopsis <span class="py-keyword">import</span> ASG</span>
<a id="line11"></a><span class="lineno">11</span><span class="line"><span class="py-keyword">from</span> Synopsis.Processor <span class="py-keyword">import</span> InvalidCommand</span>
<a id="line12"></a><span class="lineno">12</span><span class="line"><span class="py-keyword">from</span> ClassHierarchySimple <span class="py-keyword">import</span> ClassHierarchySimple</span>
<a id="line13"></a><span class="lineno">13</span><span class="line"><span class="py-keyword">import</span> os</span>
<a id="line14"></a><span class="lineno">14</span>
<a id="line15"></a><span class="lineno">15</span><span class="line"><span class="py-keyword">class</span> <a href="../../../../../Scopes/Synopsis/Formatters/HTML/Fragments/ClassHierarchyGraph/ClassHierarchyGraph.html">ClassHierarchyGraph</a>(ClassHierarchySimple):</span>
<a id="line16"></a><span class="lineno">16</span><span class="line">    <span class="py-string">&quot;&quot;&quot;Prints a graphical hierarchy for classes, using the Dot formatter.</span></span>
<a id="line17"></a><span class="lineno">17</span><span class="line"><span class="py-string">   </span></span>
<a id="line18"></a><span class="lineno">18</span><span class="line"><span class="py-string">    @see Formatters.Dot</span></span>
<a id="line19"></a><span class="lineno">19</span><span class="line"><span class="py-string">    &quot;&quot;&quot;</span></span>
<a id="line20"></a><span class="lineno">20</span><span class="line">    <span class="py-keyword">def</span> <a href="../../../../../Scopes/Synopsis/Formatters/HTML/Fragments/ClassHierarchyGraph/ClassHierarchyGraph.html#format_class">format_class</a>(self, class_):</span>
<a id="line21"></a><span class="lineno">21</span>
<a id="line22"></a><span class="lineno">22</span><span class="line">        <span class="py-keyword">from</span> Synopsis.Formatters <span class="py-keyword">import</span> Dot</span>
<a id="line23"></a><span class="lineno">23</span><span class="line">        super = self.processor.class_tree.superclasses(class_.name)</span>
<a id="line24"></a><span class="lineno">24</span><span class="line">        sub = self.processor.class_tree.subclasses(class_.name)</span>
<a id="line25"></a><span class="lineno">25</span><span class="line">        <span class="py-keyword">if</span> len(super) == 0 <span class="py-keyword">and</span> len(sub) == 0:</span>
<a id="line26"></a><span class="lineno">26</span><span class="line">            <span class="py-comment"># Skip classes with a boring graph</span></span>
<a id="line27"></a><span class="lineno">27</span><span class="line">            <span class="py-keyword">return</span> <span class="py-string">''</span></span>
<a id="line28"></a><span class="lineno">28</span><span class="line">        <span class="py-comment">#label = self.processor.files.scoped_special('inheritance', clas.name)</span></span>
<a id="line29"></a><span class="lineno">29</span><span class="line">        label = self.formatter.filename()[:-5] + <span class="py-string">'-inheritance.html'</span></span>
<a id="line30"></a><span class="lineno">30</span><span class="line">        tmp = os.path.join(self.processor.output, label)</span>
<a id="line31"></a><span class="lineno">31</span><span class="line">        ir = IR.IR(files={}, asg=ASG.ASG([class_], self.processor.ir.asg.types))</span>
<a id="line32"></a><span class="lineno">32</span><span class="line">        dot = Dot.Formatter(bgcolor=self.processor.graph_color)</span>
<a id="line33"></a><span class="lineno">33</span><span class="line">        dot.toc = self.processor.toc</span>
<a id="line34"></a><span class="lineno">34</span><span class="line">        <span class="py-keyword">try</span>:</span>
<a id="line35"></a><span class="lineno">35</span><span class="line">            dot.process(ir,</span>
<a id="line36"></a><span class="lineno">36</span><span class="line">                        output=tmp,</span>
<a id="line37"></a><span class="lineno">37</span><span class="line">                        format=<span class="py-string">'html'</span>,</span>
<a id="line38"></a><span class="lineno">38</span><span class="line">                        base_url=self.formatter.filename(),</span>
<a id="line39"></a><span class="lineno">39</span><span class="line">                        type=<span class="py-string">'single'</span>,</span>
<a id="line40"></a><span class="lineno">40</span><span class="line">                        title=label)</span>
<a id="line41"></a><span class="lineno">41</span><span class="line">            text = <span class="py-string">''</span></span>
<a id="line42"></a><span class="lineno">42</span><span class="line">            input = open(tmp, <span class="py-string">&quot;r+&quot;</span>)</span>
<a id="line43"></a><span class="lineno">43</span><span class="line">            line = input.readline()</span>
<a id="line44"></a><span class="lineno">44</span><span class="line">            <span class="py-keyword">while</span> line:</span>
<a id="line45"></a><span class="lineno">45</span><span class="line">                text = text + line</span>
<a id="line46"></a><span class="lineno">46</span><span class="line">                line = input.readline()</span>
<a id="line47"></a><span class="lineno">47</span><span class="line">            input.close()</span>
<a id="line48"></a><span class="lineno">48</span><span class="line">            os.unlink(tmp)</span>
<a id="line49"></a><span class="lineno">49</span><span class="line">            <span class="py-keyword">return</span> text</span>
<a id="line50"></a><span class="lineno">50</span><span class="line">        <span class="py-keyword">except</span> InvalidCommand, e:</span>
<a id="line51"></a><span class="lineno">51</span><span class="line">            <span class="py-keyword">print</span> <span class="py-string">'Warning : %s'</span>%str(e)</span>
<a id="line52"></a><span class="lineno">52</span><span class="line">            <span class="py-keyword">return</span> <span class="py-string">''</span></span>
<a id="line53"></a><span class="lineno">53</span>
<a id="line54"></a><span class="lineno">54</span><span class="line">    format_class_template = format_class</span>
<a id="line55"></a><span class="lineno">55</span>
</pre>
<div class="logo">Generated on Thu Apr 16 16:27:14 2009 by 
<br/>
<a href="http://synopsis.fresco.org" target="_blank"><img src="../../../../../synopsis.png" alt="logo"/> synopsis</a> (version devel)</div>
</body>
</html>