# Path: weblablib/exc.py
# class WebLabNotInitializedError(WebLabError):
#     """Requesting a WebLab object when ``weblab.init_app`` has not been called."""
#     pass


import os
import time
import base64
import datetime
from flask import current_app
from weblablib.exc import WebLabNotInitializedError
# Copyright 2017 onwards LabsLand Experimentia S.L.
# This software is licensed under the GNU AGPL v3:
# GNU Affero General Public License version 3 (see the file LICENSE)
# Read in the documentation about the license

from __future__ import unicode_literals, print_function, division




def create_token(size=None):
    if size is None:
        size = 32
    tok = os.urandom(size)
    safe_token = base64.urlsafe_b64encode(tok).strip().replace(b'=', b'').replace(b'-', b'_')
    safe_token = safe_token.decode('utf8')
    return safe_token

def _current_weblab():
    if 'weblab' not in current_app.extensions:

# Path: weblablib/exc.py
# class WebLabNotInitializedError(WebLabError):
#     """Requesting a WebLab object when ``weblab.init_app`` has not been called."""
#     pass


# Path: weblablib/utils.py
import os
import time
import base64
import datetime
from flask import current_app
from weblablib.exc import WebLabNotInitializedError

# Copyright 2017 onwards LabsLand Experimentia S.L.
# This software is licensed under the GNU AGPL v3:
# GNU Affero General Public License version 3 (see the file LICENSE)
# Read in the documentation about the license

from __future__ import unicode_literals, print_function, division




def create_token(size=None):
    if size is None:
        size = 32
    tok = os.urandom(size)
    safe_token = base64.urlsafe_b64encode(tok).strip().replace(b'=', b'').replace(b'-', b'_')
    safe_token = safe_token.decode('utf8')
    return safe_token

def _current_weblab():
    if 'weblab' not in current_app.extensions:

        raise WebLabNotInitializedError("App not initialized with weblab.init_app()")