Skip to main content

A python-native fx-alike terminal JSON viewer with JSONPath Integration.

Project description

Pyfx

Build Status Documentation Status PyPI version GitHub Pipenv locked Python version GitHub

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

python setup.py install

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

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

Directly Attach Pyfx Simple TUI

Directly integrate Pyfx's TUI into your own project.

from pyfx import Controller

# data is the JSON data to be rendered in the TUI
# only supports dict, list and primitive variable
Controller().run_with_data(data)

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, NodeFactory

# 1. create top node from the data (only supports dict, list and primitive variable)
top_node = NodeFactory.create_node("", data, display_key=False)

# 2. create JSONListBox from top node
listbox = JSONListBox(JSONListWalker(top_node))

# 3. 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 and use the default config if none is find.
    The predefined folders are searched in following order, with the first exist one has high priority.
    1. ~/.config/pyfx/config.yml

For available configuration, see configuration.

License

The code is under The MIT License.

Changelog

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

How to Contribute

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-fx-0.1.0b1.tar.gz (198.5 kB view details)

Uploaded Source

Built Distribution

python_fx-0.1.0b1-py3-none-any.whl (55.8 kB view details)

Uploaded Python 3

File details

Details for the file python-fx-0.1.0b1.tar.gz.

File metadata

  • Download URL: python-fx-0.1.0b1.tar.gz
  • Upload date:
  • Size: 198.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for python-fx-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 52fd8a208c319df499b6a6a0b52d63a1d7294388f5634c048bea8ebd687f77a5
MD5 cdde7d2181b5ca88bcfe60c3c21405a2
BLAKE2b-256 95024bdeba09994e046db5e0ad2778b76a08f23e69f582e17b059ec67439701f

See more details on using hashes here.

File details

Details for the file python_fx-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: python_fx-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 55.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for python_fx-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 101d6272593bd9a14bd229964f98a482652d6a8ed519ee5115de8494b55b2948
MD5 3d9681134b5dc28626edc6b4a13bc7b5
BLAKE2b-256 fd5f5c4c898aa31c45a9689443d6b05f625df163285d560d35d56e0a19ce0b9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page