<commit_before>#!/usr/bin/python

import os
import sys

def convert_line_endings(file):
  if '\r\n' in open(file, 'rb').read():
    print '%s contains DOS line endings. Converting' % file
    with open(file, 'rb') as infile:
      text = infile.read()
      text = text.replace('\r\n', '\n')
    with open(file, 'wb') as outfile:
      outfile.write(text)

def processPath(dirPath, ext):
  for dirpath, dirnames, filenames in os.walk(dirPath):
    for file in filenames:
      if os.path.splitext(file)[1] == ext:
        csPath = os.path.join(dirpath, file)
        convert_line_endings(csPath)

if __name__ == "__main__":
  if len(sys.argv) > 1:
    convert_line_endings(sys.argv[1])
    return
  processPath('.', '.cs')
  processPath('testpackages', '.h')
  processPath('testpackages', '.c')
  processPath('testpackages', '.cpp')<commit_msg>[trunk] Fixed tabbing, and an errant return statement<commit_after>#!/usr/bin/python

import os
import sys

def convert_line_endings(file):
    if '\r\n' in open(file, 'rb').read():
        print '%s contains DOS line endings. Converting' % file
        with open(file, 'rb') as infile:
            text = infile.read()
            text = text.replace('\r\n', '\n')
        with open(file, 'wb') as outfile:
            outfile.write(text)

def processPath(dirPath, ext):
    for dirpath, dirnames, filenames in os.walk(dirPath):
        for file in filenames:
            if os.path.splitext(file)[1] == ext:
                csPath = os.path.join(dirpath, file)
                convert_line_endings(csPath)

if __name__ == "__main__":
  if len(sys.argv) > 1:
    convert_line_endings(sys.argv[1])
  else:
    processPath('.', '.cs')
    processPath('testpackages', '.h')
    processPath('testpackages', '.c')
    processPath('testpackages', '.cpp')
{'fraction_non_alphanumeric': 0.1539319576129392, 'fraction_numerical': 0.0033463469046291134, 'mean_word_length': 3.0405405405405403, 'pattern_counts': {'":': 2, '<': 3, '<?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': '3688545', 'n_tokens_mistral': 622, 'n_tokens_neox': 611, 'n_words': 150}