<commit_before>import sys, os, shutil

class Cesgen_Utils:

    @staticmethod
    def create_file( file_path, str_to_write ):
        if not os.path.exists( file_path ):
            new_file = open( file_path, 'w' )

            new_file.write( str_to_write )

            new_file.flush( )
            new_file.close( )

    @staticmethod
    def create_and_copy_directory( project_path, dir_name, dir_to_copy ):
        dir_path = os.path.join( project_path, dir_name )
        if not os.path.exists( dir_path ):
            os.makedirs( dir_path )

        source_dir = dir_to_copy
        if len( dir_to_copy ) > 0:
            for temp_file in os.listdir( source_dir ):
                full_temp_file_path = os.path.join( source_dir, temp_file )
                if os.path.isfile( full_temp_file_path ):
                    shutil.copy( full_temp_file_path, dir_path )

    @staticmethod
    def generate_manifest_boiler( project_name, perm_new_tab, perm_storage, 
                                    perm_context_menus, perm_notifications, 
                                    background_scripts, content_scripts, 
                                    option_pages ):
        manifest_boiler = \
'{\n\
    "manifest_version"  :     2,\n\
    "name"              :     "' + project_name + '",\n\
    "short_name"        :     "' + project_name.replace( " ", "" ) + '",\n\
    "version"           :     "1.0.0",\n\
    "description"       :     "' + project_name + '."' 

        if perm_storage == True or perm_context_menus == True or perm_notifications == True:
            manifest_boiler = manifest_boiler + \
',\n\
    "permissions" : [\n'

            if perm_storage == True:
                manifest_boiler = manifest_boiler + \
'        "storage"'

            if perm_context_menus == True:
                manifest_boiler = manifest_boiler + \
',\n        "contextMenus"'

            if perm_notifications == True:
                manifest_boiler = manifest_boiler + \
',\n        "notifications"'

            manifest_boiler = manifest_boiler + \
'\n    ]'

        if perm_new_tab == True:
            manifest_boiler = manifest_boiler + \
',\n\
    "chrome_url_overrides" : {\n\
        "newtab" : "main.html"\n\
    }'

        if background_scripts == True:
            manifest_boiler = manifest_boiler + \
',\n\
    "background" : {\n\
        "scripts" : [ "scripts/background.js" ]\n\
    }'
<commit_msg>Fixing up bug with permissions in manifest<commit_after>import sys, os, shutil

class Cesgen_Utils:

    @staticmethod
    def create_file( file_path, str_to_write ):
        if not os.path.exists( file_path ):
            new_file = open( file_path, 'w' )

            new_file.write( str_to_write )

            new_file.flush( )
            new_file.close( )

    @staticmethod
    def create_and_copy_directory( project_path, dir_name, dir_to_copy ):
        dir_path = os.path.join( project_path, dir_name )
        if not os.path.exists( dir_path ):
            os.makedirs( dir_path )

        source_dir = dir_to_copy
        if len( dir_to_copy ) > 0:
            for temp_file in os.listdir( source_dir ):
                full_temp_file_path = os.path.join( source_dir, temp_file )
                if os.path.isfile( full_temp_file_path ):
                    shutil.copy( full_temp_file_path, dir_path )

    @staticmethod
    def generate_manifest_boiler( project_name, perm_new_tab, perm_storage, 
                                    perm_context_menus, perm_notifications, 
                                    background_scripts, content_scripts, 
                                    option_pages ):
        manifest_boiler = \
'{\n\
    "manifest_version"  :     2,\n\
    "name"              :     "' + project_name + '",\n\
    "short_name"        :     "' + project_name.replace( " ", "" ) + '",\n\
    "version"           :     "1.0.0",\n\
    "description"       :     "' + project_name + '."' 

        if perm_storage == True or perm_context_menus == True or perm_notifications == True:
            manifest_boiler = manifest_boiler + \
',\n\
    "permissions" : [\n'

            if perm_storage == True:
                manifest_boiler = manifest_boiler + '        "storage"'

                if perm_storage + perm_context_menus + perm_notifications > 1:
                    manifest_boiler = manifest_boiler + ',\n'

            if perm_context_menus == True:
                manifest_boiler = manifest_boiler + '        "contextMenus"'

                if perm_storage + perm_context_menus + perm_notifications > 1:
                    manifest_boiler = manifest_boiler + ',\n'

            if perm_notifications == True:
                manifest_boiler = manifest_boiler + '        "notifications"'

            manifest_boiler = manifest_boiler + '\n    ]'

        if perm_new_tab == True:
            manifest_boiler = manifest_boiler + \
',\n\
    "chrome_url_overrides" : {\n\
        "newtab" : "main.html"\n\
    }'

        if background_scripts == True:
            manifest_boiler = manifest_boiler + \
',\n\
    "background" : {\n\
        "scripts" : [ "scripts/background.js" ]\n\
    }'

{'fraction_non_alphanumeric': 0.10583446404341927, 'fraction_numerical': 0.0023260321767784456, 'mean_word_length': 1.7229551451187335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2720957', 'n_tokens_mistral': 1628, 'n_tokens_neox': 1543, 'n_words': 306}