Browse Source

Enhancements to the Siikir migrator

pull/2/head
Noah Petherbridge 5 years ago
parent
commit
49496e1c2e
2 changed files with 39 additions and 7 deletions
  1. +39
    -7
      scripts/siikir-blog-migrate.py
  2. +0
    -0
      site/www/.dummy

+ 39
- 7
scripts/siikir-blog-migrate.py View File

@@ -30,8 +30,9 @@ def main():
sys.exit(1)

convert_index()
#convert_tags()
convert_posts()
convert_comments()
convert_subscriptions()


def convert_index():
@@ -51,12 +52,6 @@ def convert_index():
JsonDB.commit("blog/index", new)


def convert_tags():
print "Converting tag index"
index = json_get("blog/tags/1.json")
JsonDB.commit("blog/tags", index)


def convert_posts():
print "Converting blog entries..."

@@ -77,6 +72,43 @@ def convert_posts():
JsonDB.commit("blog/entries/{}".format(post_id), post)


def convert_comments():
print "Converting comments..."

for name in glob.glob(os.path.join(siikir, "comments/1/*.json")):
name = name.split("/")[-1]
if name.startswith("photos-"): continue
data = json_get("comments/1/{}".format(name))

thread = name[:len(name)-5]

# Enforce data types.
for cid in data:
data[cid]["time"] = int(data[cid]["time"])
data[cid]["uid"] = int(data[cid]["uid"])

print "*", thread
JsonDB.commit("comments/threads/{}".format(thread), data)


def convert_subscriptions():
print "Converting subscriptions..."

for name in glob.glob(os.path.join(siikir, "subscribers/1/*.json")):
name = name.split("/")[-1]
if name.startswith("photos-"): continue
data = json_get("subscribers/1/{}".format(name))

thread = name[:len(name)-5]

# Enforce data types.
for email in data:
data[email] = int(data[email])

print "*", thread
JsonDB.commit("comments/subscribers/{}".format(thread), data)


def json_get(document):
fh = codecs.open(os.path.join(siikir, document), 'r', 'utf-8')
text = fh.read()


+ 0
- 0
site/www/.dummy View File


Loading…
Cancel
Save