Move filtering to new class

This commit is contained in:
Matt Nadareski
2020-12-10 13:13:54 -08:00
parent 23e911ecd4
commit b57927a4ef
7 changed files with 272 additions and 248 deletions

View File

@@ -54,7 +54,7 @@ namespace RombaSharp.Features
datfile.Header.Name = string.IsNullOrWhiteSpace(name) ? "untitled" : name; datfile.Header.Name = string.IsNullOrWhiteSpace(name) ? "untitled" : name;
datfile.Header.Description = description; datfile.Header.Description = description;
DatTool.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive); DatTool.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive);
datfile.ApplyCleaning(new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() }); DatTool.ApplyCleaning(datfile, new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() });
DatTool.Write(datfile, outdat); DatTool.Write(datfile, outdat);
} }
} }

View File

@@ -1,7 +1,7 @@
using SabreTools.Logging; using SabreTools.Logging;
// TODO: What sort of internal state should this have? Would a single DatFile be appropriate? // TODO: Should each of the individual pieces of partial classes be their own classes?
// TODO: How much of the stuff currently in DatFile should be moved here? // TODO: Is a single, consistent internal state needed for this class at all?
namespace SabreTools.DatFiles namespace SabreTools.DatFiles
{ {
/// <summary> /// <summary>

View File

@@ -160,7 +160,7 @@ Reset the internal state: reset();";
// TODO: We might not want to remove dates in the future // TODO: We might not want to remove dates in the future
Cleaner dfdCleaner = new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() }; Cleaner dfdCleaner = new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() };
dfdCleaner.ExcludeFields.Add(Field.DatItem_Date); dfdCleaner.ExcludeFields.Add(Field.DatItem_Date);
datFile.ApplyCleaning(dfdCleaner); DatTool.ApplyCleaning(datFile, dfdCleaner);
break; break;
@@ -205,7 +205,7 @@ Reset the internal state: reset();";
filter.SetFilter(filterField, filterValue, filterRemove.Value); filter.SetFilter(filterField, filterValue, filterRemove.Value);
// Apply the filter blindly // Apply the filter blindly
datFile.ApplyFilter(filter, filterPerMachine.Value); DatTool.ApplyFilter(datFile, filter, filterPerMachine.Value);
// Cleanup after the filter // Cleanup after the filter
// TODO: We might not want to remove immediately // TODO: We might not want to remove immediately
@@ -247,7 +247,7 @@ Reset the internal state: reset();";
extraIni.Items.Add(extraIniItem); extraIni.Items.Add(extraIniItem);
// Apply the extra INI blindly // Apply the extra INI blindly
datFile.ApplyExtras(extraIni); DatTool.ApplyExtras(datFile, extraIni);
break; break;
@@ -271,7 +271,7 @@ Reset the internal state: reset();";
} }
// Apply the merging flag // Apply the merging flag
datFile.ApplySplitting(mergingFlag, false); DatTool.ApplySplitting(datFile, mergingFlag, false);
break; break;
@@ -285,7 +285,7 @@ Reset the internal state: reset();";
} }
// Apply the logic // Apply the logic
datFile.MachineDescriptionToName(); DatTool.MachineDescriptionToName(datFile);
break; break;
@@ -299,7 +299,7 @@ Reset the internal state: reset();";
} }
// Run the 1G1R functionality // Run the 1G1R functionality
datFile.OneGamePerRegion(command.Arguments); DatTool.OneGamePerRegion(datFile, command.Arguments);
break; break;
@@ -313,7 +313,7 @@ Reset the internal state: reset();";
} }
// Apply the logic // Apply the logic
datFile.OneRomPerGame(); DatTool.OneRomPerGame(datFile);
break; break;
@@ -327,7 +327,7 @@ Reset the internal state: reset();";
} }
// Run the removal functionality // Run the removal functionality
datFile.RemoveFieldsFromItems(command.Arguments.Select(s => s.AsField()).ToList()); DatTool.RemoveFieldsFromItems(datFile, command.Arguments.Select(s => s.AsField()).ToList());
break; break;
@@ -341,7 +341,7 @@ Reset the internal state: reset();";
} }
// Apply the logic // Apply the logic
datFile.StripSceneDatesFromItems(); DatTool.StripSceneDatesFromItems(datFile);
break; break;

View File

