Comparing version
@@ -10,3 +10,3 @@ (function(){ | ||
} | ||
function run_child(cmd, args, cb){ | ||
function run_child(cmd, args, stdin, cb){ | ||
var child, stderr, stdout; | ||
@@ -16,4 +16,7 @@ child = child_process.spawn(cmd, args); | ||
stdout = ""; | ||
child.stdin.setEncoding('utf8'); | ||
child.stderr.setEncoding('utf8'); | ||
child.stdout.setEncoding('utf8'); | ||
child.stdin.write(stdin); | ||
child.stdin.end(); | ||
child.stderr.on('data', function(data){ | ||
@@ -36,7 +39,7 @@ stderr += data; | ||
} | ||
read_program = "import sys, json, mutagen, mutagen.asf\nclass CustomEncoder(json.JSONEncoder):\n def default(self, obj):\n mappings = {\n mutagen.asf.ASFUnicodeAttribute: unicode,\n mutagen.asf.ASFBoolAttribute: bool,\n mutagen.asf.ASFDWordAttribute: int,\n mutagen.asf.ASFQWordAttribute: int,\n mutagen.asf.ASFGUIDAttribute: (lambda obj: \"\"),\n mutagen.asf.ASFByteArrayAttribute: (lambda obj: \"\"),\n }\n try:\n func = mappings[type(obj)]\n except KeyError:\n return json.JSONEncoder.default(self, obj)\n return func(obj)\nprint(json.dumps(dict(mutagen.File(sys.argv[1], easy=True) or {}), cls=CustomEncoder))"; | ||
read_program = "import sys, json, mutagen, mutagen.asf\nclass CustomEncoder(json.JSONEncoder):\n def default(self, obj):\n mappings = {\n mutagen.asf.ASFUnicodeAttribute: unicode,\n mutagen.asf.ASFBoolAttribute: bool,\n mutagen.asf.ASFDWordAttribute: int,\n mutagen.asf.ASFQWordAttribute: int,\n mutagen.asf.ASFGUIDAttribute: (lambda obj: \"\"),\n mutagen.asf.ASFByteArrayAttribute: (lambda obj: \"\"),\n }\n try:\n func = mappings[type(obj)]\n except KeyError:\n return json.JSONEncoder.default(self, obj)\n return func(obj)\neverything = [dict(mutagen.File(path, easy=True) or {}) for path in sys.stdin.read().split(\"\\n\") if path != \"\"]\nprint(json.dumps(everything, cls=CustomEncoder))"; | ||
out$.read = read; | ||
function read(file, cb){ | ||
function read(files, cb){ | ||
cb == null && (cb = noop); | ||
run_child('python', ['-c', read_program, file], function(err, stdout){ | ||
run_child('python', ['-c', read_program], files.join('\n'), function(err, stdout){ | ||
if (err) { | ||
@@ -62,3 +65,3 @@ return cb(err); | ||
} | ||
run_child('python', args, cb); | ||
run_child('python', args, '', cb); | ||
} | ||
@@ -65,0 +68,0 @@ if (require.main === module) { |
{ | ||
"name": "mutagen", | ||
"version": "0.0.4", | ||
"version": "1.0.0", | ||
"description": "wrapper around the mutagen library", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5131
3.93%104
2.97%1
-50%