Skip to content

Commit

Permalink
deploy: b7ae85e
Browse files Browse the repository at this point in the history
  • Loading branch information
argonism committed Oct 10, 2023
1 parent 661916f commit f0fc8ac
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 14 deletions.
30 changes: 30 additions & 0 deletions changelog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,13 @@
<nav class="md-nav" aria-label="Changelog">
<ul class="md-nav__list">

<li class="md-nav__item">
<a href="#040---2023-10-09" class="md-nav__link">
[0.4.0] - 2023-10-09
</a>

</li>

<li class="md-nav__item">
<a href="#031---2023-10-09" class="md-nav__link">
[0.3.1] - 2023-10-09
Expand Down Expand Up @@ -455,6 +462,13 @@
<nav class="md-nav" aria-label="Changelog">
<ul class="md-nav__list">

<li class="md-nav__item">
<a href="#040---2023-10-09" class="md-nav__link">
[0.4.0] - 2023-10-09
</a>

</li>

<li class="md-nav__item">
<a href="#031---2023-10-09" class="md-nav__link">
[0.3.1] - 2023-10-09
Expand Down Expand Up @@ -524,6 +538,22 @@ <h1>Changelog</h1>

<!-- BEGIN INCLUDE ../CHANGELOG.md -->
<h2 id="changelog">Changelog<a class="headerlink" href="#changelog" title="Permanent link">&para;</a></h2>
<h3 id="040---2023-10-09">[0.4.0] - 2023-10-09<a class="headerlink" href="#040---2023-10-09" title="Permanent link">&para;</a></h3>
<ul>
<li>Add post_params and **payloads params to EsaMdfier.write()<ul>
<li>post_params<ul>
<li>is expected to be used as additional parameters for the post.</li>
<li>see https://docs.esa.io/posts/102#POST%20/v1/teams/:team_name/posts. Defaults to {}.</li>
</ul>
</li>
<li>**payloads<ul>
<li>offers access to piyo which is esa.io client library.</li>
<li>see https://github.com/argonism/piyo/blob/master/piyo/client.py#L112 for details.</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="031---2023-10-09">[0.3.1] - 2023-10-09<a class="headerlink" href="#031---2023-10-09" title="Permanent link">&para;</a></h3>
<ul>
<li>Remove print blended in</li>
Expand Down
18 changes: 18 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@
<nav class="md-nav" aria-label="mdfy-esa">
<ul class="md-nav__list">

<li class="md-nav__item">
<a href="#pre-requirement" class="md-nav__link">
Pre-requirement
</a>

</li>

<li class="md-nav__item">
<a href="#usage" class="md-nav__link">
Usage
Expand Down Expand Up @@ -434,6 +441,13 @@
<nav class="md-nav" aria-label="mdfy-esa">
<ul class="md-nav__list">

<li class="md-nav__item">
<a href="#pre-requirement" class="md-nav__link">
Pre-requirement
</a>

</li>

<li class="md-nav__item">
<a href="#usage" class="md-nav__link">
Usage
Expand Down Expand Up @@ -494,6 +508,10 @@ <h2 id="mdfy-esa">mdfy-esa<a class="headerlink" href="#mdfy-esa" title="Permanen
<li>PyPI: <a href="https://pypi.org/project/mdfy-esa/">https://pypi.org/project/mdfy-esa/</a></li>
<li>Free software: MIT</li>
</ul>
<h3 id="pre-requirement">Pre-requirement<a class="headerlink" href="#pre-requirement" title="Permanent link">&para;</a></h3>
<p>You need set esa.io API token and set it to environment veriable ESA_ACCESS_TOKEN.</p>
<div class="highlight"><pre><span></span><code><span class="nb">export</span><span class="w"> </span><span class="nv">ESA_ACCESS_TOKEN</span><span class="o">=</span>YOUR_ACCESS_TOKEN
</code></pre></div>
<h3 id="usage">Usage<a class="headerlink" href="#usage" title="Permanent link">&para;</a></h3>
<p>The mdfy-esa feature supports uploading of local images and files.
With the EsaMdfier, images or files designated with MdImage or MdLink are uploaded automatically.
Expand Down
74 changes: 67 additions & 7 deletions modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,15 @@ <h2 id="mdfy_esa.mdfy_esa.EsaMdfier" class="doc doc-heading">
<span class="normal"> 97</span>
<span class="normal"> 98</span>
<span class="normal"> 99</span>
<span class="normal">100</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="k">class</span> <span class="nc">EsaMdfier</span><span class="p">(</span><span class="n">Mdfier</span><span class="p">):</span>
<span class="normal">100</span>
<span class="normal">101</span>
<span class="normal">102</span>
<span class="normal">103</span>
<span class="normal">104</span>
<span class="normal">105</span>
<span class="normal">106</span>
<span class="normal">107</span>
<span class="normal">108</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="k">class</span> <span class="nc">EsaMdfier</span><span class="p">(</span><span class="n">Mdfier</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;A class to modify Markdown files and upload images to Esa.</span>

<span class="sd"> Args:</span>
Expand Down Expand Up @@ -795,12 +803,16 @@ <h2 id="mdfy_esa.mdfy_esa.EsaMdfier" class="doc doc-heading">
<span class="k">def</span> <span class="nf">write</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">contents</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">MdElement</span><span class="p">]],</span> <span class="n">MdElement</span><span class="p">],</span>
<span class="n">post_params</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{},</span>
<span class="o">**</span><span class="n">payloads</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]],</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;post the given Markdown content to esa.io.</span>

