<commit_before># Copyright 2017 The Meson development team

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Code that creates simple startup projects."""

from pathlib import Path
import subprocess
import shutil
import re
from glob import glob
from mesonbuild import mesonlib
from mesonbuild.environment import detect_ninja

from mesonbuild.templates.fortrantemplates import (create_exe_fortran_sample, create_lib_fortran_sample)
from mesonbuild.templates.objcpptemplates import (create_exe_objcpp_sample, create_lib_objcpp_sample)
from mesonbuild.templates.dlangtemplates import (create_exe_d_sample, create_lib_d_sample)
from mesonbuild.templates.rusttemplates import (create_exe_rust_sample, create_lib_rust_sample)
from mesonbuild.templates.javatemplates import (create_exe_java_sample, create_lib_java_sample)
from mesonbuild.templates.cudatemplates import (create_exe_cuda_sample, create_lib_cuda_sample)
from mesonbuild.templates.objctemplates import (create_exe_objc_sample, create_lib_objc_sample)
from mesonbuild.templates.cpptemplates import (create_exe_cpp_sample, create_lib_cpp_sample)
from mesonbuild.templates.cstemplates import (create_exe_cs_sample, create_lib_cs_sample)
from mesonbuild.templates.ctemplates import (create_exe_c_sample, create_lib_c_sample)

'''
we currently have one meson template at this time.
'''
from mesonbuild.templates.mesontemplates import create_meson_build

FORTRAN_SUFFIXES = ('.f', '.for', '.F', '.f90', '.F90')
LANG_SUFFIXES = ('.c', '.cc', '.cpp', '.cs', '.cu', '.d', '.m', '.mm', '.rs', '.java') + FORTRAN_SUFFIXES
LANG_SUPPORTED = ('c', 'cpp', 'cs', 'cuda', 'd', 'fortran', 'java', 'rust', 'objc', 'objcpp')

DEFAULT_EXE = 'executable'
DEFAULT_LIB = 'library'
DEFAULT_PROJECT = 'executable'
DEFAULT_VERSION = '0.1'

UNREACHABLE_CODE_ERROR = 'Unreachable code'

INFO_MESSAGE = '''Sample project created. To build it run the
following commands:

meson builddir
ninja -C builddir
'''


def create_sample(options) -> None:
    '''
    Based on what arguments are passed we check for a match in language
    then check for project type and create new Meson samples project.
    '''
    if options.language == 'c':
        if options.type == DEFAULT_EXE:
            create_exe_c_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_c_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'cpp':
        if options.type == DEFAULT_EXE:
            create_exe_cpp_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_cpp_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'cs':
        if options.type == DEFAULT_EXE:
            create_exe_cs_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_cs_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'cuda':
        if options.type == DEFAULT_EXE:
            create_exe_cuda_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_cuda_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'd':
        if options.type == DEFAULT_EXE:
            create_exe_d_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_d_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'fortran':
        if options.type == DEFAULT_EXE:
            create_exe_fortran_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_fortran_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'rust':
        if options.type == DEFAULT_EXE:
            create_exe_rust_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_rust_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'objc':
        if options.type == DEFAULT_EXE:
            create_exe_objc_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_objc_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'objcpp':
        if options.type == DEFAULT_EXE:
            create_exe_objcpp_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_objcpp_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'java':
        if options.type == DEFAULT_EXE:
            create_exe_java_sample(options.name, options.version)
        elif options.type == DEFAULT_LIB:
            create_lib_java_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    else:
        raise RuntimeError(UNREACHABLE_CODE_ERROR)
    print(INFO_MESSAGE)<commit_msg>make use of enums<commit_after># Copyright 2017 The Meson development team

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Code that creates simple startup projects."""

from pathlib import Path
from enum import Enum
import subprocess
import shutil
import re
from glob import glob
from mesonbuild import mesonlib
from mesonbuild.environment import detect_ninja

from mesonbuild.templates.fortrantemplates import (create_exe_fortran_sample, create_lib_fortran_sample)
from mesonbuild.templates.objcpptemplates import (create_exe_objcpp_sample, create_lib_objcpp_sample)
from mesonbuild.templates.dlangtemplates import (create_exe_d_sample, create_lib_d_sample)
from mesonbuild.templates.rusttemplates import (create_exe_rust_sample, create_lib_rust_sample)
from mesonbuild.templates.javatemplates import (create_exe_java_sample, create_lib_java_sample)
from mesonbuild.templates.cudatemplates import (create_exe_cuda_sample, create_lib_cuda_sample)
from mesonbuild.templates.objctemplates import (create_exe_objc_sample, create_lib_objc_sample)
from mesonbuild.templates.cpptemplates import (create_exe_cpp_sample, create_lib_cpp_sample)
from mesonbuild.templates.cstemplates import (create_exe_cs_sample, create_lib_cs_sample)
from mesonbuild.templates.ctemplates import (create_exe_c_sample, create_lib_c_sample)

'''
we currently have one meson template at this time.
'''
from mesonbuild.templates.mesontemplates import create_meson_build

FORTRAN_SUFFIXES = ('.f', '.for', '.F', '.f90', '.F90')
LANG_SUFFIXES = ('.c', '.cc', '.cpp', '.cs', '.cu', '.d', '.m', '.mm', '.rs', '.java') + FORTRAN_SUFFIXES
LANG_SUPPORTED = ('c', 'cpp', 'cs', 'cuda', 'd', 'fortran', 'java', 'rust', 'objc', 'objcpp')

DEFAULT_PROJECT = 'executable'
DEFAULT_VERSION = '0.1'
class DEFAULT_TYPES(Enum):
    EXE = 'executable'
    LIB = 'library'

UNREACHABLE_CODE_ERROR = 'Unreachable code'

INFO_MESSAGE = '''Sample project created. To build it run the
following commands:

meson builddir
ninja -C builddir
'''


def create_sample(options) -> None:
    '''
    Based on what arguments are passed we check for a match in language
    then check for project type and create new Meson samples project.
    '''
    if options.language == 'c':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_c_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_c_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'cpp':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_cpp_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_cpp_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'cs':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_cs_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_cs_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'cuda':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_cuda_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_cuda_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'd':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_d_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_d_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'fortran':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_fortran_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_fortran_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'rust':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_rust_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_rust_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'objc':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_objc_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_objc_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'objcpp':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_objcpp_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_objcpp_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    elif options.language == 'java':
        if options.type == DEFAULT_TYPES['EXE'].value:
            create_exe_java_sample(options.name, options.version)
        elif options.type == DEFAULT_TYPES['LIB'].value:
            create_lib_java_sample(options.name, options.version)
        else:
            raise RuntimeError(UNREACHABLE_CODE_ERROR)
    else:
        raise RuntimeError(UNREACHABLE_CODE_ERROR)
    print(INFO_MESSAGE)
{'fraction_non_alphanumeric': 0.09297163995067817, 'fraction_numerical': 0.002301685162351007, 'mean_word_length': 3.632901751713633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3470820', 'n_tokens_mistral': 3590, 'n_tokens_neox': 3524, 'n_words': 854}