<commit_before>import os

from werkzeug.datastructures import FileStorage

from .core import LagringCore, _AssetSource
from .entity import Entity
from .classproperty import classproperty
from .exceptions import StorageException


class _AssetSourceEx(_AssetSource):
    @property
    def type(self):
        if isinstance(self.src, FileStorage):
            if self.src.filename != '':
                return 'stream'
            else:
                return None
        else:
            return super().type

    @property
    def stream(self):
        if isinstance(self.src, FileStorage):
            if self.src.filename != '':
                return self.src.stream
            else:
                return None
        else:
            return super().stream


class FlaskLagring(LagringCore):
    def __init__(self):
        pass

    def init_app(self, app):
        root = app.config['ASSET_STORAGE_ROOT']
        if root[:1] != '/':
            raise StorageException('ASSET_STORAGE_ROOT path must be absolute')
        self.setup(
            root=root,<commit_msg>fix FlaskLagring initialization is order to comply Flask extension guidelines<commit_after>import os

from werkzeug.datastructures import FileStorage

from .core import LagringCore, _AssetSource
from .entity import Entity
from .classproperty import classproperty
from .exceptions import StorageException


class _AssetSourceEx(_AssetSource):
    @property
    def type(self):
        if isinstance(self.src, FileStorage):
            if self.src.filename != '':
                return 'stream'
            else:
                return None
        else:
            return super().type

    @property
    def stream(self):
        if isinstance(self.src, FileStorage):
            if self.src.filename != '':
                return self.src.stream
            else:
                return None
        else:
            return super().stream


class FlaskLagring(LagringCore):
    def __init__(self, app=None):
        self.app = app
        if app:
            self.init_app(app)

    def init_app(self, app):
        root = app.config['ASSET_STORAGE_ROOT']
        if root[:1] != '/':
            raise StorageException('ASSET_STORAGE_ROOT path must be absolute')
        self.setup(
            root=root,
{'fraction_non_alphanumeric': 0.08315098468271334, 'fraction_numerical': 0.00087527352297593, 'mean_word_length': 2.0398936170212765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4519447', 'n_tokens_mistral': 618, 'n_tokens_neox': 596, 'n_words': 167}