2021.4.post1 #31

Merged
edraft merged 92 commits from 2021.4.post1 into master 2021-05-19 09:00:40 +02:00
7 changed files with 250 additions and 129 deletions
Showing only changes of commit 850d44a105 - Show all commits

Binary file not shown.

Binary file not shown.

View File

@ -179,30 +179,52 @@
<dt id="cpl.utils.credential_manager.CredentialManager"> <dt id="cpl.utils.credential_manager.CredentialManager">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">cpl.utils.credential_manager.</span></code><code class="sig-name descname"><span class="pre">CredentialManager</span></code><a class="headerlink" href="#cpl.utils.credential_manager.CredentialManager" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">cpl.utils.credential_manager.</span></code><code class="sig-name descname"><span class="pre">CredentialManager</span></code><a class="headerlink" href="#cpl.utils.credential_manager.CredentialManager" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Handles credentials</p> <p>Handles credential encryption and decryption</p>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.credential_manager.CredentialManager.build_string"> <dt id="cpl.utils.credential_manager.CredentialManager.build_string">
<em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">build_string</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">credentials</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.credential_manager.CredentialManager.build_string" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">build_string</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">credentials</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.credential_manager.CredentialManager.build_string" title="Permalink to this definition"></a></dt>
<dd><p>Builds string with credentials in it <dd><p>Builds string with credentials in it</p>
:param string: <blockquote>
:param credentials: <div><dl class="simple">
:return:</p> <dt>string: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>String in which the variable is replaced by credentials</p>
</dd>
<dt>credentials: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>String to encode</p>
</dd>
</dl>
</div></blockquote>
<blockquote>
<div><p>Decoded string</p>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.credential_manager.CredentialManager.decrypt"> <dt id="cpl.utils.credential_manager.CredentialManager.decrypt">
<em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">decrypt</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.credential_manager.CredentialManager.decrypt" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">decrypt</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.credential_manager.CredentialManager.decrypt" title="Permalink to this definition"></a></dt>
<dd><p>Decode with base64 <dd><p>Decode with base64</p>
:param string: <blockquote>
:return:</p> <div><dl class="simple">
<dt>string: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>String to decode</p>
</dd>
</dl>
</div></blockquote>
<blockquote>
<div><p>Decoded string</p>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.credential_manager.CredentialManager.encrypt"> <dt id="cpl.utils.credential_manager.CredentialManager.encrypt">
<em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">encrypt</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.credential_manager.CredentialManager.encrypt" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">encrypt</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.credential_manager.CredentialManager.encrypt" title="Permalink to this definition"></a></dt>
<dd><p>Encode with base64 <dd><p>Encode with base64</p>
:param string: <blockquote>
:return:</p> <div><dl class="simple">
<dt>string: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>String to encode</p>
</dd>
</dl>
</div></blockquote>
<blockquote>
<div><p>Encoded string</p>
</div></blockquote>
</dd></dl> </dd></dl>
</dd></dl> </dd></dl>
@ -223,53 +245,76 @@
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.pip.Pip.get_outdated"> <dt id="cpl.utils.pip.Pip.get_outdated">
<em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">get_outdated</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; <span class="pre">bytes</span><a class="headerlink" href="#cpl.utils.pip.Pip.get_outdated" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">get_outdated</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; <span class="pre">bytes</span><a class="headerlink" href="#cpl.utils.pip.Pip.get_outdated" title="Permalink to this definition"></a></dt>
<dd><p>Gets table of outdated packages <dd><p>Gets table of outdated packages</p>
:return:</p> <blockquote>
<div><p>Bytes string of the command result</p>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.pip.Pip.get_package"> <dt id="cpl.utils.pip.Pip.get_package">
<em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">get_package</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">package</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><a class="headerlink" href="#cpl.utils.pip.Pip.get_package" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">get_package</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">package</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><a class="headerlink" href="#cpl.utils.pip.Pip.get_package" title="Permalink to this definition"></a></dt>
<dd><p>Gets given package py local pip list <dd><p>Gets given package py local pip list</p>
:param package: <blockquote>
:return:</p> <div><p>package: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></p>
</div></blockquote>
<blockquote>
<div><p>The package name as string</p>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.pip.Pip.install"> <dt id="cpl.utils.pip.Pip.install">
<em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">install</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">package</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">source</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stdout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stderr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.pip.Pip.install" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">install</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">package</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">source</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stdout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stderr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.pip.Pip.install" title="Permalink to this definition"></a></dt>
<dd><p>Installs given package <dd><p>Installs given package</p>
:param package: <blockquote>
:param args: <div><dl class="simple">
:param source: <dt>package: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>The name of the package</p>
:param stdout: </dd>
:param stderr: <dt>args: <code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></dt><dd><p>Arguments for the command</p>
:return:</p> </dd>
<dt>source: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Extra index URL</p>
</dd>
<dt>stdout: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Stdout of subprocess.run</p>
</dd>
<dt>stderr: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Stderr of subprocess.run</p>
</dd>
</dl>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.pip.Pip.reset_executable"> <dt id="cpl.utils.pip.Pip.reset_executable">
<em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">reset_executable</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.pip.Pip.reset_executable" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">reset_executable</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.pip.Pip.reset_executable" title="Permalink to this definition"></a></dt>
<dd><p>Resets the executable to system standard <dd><p>Resets the executable to system standard</p>
:return:</p>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.pip.Pip.set_executable"> <dt id="cpl.utils.pip.Pip.set_executable">
<em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">set_executable</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">executable</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.pip.Pip.set_executable" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">set_executable</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">executable</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.pip.Pip.set_executable" title="Permalink to this definition"></a></dt>
<dd><p>Sets the executable <dd><p>Sets the executable</p>
:param executable: <blockquote>
:return:</p> <div><dl class="simple">
<dt>executable: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>The python command</p>
</dd>
</dl>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.pip.Pip.uninstall"> <dt id="cpl.utils.pip.Pip.uninstall">
<em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">uninstall</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">package</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stdout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stderr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.pip.Pip.uninstall" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">classmethod</span> </em><code class="sig-name descname"><span class="pre">uninstall</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">package</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stdout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stderr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.utils.pip.Pip.uninstall" title="Permalink to this definition"></a></dt>
<dd><p>Uninstalls given package <dd><p>Uninstalls given package</p>
:param package: <blockquote>
:param stdout: <div><dl class="simple">
:param stderr: <dt>package: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>The name of the package</p>
:return:</p> </dd>
<dt>stdout: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Stdout of subprocess.run</p>
</dd>
<dt>stderr: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Stderr of subprocess.run</p>
</dd>
</dl>
</div></blockquote>
</dd></dl> </dd></dl>
</dd></dl> </dd></dl>
@ -285,39 +330,70 @@
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.string.String.convert_to_camel_case"> <dt id="cpl.utils.string.String.convert_to_camel_case">
<em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">convert_to_camel_case</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.convert_to_camel_case" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">convert_to_camel_case</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.convert_to_camel_case" title="Permalink to this definition"></a></dt>
<dd><p>Converts string to camel case <dd><p>Converts string to camel case</p>
:param chars: <blockquote>
:return:</p> <div><dl class="simple">
<dt>chars: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>String to convert</p>
</dd>
</dl>
</div></blockquote>
<blockquote>
<div><p>String converted to CamelCase</p>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.string.String.convert_to_snake_case"> <dt id="cpl.utils.string.String.convert_to_snake_case">
<em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">convert_to_snake_case</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.convert_to_snake_case" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">convert_to_snake_case</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.convert_to_snake_case" title="Permalink to this definition"></a></dt>
<dd><p>Converts string to snake case <dd><p>Converts string to snake case</p>
:param chars: <blockquote>
:return:</p> <div><dl class="simple">
<dt>chars: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>String to convert</p>
</dd>
</dl>
</div></blockquote>
<blockquote>
<div><p>String converted to snake_case</p>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.string.String.first_to_lower"> <dt id="cpl.utils.string.String.first_to_lower">
<em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">first_to_lower</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.first_to_lower" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">first_to_lower</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.first_to_lower" title="Permalink to this definition"></a></dt>
<dd><p>Converts first char to lower <dd><p>Converts first char to lower</p>
:param chars: <blockquote>
:return:</p> <div><dl class="simple">
<dt>chars: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>String to convert</p>
</dd>
</dl>
</div></blockquote>
<blockquote>
<div><p>String with first char as lower</p>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.string.String.first_to_upper"> <dt id="cpl.utils.string.String.first_to_upper">
<em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">first_to_upper</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.first_to_upper" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">first_to_upper</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.first_to_upper" title="Permalink to this definition"></a></dt>
<dd><p>Converts first char to upper <dd><p>Converts first char to upper</p>
:param chars: <blockquote>
:return:</p> <div><dl class="simple">
<dt>chars: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>String to convert</p>
</dd>
</dl>
</div></blockquote>
<blockquote>
<div><p>String with first char as upper</p>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
<dt id="cpl.utils.string.String.random_string"> <dt id="cpl.utils.string.String.random_string">
<em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">random_string</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">length</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.random_string" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">static</span> </em><code class="sig-name descname"><span class="pre">random_string</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">chars</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">length</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> &#x2192; <span class="pre">str</span><a class="headerlink" href="#cpl.utils.string.String.random_string" title="Permalink to this definition"></a></dt>
<dd><p>Creates random string by given chars and length</p> <dd><p>Creates random string by given chars and length</p>
<blockquote>
<div><p>String of random chars</p>
</div></blockquote>
</dd></dl> </dd></dl>
</dd></dl> </dd></dl>

