2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns="http://www.w3.org/1999/xhtml">
8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10 <title>src.template — salomeTools 5.0.0dev documentation</title>
12 <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
13 <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
14 <link rel="stylesheet" href="/volatile/wambeke/SAT5/SAT5_S840_MATIX24/SAT/doc/src/custom.css" type="text/css" />
16 <script type="text/javascript">
17 var DOCUMENTATION_OPTIONS = {
20 COLLAPSE_INDEX: false,
25 <script type="text/javascript" src="../../_static/jquery.js"></script>
26 <script type="text/javascript" src="../../_static/underscore.js"></script>
27 <script type="text/javascript" src="../../_static/doctools.js"></script>
28 <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
29 <link rel="top" title="salomeTools 5.0.0dev documentation" href="../../index.html" />
30 <link rel="up" title="Module code" href="../index.html" />
32 <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
35 <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
41 <div class="document">
42 <div class="documentwrapper">
43 <div class="bodywrapper">
44 <div class="body" role="main">
46 <h1>Source code for src.template</h1><div class="highlight"><pre>
47 <span class="c">#!/usr/bin/env python</span>
48 <span class="c">#-*- coding:utf-8 -*-</span>
49 <span class="c"># Copyright (C) 2010-2013 CEA/DEN</span>
50 <span class="c">#</span>
51 <span class="c"># This library is free software; you can redistribute it and/or</span>
52 <span class="c"># modify it under the terms of the GNU Lesser General Public</span>
53 <span class="c"># License as published by the Free Software Foundation; either</span>
54 <span class="c"># version 2.1 of the License.</span>
55 <span class="c">#</span>
56 <span class="c"># This library is distributed in the hope that it will be useful,</span>
57 <span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
58 <span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
59 <span class="c"># Lesser General Public License for more details.</span>
60 <span class="c">#</span>
61 <span class="c"># You should have received a copy of the GNU Lesser General Public</span>
62 <span class="c"># License along with this library; if not, write to the Free Software</span>
63 <span class="c"># Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
65 <span class="kn">import</span> <span class="nn">string</span>
67 <div class="viewcode-block" id="MyTemplate"><a class="viewcode-back" href="../../commands/apidoc/src.html#src.template.MyTemplate">[docs]</a><span class="k">class</span> <span class="nc">MyTemplate</span><span class="p">(</span><span class="n">string</span><span class="o">.</span><span class="n">Template</span><span class="p">):</span>
68 <span class="n">delimiter</span> <span class="o">=</span> <span class="s">'ยค'</span>
70 <div class="viewcode-block" id="substitute"><a class="viewcode-back" href="../../commands/apidoc/src.html#src.template.substitute">[docs]</a><span class="k">def</span> <span class="nf">substitute</span><span class="p">(</span><span class="n">template_file</span><span class="p">,</span> <span class="n">subst_dic</span><span class="p">):</span>
71 <span class="n">template</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">template_file</span><span class="p">,</span> <span class="s">'r'</span><span class="p">)</span>
72 <span class="n">template</span> <span class="o">=</span> <span class="n">MyTemplate</span><span class="p">(</span><span class="n">template</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
74 <span class="k">return</span> <span class="n">template</span><span class="o">.</span><span class="n">safe_substitute</span><span class="p">(</span><span class="n">subst_dic</span><span class="p">)</span>
80 <div class="sphinxsidebar">
81 <div class="sphinxsidebarwrapper">
82 <p class="logo"><a href="../../index.html">
83 <img class="logo" src="../../_static/sat_v5.0.png" alt="Logo"/>
84 </a></p><div class="relations">
85 <h3>Related Topics</h3>
87 <li><a href="../../index.html">Documentation overview</a><ul>
88 <li><a href="../index.html">Module code</a><ul>
93 <div id="searchbox" style="display: none">
95 <form class="search" action="../../search.html" method="get">
96 <input type="text" name="q" />
97 <input type="submit" value="Go" />
98 <input type="hidden" name="check_keywords" value="yes" />
99 <input type="hidden" name="area" value="default" />
101 <p class="searchtip" style="font-size: 90%">
102 Enter search terms or a module, class or function name.
105 <script type="text/javascript">$('#searchbox').show(0);</script>
108 <div class="clearer"></div>
114 Powered by <a href="http://sphinx-doc.org/">Sphinx 1.1.3</a>
115 & <a href="https://github.com/bitprophet/alabaster">Alabaster </a>