js_helper¶
- pysecret.js_helper.create_json_if_not_exists(path: str)[source]¶
Create an empty json file if not exists
- pysecret.js_helper.set_value(data: dict, json_path: str, value: Any) dict [source]¶
Set a field in dictionary data using JSON path syntax.
- Parameters
data – the dictionary data
json_path – the dot notation JSON path syntax, for example: “.key”, “.key1.key2.key3”
value – the changed data
TODO: add array index support
- pysecret.js_helper.get_value(data: dict, json_path: str) Any [source]¶
Get the value of a field in dictionary data using JSON path syntax.
- Parameters
data – the dictionary data
json_path – the dot notation JSON path syntax, for example:
TODO: add array index support
- pysecret.js_helper.del_key(data: dict, json_path: str)[source]¶
Delete a field in dictionary data using JSON path syntax.
- Parameters
data – the dictionary data
json_path – the dot notation JSON path syntax, for example:
TODO: add array index support
- pysecret.js_helper.strip_comment_line_with_symbol(line: str, comment_symbol: str) str [source]¶
Strip comments from line string.
- Parameters
line – the single line string that you want to strip out comments.
comment_symbol – the comment char that indicate that the comment starts from.
- Returns
the single line string with comment removed.
- pysecret.js_helper.strip_comments(text: str, comment_symbols=frozenset({'#', '//'})) str [source]¶
Strip comments from json string.
- Parameters
text – A string containing json with comments started by comment_symbols.
comment_symbols – Iterable of symbols that start a line comment (default # or //).
- Returns
the multi line text with the comments removed.