# Path: lib/_db.py
# def get_collection(db_name, collection_name, client='mongo'):
#     client = client_db_map.get(client)
#     db = getattr(client, db_name, None)
#     return getattr(db, collection_name, None)


import _env
import json
import re
import time
    import sys
from lib._db import get_collection
from tornado.escape import xhtml_unescape
from judge_upload import exist_or_insert
from config.config import CONFIG

            if not exist_or_insert(slug):
                doc_id = doc.get('_id')
                post_id = int(doc['source_url'].rsplit('/', 1)[1].split('.')[0])
                index += 1
                if index > limit:
                    break

                posts.append(replace_post(doc))
                posts_tags.append(
                    {"tag_id": 1000, "post_id": post_id}
                )

    data = {
        "posts": posts,
        "tags": TAGS,
        "posts_tags": posts_tags,
        "users": USERS
    }
    res["data"] = data
    return res


def tag_migrate(limit=10):
    res = {
        "meta": {
            "exported_on": cur_timestamp(),
            "version": "003"
        }
    }

# Path: lib/_db.py
# def get_collection(db_name, collection_name, client='mongo'):
#     client = client_db_map.get(client)
#     db = getattr(client, db_name, None)
#     return getattr(db, collection_name, None)


# Path: crawler/sharejs/sharejs_to_ghost.py
import _env
import json
import re
import time
    import sys
from lib._db import get_collection
from tornado.escape import xhtml_unescape
from judge_upload import exist_or_insert
from config.config import CONFIG


            if not exist_or_insert(slug):
                doc_id = doc.get('_id')
                post_id = int(doc['source_url'].rsplit('/', 1)[1].split('.')[0])
                index += 1
                if index > limit:
                    break

                posts.append(replace_post(doc))
                posts_tags.append(
                    {"tag_id": 1000, "post_id": post_id}
                )

    data = {
        "posts": posts,
        "tags": TAGS,
        "posts_tags": posts_tags,
        "users": USERS
    }
    res["data"] = data
    return res


def tag_migrate(limit=10):
    res = {
        "meta": {
            "exported_on": cur_timestamp(),
            "version": "003"
        }
    }

    coll = get_collection(DB, 'code')