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