New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

python-fx

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-fx

A python-native fx-alike terminal JSON viewer.

  • 0.3.2
  • PyPI
  • Socket score

Maintainers
1

Pyfx

Build Status Documentation Status PyPI version Python Python Python Python GitHub codecov

A python-native JSON Viewer TUI, inspired by fx.
Pyfx supports:

  • Read JSON files in terminal from several sources (file, pipe or clipboard).
  • Query JSON files using JSONPath query.

Table of Content

Prerequisites

  • OS: MacOS / Linux
  • python: >= 3.8
  • pip

Installation

Pip

pip install python-fx

Build from Source

Clone the this repo, change directory into the project and run

pip install -U autopep8 tox build
make install

Local Development

  1. Download and install the latest ANTLR v4
  • It is required that ANTLR version installed matches the version of the Python ANTLR runtime version.
  1. Clone the this repo, change directory into the project and run
pip install -U pipenv
pipenv install --dev

Quick Start

You can use Pyfx in two ways:

  • A standalone CLI tool
  • A python module which can be integrated in any python CLI application

For details, please check the hosted documentation.

CLI

Check Key Bindings section for default key bindings.
Pyfx comes with a CLI, use it

  • To open a JSON file
     pyfx JSON_FILE
    
  • To read JSON data from pipe
     cat JSON_FILE | pyfx
    
  • To read JSON data from clipboard
     pyfx -x / --from-clipboard
    

Python Module

Check Key Bindings section for default key bindings.

Directly Attach Pyfx Simple TUI

Directly integrate Pyfx's TUI into your own project.

from pyfx import PyfxApp

data = [1]
# data is the JSON data to be rendered in the TUI
PyfxApp(data=data).run()
Integrate with Your Own Urwid-based TUI

Integrate Pyfx native JSON widgets into your own urwid-based TUI.

from pyfx.view.json_lib import JSONListBox, JSONListWalker

data = [1]

# 1. create JSONListBox from data
listbox = JSONListBox(JSONListWalker(data))

# 2. use listbox in your own TUI

Configuration

Pyfx is configured using YAML. There are two ways to provide a configuration file:

  • Pass directly through CLI option (-c | --config).
  • Create a config file in predefined folders and Pyfx will load it with best effort.
    The predefined folders are searched in following order, with the first exist one has high priority.
    1. ~/.config/pyfx/config.yml
    2. src/pyfx/config/yaml/config.yml default config

For available configuration, see configuration.

Default Configuration

Theme

Alternative key bindings, see Theme Configuration.

NameDescriptionForeground Color
bodyPyfx body (JSON Browser)terminal default
footPyfx footer (Query Bar and Help Bar)gray
focusedfocused displaygray
Auto Complete PopUp
autocomplete_popupautocomplete popupblack
autocomplete_popup_focusedfocused display for autocomplete popupwhite
JSON Browser
json_keyobject keyblue
json_stringstring type valuegreen
json_integerinteger type valuecyan
json_numericnumeric type valuecyan
json_boolboolean type valueyellow
json_nullnull type valuered
json_focusedfocused display for JSONgray
Key Bindings

Alternative key bindings, see Key Bindings Configuration.

KeyFunction
qexit pyfx (except in Query Bar)
?open help page (except in Query Bar)
JSON Browser
upmove cursor up one line
downmove cursor down one line
eexpand all
ccollapse all
entertoggle expansion
.enter query window (used to input JSONPath query)
Query Bar
enterapply JSONPath query and switch to JSON Browser
esccancel query and restore to state before query
Autocomplete PopUp
upmove cursor up one line
downmove cursor down one line
enterselect option and complete the query
escclose pop up
Help PopUp
upmove cursor up one line
downmove cursor down one line
escclose the help popup

Known Limitation

When open with very large JSON files, Pyfx will freeze on JSONPath query.

The following statistics is tested at a MacBook Air (1.1GHz Quad-Core Intel Core i5 and 8GB RAM).

File SizeFunctionalityUsability
57MBDisplay JSONFairly good
^^Query AutocompleteLatency <= 200ms
^^Query JSONPathRoughly 1~2s latency
570MBDisplay JSONSlow loading
^^Query AutocompleteLatency <= 200ms. Give up with large data
^^Query JSONPathUI may freeze depend on the search space

License

The code is under The MIT License.

Changelog

See the changelog for a history of notable changes to Pyfx.

Contributors

Avery (@nullableVoidPtr)
Zephyr Lykos (@mochaaP)
@jcaesar

How to Contribute

If you run into any issues, please let me know by creating a GitHub issue.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc