예제 #1
0
    def is_newline(self):
        import utils.heredocs as hd

        list_param = []
        key = ''
        heredoc = None
        not_end = True
        minus = False
        self.is_abs_terminator()
        while self.heredocs_keys != [] and not_end:
            list_param = self.heredocs_keys[0]
            heredoc = hd.Heredocs(list_param[0], list_param[1], list_param[2])
            list_param[0] = k.modifify_gold_key(list_param[0])
            minus = list_param[2]
            gv.HEREDOCS.append(heredoc)
            not_end = self.next_tag_token(True)
            while not_end:
                if key == list_param[0]:
                    heredoc.close()
                    break
                heredoc.add_tags_tokens(self.tag, self.token)
                key = k.get_key(key, self.tag, self.token, minus)
                if self.tag == 'NEW_LINE':
                    key = ''
                not_end = self.next_tag_token(True)
            self.heredocs_keys.pop(0)
            key = ''
예제 #2
0
    host=[os.getenv("MICROBLOGPUB_MONGODB_HOST", "localhost:27017")])

DB_NAME = "{}_{}".format(USERNAME, DOMAIN.replace(".", "_"))
DB = mongo_client[DB_NAME]
GRIDFS = mongo_client[f"{DB_NAME}_gridfs"]
MEDIA_CACHE = MediaCache(GRIDFS, USER_AGENT)


def _drop_db():
    if not DEBUG_MODE:
        return

    mongo_client.drop_database(DB_NAME)


KEY = get_key(ID, ID + "#main-key", USERNAME, DOMAIN)

JWT_SECRET = get_secret_key("jwt")
JWT = JSONWebSignatureSerializer(JWT_SECRET)


def _admin_jwt_token() -> str:
    return JWT.dumps(  # type: ignore
        {
            "me": "ADMIN",
            "ts": datetime.now().timestamp()
        }).decode(  # type: ignore
            "utf-8")


ADMIN_API_KEY = get_secret_key("admin_api_key", _admin_jwt_token)
예제 #3
0
    DB.activities.create_index([
        ("type", pymongo.ASCENDING),
        ("activity.object.type", pymongo.ASCENDING),
        ("activity.object.inReplyTo", pymongo.ASCENDING),
        ("meta.deleted", pymongo.ASCENDING),
    ])


def _drop_db():
    if not DEBUG_MODE:
        return

    mongo_client.drop_database(DB_NAME)


KEY = get_key(ID, USERNAME, DOMAIN)

JWT_SECRET = get_secret_key("jwt")
JWT = JSONWebSignatureSerializer(JWT_SECRET)


def _admin_jwt_token() -> str:
    return JWT.dumps(  # type: ignore
        {
            "me": "ADMIN",
            "ts": datetime.now().timestamp()
        }).decode(  # type: ignore
            "utf-8")


ADMIN_API_KEY = get_secret_key("admin_api_key", _admin_jwt_token)