File diff suppressed because one or more lines are too long

View File

@ -2,35 +2,52 @@ import base64
class CredentialManager: class CredentialManager:
""" r"""Handles credential encryption and decryption"""
Handles credentials
"""
@staticmethod @staticmethod
def encrypt(string: str) -> str: def encrypt(string: str) -> str:
""" r"""Encode with base64
Encode with base64
:param string: Parameter
:return: ---------
string: :class:`str`
String to encode
Returns
-------
Encoded string
""" """
return base64.b64encode(string.encode('utf-8')).decode('utf-8') return base64.b64encode(string.encode('utf-8')).decode('utf-8')
@staticmethod @staticmethod
def decrypt(string: str) -> str: def decrypt(string: str) -> str:
""" r"""Decode with base64
Decode with base64
:param string: Parameter
:return: ---------
string: :class:`str`
String to decode
Returns
-------
Decoded string
""" """
return base64.b64decode(string).decode('utf-8') return base64.b64decode(string).decode('utf-8')
@staticmethod @staticmethod
def build_string(string: str, credentials: str): def build_string(string: str, credentials: str):
""" r"""Builds string with credentials in it
Builds string with credentials in it
:param string: Parameter
:param credentials: ---------
:return: string: :class:`str`
String in which the variable is replaced by credentials
credentials: :class:`str`
String to encode
Returns
-------
Decoded string
""" """
return string.replace('$credentials', CredentialManager.decrypt(credentials)) return string.replace('$credentials', CredentialManager.decrypt(credentials))

