<commit_before>#!/usr/bin/env python3

import sys
import os

import fsquery
import path_utils

def puaq():
    print("Usage: %s folder" % path_utils.basename_filtered(__file__))
    sys.exit(1)

def insert_pragma(path):

    exts = ["h"]
    ret = fsquery.makecontentlist(path, True, False, True, False, False, False, True, exts)

    pragma_str = "\n#ifdef __GNUC__\n#pragma GCC system_header\n#endif\n"

    failed_bucket = [] #currently unused

    for r in ret:
        contents = pragma_str
        with open(r) as f:
            contents += f.read()
        with open(r, "w") as f:
            f.write(contents)

    if len(failed_bucket) > 0:
        print("There were failures!")
        for fb in failed_bucket:
            print("%s failed." % fb)
    else:
        print("All done - no errors detected")

if __name__ == "__main__":

    if len(sys.argv) < 2:
        puaq()
    else:
        insert_pragma(sys.argv[1])<commit_msg>insert_pragma: updated after fsquery api change<commit_after>#!/usr/bin/env python3

import sys
import os

import fsquery
import path_utils

def puaq():
    print("Usage: %s folder" % path_utils.basename_filtered(__file__))
    sys.exit(1)

def insert_pragma(path):

    exts = ["h"]
    v, r = fsquery.makecontentlist(path, True, False, True, False, False, False, True, exts)
    ret = r

    pragma_str = "\n#ifdef __GNUC__\n#pragma GCC system_header\n#endif\n"

    failed_bucket = [] #currently unused

    for r in ret:
        contents = pragma_str
        with open(r) as f:
            contents += f.read()
        with open(r, "w") as f:
            f.write(contents)

    if len(failed_bucket) > 0:
        print("There were failures!")
        for fb in failed_bucket:
            print("%s failed." % fb)
    else:
        print("All done - no errors detected")

if __name__ == "__main__":

    if len(sys.argv) < 2:
        puaq()
    else:
        insert_pragma(sys.argv[1])
{'fraction_non_alphanumeric': 0.12389839294971487, 'fraction_numerical': 0.005184033177812338, 'mean_word_length': 2.5090909090909093, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '4577934', 'n_tokens_mistral': 673, 'n_tokens_neox': 642, 'n_words': 177}