Example #1
0
def find_tag_content(tags, lis):
    l = {}
    for tag in tags:
        for index, ta in enumerate(lis):
            converted_tag = re.sub(r'\.(.*)', r'(\1)', tag)
            if ta.endswith(converted_tag + ':'):
                content = ParseHelper.remove_quotes(lis[index + 1])
                l.update({tag: content})
                break

    return l
Example #2
0
def find_tag_content(tags, lis):
    l = {}
    for tag in tags:
        for index, ta in enumerate(lis):
            converted_tag = re.sub(r'\.(.*)', r'(\1)', tag)
            if ta.endswith(converted_tag + ':'):
                content = ParseHelper.remove_quotes(lis[index + 1])
                l.update({tag: content})
                break

    return l
Example #3
0
            out_html_diag += '->' + tag

    # print tag_seperation
    print out_html_diag
    #print tags_and_spaces
    tags_in_same_depth = [
        (key, [i[1] for i in group]) for key, group in groupby(
            sorted(tags_and_spaces, key=lambda x: x[0]), lambda x: x[0])
    ][::-1]
    '''Finding the parent tags'''
    ptag_tag = []
    for index, tags in tags_in_same_depth:

        for tag in tags:
            ptag_tag.append(
                (ParseHelper.find_parent(tag, out_html_diag), tag, index))
    # Main change
    tags_having_common_parent = [
        (key, [str(i[2]) + i[1] for i in group])
        for key, group in groupby(ptag_tag, lambda x: x[0])
    ]
    tags_having_common_parent_with_spaces = [
        (i[1], i[2]) for key, group in groupby(ptag_tag, lambda x: x[0])
        for i in group
    ]
    #print tags_having_common_parent_with_spaces
    '''Building the final html'''
    final_html_dict = {}
    for parent, tags in tags_having_common_parent[:-1]:
        final_html = ''
        for tag in tags:
Example #4
0
        else:
            i = index
            out_html_diag += '->' + tag

    # print tag_seperation
    print out_html_diag
    #print tags_and_spaces
    tags_in_same_depth = [(key, [i[1] for i in group]) for key, group in
                          groupby(sorted(tags_and_spaces, key=lambda x: x[0]), lambda x: x[0])][::-1]

    '''Finding the parent tags'''
    ptag_tag = []
    for index, tags in tags_in_same_depth:

        for tag in tags:
            ptag_tag.append((ParseHelper.find_parent(tag, out_html_diag), tag, index))
    # Main change
    tags_having_common_parent = [(key, [str(i[2]) + i[1] for i in group]) for key, group in groupby(ptag_tag, lambda x: x[0])]
    tags_having_common_parent_with_spaces = [(i[1], i[2]) for key, group in groupby(ptag_tag, lambda x: x[0]) for i in group]
    #print tags_having_common_parent_with_spaces

    '''Building the final html'''
    final_html_dict = {}
    for parent, tags in tags_having_common_parent[:-1]:
        final_html = ''
        for tag in tags:
            final_html += ParseHelper.extract_attributes(tag)
        if parent:
            parent_html = ParseHelper.extract_attributes(parent)
            final_html = re.sub(r'\{\[ .*? \]\}', final_html, parent_html)
            final_html_dict[parent] = final_html