<commit_before>﻿using Dewey.Manifest.Repositories;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Dewey.Manifest.Repository
{
    public class RepositoryManifest
    {
        public IEnumerable<ComponentItem> ComponentItems { get; private set; }

        public const string DEFAULT_REPOSITORY_FILE_NAME = "repository.xml";

        public static LoadRepositoryItemResult LoadRepositoryItem(RepositoryItem repositoryItem, string rootLocation)
        {
            var repositoryDirectory = new DirectoryInfo(Path.Combine(rootLocation, repositoryItem.RelativeLocation));
            if (!repositoryDirectory.Exists) return LoadRepositoryItemResult.CreateDirectoryNotFoundResult(repositoryDirectory);

            var repositoryManifestFile = new FileInfo(Path.Combine(repositoryDirectory.FullName, DEFAULT_REPOSITORY_FILE_NAME));
            if (!repositoryManifestFile.Exists) return LoadRepositoryItemResult.CreateFileNotFoundResult(repositoryDirectory, repositoryManifestFile);

            var repository = XElement.Load(repositoryManifestFile.FullName);
            var componentsElement = repository.Elements().FirstOrDefault(x => x.Name.LocalName == "components");

            var componentItemResults = new List<LoadComponentElementResult>();
            if (componentsElement != null)
            {
                var componentElements = componentsElement.Elements().Where(x => x.Name.LocalName == "component");
                foreach (var componentElement in componentElements)<commit_msg>change RepositoryManifest to have a private constructor<commit_after>﻿using Dewey.Manifest.Repositories;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Dewey.Manifest.Repository
{
    public class RepositoryManifest
    {
        public IEnumerable<ComponentItem> ComponentItems { get; private set; }

        public const string DEFAULT_REPOSITORY_FILE_NAME = "repository.xml";

        private RepositoryManifest () { }

        public static LoadRepositoryItemResult LoadRepositoryItem(RepositoryItem repositoryItem, string rootLocation)
        {
            var repositoryDirectory = new DirectoryInfo(Path.Combine(rootLocation, repositoryItem.RelativeLocation));
            if (!repositoryDirectory.Exists) return LoadRepositoryItemResult.CreateDirectoryNotFoundResult(repositoryDirectory);

            var repositoryManifestFile = new FileInfo(Path.Combine(repositoryDirectory.FullName, DEFAULT_REPOSITORY_FILE_NAME));
            if (!repositoryManifestFile.Exists) return LoadRepositoryItemResult.CreateFileNotFoundResult(repositoryDirectory, repositoryManifestFile);

            var repository = XElement.Load(repositoryManifestFile.FullName);
            var componentsElement = repository.Elements().FirstOrDefault(x => x.Name.LocalName == "components");

            var componentItemResults = new List<LoadComponentElementResult>();
            if (componentsElement != null)
            {
                var componentElements = componentsElement.Elements().Where(x => x.Name.LocalName == "component");
                foreach (var componentElement in componentElements)
{'fraction_non_alphanumeric': 0.07805463824677274, 'fraction_numerical': 0.0, 'mean_word_length': 4.071537290715373, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4433068', 'n_tokens_mistral': 765, 'n_tokens_neox': 764, 'n_words': 173}