Skip to content

Commit

Permalink
Add None to descriptions of return where needed.
Browse files Browse the repository at this point in the history
Some functions can return None instead of desired values if these values
were not found in the supplied data.
  • Loading branch information
Evildoor committed Nov 12, 2019
1 parent 9d6767d commit be3827c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 55 deletions.
36 changes: 18 additions & 18 deletions Docs/build/html/Stages/055_documents2TTL/055_documents2TTL.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>dict</em>) – ‘CDS’ part of the initial JSON</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">abstract</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">abstract or None if it was not found</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str or NoneType</td>
</tr>
</tbody>
</table>
Expand All @@ -121,9 +121,9 @@
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>dict</em>) – ‘CDS’ part of the initial JSON</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">arXiv code</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">arXiv code or None if it was not found</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str or NoneType</td>
</tr>
</tbody>
</table>
Expand All @@ -139,9 +139,9 @@
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>dict</em>) – ‘CDS’ part of the initial JSON</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">CDS id</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">CDS id or None if it was not found</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">int</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">int or NoneType</td>
</tr>
</tbody>
</table>
Expand All @@ -157,9 +157,9 @@
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>dict</em>) – ‘CDS’ part of the initial JSON</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">CDS internal report number</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">CDS internal report number or None if it was not found</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">unicode</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">unicode or NoneType</td>
</tr>
</tbody>
</table>
Expand All @@ -179,10 +179,10 @@
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">parameter value</p>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">parameter value or None if it was not found</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int, str</p>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">int, str, NoneType</p>
</td>
</tr>
</tbody>
Expand All @@ -199,9 +199,9 @@
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>dict</em>) – ‘CDS’ part of the initial JSON</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">creation date</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">creation date or None if it was not found</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str or NoneType</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -403,10 +403,10 @@
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">parameter value</p>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">parameter value or None if it was not found</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str, unicode</p>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str, unicode, NoneType</p>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -512,9 +512,9 @@
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>dict</em>) – ‘CDS’ part of the initial JSON</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">report number</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">report number or None if it was not found</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">unicode</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">unicode or NoneType</td>
</tr>
</tbody>
</table>
Expand All @@ -530,9 +530,9 @@
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>dict</em>) – ‘CDS’ part of the initial JSON</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">title</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">title or None if it was not found</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str or NoneType</td>
</tr>
</tbody>
</table>
Expand Down
36 changes: 18 additions & 18 deletions Docs/build/html/_modules/055_documents2TTL/documents2ttl.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :param data: &#39;CDS&#39; part of the initial JSON</span>
<span class="sd"> :type data: dict</span>

<span class="sd"> :return: CDS internal report number</span>
<span class="sd"> :rtype: unicode</span>
<span class="sd"> :return: CDS internal report number or None if it was not found</span>
<span class="sd"> :rtype: unicode or NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="s1">&#39;report_number&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
<span class="n">report_number</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;report_number&#39;</span><span class="p">)</span>
Expand All @@ -347,8 +347,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :param data: &#39;CDS&#39; part of the initial JSON</span>
<span class="sd"> :type data: dict</span>

<span class="sd"> :return: report number</span>
<span class="sd"> :rtype: unicode</span>
<span class="sd"> :return: report number or None if it was not found</span>
<span class="sd"> :rtype: unicode or NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="s1">&#39;report_number&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
<span class="n">report_number</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;report_number&#39;</span><span class="p">)</span>
Expand All @@ -369,8 +369,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :param json_data: &#39;GLANCE&#39; part of the initial JSON</span>
<span class="sd"> :type json_data: dict</span>

