<commit_before>﻿// Inspired by <NAME>'s UnityConstantsGenerator
namespace ConstantsGenerator {
    using UnityEngine;
    using UnityEditor;
    using System;
    using System.Text;
    using System.IO;

    public class ConstantsWriter : IDisposable {
        StringBuilder _stringBuilder;
        int _indentLevel;
        string _filePath;
        int _spacesPerIndent;

        string ChooseFilePath (string name, string extension) {
            // Try to find an existing file in the project called name+".cs"
            string filePath = null;
            string extensionWildcard = string.Format("*{0}", extension);
            foreach (var file in Directory.GetFiles(Application.dataPath, extensionWildcard, SearchOption.AllDirectories)) {
                if (Path.GetFileNameWithoutExtension(file) == name) {
                    filePath = file;
                    break;
                }
            }

            string nameWithExtension = string.Format("{0}{1}", name, extension);
            // If no such file exists yet, use a save window to ask the user for a folder in which to save the file.
            if (string.IsNullOrEmpty(_filePath)) {
                string prompt = string.Format("Choose location for {0}", nameWithExtension);
                string directory = EditorUtility.OpenFolderPanel(prompt, Application.dataPath, "");

                // Canceled choose? Do nothing.
                if (string.IsNullOrEmpty(directory)) {
                    return null;
                }

                filePath = Path.Combine(directory, nameWithExtension);
            }
            return filePath;
        }

        public ConstantsWriter (string name, string extension = ".cs", int spacesPerIndent = 4, string path = null, bool includeHeader = true) {
            _stringBuilder = new StringBuilder();

            _spacesPerIndent = spacesPerIndent;
            if (path != null) {
                path = Path.Combine(path, string.Format("{0}{1}", name, extension));
            }
            _filePath = path ?? ChooseFilePath(name, extension);
            if (_filePath == null) { return; }

            _indentLevel = 0;
            if (includeHeader) {
                _stringBuilder.AppendFormat("/* This file ({0}{1}) is auto-generated. Modifications are not saved. */\n", name, extension);
                _stringBuilder.AppendLine();
            }

<commit_msg>Fix for file path reprompts<commit_after>﻿// Inspired by <NAME>'s UnityConstantsGenerator
namespace ConstantsGenerator {
    using UnityEngine;
    using UnityEditor;
    using System;
    using System.Text;
    using System.IO;

    public class ConstantsWriter : IDisposable {
        StringBuilder _stringBuilder;
        int _indentLevel;
        string _filePath;
        int _spacesPerIndent;

        string ChooseFilePath (string name, string extension) {
            // Try to find an existing file in the project called name+".cs"
            string filePath = null;
            string extensionWildcard = string.Format("*{0}", extension);
            foreach (var file in Directory.GetFiles(Application.dataPath, extensionWildcard, SearchOption.AllDirectories)) {
                if (Path.GetFileNameWithoutExtension(file) == name) {
                    filePath = file;
                    break;
                }
            }

            string nameWithExtension = string.Format("{0}{1}", name, extension);
            // If no such file exists yet, use a save window to ask the user for a folder in which to save the file.
            if (string.IsNullOrEmpty(filePath)) {
                string prompt = string.Format("Choose location for {0}", nameWithExtension);
                string directory = EditorUtility.OpenFolderPanel(prompt, Application.dataPath, "");

                // Canceled choose? Do nothing.
                if (string.IsNullOrEmpty(directory)) {
                    return null;
                }

                filePath = Path.Combine(directory, nameWithExtension);
            }
            return filePath;
        }

        public ConstantsWriter (string name, string extension = ".cs", int spacesPerIndent = 4, string path = null, bool includeHeader = true) {
            _stringBuilder = new StringBuilder();

            _spacesPerIndent = spacesPerIndent;
            if (path != null) {
                path = Path.Combine(path, string.Format("{0}{1}", name, extension));
            }
            _filePath = path ?? ChooseFilePath(name, extension);
            if (_filePath == null) { return; }

            _indentLevel = 0;
            if (includeHeader) {
                _stringBuilder.AppendFormat("/* This file ({0}{1}) is auto-generated. Modifications are not saved. */\n", name, extension);
                _stringBuilder.AppendLine();
            }


{'fraction_non_alphanumeric': 0.09217355200332157, 'fraction_numerical': 0.004151961801951422, 'mean_word_length': 1.9722393584207278, 'pattern_counts': {'":': 0, '<': 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': '7249480', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1147, 'n_words': 354}