<commit_before># -*- coding: utf-8 -*-
"""
tsurf.core
~~~~~~~~~~

This module defines the TagSurfer class. This class serve two purpose:

  1) Defines the methods that are used by tsurf-owned vim commands.
  2) Creates all tsurf components and acts as a brigde among them.

"""

import vim

from tsurf import ui
from tsurf import finder
from tsurf import services


class TagSurfer:

    def __init__(self):
        self.services = services.Services(self)
        self.finder = finder.Finder(self)
        self.ui = ui.UserInterface(self)

    def close(self):
        """To performs cleanup actions."""
        self.finder.close()

    def Open(self):
        """To open the Tag Surfer user interface."""
        self.ui.open()

    def SetProjectRoot(self, root=""):
        """To set the current project root to the current working directory or
        to the directory passed as argument."""
        self.services.curr_project.set_root(
                root if root else vim.eval("getcwd()"))

    def UnsetProjectRoot(self):
        """To unset the current project root."""
        self.services.curr_project.set_root("")<commit_msg>Improve usability of the command "TsurfSetRoot"<commit_after># -*- coding: utf-8 -*-
"""
tsurf.core
~~~~~~~~~~

This module defines the TagSurfer class. This class serve two purpose:

  1) Defines the methods that are used by tsurf-owned vim commands.
  2) Creates all tsurf components and acts as a brigde among them.

"""

import os
import vim

from tsurf import ui
from tsurf import finder
from tsurf import services


class TagSurfer:

    def __init__(self):
        self.services = services.Services(self)
        self.finder = finder.Finder(self)
        self.ui = ui.UserInterface(self)

    def close(self):
        """To performs cleanup actions."""
        self.finder.close()

    def Open(self):
        """To open the Tag Surfer user interface."""
        self.ui.open()

    def SetProjectRoot(self, root=""):
        """To set the current project root to the current working directory or
        to the directory passed as argument."""
        home = os.path.expanduser("~")
        if root.startswith("~"):
            root = root.replace("~", home)
        elif root.startswith("$HOME"):
            root = root.replace("$HOME", home)
        self.services.curr_project.set_root(
                root if root else vim.eval("getcwd()"))

    def UnsetProjectRoot(self):
        """To unset the current project root."""
        self.services.curr_project.set_root("")
{'fraction_non_alphanumeric': 0.11582705275684252, 'fraction_numerical': 0.002380007933359778, 'mean_word_length': 2.7142857142857144, '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': '5072663', 'n_tokens_mistral': 733, 'n_tokens_neox': 716, 'n_words': 248}