<span class="sd"> :return: parameter value</span>
<span class="sd"> :rtype: str, unicode</span>
<span class="sd"> :return: parameter value or None if it was not found</span>
<span class="sd"> :rtype: str, unicode, NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">param_name</span> <span class="o">==</span> <span class="s1">&#39;id&#39;</span><span class="p">:</span>
<span class="k">return</span> <span class="n">json_data</span><span class="p">[</span><span class="s1">&#39;id&#39;</span><span class="p">]</span>
Expand All @@ -393,8 +393,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :type param_name: str</span>
<span class="sd"> :param json_data: &#39;CDS&#39; part of the initial JSON</span>

<span class="sd"> :return: parameter value</span>
<span class="sd"> :rtype: int, str</span>
<span class="sd"> :return: parameter value or None if it was not found</span>
<span class="sd"> :rtype: int, str, NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">param_name</span> <span class="o">==</span> <span class="s1">&#39;abstract&#39;</span><span class="p">:</span>
<span class="k">return</span> <span class="n">abstract_extraction</span><span class="p">(</span><span class="n">json_data</span><span class="p">)</span>
Expand All @@ -418,8 +418,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :param data: &#39;CDS&#39; part of the initial JSON</span>
<span class="sd"> :type data: dict</span>

<span class="sd"> :return: abstract</span>
<span class="sd"> :rtype: str</span>
<span class="sd"> :return: abstract or None if it was not found</span>
<span class="sd"> :rtype: str or NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">if</span> <span class="s1">&#39;abstract&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
Expand All @@ -442,8 +442,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :param data: &#39;CDS&#39; part of the initial JSON</span>
<span class="sd"> :type data: dict</span>

<span class="sd"> :return: title</span>
<span class="sd"> :rtype: str</span>
<span class="sd"> :return: title or None if it was not found</span>
<span class="sd"> :rtype: str or NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="s1">&#39;title&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
<span class="k">return</span> <span class="n">fix_string</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;title&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;title&#39;</span><span class="p">))</span></div>
Expand All @@ -455,8 +455,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :param data: &#39;CDS&#39; part of the initial JSON</span>
<span class="sd"> :type data: dict</span>

<span class="sd"> :return: CDS id</span>
<span class="sd"> :rtype: int</span>
<span class="sd"> :return: CDS id or None if it was not found</span>
<span class="sd"> :rtype: int or NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="s1">&#39;recid&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;recid&#39;</span><span class="p">))</span></div>
Expand All @@ -468,8 +468,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :param data: &#39;CDS&#39; part of the initial JSON</span>
<span class="sd"> :type data: dict</span>

<span class="sd"> :return: creation date</span>
<span class="sd"> :rtype: str</span>
<span class="sd"> :return: creation date or None if it was not found</span>
<span class="sd"> :rtype: str or NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="s1">&#39;creation_date&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
<span class="k">return</span> <span class="n">fix_string</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;creation_date&#39;</span><span class="p">))</span></div>
Expand All @@ -481,8 +481,8 @@ <h1>Source code for 055_documents2TTL.documents2ttl</h1><div class="highlight"><
<span class="sd"> :param data: &#39;CDS&#39; part of the initial JSON</span>
<span class="sd"> :type data: dict</span>

<span class="sd"> :return: arXiv code</span>
<span class="sd"> :rtype: str</span>
<span class="sd"> :return: arXiv code or None if it was not found</span>
<span class="sd"> :rtype: str or NoneType</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="s1">&#39;primary_report_number&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
<span class="n">report_number</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;primary_report_number&#39;</span><span class="p">)</span>
Expand Down
2 changes: 1 addition & 1 deletion Docs/build/html/searchindex.js

Large diffs are not rendered by default.

Binary file modified Docs/build/pdf/DKB.pdf
Binary file not shown.
36 changes: 18 additions & 18 deletions Utils/Dataflow/055_documents2TTL/documents2ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ def cds_internal_extraction(data):
:param data: 'CDS' part of the initial JSON
:type data: dict
:return: CDS internal report number
:rtype: unicode
:return: CDS internal report number or None if it was not found
:rtype: unicode or NoneType
"""
if 'report_number' in data:
report_number = data.get('report_number')
Expand All @@ -313,8 +313,8 @@ def report_number_extraction(data):
:param data: 'CDS' part of the initial JSON
:type data: dict
:return: report number
:rtype: unicode
:return: report number or None if it was not found
:rtype: unicode or NoneType
"""
if 'report_number' in data:
report_number = data.get('report_number')
Expand All @@ -335,8 +335,8 @@ def glance_parameter_extraction(param_name, json_data):
:param json_data: 'GLANCE' part of the initial JSON
:type json_data: dict
:return: parameter value
:rtype: str, unicode
:return: parameter value or None if it was not found
:rtype: str, unicode, NoneType
"""
if param_name == 'id':
return json_data['id']
Expand All @@ -359,8 +359,8 @@ def cds_parameter_extraction(param_name, json_data):
:type param_name: str
:param json_data: 'CDS' part of the initial JSON
:return: parameter value
:rtype: int, str
:return: parameter value or None if it was not found
:rtype: int, str, NoneType
"""
if param_name == 'abstract':
return abstract_extraction(json_data)
Expand All @@ -384,8 +384,8 @@ def abstract_extraction(data):
:param data: 'CDS' part of the initial JSON
:type data: dict
:return: abstract
:rtype: str
:return: abstract or None if it was not found
:rtype: str or NoneType
"""
result = None
if 'abstract' in data:
Expand All @@ -408,8 +408,8 @@ def title_extraction(data):
:param data: 'CDS' part of the initial JSON
:type data: dict
:return: title
:rtype: str
:return: title or None if it was not found
:rtype: str or NoneType
"""
if 'title' in data:
return fix_string(data.get('title').get('title'))
Expand All @@ -421,8 +421,8 @@ def cds_id_extraction(data):
:param data: 'CDS' part of the initial JSON
:type data: dict
:return: CDS id
:rtype: int
:return: CDS id or None if it was not found
:rtype: int or NoneType
"""
if 'recid' in data:
return int(data.get('recid'))
Expand All @@ -434,8 +434,8 @@ def creation_date_extraction(data):
:param data: 'CDS' part of the initial JSON
:type data: dict
:return: creation date
:rtype: str
:return: creation date or None if it was not found
:rtype: str or NoneType
"""
if 'creation_date' in data:
return fix_string(data.get('creation_date'))
Expand All @@ -447,8 +447,8 @@ def arxiv_extraction(data):
:param data: 'CDS' part of the initial JSON
:type data: dict
:return: arXiv code
:rtype: str
:return: arXiv code or None if it was not found
:rtype: str or NoneType
"""
if 'primary_report_number' in data:
report_number = data.get('primary_report_number')
Expand Down

0 comments on commit be3827c

Please sign in to comment.