mirror of
https://github.com/arsenetar/dupeguru.git
synced 2024-11-05 07:49:02 +00:00
118 lines
7.7 KiB
HTML
118 lines
7.7 KiB
HTML
|
|
|||
|
<!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">
|
|||
|
<head>
|
|||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|||
|
<title>hscommon.path — dupeGuru 4.0.3 documentation</title>
|
|||
|
<link rel="stylesheet" href="../../_static/haiku.css" type="text/css" />
|
|||
|
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
|||
|
<script type="text/javascript" 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/translations.js"></script>
|
|||
|
<link rel="index" title="Index" href="../../genindex.html" />
|
|||
|
<link rel="search" title="Search" href="../../search.html" />
|
|||
|
<link rel="next" title="hscommon.util" href="util.html" />
|
|||
|
<link rel="prev" title="hscommon.notify" href="notify.html" />
|
|||
|
</head><body>
|
|||
|
<div class="header" role="banner"><h1 class="heading"><a href="../../index.html">
|
|||
|
<span>dupeGuru 4.0.3 documentation</span></a></h1>
|
|||
|
<h2 class="heading"><span>hscommon.path</span></h2>
|
|||
|
</div>
|
|||
|
<div class="topnav" role="navigation" aria-label="top navigation">
|
|||
|
|
|||
|
<p>
|
|||
|
«  <a href="notify.html">hscommon.notify</a>
|
|||
|
  ::  
|
|||
|
<a class="uplink" href="../../index.html">Contents</a>
|
|||
|
  ::  
