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

import subprocess
import sys
import os
import argparse
import platform

def unicodeWrite(out, str):
    try:
        out.write(str)
    except UnicodeEncodeError:
        bytes = str.encode(out.encoding or 'ascii', 'replace')
        if hasattr(sys.stdout, 'buffer'):
            out.buffer.write(bytes)
        else:
            out.write(bytes.decode(out.encoding or 'ascii', 'replace'))

try:
    p = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (out, err) = p.communicate()
except Exception as e:
    print('Execution failure: %s' % str(e))
    sys.exit(-1)

includes = ''
msg = ''
if out:
    out = out.decode(sys.stdout.encoding or 'ascii', 'replace')
    includes = '\n'.join([l for l in out.split(os.linesep) if l.startswith('Note: including file:')])
    out = '\n'.join([l for l in out.split(os.linesep) if not l.startswith('Note: including file:')])
    msg = msg + out

unicodeWrite(sys.stdout, includes) # Ninja relies on result of /showIncludes when compiling with cl

if err:
    err = err.decode(sys.stderr.encoding or 'ascii', 'replace')
    msg = msg + err

if msg:
    parser = argparse.ArgumentParser()
    parser.add_argument('-o')
    parser.add_argument('-c')
    (args, unparsed) = parser.parse_known_args(sys.argv[2:])

    src_str = None
    for opt in [args.c, args.o]:
        if opt:
            src_str = opt
            break
<commit_msg>Fixed "path too long" issue on Windows (DRQS 128304440)<commit_after>#!/usr/bin/env python

import subprocess
import sys
import os
import argparse
import platform

def unicodeWrite(out, str):
    try:
        out.write(str)
    except UnicodeEncodeError:
        bytes = str.encode(out.encoding or 'ascii', 'replace')
        if hasattr(sys.stdout, 'buffer'):
            out.buffer.write(bytes)
        else:
            out.write(bytes.decode(out.encoding or 'ascii', 'replace'))

try:
    p = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (out, err) = p.communicate()
except Exception as e:
    print('Execution failure: %s' % str(e))
    sys.exit(-1)

includes = ''
msg = ''
if out:
    out = out.decode(sys.stdout.encoding or 'ascii', 'replace')
    includes = '\n'.join([l for l in out.split(os.linesep) if l.startswith('Note: including file:')])+'\n'
    out = '\n'.join([l for l in out.split(os.linesep) if not l.startswith('Note: including file:')])
    msg = msg + out

unicodeWrite(sys.stdout, includes) # Ninja relies on result of /showIncludes when compiling with cl

if err:
    err = err.decode(sys.stderr.encoding or 'ascii', 'replace')
    msg = msg + err

if msg:
    parser = argparse.ArgumentParser()
    parser.add_argument('-o')
    parser.add_argument('-c')
    (args, unparsed) = parser.parse_known_args(sys.argv[2:])

    src_str = None
    for opt in [args.c, args.o]:
        if opt:
            src_str = opt
            break

{'fraction_non_alphanumeric': 0.14164113040517534, 'fraction_numerical': 0.005107252298263534, 'mean_word_length': 3.0136612021857925, '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': '1653830', 'n_tokens_mistral': 1008, 'n_tokens_neox': 977, 'n_words': 260}