Comments (10)
I think I have this working pretty well now with -i
:
% cat .jelloconf.py
# from jello.lib import opts
# opts.mono = True
def darwin_compatible():
result = []
for entry in _.parsers:
if "darwin" in entry.compatible:
result.append(entry.name)
return result
% jc -a | jello -ic 'darwin_compatible()'
["airport","airport_s","arp","asciitable","asciitable_m","bluetoothctl","cbt","cef","cef_s","cksum","clf","clf_s","crontab","crontab_u","csv","csv_s","date","datetime_iso","df","dig","du","email_address","env","file","finger","git_log","git_log_s","git_ls_remote","group","hash","hashsum","history","hosts","id","ifconfig","ini","ini_dup","ip_address","iso_datetime","jar_manifest","jobs","jwt","kv","last","ls","ls_s","lsof","m3u","mount","netstat","openvpn","passwd","pci_ids","pgpass","ping","ping_s","pip_list","pip_show","plist","ps","rsync","rsync_s","semver","shadow","ssh_conf","sshd_conf","stat","stat_s","sysctl","syslog","syslog_s","syslog_bsd","syslog_bsd_s","time","timestamp","toml","traceroute","uname","uptime","url","ver","w","wc","who","x509_cert","xml","xrandr","yaml","zipinfo","zpool_iostat","zpool_status"]
I'll do more testing and add some unit tests before releasing.
from jello.
I've added the following features to the dev
branch which will be in the 1.6.0 release:
- Add the ability to directly use a JSON file or JSON Lines files as data input (
-f
) - Add the ability to load a query from a file (
-q
) - Add the empty data option (
-e
) - Fix user-defined functions in ~/.jelloconf initialization file
from jello.
Looks good. I'll let you know if I find anything why using it.
from jello.
Hi there - this is a good idea, but should already be supported with the -i
option. This could be better documented, but can be found under the Advanced Usage section.
The problem is I seem to have broken this functionality while tightening up some things in the query environment. It should work like this (but does not right now):
% jc -a | jello -i 'darwin_compatible()'
If you have this in your ~/.jelloconf.py
file:
def darwin_compatible(data=_):
result = []
for entry in data.parsers:
if "darwin" in entry.compatible:
result.append(entry.name)
return result
I'll look into this and add some tests.
from jello.
Yes, I had tried the -i
option but it didn't work. I was trying to debug a little before reporting it -- didn't know if it was broken or if it was me being a new user.
Personally, I think a -f program_file
option would have value on it's own, much like sed
and awk
allow you to run programs from a file. It wasn't difficult to add in myself (except for the command line parsing). I hope you'll consider it at some point.
from jello.
I have a little proof of concept working with the -i
method. I have to change quite a bit of code since I locked down the scope of the exec
call. Still thinking on how best to implement this and then the file method. It was easier before because I was not really limiting what could go into the exec
call so the variables in the pyquery
function were effectively shared.
from jello.
For the query, I did this:
diff --git a/jello/cli.py b/jello/cli.py
index 4b07197..da5b41d 100644
--- a/jello/cli.py
+++ b/jello/cli.py
@@ -122,7 +122,12 @@ def main(data=None, query='_'):
long_options = {}
for arg in sys.argv[1:]:
- if arg.startswith('-') and not arg.startswith('--'):
+ if arg.startswith('-f'):
+ _, path = arg[2:].split('=')
+ with open(path, encoding="utf-8") as f:
+ query = f.read()
+
+ elif arg.startswith('-') and not arg.startswith('--'):
options.extend(arg[1:])
from jello.
I'm wondering if it makes sense to add file support as JSON input as well. That would make the -f
option confusing, though.
$ jello -f file.json
Could maybe use something like -q
for query file and -f
for file input? Still considering options.
from jello.
-q query_file
seems reasonable.
Maybe -d json_data
or -j json_file
.
from jello.
released in v1.6.0
from jello.
Related Issues (16)
- Support accessing to the dict's values via attributes HOT 4
- Unit test failures HOT 14
- Any idea how to find easily values of (deeply) nested keys, when the keys not always exist? HOT 1
- '<' not supported between instances of 'DotMap' and 'DotMap' HOT 3
- [FEATURE REQUEST] Fedora RPM HOT 4
- scope issues in comprehensions HOT 5
- Failure to call `main()` in cli.py:211-212 causes `python -m jello.cli` to be a no-op HOT 3
- parse JSONLines format HOT 15
- Help with basic usage and syntax errors HOT 10
- Streaming support
- Safety against third-parties. HOT 3
- Web demo is down HOT 1
- Error messages / exceptions sometimes hard to pinpoint to source (missing line numbers) HOT 1
- Feature request: support for other input formats (like raw string, yaml, csv,...) HOT 5
- Enhancement: process each JSON Line separately HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jello.