Skip to content

Commit

Permalink
Update documentation (#207)
Browse files Browse the repository at this point in the history
What
- Update documentation

Why:
- In #202, we added support for optional params in `submit_sm`; this is the PR to update documentation for that previoos PR.
  • Loading branch information
komuw authored May 31, 2020
1 parent ee516fa commit bf23bfe
Show file tree
Hide file tree
Showing 13 changed files with 740 additions and 128 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ most recent version is listed first.


## **version:** v0.8.0
- support Smpp Optional Tags in `submit_sm`: https://github.com/komuw/naz/pull/202
- support Smpp Optional Tags in `submit_sm`: https://github.com/komuw/naz/pull/202, https://github.com/komuw/naz/pull/207
- Fixed some flaky tests: https://github.com/komuw/naz/pull/204, https://github.com/komuw/naz/pull/206
- Add ability to use different codecs for different messages while using the same `naz` client: https://github.com/komuw/naz/pull/201
With this change, message encoding is now a property of the message and not the client.
Expand Down
135 changes: 80 additions & 55 deletions docs/_modules/naz/client.html

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions docs/_modules/naz/codec.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ <h1>Source code for naz.codec</h1><div class="highlight"><pre>


<span class="n">_INBUILT_CODECS</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">codecs</span><span class="o">.</span><span class="n">CodecInfo</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
<span class="c1"># mypy issue; https://github.com/python/mypy/issues/8732</span>
<span class="c1"># pytype issue; https://github.com/google/pytype/issues/574</span>
<span class="s2">&quot;ucs2&quot;</span><span class="p">:</span> <span class="n">codecs</span><span class="o">.</span><span class="n">CodecInfo</span><span class="p">(</span>
<span class="n">name</span><span class="o">=</span><span class="s2">&quot;ucs2&quot;</span><span class="p">,</span>
Expand Down Expand Up @@ -422,14 +421,25 @@ <h1>Source code for naz.codec</h1><div class="highlight"><pre>
<span class="c1"># Note: Search function registration is not currently reversible,</span>
<span class="c1"># which may cause problems in some cases, such as unit testing or module reloading.</span>
<span class="c1"># https://docs.python.org/3.7/library/codecs.html#codecs.register</span>
<span class="c1">#</span>
<span class="c1"># Note: Encodings are first looked up in the registry&#39;s cache.</span>
<span class="c1"># thus if you call `register_codecs` and then call it again with different</span>
<span class="c1"># codecs, the second codecs may not take effect.</span>
<span class="c1"># ie; codecs.lookup(encoding) will return the first codecs since they were stored</span>
<span class="c1"># in the cache.</span>
<span class="c1"># There doesn&#39;t appear to be away to clear codec cache at runtime.</span>
<span class="c1"># see: https://docs.python.org/3/library/codecs.html#codecs.lookup</span>

<span class="k">def</span> <span class="nf">_codec_search_function</span><span class="p">(</span><span class="n">_encoding</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> We should try and get codecs from the custom_codecs first.</span>
<span class="sd"> This way, if someone had overridden an inbuilt codec, their</span>
<span class="sd"> implementation is chosen first and cached.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">custom_codecs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">_encoding</span><span class="p">,</span> <span class="n">_INBUILT_CODECS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">_encoding</span><span class="p">))</span>
<span class="k">if</span> <span class="n">custom_codecs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">_encoding</span><span class="p">):</span>
<span class="k">return</span> <span class="n">custom_codecs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">_encoding</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">_INBUILT_CODECS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">_encoding</span><span class="p">)</span>

<span class="n">codecs</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">_codec_search_function</span><span class="p">)</span></div>
</pre></div>
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/naz/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ <h1>Source code for naz.log</h1><div class="highlight"><pre>
<span class="k">try</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">input_msg</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s2">&quot;naz.SimpleLogger error: </span><span class="si">{0}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s2">&quot;naz.SimpleLogger error: </span><span class="si">{0}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">return</span> <span class="n">msg</span></div>


Expand Down
Loading

0 comments on commit bf23bfe

Please sign in to comment.