<span class="sd"> Args:</span>
<span class="sd"> contents (Union[List[Union[str, MdElement]], MdElement]):</span>
<span class="sd"> The Markdown content to write to the file.</span>
<span class="sd"> post_params (Dict[str, Any], optional): Additional parameters for the post. see https://docs.esa.io/posts/102#POST%20/v1/teams/:team_name/posts. Defaults to {}.</span>
<span class="sd"> **payloads (Optional[Dict[str, Any]]): Additional parameters for piyo see https://github.com/argonism/piyo/blob/master/piyo/client.py#L112.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">contents</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
Expand All @@ -812,9 +824,13 @@ <h2 id="mdfy_esa.mdfy_esa.EsaMdfier" class="doc doc-heading">
<span class="n">markdown</span> <span class="o">+=</span> <span class="n">content_md</span> <span class="o">+</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>

<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">post_fullname</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">create_post</span><span class="p">({</span><span class="s2">&quot;post&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">post_fullname</span><span class="p">,</span> <span class="s2">&quot;body_md&quot;</span><span class="p">:</span> <span class="n">markdown</span><span class="p">}})</span>
<span class="n">post_data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;post&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">post_fullname</span><span class="p">,</span> <span class="s2">&quot;body_md&quot;</span><span class="p">:</span> <span class="n">markdown</span><span class="p">,</span> <span class="o">**</span><span class="n">post_params</span><span class="p">}}</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">create_post</span><span class="p">(</span><span class="n">post_data</span><span class="p">,</span> <span class="o">**</span><span class="n">payloads</span><span class="p">)</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">post_number</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">update_post</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">post_number</span><span class="p">,</span> <span class="p">{</span><span class="s2">&quot;post&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;body_md&quot;</span><span class="p">:</span> <span class="n">markdown</span><span class="p">}})</span>
<span class="n">update_data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;post&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;body_md&quot;</span><span class="p">:</span> <span class="n">markdown</span><span class="p">,</span> <span class="o">**</span><span class="n">post_params</span><span class="p">}}</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">update_post</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">post_number</span><span class="p">,</span> <span class="n">update_data</span><span class="p">,</span> <span class="o">**</span><span class="n">payloads</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Either post_fullname or post_number must be set. Please set one of them.&quot;</span><span class="p">)</span>
</code></pre></div></td></tr></table></div>
</details>

Expand Down Expand Up @@ -1081,7 +1097,7 @@ <h3 id="mdfy_esa.mdfy_esa.EsaMdfier.stringify_element" class="doc doc-heading">


<h3 id="mdfy_esa.mdfy_esa.EsaMdfier.write" class="doc doc-heading">
<code class="highlight language-python"><span class="n">write</span><span class="p">(</span><span class="n">contents</span><span class="p">)</span></code>
<code class="highlight language-python"><span class="n">write</span><span class="p">(</span><span class="n">contents</span><span class="p">,</span> <span class="n">post_params</span><span class="o">=</span><span class="p">{},</span> <span class="o">**</span><span class="n">payloads</span><span class="p">)</span></code>

<a href="#mdfy_esa.mdfy_esa.EsaMdfier.write" class="headerlink" title="Permanent link">&para;</a></h3>

