# # Collective Knowledge (index of CK packages) # # See CK LICENSE.txt for licensing details # See CK COPYRIGHT.txt for copyright details # # Developer: Grigori Fursin # cfg={} # Will be updated by CK (meta description of this module) work={} # Will be updated by CK (temporal data) ck=None # Will be updated by CK (initialized CK kernel) # Local settings ############################################################################## # Initialize module def init(i): """ Input: {} Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ return {'return':0} ############################################################################## # add index def add_index(i): """ Input: { dict - index dict meta - original CK entry meta } Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ import copy d=i['dict'] m=i['meta'] dd=d.get('dict',{}) if 'misc' not in d: d['misc']={} misc=d['misc'] repo_url1_full=misc.get('repo_url1','') data_uoa=misc.get('data_uoa','') data_uid=misc.get('data_uid','') module_uoa=misc.get('module_uoa','') module_uid=misc.get('module_uid','') soft_uoa=dd.get('soft_uoa','') # Attempt to load Soft UOA r=ck.access({'action':'load', 'module_uoa':cfg['module_deps']['soft'], 'data_uoa':soft_uoa}) if r['return']==0: ds=r['dict'] soft_uoa=r['data_uoa'] soft_uid=r['data_uid'] misc['soft_uid']=soft_uid misc['soft_name']=ds.get('soft_name','') misc['soft_uoa']=soft_uoa cus=dd.get('customize',{}) xhos=dd.get('only_for_host_os_tags',[]) xtos=dd.get('only_for_target_os_tags',[]) tmpl=dd.get('template','') template=dd.get('template_type','') if tmpl=='yes' and template=='': template='yes' misc['template']=template tags=dd.get('tags',[]) ytags=','.join(tags) misc['tags']=tags misc['stags']=ytags yhos='' ytos='' for q in xhos: if yhos!='': yhos+=',' yhos+=q for q in xtos: if ytos!='': ytos+=',' ytos+=q if yhos=='': yhos='any' else: yhos=yhos.replace('linux','linux,macos') if ytos=='': ytos='any' else: ytos=ytos.replace('linux','linux,macos') misc['host_os']=yhos misc['target_os']=ytos return {'return':0} ############################################################################## # generate html def html(i): """ Input: { (skip_cid_predix) - if 'yes', skip "?cid=" prefix when creating URLs } Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ d=i.get('dict',{}) scp=i.get('skip_cid_prefix','') bscp=(scp=="yes") llm=d.get('meta',{}) llmisc=llm.get('misc',{}) lldict=llm.get('dict',{}) template=llmisc.get('template','') repo_url1=llmisc.get('repo_url1','') repo_url2=llmisc.get('repo_url2','') repo_url3=llmisc.get('repo_url3','') desc=llmisc.get('soft_name','') soft_uoa=llmisc.get('soft_uoa','') soft_uid=llmisc.get('soft_uid','') cus=lldict.get('customize','') ver=cus.get('version','') duoa=llmisc.get('data_uoa','') duid=llmisc.get('data_uid','') ruoa=llmisc.get('repo_uoa','') ruid=llmisc.get('repo_uid','') muoa=llmisc.get('module_uoa','') h='' if desc!='': h+=' - '+desc+'\n' host_os=llmisc.get('host_os','') target_os=llmisc.get('target_os','') stags=llmisc.get('stags','').replace(',',', ') h='' if desc!='': h+=' - '+desc+'\n' run_cmds=lldict.get('run_cmds',{}) h+='
\n' if ver!='': h+='Version: '+ver+'
\n' url0=i.get('url','') x1='' x2='' if url0!='' and ruid!='': prfx='' if not bscp: prfx='cid=' x1='' x2='' h+='Repo name: '+x1+ruoa+x2+'
\n' to_get=llmisc.get('to_get','') if to_get!='': h+='How to get: '+to_get+'
\n' if soft_uoa!='': x1='' x2='' if soft_uid!='': prfx='' if not bscp: prfx='cid=' x1='' x2='' h+='Soft plugin: '+x1+soft_uoa+x2+'
\n' if template!='': h+='Template: '+template+'
\n' h+='Host OS: '+host_os+'
\n' h+='Target OS: '+target_os+'
\n' h+='Tags: '+stags+'
\n' h+='
\n' h1='' if repo_url3!='': h1+='[ CK code ] \n' if repo_url2!='': h1+='[ CK meta ]\n' return {'return':0, 'html':h, 'html1':h1} ############################################################################## # index components def index(i): """ Input: { (data_uoa) - specific component to index (otherwise check all) (share) - if 'yes', add to Git } Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ # Clean input to pass to component for k in ['cids', 'cid', 'xcids']: if k in i: del(i[k]) duoa=i.get('data_uoa','') i['module_uoa']=cfg['module_deps']['component'] i['data_uoa']=work['self_module_uid'] i['component_uoa']=duoa return ck.access(i) ############################################################################## # find specific components def get(i): """ Input: { (data_uoa) - if not UID, search for specific UOA inside dicts (s) or (string) - search string (all) - if 'yes', show repo and path } Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ # Clean input to pass to component for k in ['cids', 'cid', 'xcids']: if k in i: del(i[k]) duoa=i.get('data_uoa','') i['action']='get_from_cmd' i['module_uoa']=cfg['module_deps']['component'] i['data_uoa']=work['self_module_uid'] i['component_uoa']=duoa return ck.access(i)