<commit_before>import neovim
from pathlib import Path
import subprocess
import os

@neovim.plugin
class Main(object):
    def __init__(self, vim):
        self.vim = vim
        self.old_cmake_files = [ Path("CMakeCache.txt"), Path("cmake_install.cmake") ]
        self.old_cmake_dir = Path("CMakeFiles")
        self.cmake_proj = Path("CMakeLists.txt")
        self.makefile = Path("Makefile")
        self.build_dir = Path("build")
        self.comp_data_cmake = Path("build/compile_commands.json")
        self.comp_data_bear = Path("compile_commands.json")

    def run_cmake(self):
        try:
            subprocess.call( ["mkdir", "build"] )
        except OSError:
            self.vim.command('echo "Can\'t setup CMake build directory."')
            raise
        try:
            subprocess.call( ["cmake", "-DCMAKE_EXPORT_COMPILE_COMMANDS=1", ".."], cwd="build" )
        except OSError:
            self.vim.command('echo "CMake Failed."')
            raise
        if self.comp_data_cmake.is_file():
            try:
                subprocess.call( ["rdm", "--silent", "--daemon"], cwd=".." )
            except OSError:
                self.vim.command('echo "Couldn\'t start the RTags daemon."')
                raise
            subprocess.call( ["rc", "-J", "build"] )
        else:
            self.vim.command('echo "Error Generating Compilation Database With CMake"')
            raise

    def run_bear(self):
        try:
            subprocess.call(["bear", "make"])
        except OSError as e:
            if e.errno == os.errno.ENOENT:
                self.vim.command('echo "No Makefile for Bear to Use"')
            else:
                self.vim.command('echo "Bear Error"')
            raise
        if self.comp_data_bear.is_file():
            subprocess.call(["rdm", "--log-file=$HOME/dev/logs/rdm.log", "--silent", "--daemon"])
            subprocess.call(["rc", "-J", "."])
        else:
            self.vim.command('echo "Error Generating Compilation Database With Bear"')

    @neovim.function('CMakeCompDB')
    def cMakeCompDB(self, args):
        self.vim.command('echo "Starting CMake Project"')

        if self.old_cmake_dir.is_dir():
            subprocess.call( ["rm", "-rf", str( old_cmake_dir ) ] )

        if self.comp_data_bear.is_file():
            subprocess.call( ["rm", str( comp_data_bear ) ] )

        for path in self.old_cmake_files:
            if path.is_file():
                subprocess.call(["rm", str( path )])

        if self.cmake_proj.is_file():
            if self.build_dir.is_dir():
                self.vim.command('echo "Cleaning up Build Directory"')
                subprocess.call(["rm", "-rf", "build"])
            self.vim.command('echo "Running CMake"')
            self.run_cmake()
        else:
            self.vim.command('echo "Not a CMake Project"')
            if self.makefile.is_file():
                self.run_bear()
            else:
                self.vim.command('echo "Not Setup for Autotools Either"')

<commit_msg>Disable Bear code and add debug message.<commit_after>import neovim
from pathlib import Path
import subprocess.call as spcall
#import os

@neovim.plugin
class Main(object):
    def __init__(self, vim):
        self.vim = vim
        self.old_cmake_files = [ Path("CMakeCache.txt"), Path("cmake_install.cmake") ]
        self.old_cmake_dir = Path("CMakeFiles")
        self.cmake_proj = Path("CMakeLists.txt")
        self.makefile = Path("Makefile")
        self.build_dir = Path("build")
        self.comp_data_cmake = Path("build/compile_commands.json")
        self.comp_data_bear = Path("compile_commands.json")

    def run_cmake(self):
        try:
            subprocess.call( ["mkdir", "build"] )
        except OSError:
            self.vim.command('echo "Can\'t setup CMake build directory."')
            raise
        try:
            self.vim.command('echo "Running CMake..."')
            subprocess.call( ["cmake", "-DCMAKE_EXPORT_COMPILE_COMMANDS=1", ".."], cwd="build" )
        except OSError:
            self.vim.command('echo "CMake Failed."')
            raise
        if self.comp_data_cmake.is_file():
            try:
                subprocess.call( ["rdm", "--silent", "--daemon"], cwd=".." )
            except OSError:
                self.vim.command('echo "Couldn\'t start the RTags daemon."')
                raise
            subprocess.call( ["rc", "-J", "build"] )
        else:
            self.vim.command('echo "Error Generating Compilation Database With CMake"')
            raise

#    def run_bear(self):
#        try:
#            subprocess.call(["bear", "make"])
#        except OSError as e:
#            if e.errno == os.errno.ENOENT:
#                self.vim.command('echo "No Makefile for Bear to Use"')
#            else:
#                self.vim.command('echo "Bear Error"')
#            raise
#        if self.comp_data_bear.is_file():
#            subprocess.call(["rdm", "--log-file=$HOME/dev/logs/rdm.log", "--silent", "--daemon"])
#            subprocess.call(["rc", "-J", "."])
#        else:
#            self.vim.command('echo "Error Generating Compilation Database With Bear"')
#
    @neovim.function('CMakeCompDB')
    def cMakeCompDB(self, args):
        self.vim.command('echo "Starting CMake Project"')

        if self.old_cmake_dir.is_dir():
            subprocess.call( ["rm", "-rf", str( old_cmake_dir ) ] )

        if self.comp_data_bear.is_file():
            subprocess.call( ["rm", str( comp_data_bear ) ] )

        for path in self.old_cmake_files:
            if path.is_file():
                subprocess.call(["rm", str( path )])

        if self.cmake_proj.is_file():
            if self.build_dir.is_dir():
                self.vim.command('echo "Cleaning up Build Directory"')
                subprocess.call(["rm", "-rf", "build"])
            self.vim.command('echo "Running CMake"')
            self.run_cmake()
        else:
            self.vim.command('echo "Not a CMake Project"')
            if self.makefile.is_file():
                self.run_bear()
            else:
                self.vim.command('echo "Not Setup for Autotools Either"')


{'fraction_non_alphanumeric': 0.14246263807667317, 'fraction_numerical': 0.0003248862897985705, 'mean_word_length': 1.9672289156626506, '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': '85343', 'n_tokens_mistral': 1958, 'n_tokens_neox': 1871, 'n_words': 393}