|
|||
|
<a href="util.html">hscommon.util</a>  »
|
|||
|
</p>
|
|||
|
|
|||
|
</div>
|
|||
|
<div class="content">
|
|||
|
|
|||
|
|
|||
|
<div class="section" id="module-hscommon.path">
|
|||
|
<span id="hscommon-path"></span><h1>hscommon.path<a class="headerlink" href="#module-hscommon.path" title="Permalink to this headline">¶</a></h1>
|
|||
|
<dl class="class">
|
|||
|
<dt id="hscommon.path.Path">
|
|||
|
<em class="property">class </em><code class="descclassname">hscommon.path.</code><code class="descname">Path</code><a class="headerlink" href="#hscommon.path.Path" title="Permalink to this definition">¶</a></dt>
|
|||
|
<dd><p>A handy class to work with paths.</p>
|
|||
|
<p>We subclass <code class="docutils literal notranslate"><span class="pre">tuple</span></code>, each element of the tuple represents an element of the path.</p>
|
|||
|
<ul class="simple">
|
|||
|
<li><code class="docutils literal notranslate"><span class="pre">Path('/foo/bar/baz')[1]</span></code> –> <code class="docutils literal notranslate"><span class="pre">'bar'</span></code></li>
|
|||
|
<li><code class="docutils literal notranslate"><span class="pre">Path('/foo/bar/baz')[1:2]</span></code> –> <code class="docutils literal notranslate"><span class="pre">Path('bar/baz')</span></code></li>
|
|||
|
<li><code class="docutils literal notranslate"><span class="pre">Path('/foo/bar')['baz']</span></code> –> <code class="docutils literal notranslate"><span class="pre">Path('/foo/bar/baz')</span></code></li>
|
|||
|
<li><code class="docutils literal notranslate"><span class="pre">str(Path('/foo/bar/baz'))</span></code> –> <code class="docutils literal notranslate"><span class="pre">'/foo/bar/baz'</span></code></li>
|
|||
|
</ul>
|
|||
|
<dl class="method">
|
|||
|
<dt id="hscommon.path.Path.is_parent_of">
|
|||
|
<code class="descname">is_parent_of</code><span class="sig-paren">(</span><em>other</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.path.Path.is_parent_of" title="Permalink to this definition">¶</a></dt>
|
|||
|
<dd><p>Whether <code class="docutils literal notranslate"><span class="pre">other</span></code> is a subpath of <code class="docutils literal notranslate"><span class="pre">self</span></code>.</p>
|
|||
|
<p>Almost the same as <code class="docutils literal notranslate"><span class="pre">other</span> <span class="pre">in</span> <span class="pre">self</span></code>, but it’s a bit more self-explicative and when
|
|||
|
<code class="docutils literal notranslate"><span class="pre">other</span> <span class="pre">==</span> <span class="pre">self</span></code>, returns False.</p>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<dl class="method">
|
|||
|
<dt id="hscommon.path.Path.parent">
|
|||
|
<code class="descname">parent</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.path.Path.parent" title="Permalink to this definition">¶</a></dt>
|
|||
|
<dd><p>Returns the parent path.</p>
|
|||
|
<p><code class="docutils literal notranslate"><span class="pre">Path('/foo/bar/baz').parent()</span></code> –> <code class="docutils literal notranslate"><span class="pre">Path('/foo/bar')</span></code></p>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<dl class="attribute">
|
|||
|
<dt id="hscommon.path.Path.name">
|
|||
|
<code class="descname">name</code><a class="headerlink" href="#hscommon.path.Path.name" title="Permalink to this definition">¶</a></dt>
|
|||
|
<dd><p>Last element of the path (filename), with extension.</p>
|
|||
|
<p><code class="docutils literal notranslate"><span class="pre">Path('/foo/bar/baz').name</span></code> –> <code class="docutils literal notranslate"><span class="pre">'baz'</span></code></p>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<dl class="function">
|
|||
|
<dt id="hscommon.path.log_io_error">
|
|||
|
<code class="descclassname">hscommon.path.</code><code class="descname">log_io_error</code><span class="sig-paren">(</span><em>func</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.path.log_io_error" title="Permalink to this definition">¶</a></dt>
|
|||
|
<dd><p>Catches OSError, IOError and WindowsError and log them</p>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<dl class="function">
|
|||
|
<dt id="hscommon.path.pathify">
|
|||
|
<code class="descclassname">hscommon.path.</code><code class="descname">pathify</code><span class="sig-paren">(</span><em>f</em><span class="sig-paren">)</span><a class="headerlink" href="#hscommon.path.pathify" title="Permalink to this definition">¶</a></dt>
|
|||
|
<dd><p>Ensure that every annotated <a class="reference internal" href="#hscommon.path.Path" title="hscommon.path.Path"><code class="xref py py-class docutils literal notranslate"><span class="pre">Path</span></code></a> arguments are actually paths.</p>
|
|||
|
<p>When a function is decorated with <code class="docutils literal notranslate"><span class="pre">@pathify</span></code>, every argument with annotated as Path will be
|
|||
|
converted to a Path if it wasn’t already. Example:</p>
|
|||
|
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@pathify</span>
|
|||
|
<span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">path</span><span class="p">:</span> <span class="n">Path</span><span class="p">,</span> <span class="n">otherarg</span><span class="p">):</span>
|
|||
|
<span class="k">return</span> <span class="n">path</span><span class="o">.</span><span class="n">listdir</span><span class="p">()</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>Calling <code class="docutils literal notranslate"><span class="pre">foo('/bar',</span> <span class="pre">0)</span></code> will convert <code class="docutils literal notranslate"><span class="pre">'/bar'</span></code> to <code class="docutils literal notranslate"><span class="pre">Path('/bar')</span></code>.</p>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
<div class="bottomnav" role="navigation" aria-label="bottom navigation">
|
|||
|
|
|||
|
<p>
|
|||
|
«  <a href="notify.html">hscommon.notify</a>
|
|||
|
  ::  
|
|||
|
<a class="uplink" href="../../index.html">Contents</a>
|
|||
|
  ::  
|
|||
|
<a href="util.html">hscommon.util</a>  »
|
|||
|
</p>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="footer" role="contentinfo">
|
|||
|
© Copyright 2016, Hardcoded Software.
|
|||
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.1.
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|