A python-native fx-alike terminal JSON viewer with JSONPath Integration.
Project description
pyfx
Inspired by fx, a python implementation of JSON Viewer TUI.
Installation
Use pip
Before using pip, please check your Python version, pyfx requires >= 3.8.
pip install python-fx
Build From Source
Clone the this repo, change directory into the project and run
python setup.py install
Usage
CLI
pyfx comes with a CLI, which you can use to directly open a JSON file.
After installation, simply run
pyfx JSON_FILE
Import as Module
Import pyfx Simple TUI
You can directly integrate pyfx's TUI into your own project.
One would expect this to be the last step of your CLI application. The method Controller#run_with_data
contains a infinite loop MainLoop to render image until exit (press q
).
from pyfx import Controller
...
# data is the what you want to render as TUI
# only supports dict, list and primitive variable
Controller().run_with_data(data)
Import pyfx's Native JSON Library and Integrate with Your Own TUI
You can also import pyfx native JSON lib to integrate it into your own urwid TUI, e.g. view_window.py.
from pyfx.view.json_lib import JSONListBox, JSONListWalker, NodeFactory
...
# create top node from the data (only supports dict, list and primitive variable)
top_node = NodeFactory.create_node("", data, display_key=False)
# create JSONListBox from top node, a urwid ListBox compatible widget (http://urwid.org/reference/widget.html#listbox)
listbox = JSONListBox(JSONListWalker(top_node))
# use listbox in your own TUI
...
Key Mappings
Key | Function |
---|---|
Main Window | |
q | exit pyfx |
View Window | |
enter | toggle expansion |
up/ctrl p | move cursor up one line |
down/ctrl n | move cursor down one line |
Query Window | |
. | enter query window (used to input JSONPath query) |
enter | apply JSONPath query and switch to View Window |
esc | apply JSONPath query and exit Query Window |
Full Documentation
Please visit Documentation
License
Please visit LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python_fx-0.1.0a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f133c7dd1e78cdf09587eeb2bc898e595784016903181d160497e626aef977fa |
|
MD5 | bb1098c7c784d50727d7c38dd39a3e35 |
|
BLAKE2b-256 | a1a6a45e829adfe13a765fe750ab0f0482adbc3578ffb4fb4ffb091102178705 |