<commit_before>"""A notebook manager that uses the local file system for storage.

Authors:

* <NAME>
"""

#-----------------------------------------------------------------------------
#  Copyright (C) 2008-2011  The IPython Development Team
#
#  Distributed under the terms of the BSD License.  The full license is in
#  the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

import datetime
import os
import uuid

from tornado import web

from IPython.config.configurable import LoggingConfigurable
from IPython.nbformat import current
from IPython.utils.traitlets import Unicode, List, Dict


#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------


class NotebookManager(LoggingConfigurable):

    notebook_dir = Unicode(os.getcwd(), config=True, help="""
        The directory to use for notebooks.
    """)
    filename_ext = Unicode(u'.ipynb')
    allowed_formats = List([u'json',u'xml',u'py'])

    # Map notebook_ids to notebook names
    mapping = Dict()
    # Map notebook names to notebook_ids
    rev_mapping = Dict()

    def list_notebooks(self):
        """List all notebooks in the notebook dir.

        This returns a list of dicts of the form::

            dict(notebook_id=notebook,name=name)
        """
        import glob

        names = glob.glob(os.path.join(self.notebook_dir,
                                       '*' + self.filename_ext))
        names = [os.path.splitext(os.path.basename(name))[0]
                 for name in names]

        data = []
        for name in names:<commit_msg>Move glob to global level import.<commit_after>"""A notebook manager that uses the local file system for storage.

Authors:

* <NAME>
"""

#-----------------------------------------------------------------------------
#  Copyright (C) 2008-2011  The IPython Development Team
#
#  Distributed under the terms of the BSD License.  The full license is in
#  the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

import datetime
import os
import uuid
import glob

from tornado import web

from IPython.config.configurable import LoggingConfigurable
from IPython.nbformat import current
from IPython.utils.traitlets import Unicode, List, Dict


#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------


class NotebookManager(LoggingConfigurable):

    notebook_dir = Unicode(os.getcwd(), config=True, help="""
        The directory to use for notebooks.
    """)
    filename_ext = Unicode(u'.ipynb')
    allowed_formats = List([u'json',u'xml',u'py'])

    # Map notebook_ids to notebook names
    mapping = Dict()
    # Map notebook names to notebook_ids
    rev_mapping = Dict()

    def list_notebooks(self):
        """List all notebooks in the notebook dir.

        This returns a list of dicts of the form::

            dict(notebook_id=notebook,name=name)
        """
        names = glob.glob(os.path.join(self.notebook_dir,
                                       '*' + self.filename_ext))
        names = [os.path.splitext(os.path.basename(name))[0]
                 for name in names]

        data = []
        for name in names:
{'fraction_non_alphanumeric': 0.31588686227861484, 'fraction_numerical': 0.004758128469468675, 'mean_word_length': 1.2443653618030843, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2267545', 'n_tokens_mistral': 904, 'n_tokens_neox': 866, 'n_words': 270}