def access(i):

    """
    Input:  Can be dictionary or string (string will be converted to dictionary)

            {
               action

               module_uoa or CID -> converted to cid
                 or
               (cid1)            -  if doesn't have = and doesn't start from -- or - or @ -> appended to cids[]
               (cid2)            -  if doesn't have = and doesn't start from -- or - or @ -> appended to cids[]
               (cid3)            -  if doesn't have = and doesn't start from -- or - or @ -> appended to cids[]
                 or
               (repo_uoa)
               (module_uoa)
               (data_uoa)

               (out=type)     Module output
                              == ''              - none
                              == 'con'           - console interaction (if from CMD, default)
                              == 'json'          - return dict as json to console
                              == 'json_with_sep' - separation line and return dict as json to console
                              == 'json_file'     - return dict as json to file

               (out_file)     Output file if out=='json_file'

               (con_encoding) - force encoding for IO
               (ck_profile)   - if 'yes', profile CK

               INPUT TO A GIVEN FUNCTION


               NOTE: If INPUT is a string and it will be converted to INPUT dictionary as follows (the same as CK command line):

                     ck key1=value1    -> converted to {key1:value1}

                        -key10         -> converted to {key10:"yes"}
                        -key11=value11 -> converted to {key11:value11}

                        --key12         -> converted to {key12:"yes"}
                        --key13=value13 -> converted to {key13:value13}


                     @file_json         -> JSON from this file will be merged with INPUT
                     @@                 -> CK will ask user ot enter manually JSON from console and merge with INPUT
                     @@key              -> Enter JSON manually from console and merge with INPUT under this key

                     @@@cmd_json        -> convert string to JSON (special format) and merge with INPUT

                     -- xyz             -> add everything after -- to "unparsed_cmd" key in INPUT

                     When string is converted to INPUT dictionary, "cmd" variable is set to True
            }

    Output: {
              return       - return code =  0, if successful
                                         >  0, if error
              (error)      - error text if return > 0

              OUTPUT FROM A GIVEN FUNCTION
            }

    """

    global con_encoding

#    # Set fresh configuration for each access - very costly
#    if cfg.get('loading_config','') == '':
#        cfg['loading_config'] = 'yes'
#        r=access({'action':'load',
#                  'repo_uoa':cfg['repo_name_default'],
#                  'module_uoa':cfg['subdir_kernel'],
#                  'data_uoa':cfg['subdir_kernel_default']})
#        if r['return']==0:
#           cfg.update(r['dict'])
#
#        r=access({'action':'load',
#                  'repo_uoa':cfg['repo_name_local'],
#                  'module_uoa':cfg['subdir_kernel'],
#                  'data_uoa':cfg['subdir_kernel_default']})
#        if r['return']==0:
#           cfg.update(r['dict'])
#        cfg['loading_config'] = ''

    rr={'return':0}
    ii={}
    cmd=False
    o=''

    ### If input is string, split into list and process in the next condition
    if type(i)==str:
       cmd=True
       x=i.split(' ')
       i=x 

    ### If input is a list
    if type(i)==list:
       if len(i)==1 and i[0].strip()=='test_install':
          return rr # installation test

       cmd=True
       rr=convert_ck_list_to_dict(i)
       if rr['return']==0:
          i=rr.get('ck_dict',{})

          if i.get('out','')=='': i['out']='con' # Default output is console 
                                                 # if called from CMD or with string

    o=''
    if rr['return']==0:
       # Check output mode
       o=i.get('out','')

       ### If profile
       cp=i.get('ck_profile','')
       if cp=='yes':
          import time
          start_time = time.time()

       ### Process request ######################################

       if i.get('con_encoding','')!='': con_encoding=i['con_encoding']

       ### Process action ###################################
       rr=init({})
       if rr['return']==0:
          # Run module with a given action
          rr=perform_action(i)
          if rr.get('out','')!='': o=rr['out']

       if cp=='yes':
          elapsed_time=time.time()-start_time
          rr['ck_profile_time']=elapsed_time
          if o=='con':
             out('CK profile time: '+str(elapsed_time)+' sec.')

    # Finalize call (check output) ####################################
    if o=='json' or o=='json_with_sep':
       if o=='json_with_sep': out(cfg['json_sep'])

       rr1=dumps_json({'dict':rr})
       if rr1['return']==0:
          s=rr1['string']
          out(s)

    elif o=='json_file':
       fn=i.get('out_file','')
       if fn=='':
          rr['return']=1
          rr['error']='out==json_file but out_file is not defined in kernel access function'
       else:
          rr1=save_json_to_file({'json_file':fn, 'dict':rr})
          if rr1['return']>0:
             rr['return']=1
             rr['error']=rr1['error']

    # If error and CMD, output error to console
    if cmd:
       if rr['return']>0:
          x=''
          if type(i)==dict:
             x=i.get('module_uoa','')
             if x!='':
                x='['+x+'] '
          out(cfg['error']+x+rr['error']+'!')

    return rr
Input:  Can be dictionary or string (string will be converted to dictionary)

            {
               action

               module_uoa or CID -> converted to cid
                 or
               (cid1)            -  if doesn't have = and doesn't start from -- or - or @ -> appended to cids[]
               (cid2)            -  if doesn't have = and doesn't start from -- or - or @ -> appended to cids[]
               (cid3)            -  if doesn't have = and doesn't start from -- or - or @ -> appended to cids[]
                 or
               (repo_uoa)
               (module_uoa)
               (data_uoa)

               (out=type)     Module output
                              == ''              - none
                              == 'con'           - console interaction (if from CMD, default)
                              == 'json'          - return dict as json to console
                              == 'json_with_sep' - separation line and return dict as json to console
                              == 'json_file'     - return dict as json to file

               (out_file)     Output file if out=='json_file'

               (con_encoding) - force encoding for IO
               (ck_profile)   - if 'yes', profile CK

               INPUT TO A GIVEN FUNCTION


               NOTE: If INPUT is a string and it will be converted to INPUT dictionary as follows (the same as CK command line):

                     ck key1=value1    -> converted to {key1:value1}

                        -key10         -> converted to {key10:"yes"}
                        -key11=value11 -> converted to {key11:value11}

                        --key12         -> converted to {key12:"yes"}
                        --key13=value13 -> converted to {key13:value13}


                     @file_json         -> JSON from this file will be merged with INPUT
                     @@                 -> CK will ask user ot enter manually JSON from console and merge with INPUT
                     @@key              -> Enter JSON manually from console and merge with INPUT under this key

                     @@@cmd_json        -> convert string to JSON (special format) and merge with INPUT

                     -- xyz             -> add everything after -- to "unparsed_cmd" key in INPUT

                     When string is converted to INPUT dictionary, "cmd" variable is set to True
            }

    Output: {
              return       - return code =  0, if successful
                                         >  0, if error
              (error)      - error text if return > 0

              OUTPUT FROM A GIVEN FUNCTION
            }