CK Python package

Submodules

ck.files module

ck.files.load_json_file(i)[source]

Desc: Load json from file into dict

Target: end users

Input: {

json_file - name of file with json

}

Output: {
return - return code = 0, if successful

= 16, if file not found (may be warning) > 0, if error

(error) - error text if return > 0

dict - dict from json file

}

ck.files.load_text_file(i)[source]

Desc: Load text file into string or list

Target: end users

Input: {

text_file - name of text file (keep_as_bin) - if ‘yes’, return only bin (encoding) - by default ‘utf8’, however sometimes we use utf16

(split_to_list) - if ‘yes’, split to list

(convert_to_dict) - if ‘yes’, split to list and convert to dict (str_split) - if !=’’, use as separator of keys/values when converting to dict (remove_quotes) - if ‘yes’, remove quotes from values when converting to dict

(delete_after_read) - if ‘yes’, delete file after read (useful when reading tmp files)

}

Output: {
return - return code = 0, if successful

= 16, if file not found (may be warning) > 0, if error

(error) - error text if return > 0

bin - bin (string) - loaded text (with removed

)

(lst) - if split_to_list==’yes’, return as list (dict) - if convert_to_dict==’yes’, return as dict

}

ck.files.load_yaml_file(i)[source]

Desc: Load YAML from file into dict

Target: end users

Input: {

yaml_file - name of YAML file

}

Output: {
return - return code = 0, if successful

= 16, if file not found (may be warning) > 0, if error

(error) - error text if return > 0

dict - dict from YAML file

}

ck.files.save_json_to_file(i)[source]

Desc: Save dict as json file

Target: end users

