OSDN Git Service

add importer/exporter initial codes
authort.moriyama <t.moriyama@users.sourceforge.jp>
Sun, 16 Jun 2013 12:17:58 +0000 (21:17 +0900)
committert.moriyama <t.moriyama@users.sourceforge.jp>
Sun, 16 Jun 2013 12:17:58 +0000 (21:17 +0900)
linkpair/exporter/__init__.py [new file with mode: 0755]
linkpair/exporter/json.py [new file with mode: 0755]
linkpair/importer/__init__.py [new file with mode: 0755]

diff --git a/linkpair/exporter/__init__.py b/linkpair/exporter/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/linkpair/exporter/json.py b/linkpair/exporter/json.py
new file mode 100755 (executable)
index 0000000..5ab6bbf
--- /dev/null
@@ -0,0 +1,33 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+# -*- coding: utf-8 -*-
+#
+
+__version__ = '1.1'
+
+import sys
+import os
+import re
+
+
+class JsonExporter(object):
+
+    def __init__(self, util, linkpairs):
+        self._u = util
+        self._linkpairs = linkpairs
+
+    def export(self):
+        json_strings = ""
+        for linkpair in self._linkpairs:
+            json_strings = json_strings + linkpair.to_json() + "\n"
+        json_strings = json_strings.rstrip(",")
+        return json_strings
+
+#         try:
+#             json_file = open(db_name, 'w')
+#             json_file.write("{\"linkpairs\": [")
+#             json_file.write(json_strings)
+#             json_file.write("]\n}")
+#             json_file.close()
+#         except:
+#             print "error:", sys.exc_info()[0]
+#             raise
diff --git a/linkpair/importer/__init__.py b/linkpair/importer/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29