diff --git a/.chezmoiignore b/.chezmoiignore index 01d80b4..6212704 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -1,3 +1,4 @@ +/.idea /README.md /scripts/ {{- if not .include_legacy }} diff --git a/.gitignore b/.gitignore index 2c66cd4..a09c56d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -vim/plugged +/.idea diff --git a/dot_local/bin/executable_query-parse b/dot_local/bin/executable_query-parse new file mode 100755 index 0000000..e578380 --- /dev/null +++ b/dot_local/bin/executable_query-parse @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import json +import select +import sys +import urllib.parse + + +def main(args=(), stdin=()): + for arg in args: + print(parse(arg)) + + for line in stdin: + print(parse(line)) + + +def parse(params): + qs = urllib.parse.parse_qs(params.strip(), keep_blank_values=True) + obj = {} + for key, value in qs.items(): + obj[key] = value[0] if len(value) == 1 else value + return json.dumps(obj) + + +def get_stdin(): + found = select.select((sys.stdin,), (), (), 0.0)[0] + return found[0] if found else () + + +if __name__ == "__main__": + main(sys.argv[1:], get_stdin())