View File

@ -1,38 +1,30 @@
import os import os
import subprocess import subprocess
import sys import sys
import shlex
from contextlib import suppress from contextlib import suppress
from textwrap import dedent
from typing import Optional from typing import Optional
class Pip: class Pip:
""" r"""Executes pip commands"""
Executes pip commands
"""
_executable = sys.executable _executable = sys.executable
_env = os.environ _env = os.environ
_is_venv = False _is_venv = False
""" """Getter"""
Getter
"""
@classmethod @classmethod
def get_executable(cls) -> str: def get_executable(cls) -> str:
return cls._executable return cls._executable
""" """Setter"""
Setter
"""
@classmethod @classmethod
def set_executable(cls, executable: str): def set_executable(cls, executable: str):
""" r"""Sets the executable
Sets the executable
:param executable: Parameter
:return: ---------
executable: :class:`str`
The python command
""" """
if executable is not None and executable != sys.executable: if executable is not None and executable != sys.executable:
cls._executable = executable cls._executable = executable
@ -48,23 +40,22 @@ class Pip:
@classmethod @classmethod
def reset_executable(cls): def reset_executable(cls):
""" r"""Resets the executable to system standard"""
Resets the executable to system standard
:return:
"""
cls._executable = sys.executable cls._executable = sys.executable
cls._is_venv = False cls._is_venv = False
""" """Public utils functions"""
Public utils functions
"""
@classmethod @classmethod
def get_package(cls, package: str) -> Optional[str]: def get_package(cls, package: str) -> Optional[str]:
""" r"""Gets given package py local pip list
Gets given package py local pip list
:param package: Parameter
:return: ---------
package: :class:`str`
Returns
-------
The package name as string
""" """
result = None result = None
with suppress(Exception): with suppress(Exception):
@ -94,9 +85,11 @@ class Pip:
@classmethod @classmethod
def get_outdated(cls) -> bytes: def get_outdated(cls) -> bytes:
""" r"""Gets table of outdated packages
Gets table of outdated packages
:return: Returns
-------
Bytes string of the command result
""" """
args = [cls._executable, "-m", "pip", "list", "--outdated"] args = [cls._executable, "-m", "pip", "list", "--outdated"]
if cls._is_venv: if cls._is_venv:
@ -106,14 +99,20 @@ class Pip:
@classmethod @classmethod
def install(cls, package: str, *args, source: str = None, stdout=None, stderr=None): def install(cls, package: str, *args, source: str = None, stdout=None, stderr=None):
""" r"""Installs given package
Installs given package
:param package: Parameter
:param args: ---------
:param source: package: :class:`str`
:param stdout: The name of the package
:param stderr: args: :class:`list`
:return: Arguments for the command
source: :class:`str`
Extra index URL
stdout: :class:`str`
Stdout of subprocess.run
stderr: :class:`str`
Stderr of subprocess.run
""" """
pip_args = [cls._executable, "-m", "pip", "install"] pip_args = [cls._executable, "-m", "pip", "install"]
if cls._is_venv: if cls._is_venv:
@ -131,12 +130,16 @@ class Pip:
@classmethod @classmethod
def uninstall(cls, package: str, stdout=None, stderr=None): def uninstall(cls, package: str, stdout=None, stderr=None):
""" r"""Uninstalls given package
Uninstalls given package
:param package: Parameter
:param stdout: ---------
:param stderr: package: :class:`str`
:return: The name of the package
stdout: :class:`str`
Stdout of subprocess.run
stderr: :class:`str`
Stderr of subprocess.run
""" """
args = [cls._executable, "-m", "pip", "uninstall", "--yes", package] args = [cls._executable, "-m", "pip", "uninstall", "--yes", package]
if cls._is_venv: if cls._is_venv:

