From: MyungJoo Ham Date: Thu, 13 Apr 2017 11:08:33 +0000 (+0900) Subject: [TIC-Core] handle dscription data, show other blocks in block X-Git-Tag: v20170428~10 X-Git-Url: http://review.tizen.org/git/?p=archive%2F20170607%2Ftools%2Ftic-core.git;a=commitdiff_plain;h=54fc68208a16636f09154ad2ccbdd980441ca7c2 [TIC-Core] handle dscription data, show other blocks in block These are emergency implementation for TDC demo/keynotes The syntax (__KS_URL__, __EXPAND__) can be changed later. 1. %description / __KS_URL__: URL allows to link KS (to extract ks script except for %packages) from a block. TODO: if there are two blocks with ks, ignore one with warning. (and warning at choose) TODO: apply the content from the URL to recipe for MIC 2. %description / __EXPAND__ allows to expand the block by default at the load of TIC TODO: in, __EXPAND: {str}, handle {str} AFTER filter-tab is implemented 3. Allow to show blocks that is not children. Change-Id: If9e7b9ad92aa65b6e0f1d894a588b85bc2905bc3 Signed-off-by: MyungJoo Ham --- diff --git a/tic/parser/view_parser.py b/tic/parser/view_parser.py index 9e6419b..59603b4 100644 --- a/tic/parser/view_parser.py +++ b/tic/parser/view_parser.py @@ -1,4 +1,6 @@ import logging +import requests +import re from operator import itemgetter from tic.utils.rpmmisc import meetRequireVersion @@ -26,8 +28,10 @@ def make_view_data(pkg_group): def set_meta_require(meta_info): meta_nodes = meta_info.get('nodes') + children = set() for child_meta in meta_nodes: set_meta_require(child_meta) + children.add(child_meta['metaname']) duplicate = set() pkg_info = pkg_dict[meta_info['metaname']] @@ -48,19 +52,29 @@ def make_view_data(pkg_group): for pkg in targets: # The meta-pkg of the other group are excluded. - if not pkg.get('meta') and pkg['name'] not in duplicate: + if pkg['name'] not in duplicate: refer_count[pkg['id']] += 1 duplicate.add(pkg['name']) - meta_nodes.append(make_node(pkg, meta_info.get('category'))) + + if pkg.get('meta'): + if not pkg['name'] in children: + meta_nodes.append(make_linked_meta_node(pkg['name'], pkg['summary'])) + else: + meta_nodes.append(make_node(pkg, meta_info.get('category'))) # Added 'zz' to non meta-package because they are to be listed last - meta_nodes = sorted(meta_nodes, key = lambda k: k['metaname'] if 'metaname' in k else 'zz'+k['text']) - meta_info['nodes'] = meta_nodes + meta_nodes = sorted(meta_nodes, key = lambda k: 'aa'+k['metaname'] if 'metaname' in k else 'zz'+k['text']) + meta_info['nodes'] = meta_nodes + + if meta_info['metaname'] =='building-blocks-sub2-Preset_iot-examples-3_RPI3_headless_devboard': + print(pkg_info) def make_node(pkg_info, category=None): n = dict(text=pkg_info['name'], nodes=[]) if category: n['category'] = category return n def make_meta_node(pkgname, viewtext): return dict(text=viewtext, metaname=pkgname, nodes=[]) + def make_linked_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): @@ -82,6 +96,42 @@ def make_view_data(pkg_group): else: node['text'] = '' return node + def handle_description(node): + if 'metaname' in node: + name = node['metaname'] + pkg_info = pkg_dict[name] + desc = pkg_info.get('description') + if desc[0:10] == '__KS_URL__': + logger.info("Processing "+name+" for its description: "+pkg_info.get('description')) + # Extract URL from __KS_URL__ + ksURL = desc[11:].splitlines()[0].strip() + # Omit the first line with __KS_URL__ from showing. + pkg_info['description'] = desc[len(desc.splitlines(True)[0]):] + + # Search for filename if directory is given + # e.g., Convert http://a.com/a/ to https://a.com/a/blahblah.ks + # Works for file-indexing html + if ksURL[-3:].lower() != ".ks": + if ksURL[-1:] != "/": + ksURL += "/" + r = requests.get(ksURL) + m = re.search('>([^<]*\\.ks)\\s*<', r.text) + if not m.group(1): + m = re.search('"([^"]*\\.ks)\\s*"', r.text) + if not m.group(1): + m = re.search("'([^']*\\.ks)\\s*'", r.text) + if not m.group(1): + node['icon'] = 'glyphicon glyphicon-remove-sign' + node['tooltip'] = 'Cannot find image base from' + ksURL + return node + ksURL += m.group(1) + node['tooltip'] = 'Image base from '+ksURL + node['ks'] = ksURL + elif desc[0:10] == '__EXPAND__': + # Omit the first line with __EXPAND__ from showing. + pkg_info['description'] = desc[len(desc.splitlines(True)[0]):] + node['state'] = { 'expanded': True } + return node # view_data for tree view on web-ui view_data = [] @@ -124,6 +174,7 @@ def make_view_data(pkg_group): if is_blank_ui_meta_node(root[0]): name = root[0] sub1_node = handle_ui_meta_node(name[-2:], root_node) + root_node = handle_description(root_node) view_data.append(root_node) for sub1 in meta_info['sub1']: @@ -132,6 +183,7 @@ def make_view_data(pkg_group): if is_blank_ui_meta_node(sub1[0]): name = sub1[0] sub1_node = handle_ui_meta_node(name[-2:], sub1_node) + sub1_node = handle_description(sub1_node) # search root if sub1[1] in view_ref: # add to root node @@ -148,6 +200,7 @@ def make_view_data(pkg_group): if is_blank_ui_meta_node(sub2[0]): name = sub2[0] sub1_node = handle_ui_meta_node(name[-2:], sub2_node) + sub2_node = handle_description(sub2_node) # search sub1 if sub2[2] in view_ref: if 'category' in view_ref[sub2[2]] and view_ref[sub2[2]]['category']: