Отчистка кода
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.Compendium;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry
|
||||
@@ -164,7 +163,7 @@ namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry
|
||||
public FileInfo File { get; } = file;
|
||||
public JObject Json { get; } = itemJson;
|
||||
public CompendiumFolder Folder { get; } = folder;
|
||||
public string Type { get; } = itemJson["type"]?.ToString()
|
||||
public string Type { get; } = itemJson["type"]?.ToString()
|
||||
?? throw new Exception($"Expected to have `type` field in file {file.FullName}");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
using LinqToDB.DataProvider.SapHana;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Npgsql;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
|
||||
{
|
||||
|
||||
+2
-4
@@ -1,11 +1,9 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
internal class Pf2eTypeProcessor(string type) : Attribute
|
||||
{
|
||||
public readonly string Type = type;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -2,7 +2,6 @@
|
||||
using Pf2eDataScrapper.Model;
|
||||
using Pf2eDataScrapper.Model.Enum;
|
||||
using Slugify;
|
||||
using static LinqToDB.Common.Configuration;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder.Processors
|
||||
{
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
using Konsole;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.Compendium;
|
||||
using Pf2eDataScrapper.SchemaBuilder;
|
||||
|
||||
|
||||
+2
-7
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eDataScrapper.SchemaBuilder;
|
||||
using Pf2eDataScrapper.SchemaBuilder.Types;
|
||||
|
||||
@@ -55,7 +50,7 @@ namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.SchemaBuilder
|
||||
{
|
||||
return new DictionarySchemaType(node);
|
||||
}
|
||||
|
||||
|
||||
if (node.Path.EndsWith(".rules"))
|
||||
{
|
||||
return new FoundryRulesSchemaType(node);
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using LinqToDB.SqlQuery;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Pf2eDataScrapper.Model;
|
||||
using Pf2eDataScrapper.Model.Enum;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pf2eDataScrapper;
|
||||
|
||||
@@ -103,7 +100,8 @@ public partial class Pf2eTestContext : DbContext
|
||||
|
||||
public virtual DbSet<Trait> Traits { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql(EnvSettings.DatabaseConnection,
|
||||
builder =>
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Pf2eDataScrapper.SchemaBuilder
|
||||
/// <summary>
|
||||
/// Конструктор корневого элемента.
|
||||
/// </summary>
|
||||
public SchemaNode()
|
||||
public SchemaNode()
|
||||
{
|
||||
this.Root = true;
|
||||
}
|
||||
@@ -139,7 +139,8 @@ namespace Pf2eDataScrapper.SchemaBuilder
|
||||
/// <returns>Строковое представление элемента.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
var result = new Dictionary<string, string>() {
|
||||
var result = new Dictionary<string, string>()
|
||||
{
|
||||
["type"] = GetTypeName(),
|
||||
["path"] = Path,
|
||||
["is_null"] = IsNullable ? "true" : "false",
|
||||
@@ -204,7 +205,7 @@ namespace Pf2eDataScrapper.SchemaBuilder
|
||||
/// </summary>
|
||||
/// <param name="input">Словарь данных.</param>
|
||||
/// <returns>Строка форматированных данных</returns>
|
||||
public static string FormatYaml(params Dictionary<string, string>[] input)
|
||||
public static string FormatYaml(params List<Dictionary<string, string>> input)
|
||||
{
|
||||
var result = "";
|
||||
|
||||
@@ -218,7 +219,7 @@ namespace Pf2eDataScrapper.SchemaBuilder
|
||||
return result.Trim();
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> MergeDictionaries(params Dictionary<string, string>[] input)
|
||||
public static Dictionary<string, string> MergeDictionaries(params List<Dictionary<string, string>> input)
|
||||
{
|
||||
var result = new Dictionary<string, string>();
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Pf2eDataScrapper.SchemaBuilder.Types
|
||||
public override void AddValue(JToken value)
|
||||
{
|
||||
var obj = (JObject)value;
|
||||
|
||||
|
||||
foreach (var field in Fields)
|
||||
{
|
||||
if (!obj.ContainsKey(field.Name))
|
||||
@@ -114,7 +114,8 @@ namespace Pf2eDataScrapper.SchemaBuilder.Types
|
||||
/// <returns>Словарь данных</returns>
|
||||
public override Dictionary<string, string> GetYamlData()
|
||||
{
|
||||
return new() {
|
||||
return new()
|
||||
{
|
||||
["schema"] = SchemaNode.FormatYaml(GetSchemaYaml())
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Linq.Expressions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Pf2eDataScrapper.SchemaBuilder.Types
|
||||
{
|
||||
@@ -91,7 +90,8 @@ namespace Pf2eDataScrapper.SchemaBuilder.Types
|
||||
}
|
||||
}
|
||||
|
||||
return new() {
|
||||
return new()
|
||||
{
|
||||
["different_values"] = count.ToString() +
|
||||
((count == Root.Values) ? " (all different)" : "") +
|
||||
((count == 1) ? " (all same)" : ""),
|
||||
|
||||
Reference in New Issue
Block a user