View File

@ -4,16 +4,20 @@ import random
class String: class String:
""" r"""Useful functions for strings"""
Useful functions for strings
"""
@staticmethod @staticmethod
def convert_to_camel_case(chars: str) -> str: def convert_to_camel_case(chars: str) -> str:
""" r"""Converts string to camel case
Converts string to camel case
:param chars: Parameter
:return: ---------
chars: :class:`str`
String to convert
Returns
-------
String converted to CamelCase
""" """
converted_name = chars converted_name = chars
char_set = string.punctuation + ' ' char_set = string.punctuation + ' '
@ -25,10 +29,16 @@ class String:
@staticmethod @staticmethod
def convert_to_snake_case(chars: str) -> str: def convert_to_snake_case(chars: str) -> str:
""" r"""Converts string to snake case
Converts string to snake case
:param chars: Parameter
:return: ---------
chars: :class:`str`
String to convert
Returns
-------
String converted to snake_case
""" """
# convert to train-case to CamelCase # convert to train-case to CamelCase
if '-' in chars: if '-' in chars:
@ -41,26 +51,41 @@ class String:
@staticmethod @staticmethod
def first_to_upper(chars: str) -> str: def first_to_upper(chars: str) -> str:
""" r"""Converts first char to upper
Converts first char to upper
:param chars: Parameter
:return: ---------
chars: :class:`str`
String to convert
Returns
-------
String with first char as upper
""" """
return f'{chars[0].upper()}{chars[1:]}' return f'{chars[0].upper()}{chars[1:]}'
@staticmethod @staticmethod
def first_to_lower(chars: str) -> str: def first_to_lower(chars: str) -> str:
""" r"""Converts first char to lower
Converts first char to lower
:param chars: Parameter
:return: ---------
chars: :class:`str`
String to convert
Returns
-------
String with first char as lower
""" """
return f'{chars[0].lower()}{chars[1:]}' return f'{chars[0].lower()}{chars[1:]}'
@staticmethod @staticmethod
def random_string(chars: str, length: int) -> str: def random_string(chars: str, length: int) -> str:
""" r"""Creates random string by given chars and length
Creates random string by given chars and length
Returns
-------
String of random chars
""" """
return ''.join(random.choice(chars) for _ in range(length)) return ''.join(random.choice(chars) for _ in range(length))