| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <!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">
- <head>
- <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>pypdevsbbl.extra.fileutils — Python(P)DEVS-BBL documentation</title>
- <link rel="stylesheet" href="../../../_static/nature.css" type="text/css" />
- <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
- <link rel="stylesheet" type="text/css" href="../../../_static/custom.css" />
- <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
- <script type="text/javascript" src="../../../_static/jquery.js"></script>
- <script type="text/javascript" src="../../../_static/underscore.js"></script>
- <script type="text/javascript" src="../../../_static/doctools.js"></script>
- <script type="text/javascript" src="../../../_static/language_data.js"></script>
- <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
- <link rel="index" title="Index" href="../../../genindex.html" />
- <link rel="search" title="Search" href="../../../search.html" />
- </head><body>
- <div class="related" role="navigation" aria-label="related navigation">
- <h3>Navigation</h3>
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="../../../genindex.html" title="General Index"
- accesskey="I">index</a></li>
- <li class="right" >
- <a href="../../../py-modindex.html" title="Python Module Index"
- >modules</a> |</li>
- <li class="nav-item nav-item-0"><a href="../../../index.html">Python(P)DEVS-BBL documentation</a> »</li>
- <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
- <li class="nav-item nav-item-2"><a href="../extra.html" accesskey="U">pypdevsbbl.extra</a> »</li>
- </ul>
- </div>
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body" role="main">
-
- <h1>Source code for pypdevsbbl.extra.fileutils</h1><div class="highlight"><pre>
- <span></span><span class="c1"># Copyright 2020 Modelling, Simulation and Design Lab (MSDL) at</span>
- <span class="c1"># McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)</span>
- <span class="c1">#</span>
- <span class="c1"># Licensed under the Apache License, Version 2.0 (the "License");</span>
- <span class="c1"># you may not use this file except in compliance with the License.</span>
- <span class="c1"># You may obtain a copy of the License at</span>
- <span class="c1">#</span>
- <span class="c1"># http://www.apache.org/licenses/LICENSE-2.0</span>
- <span class="c1">#</span>
- <span class="c1"># Unless required by applicable law or agreed to in writing, software</span>
- <span class="c1"># distributed under the License is distributed on an "AS IS" BASIS,</span>
- <span class="c1"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
- <span class="c1"># See the License for the specific language governing permissions and</span>
- <span class="c1"># limitations under the License.</span>
- <span class="sd">"""This file is a simple helperfile to allow a valid binding of files and folders.</span>
- <span class="sd">It has a set of functions that will always point towards the correct directory.</span>
- <span class="sd">This was created because the linking for the dependencies folder was not as</span>
- <span class="sd">straightforward as required.</span>
- <span class="sd">"""</span>
- <span class="kn">import</span> <span class="nn">os</span>
- <div class="viewcode-block" id="pypdevsbbl"><a class="viewcode-back" href="../../../pypdevsbbl.extra.fileutils.html#pypdevsbbl.extra.fileutils.pypdevsbbl">[docs]</a><span class="k">def</span> <span class="nf">pypdevsbbl</span><span class="p">(</span><span class="o">*</span><span class="n">paths</span><span class="p">):</span>
- <span class="sd">"""Gets the absolute path of the ``pypdevsbbl`` directory.</span>
- <span class="sd"> Args:</span>
- <span class="sd"> *paths: Unpacked list of paths to join.</span>
- <span class="sd"> Returns:</span>
- <span class="sd"> The absolute path of the code directory followed by the paths.</span>
- <span class="sd"> """</span>
- <span class="n">dname</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="vm">__file__</span><span class="p">))</span>
- <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dname</span><span class="p">,</span> <span class="s2">".."</span><span class="p">),</span> <span class="o">*</span><span class="n">paths</span><span class="p">))</span></div>
- <div class="viewcode-block" id="src"><a class="viewcode-back" href="../../../pypdevsbbl.extra.fileutils.html#pypdevsbbl.extra.fileutils.src">[docs]</a><span class="k">def</span> <span class="nf">src</span><span class="p">(</span><span class="o">*</span><span class="n">paths</span><span class="p">):</span>
- <span class="sd">"""Gets the absolute path of the code source directory.</span>
- <span class="sd"> Args:</span>
- <span class="sd"> *paths: Unpacked list of paths to join.</span>
- <span class="sd"> Returns:</span>
- <span class="sd"> The absolute path of the code directory followed by the paths.</span>
- <span class="sd"> """</span>
- <span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">pypdevsbbl</span><span class="p">(),</span> <span class="s2">".."</span><span class="p">),</span> <span class="o">*</span><span class="n">paths</span><span class="p">))</span></div>
- <div class="viewcode-block" id="dependencies"><a class="viewcode-back" href="../../../pypdevsbbl.extra.fileutils.html#pypdevsbbl.extra.fileutils.dependencies">[docs]</a><span class="k">def</span> <span class="nf">dependencies</span><span class="p">(</span><span class="o">*</span><span class="n">paths</span><span class="p">):</span>
- <span class="sd">"""Gets the absolute path of the ``dependencies`` directory.</span>
- <span class="sd"> Args:</span>
- <span class="sd"> *paths: Unpacked list of paths to join.</span>
- <span class="sd"> Returns:</span>
- <span class="sd"> The absolute path of the dependencies directory followed by the paths.</span>
- <span class="sd"> """</span>
- <span class="k">return</span> <span class="n">src</span><span class="p">(</span><span class="s2">"dependencies"</span><span class="p">,</span> <span class="o">*</span><span class="n">paths</span><span class="p">)</span></div>
- <div class="viewcode-block" id="test"><a class="viewcode-back" href="../../../pypdevsbbl.extra.fileutils.html#pypdevsbbl.extra.fileutils.test">[docs]</a><span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="o">*</span><span class="n">paths</span><span class="p">):</span>
- <span class="sd">"""Gets the absolute path of the ``test`` directory.</span>
- <span class="sd"> Args:</span>
- <span class="sd"> *paths: Unpacked list of paths to join.</span>
- <span class="sd"> Returns:</span>
- <span class="sd"> The absolute path of the test directory followed by the paths.</span>
- <span class="sd"> """</span>
- <span class="k">return</span> <span class="n">src</span><span class="p">(</span><span class="s2">"test"</span><span class="p">,</span> <span class="o">*</span><span class="n">paths</span><span class="p">)</span></div>
- </pre></div>
- </div>
- </div>
- </div>
- <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
- <div class="sphinxsidebarwrapper">
- <div id="searchbox" style="display: none" role="search">
- <h3>Quick search</h3>
- <div class="searchformwrapper">
- <form class="search" action="../../../search.html" method="get">
- <input type="text" name="q" />
- <input type="submit" value="Go" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
- </div>
- <script type="text/javascript">$('#searchbox').show(0);</script>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- <div class="related" role="navigation" aria-label="related navigation">
- <h3>Navigation</h3>
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="../../../genindex.html" title="General Index"
- >index</a></li>
- <li class="right" >
- <a href="../../../py-modindex.html" title="Python Module Index"
- >modules</a> |</li>
- <li class="nav-item nav-item-0"><a href="../../../index.html">Python(P)DEVS-BBL documentation</a> »</li>
- <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
- <li class="nav-item nav-item-2"><a href="../extra.html" >pypdevsbbl.extra</a> »</li>
- </ul>
- </div>
- <div class="footer" role="contentinfo">
- © Copyright 2020, Randy Paredis.
- Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
- </div>
- </body>
- </html>
|