<commit_before>"""
.. module:: configuration
    :synopsys: Recover the list of existing notebooks

.. moduleauthor:: <NAME> <<EMAIL>>
"""
from __future__ import unicode_literals
import os
from noteorganiser.constants import EXTENSION

from PySide import QtCore

def initialise(logger):
    """
    Platform independent recovery of the main folder and notebooks

    """
    # Platform independent recovery of the home directory. It is always put as
    # a hidden folder, '.noteorganiser', in the unix tradition.
    home = os.path.expanduser("~")
    main = os.path.join(home, '.noteorganiser')

    settings = QtCore.QSettings("audren", "NoteOrganiser")
    if settings.contains("display_empty"):
        if settings.value("display_empty") == "true":
            display_empty = True
        else:
            display_empty = False
    else:
        display_empty = True

    # commandline for the external editor
    externalEditor = ''
    if settings.contains("externalEditor"):
        externalEditor = settings.value("externalEditor")

    # Recursively search the main folder for notebooks or folders of notebooks
    # It also checks if the folder ".noteorganiser" exists, and creates it
    # otherwise.
    # folders will contain all the non-empty folders in the main. The method
    # search_folder_recursively will be called again when the user wants to
    # explore also the contents of this folder
    notebooks, folders = search_folder_recursively(logger, main, display_empty)

    # Return both the path to the folder where it is stored, and the list of
    # notebooks
    return main, notebooks, folders


def search_folder_recursively(logger, main, display_empty=True):
    """
    Search the main folder for notebooks and folders with notebooks

    Note that the returned notebooks and folders are flat (that is, folders is
    not a list that then contains all the subnotebooks. They are discarded, and
    only loaded if the folder is then clicked on).

    Parameters
    ----------
    logger : logging module instance

    main : str
        folder to search

    display_empty : bool<commit_msg>deleted unneeded call to settings<commit_after>"""
.. module:: configuration
    :synopsys: Recover the list of existing notebooks

.. moduleauthor:: <NAME> <<EMAIL>>
"""
from __future__ import unicode_literals
import os
from noteorganiser.constants import EXTENSION

from PySide import QtCore

def initialise(logger):
    """
    Platform independent recovery of the main folder and notebooks

    """
    # Platform independent recovery of the home directory. It is always put as
    # a hidden folder, '.noteorganiser', in the unix tradition.
    home = os.path.expanduser("~")
    main = os.path.join(home, '.noteorganiser')

    settings = QtCore.QSettings("audren", "NoteOrganiser")
    if settings.contains("display_empty"):
        if settings.value("display_empty") == "true":
            display_empty = True
        else:
            display_empty = False
    else:
        display_empty = True

    # Recursively search the main folder for notebooks or folders of notebooks
    # It also checks if the folder ".noteorganiser" exists, and creates it
    # otherwise.
    # folders will contain all the non-empty folders in the main. The method
    # search_folder_recursively will be called again when the user wants to
    # explore also the contents of this folder
    notebooks, folders = search_folder_recursively(logger, main, display_empty)

    # Return both the path to the folder where it is stored, and the list of
    # notebooks
    return main, notebooks, folders


def search_folder_recursively(logger, main, display_empty=True):
    """
    Search the main folder for notebooks and folders with notebooks

    Note that the returned notebooks and folders are flat (that is, folders is
    not a list that then contains all the subnotebooks. They are discarded, and
    only loaded if the folder is then clicked on).

    Parameters
    ----------
    logger : logging module instance

    main : str
        folder to search

    display_empty : bool
{'fraction_non_alphanumeric': 0.0736405754693977, 'fraction_numerical': 0.0, 'mean_word_length': 3.1857142857142855, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, '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': '4097719', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1050, 'n_words': 447}