Documenting code re-org.
This commit is contained in:
parent
3aa7cad2c6
commit
d87f441d9d
|
@ -49,11 +49,9 @@
|
|||
<h1 id="index">Index</h1>
|
||||
|
||||
<div class="genindex-jumpbox">
|
||||
<a href="#B"><strong>B</strong></a>
|
||||
| <a href="#C"><strong>C</strong></a>
|
||||
<a href="#C"><strong>C</strong></a>
|
||||
| <a href="#D"><strong>D</strong></a>
|
||||
| <a href="#E"><strong>E</strong></a>
|
||||
| <a href="#F"><strong>F</strong></a>
|
||||
| <a href="#G"><strong>G</strong></a>
|
||||
| <a href="#L"><strong>L</strong></a>
|
||||
| <a href="#M"><strong>M</strong></a>
|
||||
|
@ -63,16 +61,6 @@
|
|||
| <a href="#W"><strong>W</strong></a>
|
||||
|
||||
</div>
|
||||
<h2 id="B">B</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
||||
<dt><a href="git_lint.html#git_lint.reporters.base_file_cleaner">base_file_cleaner() (in module git_lint.reporters)</a>
|
||||
</dt>
|
||||
|
||||
</dl></td>
|
||||
</tr></table>
|
||||
|
||||
<h2 id="C">C</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
@ -109,16 +97,6 @@
|
|||
</dl></td>
|
||||
</tr></table>
|
||||
|
||||
<h2 id="F">F</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
||||
<dt><a href="git_lint.html#git_lint.git_lint.find_config_file">find_config_file() (in module git_lint.git_lint)</a>
|
||||
</dt>
|
||||
|
||||
</dl></td>
|
||||
</tr></table>
|
||||
|
||||
<h2 id="G">G</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
@ -146,14 +124,10 @@
|
|||
<dt><a href="git_lint.html#git_lint.git_lint.get_linter_status">get_linter_status() (in module git_lint.git_lint)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="git_lint.html#git_lint.git_lint.get_shell_response">get_shell_response() (in module git_lint.git_lint)</a>
|
||||
</dt>
|
||||
|
||||
</dl></td>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
||||
<dt><a href="git_lint.html#git_lint.git_lint.get_working_linter_names">get_working_linter_names() (in module git_lint.git_lint)</a>
|
||||
<dt><a href="git_lint.html#git_lint.git_lint.get_shell_response">get_shell_response() (in module git_lint.git_lint)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
|
@ -176,10 +150,6 @@
|
|||
<dt><a href="git_lint.html#module-git_lint.reporters">git_lint.reporters (module)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="git_lint.html#git_lint.reporters.group_by">group_by() (in module git_lint.reporters)</a>
|
||||
</dt>
|
||||
|
||||
</dl></td>
|
||||
</tr></table>
|
||||
|
||||
|
|
|
@ -110,24 +110,6 @@ return code and the output of the lint process.</p>
|
|||
<code class="descclassname">git_lint.git_lint.</code><code class="descname">executable_exists</code><span class="sig-paren">(</span><em>script</em>, <em>label</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/git_lint.html#executable_exists"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.git_lint.executable_exists" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="git_lint.git_lint.find_config_file">
|
||||
<code class="descclassname">git_lint.git_lint.</code><code class="descname">find_config_file</code><span class="sig-paren">(</span><em>options</em>, <em>base</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/git_lint.html#find_config_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.git_lint.find_config_file" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the configuration file from a prioritized list of locations.</p>
|
||||
<dl class="docutils">
|
||||
<dt>Locations are prioritized as:</dt>
|
||||
<dd><ol class="first last arabic simple">
|
||||
<li>From the command line. Fail if specified but not found</li>
|
||||
<li>The repository’s root directory, as the file .git-lint</li>
|
||||
<li>The repository’s root directory, as the file .git-lint/config</li>
|
||||
<li>The user’s home directory, as file .git-lint</li>
|
||||
<li>The user’s home directory, as the file .git-lint/config</li>
|
||||
</ol>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>If no configuration file is found, this is an error.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="git_lint.git_lint.get_filelist">
|
||||
<code class="descclassname">git_lint.git_lint.</code><code class="descname">get_filelist</code><span class="sig-paren">(</span><em>options</em>, <em>extras</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/git_lint.html#get_filelist"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.git_lint.get_filelist" title="Permalink to this definition">¶</a></dt>
|
||||
|
@ -164,11 +146,6 @@ return code and the output of the lint process.</p>
|
|||
<code class="descclassname">git_lint.git_lint.</code><code class="descname">get_shell_response</code><span class="sig-paren">(</span><em>fullcmd</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/git_lint.html#get_shell_response"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.git_lint.get_shell_response" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="git_lint.git_lint.get_working_linter_names">
|
||||
<code class="descclassname">git_lint.git_lint.</code><code class="descname">get_working_linter_names</code><span class="sig-paren">(</span><em>config</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/git_lint.html#get_working_linter_names"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.git_lint.get_working_linter_names" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="git_lint.git_lint.load_config">
|
||||
<code class="descclassname">git_lint.git_lint.</code><code class="descname">load_config</code><span class="sig-paren">(</span><em>options</em>, <em>base</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/git_lint.html#load_config"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.git_lint.load_config" title="Permalink to this definition">¶</a></dt>
|
||||
|
@ -221,16 +198,6 @@ Help text, list of (long) options superseded by this one.</dd>
|
|||
</div>
|
||||
<div class="section" id="module-git_lint.reporters">
|
||||
<span id="git-lint-reporters-module"></span><h2>git_lint.reporters module<a class="headerlink" href="#module-git_lint.reporters" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt id="git_lint.reporters.base_file_cleaner">
|
||||
<code class="descclassname">git_lint.reporters.</code><code class="descname">base_file_cleaner</code><span class="sig-paren">(</span><em>files</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/reporters.html#base_file_cleaner"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.reporters.base_file_cleaner" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="git_lint.reporters.group_by">
|
||||
<code class="descclassname">git_lint.reporters.</code><code class="descname">group_by</code><span class="sig-paren">(</span><em>iterable</em>, <em>field_id</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/reporters.html#group_by"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.reporters.group_by" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="git_lint.reporters.print_help">
|
||||
<code class="descclassname">git_lint.reporters.</code><code class="descname">print_help</code><span class="sig-paren">(</span><em>options</em>, <em>name</em><span class="sig-paren">)</span><a class="reference internal" href="modules/git_lint/reporters.html#print_help"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#git_lint.reporters.print_help" title="Permalink to this definition">¶</a></dt>
|
||||
|
|
|
@ -73,39 +73,6 @@
|
|||
<span class="c1"># |___/</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="find_config_file"><a class="viewcode-back" href="../../git_lint.html#git_lint.git_lint.find_config_file">[docs]</a><span class="k">def</span> <span class="nf">find_config_file</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">base</span><span class="p">):</span>
|
||||
<span class="sd">""" Returns the configuration file from a prioritized list of locations.</span>
|
||||
|
||||
<span class="sd"> Locations are prioritized as:</span>
|
||||
<span class="sd"> 1. From the command line. Fail if specified but not found</span>
|
||||
<span class="sd"> 2. The repository's root directory, as the file .git-lint</span>
|
||||
<span class="sd"> 3. The repository's root directory, as the file .git-lint/config</span>
|
||||
<span class="sd"> 4. The user's home directory, as file .git-lint</span>
|
||||
<span class="sd"> 5. The user's home directory, as the file .git-lint/config</span>
|
||||
|
||||
<span class="sd"> If no configuration file is found, this is an error.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="s1">'config'</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span>
|
||||
<span class="n">config</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s1">'config'</span><span class="p">]</span>
|
||||
<span class="n">configpath</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">abspath</span><span class="p">(</span><span class="n">config</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">configpath</span><span class="p">):</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">_</span><span class="p">(</span><span class="s1">'Configuration file not found: </span><span class="si">{}</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">config</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="n">configpath</span>
|
||||
|
||||
<span class="n">home</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'HOME'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">possibles</span> <span class="o">=</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">base</span><span class="p">,</span> <span class="s1">'.git-lint'</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">base</span><span class="p">,</span> <span class="s1">'.git-lint/config'</span><span class="p">)]</span> <span class="o">+</span> <span class="p">((</span><span class="n">home</span> <span class="ow">and</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">home</span><span class="p">,</span> <span class="s1">'.git-lint'</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">home</span><span class="p">,</span> <span class="s1">'.git-lint/config'</span><span class="p">)])</span> <span class="ow">or</span> <span class="p">[])</span>
|
||||
|
||||
<span class="n">matches</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">possibles</span> <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">p</span><span class="p">)]</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">matches</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">_</span><span class="p">(</span><span class="s1">'No configuration file found, tried: </span><span class="si">{}</span><span class="s1">'</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">':'</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">possibles</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">matches</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<span class="c1"># (commandLineDictionary, repositoryLocation) -> (configurationDictionary | exit)</span>
|
||||
<div class="viewcode-block" id="load_config"><a class="viewcode-back" href="../../git_lint.html#git_lint.git_lint.load_config">[docs]</a><span class="k">def</span> <span class="nf">load_config</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">base</span><span class="p">):</span>
|
||||
<span class="sd">"""Loads the git-lint configuration file.</span>
|
||||
|
@ -119,6 +86,38 @@
|
|||
<span class="sd"> files for specific linters.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">find_config_file</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">base</span><span class="p">):</span>
|
||||
<span class="sd">""" Returns the configuration file from a prioritized list of locations.</span>
|
||||
<span class="sd"> </span>
|
||||
<span class="sd"> Locations are prioritized as:</span>
|
||||
<span class="sd"> 1. From the command line. Fail if specified but not found</span>
|
||||
<span class="sd"> 2. The repository's root directory, as the file .git-lint</span>
|
||||
<span class="sd"> 3. The repository's root directory, as the file .git-lint/config</span>
|
||||
<span class="sd"> 4. The user's home directory, as file .git-lint</span>
|
||||
<span class="sd"> 5. The user's home directory, as the file .git-lint/config</span>
|
||||
<span class="sd"> </span>
|
||||
<span class="sd"> If no configuration file is found, this is an error.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="s1">'config'</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span>
|
||||
<span class="n">config</span> <span class="o">=</span> <span class="n">options</span><span class="p">[</span><span class="s1">'config'</span><span class="p">]</span>
|
||||
<span class="n">configpath</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">abspath</span><span class="p">(</span><span class="n">config</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">configpath</span><span class="p">):</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">_</span><span class="p">(</span><span class="s1">'Configuration file not found: </span><span class="si">{}</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">config</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="n">configpath</span>
|
||||
|
||||
<span class="n">home</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'HOME'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">possibles</span> <span class="o">=</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">base</span><span class="p">,</span> <span class="s1">'.git-lint'</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">base</span><span class="p">,</span> <span class="s1">'.git-lint/config'</span><span class="p">)]</span> <span class="o">+</span> <span class="p">((</span><span class="n">home</span> <span class="ow">and</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">home</span><span class="p">,</span> <span class="s1">'.git-lint'</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">home</span><span class="p">,</span> <span class="s1">'.git-lint/config'</span><span class="p">)])</span> <span class="ow">or</span> <span class="p">[])</span>
|
||||
|
||||
<span class="n">matches</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">possibles</span> <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">p</span><span class="p">)]</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">matches</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">_</span><span class="p">(</span><span class="s1">'No configuration file found, tried: </span><span class="si">{}</span><span class="s1">'</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">':'</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">possibles</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">matches</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
|
||||
<span class="n">Linter</span> <span class="o">=</span> <span class="n">namedtuple</span><span class="p">(</span><span class="s1">'Linter'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'name'</span><span class="p">,</span> <span class="s1">'linter'</span><span class="p">])</span>
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="n">find_config_file</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">base</span><span class="p">)</span>
|
||||
<span class="n">configloader</span> <span class="o">=</span> <span class="n">configparser</span><span class="o">.</span><span class="n">SafeConfigParser</span><span class="p">()</span>
|
||||
|
@ -242,12 +241,12 @@
|
|||
<span class="k">return</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">possibles</span><span class="p">)</span> <span class="ow">and</span> <span class="n">possibles</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="ow">or</span> <span class="kc">False</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_working_linter_names"><a class="viewcode-back" href="../../git_lint.html#git_lint.git_lint.get_working_linter_names">[docs]</a><span class="k">def</span> <span class="nf">get_working_linter_names</span><span class="p">(</span><span class="n">config</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">i</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">config</span>
|
||||
<span class="k">if</span> <span class="n">executable_exists</span><span class="p">(</span><span class="n">i</span><span class="o">.</span><span class="n">linter</span><span class="p">[</span><span class="s1">'command'</span><span class="p">],</span> <span class="n">i</span><span class="o">.</span><span class="n">name</span><span class="p">)]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_linter_status"><a class="viewcode-back" href="../../git_lint.html#git_lint.git_lint.get_linter_status">[docs]</a><span class="k">def</span> <span class="nf">get_linter_status</span><span class="p">(</span><span class="n">config</span><span class="p">):</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">get_working_linter_names</span><span class="p">(</span><span class="n">config</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">i</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">config</span>
|
||||
<span class="k">if</span> <span class="n">executable_exists</span><span class="p">(</span><span class="n">i</span><span class="o">.</span><span class="n">linter</span><span class="p">[</span><span class="s1">'command'</span><span class="p">],</span> <span class="n">i</span><span class="o">.</span><span class="n">name</span><span class="p">)]</span>
|
||||
|
||||
<span class="n">working_linter_names</span> <span class="o">=</span> <span class="n">get_working_linter_names</span><span class="p">(</span><span class="n">config</span><span class="p">)</span>
|
||||
<span class="n">broken_linter_names</span> <span class="o">=</span> <span class="p">(</span><span class="nb">set</span><span class="p">([</span><span class="n">i</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">config</span><span class="p">])</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">working_linter_names</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="n">working_linter_names</span><span class="p">,</span> <span class="n">broken_linter_names</span></div>
|
||||
|
|
|
@ -54,26 +54,25 @@
|
|||
<span class="n">_</span> <span class="o">=</span> <span class="n">gettext</span><span class="o">.</span><span class="n">gettext</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="base_file_cleaner"><a class="viewcode-back" href="../../git_lint.html#git_lint.reporters.base_file_cleaner">[docs]</a><span class="k">def</span> <span class="nf">base_file_cleaner</span><span class="p">(</span><span class="n">files</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">file</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">git_base</span> <span class="o">+</span> <span class="s1">'/'</span><span class="p">,</span> <span class="s1">''</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">files</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<span class="c1"># ICK. Mutation, references, and hidden assignment.</span>
|
||||
<div class="viewcode-block" id="group_by"><a class="viewcode-back" href="../../git_lint.html#git_lint.reporters.group_by">[docs]</a><span class="k">def</span> <span class="nf">group_by</span><span class="p">(</span><span class="n">iterable</span><span class="p">,</span> <span class="n">field_id</span><span class="p">):</span>
|
||||
<span class="n">results</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">keys</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="k">for</span> <span class="n">obj</span> <span class="ow">in</span> <span class="n">iterable</span><span class="p">:</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="n">obj</span><span class="p">[</span><span class="n">field_id</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span>
|
||||
<span class="n">keys</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="n">keys</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">obj</span><span class="p">]</span>
|
||||
<span class="n">results</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">key</span><span class="p">,</span> <span class="n">keys</span><span class="p">[</span><span class="n">key</span><span class="p">]))</span>
|
||||
<span class="k">return</span> <span class="n">results</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="print_report"><a class="viewcode-back" href="../../git_lint.html#git_lint.reporters.print_report">[docs]</a><span class="k">def</span> <span class="nf">print_report</span><span class="p">(</span><span class="n">results</span><span class="p">,</span> <span class="n">unlintable_filenames</span><span class="p">,</span> <span class="n">cant_lint_filenames</span><span class="p">,</span>
|
||||
<span class="n">broken_linter_names</span><span class="p">,</span> <span class="n">unfindable_filenames</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="p">{</span><span class="s1">'bylinter'</span><span class="p">:</span> <span class="kc">True</span><span class="p">}):</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">base_file_cleaner</span><span class="p">(</span><span class="n">files</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">file</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">git_base</span> <span class="o">+</span> <span class="s1">'/'</span><span class="p">,</span> <span class="s1">''</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">files</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># ICK. Mutation, references, and hidden assignment.</span>
|
||||
<span class="k">def</span> <span class="nf">group_by</span><span class="p">(</span><span class="n">iterable</span><span class="p">,</span> <span class="n">field_id</span><span class="p">):</span>
|
||||
<span class="n">results</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">keys</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="k">for</span> <span class="n">obj</span> <span class="ow">in</span> <span class="n">iterable</span><span class="p">:</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="n">obj</span><span class="p">[</span><span class="n">field_id</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span>
|
||||
<span class="n">keys</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="n">keys</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">obj</span><span class="p">]</span>
|
||||
<span class="n">results</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">key</span><span class="p">,</span> <span class="n">keys</span><span class="p">[</span><span class="n">key</span><span class="p">]))</span>
|
||||
<span class="k">return</span> <span class="n">results</span>
|
||||
|
||||
<span class="n">sort_position</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="n">grouping</span> <span class="o">=</span> <span class="n">_</span><span class="p">(</span><span class="s1">'Linter: </span><span class="si">{}</span><span class="s1">'</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="s1">'byfile'</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span>
|
||||
|
|
BIN
objects.inv
BIN
objects.inv
Binary file not shown.
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue