summaryrefslogtreecommitdiff
path: root/parser.py
diff options
context:
space:
mode:
authorPaul Sherwood <paul.sherwood@codethink.co.uk>2014-02-25 17:19:09 +0000
committerPaul Sherwood <paul.sherwood@codethink.co.uk>2014-02-25 23:16:11 +0000
commit75fc79f6287a567b0e758daa101c59b6fe7bccec (patch)
tree16249a4c0c0f3c460d4cd413d21242a8e0029dee /parser.py
parentfe7238ac335d8591591eae8998c67c6c98ac595b (diff)
downloaddefinitions-75fc79f6287a567b0e758daa101c59b6fe7bccec.tar.gz
explicitly state subway dependencies, and proto-parser for npm filesbaserock/ps/add-subway-wip
Diffstat (limited to 'parser.py')
-rw-r--r--parser.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/parser.py b/parser.py
new file mode 100644
index 00000000..5d229de1
--- /dev/null
+++ b/parser.py
@@ -0,0 +1,23 @@
+import sys, json
+import subprocess
+import yaml
+
+package = json.load(sys.stdin)
+
+deps = package['dependencies'].items() + package['devDependencies'].items()
+
+morphs = list()
+
+for chunk in deps:
+ cmd = "npm view %s repository.url" % chunk[0]
+ process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
+ output = process.communicate()
+ print 'name:', chunk[0]
+ print 'morph:', output[0].splitlines()[0]
+ print 'ref:', chunk[1]
+
+ morph={'morph':chunk[0] , 'repo':output[0].splitlines()[0], 'ref':chunk[1]}
+ morphs.append(morph)
+
+with open('data.yaml', 'a') as outfile:
+ outfile.write( yaml.safe_dump(morphs, default_flow_style=False) )