@@ -100,10 +100,10 @@ namespace SabreTools.Features
if (success) if (success)
{ {
// Perform additional processing steps // Perform additional processing steps
datdata.ApplyExtras(Extras); DatTool.ApplyExtras(datdata, Extras);
datdata.ApplySplitting(splitType, false); DatTool.ApplySplitting(datdata, splitType, false);
datdata.ApplyFilter(Filter); DatTool.ApplyFilter(datdata, Filter);
datdata.ApplyCleaning(Cleaner); DatTool.ApplyCleaning(datdata, Cleaner);
// Write out the file // Write out the file
DatTool.Write(datdata, OutputDir); DatTool.Write(datdata, OutputDir);

View File

@@ -167,10 +167,10 @@ namespace SabreTools.Features
|| datFile.Header.DatFormat.HasFlag(DatFormat.SSV)); || datFile.Header.DatFormat.HasFlag(DatFormat.SSV));
// Perform additional processing steps // Perform additional processing steps
datFile.ApplyExtras(Extras); DatTool.ApplyExtras(datFile, Extras);
datFile.ApplySplitting(GetSplitType(features), false); DatTool.ApplySplitting(datFile, GetSplitType(features), false);
datFile.ApplyFilter(Filter); DatTool.ApplyFilter(datFile, Filter);
datFile.ApplyCleaning(Cleaner); DatTool.ApplyCleaning(datFile, Cleaner);
// Get the correct output path // Get the correct output path
string realOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue)); string realOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
@@ -205,10 +205,10 @@ namespace SabreTools.Features
datHeaders = DatTool.PopulateUserData(userInputDat, inputPaths); datHeaders = DatTool.PopulateUserData(userInputDat, inputPaths);
// Perform additional processing steps // Perform additional processing steps
userInputDat.ApplyExtras(Extras); DatTool.ApplyExtras(userInputDat, Extras);
userInputDat.ApplySplitting(GetSplitType(features), false); DatTool.ApplySplitting(userInputDat, GetSplitType(features), false);
userInputDat.ApplyFilter(Filter); DatTool.ApplyFilter(userInputDat, Filter);
userInputDat.ApplyCleaning(Cleaner); DatTool.ApplyCleaning(userInputDat, Cleaner);
// Output only DatItems that are duplicated across inputs // Output only DatItems that are duplicated across inputs
if (updateMode.HasFlag(UpdateMode.DiffDupesOnly)) if (updateMode.HasFlag(UpdateMode.DiffDupesOnly))
@@ -297,10 +297,10 @@ namespace SabreTools.Features
DatTool.ParseInto(repDat, inputPath, indexId: 1, keep: true); DatTool.ParseInto(repDat, inputPath, indexId: 1, keep: true);
// Perform additional processing steps // Perform additional processing steps
repDat.ApplyExtras(Extras); DatTool.ApplyExtras(repDat, Extras);
repDat.ApplySplitting(GetSplitType(features), false); DatTool.ApplySplitting(repDat, GetSplitType(features), false);
repDat.ApplyFilter(Filter); DatTool.ApplyFilter(repDat, Filter);
repDat.ApplyCleaning(Cleaner); DatTool.ApplyCleaning(repDat, Cleaner);
// Now replace the fields from the base DatFile // Now replace the fields from the base DatFile
DatTool.DiffAgainst(userInputDat, repDat, GetBoolean(Features, ByGameValue)); DatTool.DiffAgainst(userInputDat, repDat, GetBoolean(Features, ByGameValue));
@@ -322,10 +322,10 @@ namespace SabreTools.Features
DatTool.ParseInto(repDat, inputPath, indexId: 1, keep: true); DatTool.ParseInto(repDat, inputPath, indexId: 1, keep: true);
// Perform additional processing steps // Perform additional processing steps
repDat.ApplyExtras(Extras); DatTool.ApplyExtras(repDat, Extras);
repDat.ApplySplitting(GetSplitType(features), false); DatTool.ApplySplitting(repDat, GetSplitType(features), false);
repDat.ApplyFilter(Filter); DatTool.ApplyFilter(repDat, Filter);
repDat.ApplyCleaning(Cleaner); DatTool.ApplyCleaning(repDat, Cleaner);
// Now replace the fields from the base DatFile // Now replace the fields from the base DatFile
DatTool.BaseReplace(userInputDat, repDat, updateFields, GetBoolean(features, OnlySameValue)); DatTool.BaseReplace(userInputDat, repDat, updateFields, GetBoolean(features, OnlySameValue));
@@ -342,7 +342,7 @@ namespace SabreTools.Features
{ {
// If we're in SuperDAT mode, prefix all games with their respective DATs // If we're in SuperDAT mode, prefix all games with their respective DATs
if (string.Equals(userInputDat.Header.Type, "SuperDAT", StringComparison.OrdinalIgnoreCase)) if (string.Equals(userInputDat.Header.Type, "SuperDAT", StringComparison.OrdinalIgnoreCase))
userInputDat.ApplySuperDAT(inputPaths); DatTool.ApplySuperDAT(userInputDat, inputPaths);
DatTool.Write(userInputDat, OutputDir); DatTool.Write(userInputDat, OutputDir);
} }

View File

@@ -61,10 +61,10 @@ namespace SabreTools.Features
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true); DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
// Perform additional processing steps // Perform additional processing steps
datdata.ApplyExtras(Extras); DatTool.ApplyExtras(datdata, Extras);
datdata.ApplySplitting(splitType, true); DatTool.ApplySplitting(datdata, splitType, true);
datdata.ApplyFilter(Filter); DatTool.ApplyFilter(datdata, Filter);
datdata.ApplyCleaning(Cleaner); DatTool.ApplyCleaning(datdata, Cleaner);
// Set depot information // Set depot information
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;
@@ -108,10 +108,10 @@ namespace SabreTools.Features
} }
// Perform additional processing steps // Perform additional processing steps
datdata.ApplyExtras(Extras); DatTool.ApplyExtras(datdata, Extras);
datdata.ApplySplitting(splitType, true); DatTool.ApplySplitting(datdata, splitType, true);
datdata.ApplyFilter(Filter); DatTool.ApplyFilter(datdata, Filter);
datdata.ApplyCleaning(Cleaner); DatTool.ApplyCleaning(datdata, Cleaner);
// Set depot information // Set depot information
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;