We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The shyaml script is very useful. You could easily make a JSON version, shjson, of the script:
--- shyaml 2013-03-29 19:42:05.893082254 +0100 +++ shjson 2013-03-29 21:13:47.920416719 +0100 @@ -6,11 +6,12 @@ ## nosetests import sys -import yaml +import simplejson import os.path EXNAME = os.path.basename(sys.argv[0]) +json2python = lambda fp: simplejson.load(fp, encoding='utf-8') def mget(dct, key, default=None): """Allow to get values deep in a dict with doted keys. @@ -63,7 +64,7 @@ if action in ["get-value", "get-type"]: key_value = "" if len(args) == 1 else args[1] default = args[2] if len(args) > 2 else "" - contents = yaml.load(sys.stdin) + contents = json2python(sys.stdin) try: value = mget(contents, key_value, default) except IndexError: @@ -72,8 +73,13 @@ die("Error: invalid path %r." % key_value) if action == "get-value": if not isinstance(value, (basestring, int, float)): - value = yaml.dump(value, default_flow_style=False) - print value, + value = simplejson.dumps( + value, + ensure_ascii = False, + indent = 2, + sort_keys = sort + ).encode('utf-8') + print value return 0 else: ## action == "get-type" print "struct" if isinstance(value, dict) else \ @@ -81,7 +87,7 @@ type(value).__name__ return 0 if action == "keys": - for k in yaml.load(sys.stdin).keys(): + for k in sorted(json2python(sys.stdin).keys()): print k return 0 die("Error: Invalid argument.\n%s" % usage)
Or something like that…
The text was updated successfully, but these errors were encountered:
Thanks, that's of some interest ! The biggest concerns I could have to integrate this is to find a project name to hold both scripts ;) . Any ideas ?
I would naturally put them in the same project as they share 90% of their small code.
Sorry, something went wrong.
Hm, good question… I'm blank.
No branches or pull requests
The shyaml script is very useful. You could easily make a JSON version, shjson, of the script:
Or something like that…
The text was updated successfully, but these errors were encountered: