summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Cholewiński <harry666t@gmail.com>2016-01-11 13:58:04 +0100
committerKamil Cholewiński <harry666t@gmail.com>2016-01-11 13:58:04 +0100
commit9508e92918bbd8c44c256e29e28c8e5d87340bb8 (patch)
tree29efb040a4db02b60bcb673c8ee70fbdddf57b96
parent0eb122e388eb394c32a9463bdf9e064a2eb5a02d (diff)
downloadjrep-9508e92918bbd8c44c256e29e28c8e5d87340bb8.zip
jrep-9508e92918bbd8c44c256e29e28c8e5d87340bb8.tar.gz
jrep-9508e92918bbd8c44c256e29e28c8e5d87340bb8.tar.bz2
Read ini files too
-rwxr-xr-xjrep15
1 files changed, 15 insertions, 0 deletions
diff --git a/jrep b/jrep
index 73ec06a..3097e49 100755
--- a/jrep
+++ b/jrep
@@ -12,6 +12,12 @@ except ImportError:
yaml = None
+try:
+ import ConfigParser as configparser
+except ImportError:
+ import configparser
+
+
def linify(o):
simple_types = {str, unicode, int, long, float, bool, type(None)}
linify_complex = {
@@ -23,6 +29,14 @@ def linify(o):
return linifier(o)
+def read_ini(fd):
+ p = configparser.ConfigParser()
+ p.readfp(fd)
+ return dict([(section, dict([(k, v) for k, v in items.items()
+ if k != "__name__"]))
+ for section, items in p._sections.items()])
+
+
formats = {
"json": json.dumps,
"pretty": lambda o: json.dumps(o, indent=4),
@@ -32,6 +46,7 @@ formats = {
loaders = {
"json": json.load,
"eval": lambda fd: eval(fd.read()),
+ "ini": read_ini,
}