Skip to content

Commit

Permalink
📦 v1.0.0 released
Browse files Browse the repository at this point in the history
  • Loading branch information
shaileshmishra authored and shaileshmishra committed Apr 5, 2021
1 parent 883206a commit c2544a8
Show file tree
Hide file tree
Showing 27 changed files with 2,273 additions and 31 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ Contentstack Utils SDK lets you interact with the Content Delivery APIs and retr
To get an embedded item of a single entry, you need to provide the stack API key, environment name, content type’s UID, and entry’s UID. Then, use the `entry.fetch` function as shown below:

```python
import contentstack
import contentstack

stack = contentstack.Stack('api_key','delivery_token','environment')
content_type = stack.content_type("content_type_uid")
entry = content_type.entry("entry_uid")
result = entry.fetch()
if result is not None:
entry = result['entries']
Utils.render(entry, ['rich_text_editor', 'some_other_text'], Option())

```

## Fetch Embedded Item(s) from Multiple Entries
Expand All @@ -82,4 +86,8 @@ To get embedded items from multiple entries, you need to provide the stack API k
stack = contentstack.Stack('api_key','delivery_token','environment')
query = stack.content_type("content_type_uid").query()
result = query.find()
if result is not None and 'entries' in result:
entry = result['entries']
for item in range:
Utils.render(item, ['rich_text_editor', 'some_other_text'], Option())
```
6 changes: 3 additions & 3 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

ENHANCEMENT, NEW FEATURE, BUG RESOLVE

*v0.0.1*
*v0.1.0*
============

**Date: 20-Nov-2020**
**Date: 02-Sept-2021**

- initial release of contentstack utility package
- Initial release of contentstack utility package
25 changes: 0 additions & 25 deletions contentstack_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,3 @@ def get_embedded_objects(html_doc, embedded_obj, callback):
elements = tag.xpath("//*[contains(@class, 'embedded-asset') or contains(@class, 'embedded-entry')]")
metadata = get_metadata(elements)
return get_html_doc(embedded_obj, metadata, callback, html_doc)

# if '_embedded_items' in embedded_obj:
# keys = extract_keys(embedded_obj['_embedded_items'])
# for key in keys:
# items_array = embedded_obj['_embedded_items'][key]
# item = find_embedded_entry(items_array, metadata)
# if item is not None:
# replaceable_str = callback.render_options(item, metadata)
# html_doc = html_doc.replace(metadata.outer_html, replaceable_str)
# break
# return html_doc

# for element in elements:
# content_type = None
# typeof = element.attrib['type']
# if typeof == 'asset':
# uid = element.attrib['data-sys-asset-uid']
# else:
# uid = element.attrib['data-sys-entry-uid']
# content_type = element.attrib['data-sys-content-type-uid']
# style = element.attrib['sys-style-type']
# outer_html = etree.tostring(element).decode('utf-8')
# attributes = element.attrib
# style = Utils.convert_style(style)
# metadata = Metadata(element.text, typeof, uid, content_type, style, outer_html, attributes)
93 changes: 93 additions & 0 deletions coverage/contentstack_utils___init___py.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for contentstack_utils/__init__.py: 100%</title>
<link rel="icon" sizes="32x32" href="favicon_32.png">
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>contentstack_utils/__init__.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
12 statements &nbsp;
<button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">12 run</button>
<button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">0 missing</button>
<button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="com"># pip install -r requirements.txt</span>&nbsp;</span><span class="r"></span></p>
<p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="com"># pytest --html=tests/report/test-report.html</span>&nbsp;</span><span class="r"></span></p>
<p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"><span class="com"># coverage report -m</span>&nbsp;</span><span class="r"></span></p>
<p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="com"># coverage html -d coveragereport</span>&nbsp;</span><span class="r"></span></p>
<p id="t5" class="run"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str">"""</span>&nbsp;</span><span class="r"></span></p>
<p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"><span class="str">The __init__.py files are required to make Python treat the directories as containing</span>&nbsp;</span><span class="r"></span></p>
<p id="t7" class="pln"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="str">packages; this is done to prevent directories with a common name, such as string,</span>&nbsp;</span><span class="r"></span></p>
<p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t"><span class="str">from unintentionally hiding valid modules that occur later on the module search path</span>&nbsp;</span><span class="r"></span></p>
<p id="t9" class="pln"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="str">Used: Safety checks your installed dependencies for known security vulnerabilities</span>&nbsp;</span><span class="r"></span></p>
<p id="t10" class="pln"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="str">file __init__.py contains package information like</span>&nbsp;</span><span class="r"></span></p>
<p id="t11" class="pln"><span class="n"><a href="#t11">11</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t12" class="pln"><span class="n"><a href="#t12">12</a></span><span class="t"><span class="str">__author__, __status__, __version__, __endpoint__ and __email__</span>&nbsp;</span><span class="r"></span></p>
<p id="t13" class="pln"><span class="n"><a href="#t13">13</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t14" class="pln"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="str">`Your code has been rated at 10.00/10`</span>&nbsp;</span><span class="r"></span></p>
<p id="t15" class="pln"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="str">"""</span>&nbsp;</span><span class="r"></span></p>
<p id="t16" class="pln"><span class="n"><a href="#t16">16</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t17" class="run"><span class="n"><a href="#t17">17</a></span><span class="t"><span class="key">from</span> <span class="nam">contentstack_utils</span><span class="op">.</span><span class="nam">embedded</span><span class="op">.</span><span class="nam">item_type</span> <span class="key">import</span> <span class="nam">ItemType</span>&nbsp;</span><span class="r"></span></p>
<p id="t18" class="run"><span class="n"><a href="#t18">18</a></span><span class="t"><span class="key">from</span> <span class="nam">contentstack_utils</span><span class="op">.</span><span class="nam">embedded</span><span class="op">.</span><span class="nam">styletype</span> <span class="key">import</span> <span class="nam">StyleType</span>&nbsp;</span><span class="r"></span></p>
<p id="t19" class="run"><span class="n"><a href="#t19">19</a></span><span class="t"><span class="key">from</span> <span class="nam">contentstack_utils</span><span class="op">.</span><span class="nam">helper</span><span class="op">.</span><span class="nam">metadata</span> <span class="key">import</span> <span class="nam">Metadata</span>&nbsp;</span><span class="r"></span></p>
<p id="t20" class="run"><span class="n"><a href="#t20">20</a></span><span class="t"><span class="key">from</span> <span class="nam">contentstack_utils</span><span class="op">.</span><span class="nam">render</span><span class="op">.</span><span class="nam">options</span> <span class="key">import</span> <span class="nam">Options</span>&nbsp;</span><span class="r"></span></p>
<p id="t21" class="run"><span class="n"><a href="#t21">21</a></span><span class="t"><span class="key">from</span> <span class="nam">contentstack_utils</span><span class="op">.</span><span class="nam">utils</span> <span class="key">import</span> <span class="nam">Utils</span>&nbsp;</span><span class="r"></span></p>
<p id="t22" class="pln"><span class="n"><a href="#t22">22</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t23" class="run"><span class="n"><a href="#t23">23</a></span><span class="t"><span class="nam">__title__</span> <span class="op">=</span> <span class="str">'contentstack_utils'</span>&nbsp;</span><span class="r"></span></p>
<p id="t24" class="run"><span class="n"><a href="#t24">24</a></span><span class="t"><span class="nam">__author__</span> <span class="op">=</span> <span class="str">'contentstack'</span>&nbsp;</span><span class="r"></span></p>
<p id="t25" class="run"><span class="n"><a href="#t25">25</a></span><span class="t"><span class="nam">__status__</span> <span class="op">=</span> <span class="str">'debug'</span>&nbsp;</span><span class="r"></span></p>
<p id="t26" class="run"><span class="n"><a href="#t26">26</a></span><span class="t"><span class="nam">__version__</span> <span class="op">=</span> <span class="str">'0.0.1'</span>&nbsp;</span><span class="r"></span></p>
<p id="t27" class="run"><span class="n"><a href="#t27">27</a></span><span class="t"><span class="nam">__endpoint__</span> <span class="op">=</span> <span class="str">'cdn.contentstack.io'</span>&nbsp;</span><span class="r"></span></p>
<p id="t28" class="run"><span class="n"><a href="#t28">28</a></span><span class="t"><span class="nam">__contact__</span> <span class="op">=</span> <span class="str">'[email protected]'</span>&nbsp;</span><span class="r"></span></p>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v5.5</a>,
created at 2021-03-12 21:42 +0530
</p>
</div>
</div>
</body>
</html>
85 changes: 85 additions & 0 deletions coverage/contentstack_utils_embedded_item_type_py.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for contentstack_utils/embedded/item_type.py: 100%</title>
<link rel="icon" sizes="32x32" href="favicon_32.png">
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>contentstack_utils/embedded/item_type.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
4 statements &nbsp;
<button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">4 run</button>
<button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">0 missing</button>
<button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">"""</span>&nbsp;</span><span class="r"></span></p>
<p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str">ItemType is Enumeration class that conatains two options for ItemType:</span>&nbsp;</span><span class="r"></span></p>
<p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="str">ASSET</span>&nbsp;</span><span class="r"></span></p>
<p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"><span class="str">ENTRY</span>&nbsp;</span><span class="r"></span></p>
<p id="t7" class="pln"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="str">"""</span>&nbsp;</span><span class="r"></span></p>
<p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">enum</span>&nbsp;</span><span class="r"></span></p>
<p id="t10" class="pln"><span class="n"><a href="#t10">10</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t11" class="pln"><span class="n"><a href="#t11">11</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t12" class="run"><span class="n"><a href="#t12">12</a></span><span class="t"><span class="key">class</span> <span class="nam">ItemType</span><span class="op">(</span><span class="nam">enum</span><span class="op">.</span><span class="nam">Enum</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
<p id="t13" class="pln"><span class="n"><a href="#t13">13</a></span><span class="t"> <span class="str">"""</span>&nbsp;</span><span class="r"></span></p>
<p id="t14" class="pln"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="str"> Contains Two option for ItemsType</span>&nbsp;</span><span class="r"></span></p>
<p id="t15" class="pln"><span class="n"><a href="#t15">15</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
<p id="t16" class="pln"><span class="n"><a href="#t16">16</a></span><span class="t"><span class="str"> ENTRY</span>&nbsp;</span><span class="r"></span></p>
<p id="t17" class="pln"><span class="n"><a href="#t17">17</a></span><span class="t"><span class="str"> ASSET</span>&nbsp;</span><span class="r"></span></p>
<p id="t18" class="pln"><span class="n"><a href="#t18">18</a></span><span class="t"><span class="str"> """</span>&nbsp;</span><span class="r"></span></p>
<p id="t19" class="run"><span class="n"><a href="#t19">19</a></span><span class="t"> <span class="nam">ENTRY</span> <span class="op">=</span> <span class="str">'entry'</span>&nbsp;</span><span class="r"></span></p>
<p id="t20" class="run"><span class="n"><a href="#t20">20</a></span><span class="t"> <span class="nam">ASSET</span> <span class="op">=</span> <span class="str">'asset'</span>&nbsp;</span><span class="r"></span></p>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v5.5</a>,
created at 2021-03-12 21:42 +0530
</p>
</div>
</div>
</body>
</html>
Loading

0 comments on commit c2544a8

Please sign in to comment.