Skip to content

Commit 4a49743

Browse files
shaileshmishrashaileshmishra
authored andcommitted
initial push
1 parent 5beb046 commit 4a49743

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

contentstack/utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
[type]: [description]
1010
"""
1111

12-
1312
import json
1413

1514
from lxml import etree
@@ -35,6 +34,7 @@ class Utils:
3534
FileNotFoundError: [description]
3635
NameError: [description]
3736
"""
37+
3838
@staticmethod
3939
def render(entry_obj, key_path: list, option_callback: OptionsCallback):
4040
valid = _is_json(entry_obj)
@@ -106,7 +106,7 @@ def _get_content(keys_array: list, entry, option_callback: OptionsCallback):
106106
Utils._get_content(keys_array, node, option_callback)
107107

108108
@staticmethod
109-
def render_content(rte_array, embed_entry: dict,
109+
def render_content(rte_array, embed_obj: dict,
110110
option_callback: OptionsCallback) -> object:
111111
if isinstance(rte_array, str):
112112
# convert to html
@@ -118,12 +118,16 @@ def render_content(rte_array, embed_entry: dict,
118118
return None
119119

120120
@staticmethod
121-
def get_embedded_objects(html_doc, metadata: Metadata):
121+
def get_embedded_objects(html_doc):
122122
tag = etree.fromstring(html_doc)
123-
print(tag)
123+
typeof = tag.attrib['type']
124+
uid = tag.attrib['data-sys-entry-uid']
125+
content_type = tag.attrib['data-sys-content-type-uid']
126+
style = tag.attrib['sys-style-type']
127+
# outer_html = tag.attrib['outer_html']
124128
# Elements embeddedEntries = html.body().getElementsByClass("embedded-entry");
125129
# Elements embeddedAssets = html.body().getElementsByClass("embedded-asset");
126-
130+
metadata = Metadata('text', typeof, uid, content_type, style, 'outer_html', 'attributes')
127131
return tag, metadata
128132

129133
@staticmethod

tests/test_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import unittest
3-
import os
3+
44
from contentstack.embedded.style_type import StyleType
55
from contentstack.helper.metadata import Metadata
66
from contentstack.render.options import OptionsCallback
@@ -41,7 +41,7 @@ def test_embedded_objects(self):
4141
'type=\"entry\"></div>'
4242
metadata = Metadata('text_example', 'entry', 'blt647367443', 'products', StyleType.BLOCK, 'outer_html',
4343
'attributes')
44-
html, meta = Utils.get_embedded_objects(html_string, metadata=metadata)
44+
html, meta = Utils.get_embedded_objects(html_string)
4545
print(html, meta)
4646

4747
def test_embedded_rte_string(self):
@@ -53,5 +53,5 @@ def test_embedded_rte_string(self):
5353
"data-sys-asset-contenttype=\"image/jpeg\" type=\"asset\" sys-style-type=\"display\"></figure> "
5454
metadata = Metadata('text_example', 'entry', 'blt647367443', 'products', StyleType.BLOCK, 'outer_html',
5555
'attributes')
56-
html, meta = Utils.get_embedded_objects(html_text, metadata)
56+
html, meta = Utils.get_embedded_objects(html_text)
5757
print(html, meta)

0 commit comments

Comments
 (0)