Expand Down Expand Up @@ -1117,6 +1133,34 @@ <h3 id="mdfy_esa.mdfy_esa.EsaMdfier.write" class="doc doc-heading">
<em>required</em>
</td>
</tr>
<tr>
<td><code>post_params</code></td>
<td>
<code><span title="typing.Dict">Dict</span>[str, <span title="typing.Any">Any</span>]</code>
</td>
<td>
<div class="doc-md-description">
<p>Additional parameters for the post. see https://docs.esa.io/posts/102#POST%20/v1/teams/:team_name/posts. Defaults to {}.</p>
</div>
</td>
<td>
<code>{}</code>
</td>
</tr>
<tr>
<td><code>**payloads</code></td>
<td>
<code><span title="typing.Optional">Optional</span>[<span title="typing.Dict">Dict</span>[str, <span title="typing.Any">Any</span>]]</code>
</td>
<td>
<div class="doc-md-description">
<p>Additional parameters for piyo see https://github.com/argonism/piyo/blob/master/piyo/client.py#L112.</p>
</div>
</td>
<td>
<code>{}</code>
</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -1144,15 +1188,27 @@ <h3 id="mdfy_esa.mdfy_esa.EsaMdfier.write" class="doc doc-heading">
<span class="normal"> 97</span>
<span class="normal"> 98</span>
<span class="normal"> 99</span>
<span class="normal">100</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="k">def</span> <span class="nf">write</span><span class="p">(</span>
<span class="normal">100</span>
<span class="normal">101</span>
<span class="normal">102</span>
<span class="normal">103</span>
<span class="normal">104</span>
<span class="normal">105</span>
<span class="normal">106</span>
<span class="normal">107</span>
<span class="normal">108</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="k">def</span> <span class="nf">write</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">contents</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">MdElement</span><span class="p">]],</span> <span class="n">MdElement</span><span class="p">],</span>
<span class="n">post_params</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{},</span>
<span class="o">**</span><span class="n">payloads</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]],</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;post the given Markdown content to esa.io.</span>

<span class="sd"> Args:</span>
<span class="sd"> contents (Union[List[Union[str, MdElement]], MdElement]):</span>
<span class="sd"> The Markdown content to write to the file.</span>
<span class="sd"> post_params (Dict[str, Any], optional): Additional parameters for the post. see https://docs.esa.io/posts/102#POST%20/v1/teams/:team_name/posts. Defaults to {}.</span>
<span class="sd"> **payloads (Optional[Dict[str, Any]]): Additional parameters for piyo see https://github.com/argonism/piyo/blob/master/piyo/client.py#L112.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">contents</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
Expand All @@ -1164,9 +1220,13 @@ <h3 id="mdfy_esa.mdfy_esa.EsaMdfier.write" class="doc doc-heading">
<span class="n">markdown</span> <span class="o">+=</span> <span class="n">content_md</span> <span class="o">+</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>

<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">post_fullname</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">create_post</span><span class="p">({</span><span class="s2">&quot;post&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">post_fullname</span><span class="p">,</span> <span class="s2">&quot;body_md&quot;</span><span class="p">:</span> <span class="n">markdown</span><span class="p">}})</span>
<span class="n">post_data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;post&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">post_fullname</span><span class="p">,</span> <span class="s2">&quot;body_md&quot;</span><span class="p">:</span> <span class="n">markdown</span><span class="p">,</span> <span class="o">**</span><span class="n">post_params</span><span class="p">}}</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">create_post</span><span class="p">(</span><span class="n">post_data</span><span class="p">,</span> <span class="o">**</span><span class="n">payloads</span><span class="p">)</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">post_number</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">update_post</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">post_number</span><span class="p">,</span> <span class="p">{</span><span class="s2">&quot;post&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;body_md&quot;</span><span class="p">:</span> <span class="n">markdown</span><span class="p">}})</span>
<span class="n">update_data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;post&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;body_md&quot;</span><span class="p">:</span> <span class="n">markdown</span><span class="p">,</span> <span class="o">**</span><span class="n">post_params</span><span class="p">}}</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">update_post</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">post_number</span><span class="p">,</span> <span class="n">update_data</span><span class="p">,</span> <span class="o">**</span><span class="n">payloads</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Either post_fullname or post_number must be set. Please set one of them.&quot;</span><span class="p">)</span>
</code></pre></div></td></tr></table></div>
</details>
</div>
Expand Down
Loading

0 comments on commit f0fc8ac

Please sign in to comment.