Add visidata plugin and json-function
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
# copy or link this file to ~/.visidatarc
|
||||
options.disp_date_fmt="%Y-%m-%dT%H:%M:%S"
|
||||
|
||||
import plugins.hidecol
|
||||
|
||||
from datetime import datetime
|
||||
import functools
|
||||
import json
|
||||
|
||||
from urllib.parse import unquote_plus
|
||||
|
||||
def decode_url_safe(url_safe_string):
|
||||
utf8_string = unquote_plus(url_safe_string)
|
||||
return utf8_string
|
||||
|
||||
|
||||
|
||||
def what(item):
|
||||
return f"{type(item)}:{str(item)}"
|
||||
|
||||
@@ -267,3 +276,15 @@ def int2ip(zahl):
|
||||
# convert IP-String to Integer
|
||||
def ip2int(ip):
|
||||
return int.from_bytes(b"".join([int(c).to_bytes(1,'big') for c in b.split('.')]),'big')
|
||||
|
||||
# parse KeyValue
|
||||
def dirty_kv(data):
|
||||
return {y[0] : y[1] for y in [x.strip().split("=") for x in data.strip().strip('"{}').split(',')]}
|
||||
|
||||
|
||||
|
||||
|
||||
# parse json with missing quotes around attribute names
|
||||
import yaml
|
||||
def dirty_json(data):
|
||||
return yaml.load(data, yaml.SafeLoader)
|
||||
Reference in New Issue
Block a user