Input: {

json_file - file name dict - dict to save (sort_keys) - if ‘yes’, sort keys (safe) - if ‘yes’, ignore non-JSON values (only for Debugging - changes original dict!)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.files.save_text_file(i)[source]

Desc: save string to text file

Target: end users

Input: {

text_file - name of text file string - string to write (with removed

)

(append) - if ‘yes’, append

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.files.save_yaml_to_file(i)[source]

Desc: Save dict as yaml file

Target: end users

Input: {

yaml_file - file name dict - dict to save

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel module

ck.kernel.access(i)[source]

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

}

ck.kernel.access_index_server(i)[source]
Input: {

request - request type (‘PUT’ | ‘DELETE’ | ‘TEST’ | ‘GET’) (path) - path (dict) - query as dict to send (limit_size) - limit queries with this number (if ‘GET’) (start_from) - start from a given entry in a query

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

dict - returned dict

}

ck.kernel.add(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA (data_uid) - data UID (if uoa is an alias) (data_name) - user friendly data name

(dict_from_cid) - (dict_from_repo_uoa) - (dict_from_module_uoa) - (dict_from_data_uoa) - if present, pre-load dict

from this (module_uoa):data_uoa (analog of copy)

(update) - if == ‘yes’ and entry exists, update it

(dict) - meta description to record (substitute) - if ‘yes’ and update==’yes’ substitute dictionaries, otherwise merge!

(desc) - description of an entry (gradually adding API description in flat format)

(extra_json_files) - dict with extra json files to save to entry (key is a filename)

(tags) - list or comma separated list of tags to add to entry

(info) - entry info to record - normally, should not use it! (extra_info) - enforce extra info such as

author author_email author_webpage license copyright

If not specified then taken from kernel (prefix ‘default_’)

(updates) - entry updates info to record - normally, should not use it! (ignore_update) - if ‘yes’, do not add info about update

(ask) - if ‘yes’, ask questions, otherwise silent

(unlock_uid) - unlock UID if was previously locked

(sort_keys) - by default, ‘yes’

(share) - if ‘yes’, try to add via GIT

(skip_indexing) - if ‘yes’, skip indexing even if it is globally on

(allow_multiple_aliases) - if ‘yes’, allow multiple aliases for the same UID

(needed for cKnowledge.io to publish renamed components with the same UID)

}

Output: {
return - return code = 0, if successful

16, if entry already exists

> 0, if error

(error) - error text if return > 0

Output from the ‘create_entry’ function

}

ck.kernel.add_action(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - normally should be ‘module’ already data_uoa - UOA of the module to be created

func - action (desc) - desc

(for_web) - if ‘yes’, make it a web API, i.e. allow an access to this function in the CK server

(skip_appending_dummy_code) - if ‘yes’, do not append code

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

Output of ‘update’ function

}

ck.kernel.add_index(i)[source]
Input: {

(repo_uoa) - repo UOA with wild cards (module_uoa) - module UOA with wild cards (data_uoa) - data UOA with wild cards

(print_full) - if ‘yes’, show CID (repo_uoa:module_uoa:data_uoa)

(print_time) - if ‘yes’. print elapse time at the end

(time_out) - in sec. (default -1, i.e. no timeout)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.browser(i)[source]
Input: {

(template) - use this web template (repo_uoa) - (module_uoa) - (data_uoa) - view a given entry (extra_url) - extra URL

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.cd(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

or

cid

}

Output: {

Output of the ‘load’ function

string - prepared string ‘cd {path to entry}’

}

ck.kernel.cdc(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

or

cid

}

Output: {

Output of the ‘load’ function

}

ck.kernel.check_lock(i)[source]
Input: {

path - path to be locked (unlock_uid) - UID of the lock to release it

}

Output: {
return - return code = 0, if successful

= 32, lock UID is not matching > 0, if error

(error) - error text if return > 0

}

ck.kernel.check_version(i)[source]
Input: {

version - your version (string)

}

Output: {

return - return code = 0

ok - if ‘yes’, your CK kernel version is outdated current_version - your CK kernel version

}

ck.kernel.check_writing(i)[source]
Input: {

(module_uoa) (module_uid)

(repo_uoa) (repo_uid) (repo_dict)

(delete) - if ‘yes’, check if global delete operation is allowed

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 (repo_dict) - repo cfg if available

}

ck.kernel.cid(i)[source]
Input: {

(repo_uoa) - repo UOA (module_uoa) - module UOA (data_uoa) - data UOA

If above is empty, detect in current path !

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

Output from from ‘detect_cid_in_current_path’ function

data_uoa - data UOA module_uoa - module UOA (repo_uoa) - repo UOA

}

ck.kernel.compare_dicts(i)[source]
Input: {

dict1 - dictionary 1 dict2 - dictionary 2 (ignore_case) - ignore case of letters

Note that if dict1 and dict2 has lists, the results will be as follows:

  • dict1={“key”:[‘a’,’b’,’c’]} dict2={“key”:[‘a’,’b’]} EQUAL

  • dict1={“key”:[‘a’,’b’]} dict2={“key”:[‘a’,’b’,’c’]} NOT EQUAL

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

equal - if ‘yes’ dictionaries are equal

}

ck.kernel.compare_flat_dicts(i)[source]
Input: {

dict1 - dictionary 1 dict2 - dictionary 2 (ignore_case) - ignore case of letters (space_as_none) - if ‘yes’, consider “” as None (keys_to_ignore) - list of keys to ignore (can be wildcards)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

equal - if ‘yes’ dictionaries are equal

}

ck.kernel.convert_ck_list_to_dict(i)[source]
Input: [

CK list: see ‘action’ function from this kernel

]

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

ck_dict - {

“action”:action “cid”:module_uoa or CID (x means that it may not be really CID

and has to be processed specially

“cids”:[cid1, cid2, cid3, …] “key1”:value1 “key2”:value2 … “key10”:”” “key11”:value11 keys/values from file_json; if file extension is .tmp,

it will be deleted after read!

keys/values from cmd_json “unparsed”:unparsed_cmd

}

ck.kernel.convert_cm_to_ck(i)[source]
Input: {

(repo_uoa) - repo UOA with wild cards (module_uoa) - module UOA with wild cards (data_uoa) - data UOA with wild cards

(print_full) - if ‘yes’, show CID (repo_uoa:module_uoa:data_uoa)

(print_time) - if ‘yes’. print elapse time at the end

(ignore_update) - if ‘yes’, do not add info about update

(time_out) - in sec. (default -1, i.e. no timeout)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.convert_entry_to_cid(i)[source]
Input: {

(repo_uoa) - Repo UOA (repo_uid) - Repo UID (module_uoa) - Module UOA (module_uid) - Module UID (data_uoa) - Data UOA (data_uid) - Data UID

}

Output: {

return - return code = 0

cuoa - module_uoa:data_uoa (substituted with ? if can’t find) cid - module_uid:data_uid (substituted with ? if can’t find) xcuoa - repo_uoa:module_uoa:data_uoa (substituted with ? if can’t find) xcid - repo_uid:module_uid:data_uid (substituted with ? if can’t find)

}

ck.kernel.convert_file_to_upload_string(i)[source]
Input: {

filename - file name to convert

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 file_content_base64 - string that can be transmitted through Internet

}

ck.kernel.convert_iso_time(i)[source]
Input: {

iso_datetime - iso date time

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 (datetime_obj) - datetime object

}

ck.kernel.convert_json_str_to_dict(i)[source]
ck.kernel.convert_str_key_to_int(key)[source]
ck.kernel.convert_str_tags_to_list(i)[source]

Input: either a list, or a string of comma-separated tags.

Output: If i is a list, it’s returned.

If i is a string, the list of tags it represents is returned (each tag is stripped of leading and trailing whitespace).

ck.kernel.convert_upload_string_to_file(i)[source]
Input: {

file_content_base64 - string transmitted through Internet (filename) - file name to write (if empty, generate tmp file)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 filename - filename with full path filename_ext - filename extension

}

ck.kernel.copy(i)[source]

Input: { See ‘cp’ function } Output: { See ‘cp’ function }

ck.kernel.copy_path_to_clipboard(i)[source]
Input: {

(add_quotes) - if ‘yes’, add quotes

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.copy_to_clipboard(i)[source]
ck.kernel.cp(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

xcids[0] - {‘repo_uoa’, ‘module_uoa’, ‘data_uoa’} - new CID

or

(new_repo_uoa) - new repo UOA (new_module_uoa) - new module UOA new_data_uoa - new data alias (new_data_uid) - new data UID (leave empty to generate new one)

(move) - if ‘yes’, remove old (keep_old_uid) - if ‘yes’, keep old UID

(without_files) - if ‘yes’, do not move/copy files

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

Output of ‘add’ function

}

ck.kernel.create_entry(i)[source]
Input: {

path - path where to create an entry (split_dirs) - (int) number of first characters to split directory into subdirectories

to be able to handle many entries (similar to Mediawiki)

(data_uoa) - data UOA (data_uid) - if uoa is an alias, we can force data UID

(force) - if ‘yes’, force creation even if directory already exists

(allow_multiple_aliases) - if ‘yes’, allow multiple aliases for the same UID

(needed for cKnowledge.io to publish renamed components with the same UID)

}

Output: {
return - return code = 0, if successful

16, if data entry already exists

> 0, if error

(error) - error text if return > 0

path - path to data entry data_uid - data UID (from UOA) data_alias - data alias (from UOA) data_uoa - data alias or data uid if data alias==’’

}

ck.kernel.debug_out(i)[source]

Input: i - dictionary

Output: return = 0

ck.kernel.delete(i)[source]

Input: { See rm function } Output: { See rm function }

ck.kernel.delete_alias(i)[source]
Input: {

path - path to the entry data_uid - data UID (data_alias) - data alias (repo_dict) - repo cfg if available to check sync (share) - if ‘yes’, try to rm via GIT

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.delete_directory(i)[source]
Input: {

path - path to delete

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.delete_file(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

filename - filename to delete including relative path (force) - if ‘yes’, force deleting without questions

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.delete_index(i)[source]
Input: {

(repo_uoa) - repo UOA with wild cards (module_uoa) - module UOA with wild cards (data_uoa) - data UOA with wild cards

(print_time) - if ‘yes’. print elapse time at the end

(time_out) - in sec. (default -1, i.e. no timeout)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.detect_cid_in_current_path(i)[source]
Input: {

(path) - path, otherwise current directory

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

repo_uoa - repo UOA repo_uid - repo UID repo_alias - repo alias (module_uoa) - module UOA (module_uid) - module UID (module_alias) - module alias (data_uoa) - data UOA (data_uid) - data UID (data_alias) - data alias

}

ck.kernel.download(i)[source]
Input: {

(repo_uoa) (module_uoa) (data_uoa)

(new_repo_uoa) - new repo UOA; “local” by default

(skip_module_check) - if ‘yes’, do not check if module for a given component exists

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.dump_json(i)[source]
ck.kernel.dumps_json(i)[source]
ck.kernel.edit(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

(ignore_update) - (default==yes) if ‘yes’, do not add info about update (sort_keys) - (default==yes) if ‘yes’, sort keys

(edit_desc) - if ‘yes’, edit description rather than meta

(useful for compiler descriptions)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.eout(s)[source]

Input: s - unicode string to print

Output: Nothing

ck.kernel.err(r)[source]
Input: {

return - return code error - error text

}

Output: Nothing; quits program

ck.kernel.filter_add_index(i)[source]
Input: {

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.filter_convert_cm_to_ck(i)[source]
Input: {

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.filter_delete_index(i)[source]
Input: {

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.find(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

}

Output: {

Output of the ‘load’ function

number_of_entries - total number of found entries

}

ck.kernel.find2(i)[source]
ck.kernel.find_path_to_data(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

}

Output: {
return - return code = 0, if successful

16, if data not found (may be warning)

> 0, if error

(error) - error text if return > 0 path - path to data path_module - path to module entry with this entry path_repo - path to the repository of this entry repo_uoa - repo UOA repo_uid - repo UID repo_alias - repo alias module_uoa - module UOA module_uid - module UID module_alias - module alias uoa - data UOA uid - data UID alias - data alias

}

ck.kernel.find_path_to_entry(i)[source]
Input: {

path - (str) path to a repository data_uoa - (str) data UOA (split_dirs) - (int/str) number of first characters to split directory into subdirectories

to be able to handle many entries (similar to Mediawiki)

}

Output: {
return - return code = 0, if successful

16, if data not found (may be warning)

> 0, if error

(error) - error text if return > 0

path - path to data entry data_uid - data uid (from UOA) data_alias - data alias (from UOA) data_uoa - data alias or data uid, if data alias==’’

}

ck.kernel.find_path_to_repo(i)[source]
Input: {

(repo_uoa) - repo UOA; if empty, get the default repo

}

Output: {
return - return code = 0, if successful

16, if repo not found (may be warning)

> 0, if error

(error) - error text if return > 0

dict - dict from cache path - path to repo

repo_uoa - repo UOA repo_uid - repo UID repo_alias - repo alias

}

ck.kernel.find_repo_by_path(i)[source]
Input: {

path - path to repo

}

Output: {
return - return code = 0, if successful

16, if repo not found (may be warning)

> 0, if error

(error) - error text if return > 0

repo_uoa - repo UOA repo_uid - repo UID repo_alias - repo alias

}

ck.kernel.find_string_in_dict_or_list(i)[source]
Input: {

dict - dictionary 1 (search_string) - search string (ignore_case) - ignore case of letters

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

found - if ‘yes’, string found

}

ck.kernel.flatten_dict(i)[source]

Any list item is converted to @number=value Any dict item is converted to #key=value # is always added at the beginning

Input: {

dict - python dictionary

(prefix) - prefix (for recursion)

(prune_keys) - list of keys to prune (can have wildcards)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 dict - flattened dictionary

}

ck.kernel.flatten_dict_internal(a, aa, prefix, pk)[source]
ck.kernel.flatten_dict_internal_check_key(prefix, pk)[source]
ck.kernel.gen_tmp_file(i)[source]
Input: {

(suffix) - temp file suffix (prefix) - temp file prefix (remove_dir) - if ‘yes’, remove dir

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

file_name - temp file name

}

ck.kernel.gen_uid(i)[source]

Input: {}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

data_uid - UID in string format (16 characters 0..9,a..f)

}

ck.kernel.get_api(i)[source]
Input: {
(path) - path to module, if comes from access function

or

(module_uoa) - if comes from CMD

(func) - func for API

(out) - output

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

title - title string desc - original description module - module name api - api as string line - line in found module

}

ck.kernel.get_by_flat_key(i)[source]
Input: {

dict - dictionary key - flat key

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 value - value or None, if doesn’t exist

}

ck.kernel.get_current_date_time(i)[source]

Input: {}

Output: {

return - return code = 0

array - array with date and time iso_datetime - date and time in ISO format

}

ck.kernel.get_from_dicts(dict1, key, default_value, dict2, extra='')[source]
Input: dict1 - first check in this dict (and remove if there)

key - key in dict1 default_value - default value if not found dict2 - then check from here

Output: value

ck.kernel.get_os_ck(i)[source]
Input: {

(bits) - force OS bits

}

Output: {

return - return code = 0 platform - ‘win’ or ‘linux’ bits - OS bits in string: 32 or 64 python_bits - Python installation bits in string: 32 or 64

}

ck.kernel.get_split_dir_number(repo_dict, module_uid, module_uoa)[source]
ck.kernel.get_version(i)[source]

Input: {}

Output: {

return - return code = 0

version - list starting from major version number version_str - version string

}

ck.kernel.guide(i)[source]

Input: {}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.help(i)[source]
Input: {

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

help - help text

}

ck.kernel.index_module(module_uoa, repo_uoa)[source]
ck.kernel.info(i)[source]
Input: {

(repo_uoa) module_uoa (data_uoa)

}

Output: {

Output of ‘load’ function

}

ck.kernel.init(i)[source]

Input: {}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.inp(i)[source]
Input: {

text - text to print

}

Output: {

return - return code = 0

string - input string

}

ck.kernel.input_json(i)[source]
Input: {

text - text to print

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

string dict - parsed JSON

}

ck.kernel.is_uid(str)[source]

Input: string to check

Output: True if UID, otherwise False

ck.kernel.is_uoa(str)[source]

Input: string to check

Output: True if allowed UOA, False otherwise

ck.kernel.jerr(r)[source]
Input: {

return - return code error - error text

}

Output: Nothing; quits program

ck.kernel.list_actions(i)[source]
Input: {

(repo_uoa) - repo UOA (module_uoa) - module_uoa, if ==””, use kernel (data_uoa)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

actions - list of actions

}

ck.kernel.list_all_files(i)[source]
Input: {

path - top level path (file_name) - search for a specific file name (pattern) - return only files with this pattern (path_ext) - path extension (needed for recursion) (limit) - limit number of files (if directories with a large number of files) (number) - current number of files (all) - if ‘yes’ do not ignore special directories (like .cm) (ignore_names) - list of names to ignore (ignore_symb_dirs) - if ‘yes’, ignore symbolically linked dirs

(to avoid recursion such as in LLVM)

(add_path) - if ‘yes’, add path

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

list - dictionary of all files:

{“file_with_full_path”:{“size”:.., “path”:..}

sizes - sizes of files (the same order) number - number of files in a current directory (needed for recursion)

}

ck.kernel.list_data(i)[source]
Input: {

(repo_uoa) - repo UOA (module_uoa) - module UOA (data_uoa) - data UOA

(repo_uoa_list) - list of repos to search (module_uoa_list) - list of module to search (data_uoa_list) - list of data to search

(filter_func) - name of filter function (filter_func_addr) - address of filter function

(add_if_date_before) - add only entries with date before this date (add_if_date_after) - add only entries with date after this date (add_if_date) - add only entries with this date

(ignore_update) - if ‘yes’, do not add info about update (when updating in filter)

(search_by_name) - search by name

(search_dict) - search if this dict is a part of the entry

(ignore_case) - ignore case when searching!

(print_time) - if ‘yes’, print elapsed time at the end

(do_not_add_to_lst) - if ‘yes’, do not add entries to lst

(time_out) - in secs, default=30 (if -1, no timeout)

(limit_size) - if !=’’ limit size

(print_full) - if ‘yes’, show CID (repo_uoa:module_uoa:data_uoa)

or

(all)

(print_uid) - if ‘yes’, print UID in brackets

(print_name) - if ‘yes’, print name (and add info to the list)

or

(name)

(add_info) - if ‘yes’, add info about entry to the list (add_meta) - if ‘yes’, add meta about entry to the list

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

lst - [{‘repo_uoa’, ‘repo_uid’,

‘module_uoa’, ‘module_uid’, ‘data_uoa’,’data_uid’, ‘path’ (,info) }]

elapsed_time - elapsed time in string

(timed_out) - if ‘yes’, timed out or limited by size

}

ck.kernel.list_data2(i)[source]
ck.kernel.list_files(i)[source]
Input: {

(repo_uoa) (module_uoa) (data_uoa)

parameters for function ‘list_all_files’

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

Output of list all files

}

ck.kernel.load(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

(get_lock) - if ‘yes’, lock this entry (lock_retries) - number of retries to aquire lock (default=5) (lock_retry_delay) - delay in seconds before trying to aquire lock again (default=10) (lock_expire_time) - number of seconds before lock expires (default=30)

(skip_updates) - if ‘yes’, do not load updates (skip_desc) - if ‘yes’, do not load descriptions

(load_extra_json_files) - list of files to load from the entry

(unlock_uid) - UID of the lock to release it

(min) - show minimum when output to console (i.e. meta and desc)

(create_if_not_found) - if ‘yes’, create, if entry is not found - useful to create and lock entries

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

dict - entry meta description (info) - entry info (updates) - entry updates (desc) - entry description

path - path to data entry path_module - path to module entry with this entry path_repo - path to the repository of this entry repo_uoa - repo UOA repo_uid - repo UID repo_alias - repo alias module_uoa - module UOA module_uid - module UID module_alias - module alias data_uoa - data UOA data_uid - data UID data_alias - data alias data_name - user friendly name

(extra_json_files) - dict with extra json files (key is the filename from ‘load_extra_json_files’)

(lock_uid) - unlock UID, if locked successfully

}

ck.kernel.load_json_file(i)[source]
ck.kernel.load_meta_from_path(i)[source]
Input: {

path - path to a data entry

(skip_updates) - if ‘yes’, do not load updates (skip_desc) - if ‘yes’, do not load descriptions

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

dict - dict with meta description path - path to json file with meta description

(info) - dict with info if exists (path_info) - path to json file with info

(updates) - dict with updates if exists (path_updates) - path to json file with updates (path_desc) - path to json file with API description

}

ck.kernel.load_module_from_path(i)[source]
Input: {

path - module path module_code_name - module name (cfg) - configuration of the module if exists … (skip_init) - if ‘yes’, skip init (data_uoa) - module UOA (useful when printing error)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

code - python code object path - full path to the module cuid - internal UID of the module

}

ck.kernel.load_repo_info_from_cache(i)[source]
Input: {

repo_uoa - repo_uoa

}

Output: {
return - return code = 0, if successful

16, if repo not found (may be warning)

> 0, if error

(error) - error text if return > 0

repo_uoa - repo UOA repo_uid - repo UID repo_alias - repo alias

all other info from repo dict

}

ck.kernel.load_text_file(i)[source]
ck.kernel.load_yaml_file(i)[source]
ck.kernel.lower_list(lst)[source]
ck.kernel.merge_dicts(i)[source]
Input: {

dict1 - merge this dict with dict2 (will be directly modified!) dict2 - dict

Output: {

return - return code = 0, if successful

dict1 - output dict

}

ck.kernel.move(i)[source]

Input: { See ‘mv’ function } Output: { See ‘mv’ function }

ck.kernel.mv(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA

xcids[0] - {‘repo_uoa’, ‘module_uoa’, ‘data_uoa’} - new CID

or

(new_repo_uoa) - new repo UOA (new_module_uoa) - new module UOA (new_data_uoa) - new data alias (new_data_uid) - new data UID (leave empty to generate new one)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

Output of ‘copy’ function

}

ck.kernel.out(s)[source]

Input: s - unicode string to print

Output: Nothing

ck.kernel.parse_cid(i)[source]
Input: {

cid - in format (REPO_UOA:)MODULE_UOA:DATA_UOA (cur_cid) - output of function ‘detect_cid_in_current_path’ (ignore_error) - if ‘yes’, ignore wrong format

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

data_uoa - data UOA module_uoa - module UOA (repo_uoa) - repo UOA

}

ck.kernel.path(i)[source]

Input: {}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

Output from from ‘detect_cid_in_current_path’ function

}

ck.kernel.perform_action(i)[source]
Input: {

all parameters from function ‘access’

(web) - if ‘yes’, called from the web

(common_func) - if ‘yes’, ignore search for modules

and call common func from the CK kernel

or

(kernel)

(local) - if ‘yes’, run locally even if remote repo …

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

(out) - if action change output, return it Output from the module/action

}

ck.kernel.perform_remote_action(i)[source]

Input: { See ‘perform_action’ function } Output: { See ‘perform_action’ function }

ck.kernel.prepare_special_info_about_entry(i)[source]
Input: {

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

dict - dict with info

}

ck.kernel.print_input(i)[source]
Input: {

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

html - input as JSON

}

ck.kernel.pull(i)[source]
Input: {

(repo_uoa) - repo UOA, if needed module_uoa - module UOA data_uoa - data UOA

(filename) - filename (with path) (if empty, set archive to ‘yes’)

or

(cid[0])

if empty, create an archive of the entry

(archive) - if ‘yes’ pull whole entry as zip archive using filename or ck_archive.zip (all) - if ‘yes’ and archive, add even special directories (.cm, .svn, .git, etc)

(out) - if ‘json’ or ‘json_file’, encode file and return in r (skip_writing) - if ‘yes’, do not write file (not archive) to current directory

(pattern) - return only files with this pattern (patterns) - multiple patterns (useful to pack mutiple points in experiments)

(encode_file) - if ‘yes’, encode file

(skip_tmp) - if ‘yes’, skip tmp files and directories

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 (file_content_base64) - if i[‘to_json’]==’yes’, encoded file (filename) - filename to record locally

}

ck.kernel.push(i)[source]
Input: {

(repo_uoa) - repo UOA, if needed module_uoa - module UOA data_uoa - data UOA

(filename) - local filename

or

(cid[0])

(extra_path) - extra path inside entry (create if doesn’t exist)

(file_content_base64) - if !=’’, take its content and record into filename

(archive) - if ‘yes’ push to entry and unzip …

(overwrite) - if ‘yes’, overwrite files

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.pwiki(i)[source]
Input: {

(repo_uoa) (module_uoa) (data_uoa)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.python_version(i)[source]

Input: {}

Output: {

version - sys.version version_info - sys.version_info

}

ck.kernel.reinit()[source]

Input: None

Output: output from “init” function

ck.kernel.reload_repo_cache(i)[source]
Input: {

(force) - if ‘yes’, force recaching

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.remove(i)[source]

Input: { See rm function } Output: { See rm function }

ck.kernel.remove_action(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - normally should be ‘module’ already data_uoa - UOA of the module to be created

func - action

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

Output of ‘update’ function

}

ck.kernel.ren(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - old data UOA

new_data_uoa - new data alias

or

new_data_uid - new data UID (leave empty to keep old one)

or

xcids[0] - {‘data_uoa’} - new data UOA

(new_uid) - generate new UID

(remove_alias) - if ‘yes’, remove alias

(add_uid_to_alias) - if ‘yes’, add UID to alias

(share) - if ‘yes’, try to remove old entry via GIT and add new one

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.rename(i)[source]

Input: { See ren function } Output: { See ren function }

ck.kernel.restore_flattened_dict(i)[source]
Input: {

dict - flattened dict

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 dict - restored dict

}

ck.kernel.restore_state(r)[source]

Input: dict with state

Output: output from “init” function

ck.kernel.rm(i)[source]
Input: {

(repo_uoa) - repo UOA ; can be wild cards module_uoa - module UOA ; can be wild cards data_uoa - data UOA ; can be wild cards

(force) - if ‘yes’, force deleting without questions

or

    • to be compatible with rm -f

(share) - if ‘yes’, try to remove via GIT

(tags) - use these tags in format tags=x,y,z to prune rm

or

(search_string) - prune entries with expression *?

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.rm_read_only(f, p, e)[source]
ck.kernel.run_and_get_stdout(i)[source]
Input: {

cmd [list] - list of command line arguments, starting with the command itself (shell) - if ‘yes’, reuse shell environment

}

Output: {
return - return code = 0, if successful

> 0, if error = 8, if timeout

(error) - error text if return > 0

return_code - return code from app

stdout - string, standard output of the command stderr - string, standard error of the command

}

ck.kernel.safe_float(i, d)[source]
ck.kernel.safe_get_val_from_list(lst, index, default_value)[source]
ck.kernel.safe_int(i, d)[source]
ck.kernel.save_json_to_file(i)[source]
ck.kernel.save_repo_cache(i)[source]

Input: {}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.save_state()[source]

Input: None

Output: dict with state

ck.kernel.save_text_file(i)[source]
ck.kernel.save_yaml_to_file(i)[source]
ck.kernel.search(i)[source]
Input: {

(repo_uoa) - repo UOA (module_uoa) - module UOA (data_uoa) - data UOA

(repo_uoa_list) - list of repos to search (module_uoa_list) - list of module to search (data_uoa_list) - list of data to search

(add_if_date_before) - add only entries with date before this date (add_if_date_after) - add only entries with date after this date (add_if_date) - add only entries with this date

(search_by_name) - search by name

(print_time) - if ‘yes’, print elapsed time at the end

(search_flat_dict) - search if these flat keys/values exist in entries (search_dict) - search if this dict is a part of the entry (tags) - add tags to search in format tags=x,y,z

or

(search_string) - search with expressions *?

(ignore_case) - if ‘yes’, ignore case of letters

(time_out) - in secs, default=30

(internal) - if ‘yes’, use internal search even if indexing is on

(limit_size) - by default 5000 or -1 if no limit (start_from) - start from a specific entry (only for ElasticSearch)

(print_full) - if ‘yes’, show CID (repo_uoa:module_uoa:data_uoa) (print_uid) - if ‘yes’, print UID in brackets

(print_name) - if ‘yes’, print name (and add info to the list) (add_info) - if ‘yes’, add info about entry to the list (add_meta) - if ‘yes’, add meta about entry to the list

(debug) - if ‘yes’, print debug info

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

lst - [{‘repo_uoa’, ‘repo_uid’,

‘module_uoa’, ‘module_uid’, ‘data_uoa’,’data_uid’, ‘path’}]

elapsed_time - elapsed time in string

(timed_out) - if ‘yes’, timed out

}

ck.kernel.search2(i)[source]
ck.kernel.search_filter(i)[source]
Input: {

repo_uoa - repo UOA module_uoa - module UOA data_uoa - data UOA path - path

(search_dict) - search if this dict is a part of the entry (ignore_case) - if ‘yes’, ignore case of letters

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

lst - [{‘repo_uoa’, ‘repo_uid’,

‘module_uoa’, ‘module_uid’, ‘data_uoa’,’data_uid’, ‘path’}]

}

ck.kernel.search_string_filter(i)[source]
Input: {

repo_uoa - repo UOA module_uoa - module UOA data_uoa - data UOA path - path

(search_string) - search with expressions *?

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

lst - [{‘repo_uoa’, ‘repo_uid’,

‘module_uoa’, ‘module_uid’, ‘data_uoa’,’data_uid’, ‘path’}]

}

ck.kernel.select(i)[source]
Input: {

dict - dict with values being dicts with ‘name’ as string to display and ‘sort’ as int (for ordering) (title) - print title (error_if_empty) - if ‘yes’ and Enter, make error (skip_sort) - if ‘yes’, do not sort array

}

Output: {

return - return code = 0

string - selected dictionary key

}

ck.kernel.select_uoa(i)[source]
Input: {

choices - list from search function (skip_enter) - if ‘yes’, do not select 0 when user presses Enter (skip_sort) - if ‘yes’, do not sort array

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 choice - data UOA

}

ck.kernel.set_by_flat_key(i)[source]
Input: {

dict - dict (it will be directly changed!) key - flat key (or not if doesn’t start with #) value - value to set

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0 dict - modified dict

}

ck.kernel.set_lock(i)[source]
Input: {

path - path to be locked

(get_lock) - if ‘yes’, lock this entry (lock_retries) - number of retries to aquire lock (default=11) (lock_retry_delay) - delay in seconds before trying to aquire lock again (default=3) (lock_expire_time) - number of seconds before lock expires (default=30)

(unlock_uid) - UID of the lock to release it

}

Output: {
return - return code = 0, if successful

= 32, couldn’t acquire lock (still locked after all retries) > 0, if error

(error) - error text if return > 0

(lock_uid) - lock UID, if locked successfully

}

ck.kernel.short_help(i)[source]
Input: {

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

help - help text

}

ck.kernel.split_name(name, number)[source]
ck.kernel.status(i)[source]

Input: {}

Output: {

outdated - if ‘yes’, newer version exists

return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.substitute_str_in_file(i)[source]
Input: {

filename - file string1 - string to be replaced string2 - replace string

}

Output: {
return - return code = 0, if successful

= 16, if file not found > 0, if error

(error) - error text if return > 0

}

ck.kernel.system_with_timeout(i)[source]
Input: {

cmd - command line (timeout) - timeout in seconds (granularity 0.01 sec) - may cause overheads …

}

Output: {
return - return code = 0, if successful

> 0, if error = 8, if timeout

(error) - error text if return > 0

return_code - return code from app

}

ck.kernel.system_with_timeout_kill(proc)[source]
ck.kernel.uid(i)[source]

Input: {}

Output: {

Output from ‘gen_uid’ function

}

ck.kernel.unzip_file(i)[source]
Input: {

archive_file - full path to zip file (path) - path where unzip (current if empty) (overwrite) - if ‘yes’, overwrite (delete_after_unzip) - if ‘yes’, delete original zip file after unzipping

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

skipped - list of files which was not overwritten

}

ck.kernel.update(i)[source]
Input: {

(repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA (data_uid) - data UID (if uoa is an alias) (data_name) - user friendly data name

(dict_from_cid) - (dict_from_repo_uoa) - (dict_from_module_uoa) - (dict_from_data_uoa) - if present, pre-load dict

from this (module_uoa):data_uoa (analog of copy)

(dict) - meta description to record (substitute) - if ‘yes’, substitute dictionaries, otherwise merge!

(tags) - list or comma separated list of tags to add to entry

(info) - entry info to record - normally, should not use it! (updates) - entry updates info to record - normally, should not use it! (ignore_update) - if ‘yes’, do not add info about update

(ask) - if ‘yes’, ask questions, otherwise silent

(unlock_uid) - unlock UID if was previously locked

(sort_keys) - if ‘yes’, sort keys

(skip_indexing) - if ‘yes’, skip indexing even if it is globally on

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

Output from the ‘add’ function (the last one in case of wildcards)

}

ck.kernel.version(i)[source]

Input: {}

Output: {

output from function ‘get_version’

}

ck.kernel.webapi(i)[source]

Input: { from access function }

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.webhelp(i)[source]

Input: { from access function }

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.wiki(i)[source]
Input: {

(repo_uoa) (module_uoa) (data_uoa)

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.kernel.zip(i)[source]
Input: {

(repo_uoa) - repo UOA with wild cards (module_uoa) - module UOA with wild cards (data_uoa) - data UOA with wild cards

(archive_path) - if ‘’ create inside repo path

(archive_name) - if !=’’ use it for zip name (auto_name) - if ‘yes’, generate name name from data_uoa: ckr-<repo_uoa>.zip (bittorent) - if ‘yes’, generate zip name for BitTorrent: ckr-<repo_uid>-YYYYMMDD.zip

(overwrite) - if ‘yes’, overwrite zip file (store) - if ‘yes’, store files instead of packing

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.net module

ck.net.access_ck_api(i)[source]
Input: {

url - URL API (dict) - sending dict to cKnowledge.io API

}

Output: {

return - return code = 0 if success or >0 if error (error) - error string if return>0

… response from cKnowledge.io

}

ck.net.request(i)[source]
Input: {

get - get parameters post - post parameters

}

Output: {

return - return code = 0 if success or >0 if error (error) - error string if return>0

}

ck.strings module

ck.strings.convert_json_str_to_dict(i)[source]

Desc: Convert string of a special format to json

Target: end users

Input: {
str - string (use ‘ instead of “, i.e. {‘a’:’b’}

to avoid issues in CMD in Windows and Linux!)

(skip_quote_replacement) - if ‘yes’, do not make above replacement

}

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

dict - dict from json file

}

ck.strings.copy_to_clipboard(i)[source]

Desc: Copy string to clipboard if supported by OS (requires Tk or pyperclip)

Target: end users

Input: {

string - string to copy

Output: {
return - return code = 0, if successful

> 0, if error

(error) - error text if return > 0

}

ck.strings.dump_json(i)[source]

Desc: dump json to string

Target: end users

Input: {

dict - dictionary (skip_indent) - if ‘yes’, skip indent (sort_keys) - if ‘yes’, sort keys

}

Output: {
return - return code = 0, if successful

> 0, if error

string - json string (in utf8)

}

Module contents