From 9db41777008e06ac8800a6001047e7fe8bdca76a Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Wed, 12 Apr 2017 19:22:41 +0900 Subject: [TIC-Core] Allow to express UI elements within package list with UI meta blocks If a meta package name ends with "__UI__xx", it is a UI meta block. xx denotes for the UI element it stands for: - BR/br: blank line - HR/hr:
- SD/sd: shade (not tested) - SM/sm: Summary text message - HT/ht: HTML code from summary message (not tested) Change-Id: Ife75da45f642be998910e23b9cd2b0b11da49d1c Signed-off-by: MyungJoo Ham --- tic/parser/view_parser.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tic/parser/view_parser.py b/tic/parser/view_parser.py index a35c94d..9e6419b 100644 --- a/tic/parser/view_parser.py +++ b/tic/parser/view_parser.py @@ -61,6 +61,27 @@ def make_view_data(pkg_group): return n def make_meta_node(pkgname, viewtext): return dict(text=viewtext, metaname=pkgname, nodes=[]) + def is_blank_ui_meta_node(pkgname): + return (pkgname[-8:-2] == '__UI__') + def handle_ui_meta_node(tag, node): + node['selectable'] = False + node['hideCheckbox'] = True + if tag == 'BR' or tag == 'br': + node['text'] = '' + elif tag == 'HR' or tag == 'hr': + node['text'] = '
' + elif tag == 'SD' or tag == 'sd': + node['text'] = '' + node['backColor'] = '#101010' + elif tag == 'SM' or tag == 'sm': + # Keep the summary text + node['text'] = node['text'] + elif tag == 'HT' or tag == 'ht': + # Keep the summary (TODO: verify the usage of HTML tags.) + node['text'] = node['text'] # Do we need conversion? + else: + node['text'] = '' + return node # view_data for tree view on web-ui view_data = [] @@ -86,7 +107,7 @@ def make_view_data(pkg_group): if meta_info.get('category'): for category in meta_info['category']: c_rpm = pkg_dict[category[0]] - if hasattr(c_rpm.get('suggests'), '__iter__'): + if hasattr(c_rpm.get('suggests'), '__iter__'): for suggest in c_rpm.get('suggests'): category_dict[suggest['name']] = category[1] else: @@ -100,11 +121,17 @@ def make_view_data(pkg_group): view_ref[root[0]] = root_node if root[0] in category_dict: root_node['category'] = category_dict[root[0]] + if is_blank_ui_meta_node(root[0]): + name = root[0] + sub1_node = handle_ui_meta_node(name[-2:], root_node) view_data.append(root_node) for sub1 in meta_info['sub1']: sub1_node = make_meta_node(sub1[0], sub1[2]) view_ref[sub1[0]] = sub1_node + if is_blank_ui_meta_node(sub1[0]): + name = sub1[0] + sub1_node = handle_ui_meta_node(name[-2:], sub1_node) # search root if sub1[1] in view_ref: # add to root node @@ -118,6 +145,9 @@ def make_view_data(pkg_group): for sub2 in meta_info['sub2']: sub2_node = make_meta_node(sub2[0], sub2[3]) view_ref[sub2[0]] = sub2_node + if is_blank_ui_meta_node(sub2[0]): + name = sub2[0] + sub1_node = handle_ui_meta_node(name[-2:], sub2_node) # search sub1 if sub2[2] in view_ref: if 'category' in view_ref[sub2[2]] and view_ref[sub2[2]]['category']: -- cgit v1.2.3