From e5e6317f2a43987701817b56981834a7ce203c06 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 8 Feb 2019 20:53:13 -0800 Subject: [PATCH] [Reports/] Untabify --- SabreTools.Library/Reports/BaseReport.cs | 150 +++++------ SabreTools.Library/Reports/Html.cs | 252 +++++++++---------- SabreTools.Library/Reports/SeparatedValue.cs | 190 +++++++------- SabreTools.Library/Reports/Textfile.cs | 168 ++++++------- 4 files changed, 380 insertions(+), 380 deletions(-) diff --git a/SabreTools.Library/Reports/BaseReport.cs b/SabreTools.Library/Reports/BaseReport.cs index 647e5849..2b25007e 100644 --- a/SabreTools.Library/Reports/BaseReport.cs +++ b/SabreTools.Library/Reports/BaseReport.cs @@ -14,90 +14,90 @@ using StreamWriter = System.IO.StreamWriter; namespace SabreTools.Library.Reports { - /// - /// Base class for a report output format - /// - public abstract class BaseReport - { - protected DatFile _datFile; - protected StreamWriter _writer; - protected bool _baddumpCol; - protected bool _nodumpCol; + /// + /// Base class for a report output format + /// + public abstract class BaseReport + { + protected DatFile _datFile; + protected StreamWriter _writer; + protected bool _baddumpCol; + protected bool _nodumpCol; - /// - /// Create a new report from the input DatFile and the filename - /// - /// DatFile to write out statistics for - /// Name of the file to write out to - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - public BaseReport(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false) - { - _datFile = datfile; - _writer = new StreamWriter(Utilities.TryCreate(filename)); - _baddumpCol = baddumpCol; - _nodumpCol = nodumpCol; - } + /// + /// Create a new report from the input DatFile and the filename + /// + /// DatFile to write out statistics for + /// Name of the file to write out to + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + public BaseReport(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false) + { + _datFile = datfile; + _writer = new StreamWriter(Utilities.TryCreate(filename)); + _baddumpCol = baddumpCol; + _nodumpCol = nodumpCol; + } - /// - /// Create a new report from the input DatFile and the stream - /// - /// DatFile to write out statistics for - /// Output stream to write to - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - public BaseReport(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false) - { - _datFile = datfile; + /// + /// Create a new report from the input DatFile and the stream + /// + /// DatFile to write out statistics for + /// Output stream to write to + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + public BaseReport(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false) + { + _datFile = datfile; - if (!stream.CanWrite) - { - throw new ArgumentException(nameof(stream)); - } + if (!stream.CanWrite) + { + throw new ArgumentException(nameof(stream)); + } - _writer = new StreamWriter(stream); - _baddumpCol = baddumpCol; - _nodumpCol = nodumpCol; - } + _writer = new StreamWriter(stream); + _baddumpCol = baddumpCol; + _nodumpCol = nodumpCol; + } - /// - /// Replace the DatFile that is being output - /// - /// - public void ReplaceDatFile(DatFile datfile) - { - _datFile = datfile; - } + /// + /// Replace the DatFile that is being output + /// + /// + public void ReplaceDatFile(DatFile datfile) + { + _datFile = datfile; + } - /// - /// Write the report to the output stream - /// - /// Number of games to use, -1 means use the number of keys - public abstract void Write(long game = -1); + /// + /// Write the report to the output stream + /// + /// Number of games to use, -1 means use the number of keys + public abstract void Write(long game = -1); - /// - /// Write out the header to the stream, if any exists - /// - public abstract void WriteHeader(); + /// + /// Write out the header to the stream, if any exists + /// + public abstract void WriteHeader(); - /// - /// Write out the mid-header to the stream, if any exists - /// - public abstract void WriteMidHeader(); + /// + /// Write out the mid-header to the stream, if any exists + /// + public abstract void WriteMidHeader(); - /// - /// Write out the separator to the stream, if any exists - /// - public abstract void WriteMidSeparator(); + /// + /// Write out the separator to the stream, if any exists + /// + public abstract void WriteMidSeparator(); - /// - /// Write out the footer-separator to the stream, if any exists - /// - public abstract void WriteFooterSeparator(); + /// + /// Write out the footer-separator to the stream, if any exists + /// + public abstract void WriteFooterSeparator(); - /// - /// Write out the footer to the stream, if any exists - /// - public abstract void WriteFooter(); - } + /// + /// Write out the footer to the stream, if any exists + /// + public abstract void WriteFooter(); + } } diff --git a/SabreTools.Library/Reports/Html.cs b/SabreTools.Library/Reports/Html.cs index 08325797..89699c87 100644 --- a/SabreTools.Library/Reports/Html.cs +++ b/SabreTools.Library/Reports/Html.cs @@ -15,144 +15,144 @@ using Stream = System.IO.Stream; namespace SabreTools.Library.Reports { - /// - /// HTML report format - /// - /// TODO: Make output standard width, without making the entire thing a table - internal class Html : BaseReport - { - /// - /// Create a new report from the input DatFile and the filename - /// - /// DatFile to write out statistics for - /// Name of the file to write out to - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - public Html(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false) - : base(datfile, filename, baddumpCol, nodumpCol) - { - } + /// + /// HTML report format + /// + /// TODO: Make output standard width, without making the entire thing a table + internal class Html : BaseReport + { + /// + /// Create a new report from the input DatFile and the filename + /// + /// DatFile to write out statistics for + /// Name of the file to write out to + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + public Html(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false) + : base(datfile, filename, baddumpCol, nodumpCol) + { + } - /// - /// Create a new report from the input DatFile and the stream - /// - /// DatFile to write out statistics for - /// Output stream to write to - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - public Html(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false) - : base(datfile, stream, baddumpCol, nodumpCol) - { - } + /// + /// Create a new report from the input DatFile and the stream + /// + /// DatFile to write out statistics for + /// Output stream to write to + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + public Html(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false) + : base(datfile, stream, baddumpCol, nodumpCol) + { + } - /// - /// Write the report to file - /// - /// Number of games to use, -1 means use the number of keys - public override void Write(long game = -1) - { - string line = "\t\t\t" + HttpUtility.HtmlEncode(_datFile.FileName.Remove(0, 5)) - : ">" + HttpUtility.HtmlEncode(_datFile.FileName)) + "" - + "" + Utilities.GetBytesReadable(_datFile.TotalSize) + "" - + "" + (game == -1 ? _datFile.Keys.Count() : game) + "" - + "" + _datFile.RomCount + "" - + "" + _datFile.DiskCount + "" - + "" + _datFile.CRCCount + "" - + "" + _datFile.MD5Count + "" - + "" + _datFile.SHA1Count + "" - + "" + _datFile.SHA256Count + "" - + (_baddumpCol ? "" + _datFile.BaddumpCount + "" : "") - + (_nodumpCol ? "" + _datFile.NodumpCount + "" : "") - + "\n"; - _writer.Write(line); - _writer.Flush(); - } + /// + /// Write the report to file + /// + /// Number of games to use, -1 means use the number of keys + public override void Write(long game = -1) + { + string line = "\t\t\t" + HttpUtility.HtmlEncode(_datFile.FileName.Remove(0, 5)) + : ">" + HttpUtility.HtmlEncode(_datFile.FileName)) + "" + + "" + Utilities.GetBytesReadable(_datFile.TotalSize) + "" + + "" + (game == -1 ? _datFile.Keys.Count() : game) + "" + + "" + _datFile.RomCount + "" + + "" + _datFile.DiskCount + "" + + "" + _datFile.CRCCount + "" + + "" + _datFile.MD5Count + "" + + "" + _datFile.SHA1Count + "" + + "" + _datFile.SHA256Count + "" + + (_baddumpCol ? "" + _datFile.BaddumpCount + "" : "") + + (_nodumpCol ? "" + _datFile.NodumpCount + "" : "") + + "\n"; + _writer.Write(line); + _writer.Flush(); + } - /// - /// Write out the header to the stream, if any exists - /// - public override void WriteHeader() - { - _writer.Write(@" + /// + /// Write out the header to the stream, if any exists + /// + public override void WriteHeader() + { + _writer.Write(@" -
- DAT Statistics Report - -
- -

DAT Statistics Report (" + DateTime.Now.ToShortDateString() + @")

- +
+ DAT Statistics Report + +
+ +

DAT Statistics Report (" + DateTime.Now.ToShortDateString() + @")

+
"); - _writer.Flush(); + _writer.Flush(); - // Now write the mid header for those who need it - WriteMidHeader(); - } + // Now write the mid header for those who need it + WriteMidHeader(); + } - /// - /// Write out the mid-header to the stream, if any exists - /// - public override void WriteMidHeader() - { - _writer.Write(@" " + /// + /// Write out the mid-header to the stream, if any exists + /// + public override void WriteMidHeader() + { + _writer.Write(@" " + @"" + (_baddumpCol ? "" : "") + (_nodumpCol ? "" : "") + "\n"); - _writer.Flush(); - } + _writer.Flush(); + } - /// - /// Write out the separator to the stream, if any exists - /// - public override void WriteMidSeparator() - { - _writer.Write("\n"); - _writer.Flush(); - } + /// + /// Write out the separator to the stream, if any exists + /// + public override void WriteMidSeparator() + { + _writer.Write("\n"); + _writer.Flush(); + } - /// - /// Write out the footer-separator to the stream, if any exists - /// - public override void WriteFooterSeparator() - { - _writer.Write("\n"); - _writer.Flush(); - } + /// + /// Write out the footer-separator to the stream, if any exists + /// + public override void WriteFooterSeparator() + { + _writer.Write("\n"); + _writer.Flush(); + } - /// - /// Write out the footer to the stream, if any exists - /// - public override void WriteFooter() - { - _writer.Write(@"
File NameTotal SizeGamesRoms
File NameTotal SizeGamesRomsDisks# with CRC# with MD5# with SHA-1# with SHA-256BaddumpsNodumps
- + /// + /// Write out the footer to the stream, if any exists + /// + public override void WriteFooter() + { + _writer.Write(@" + "); - _writer.Flush(); - } - } + _writer.Flush(); + } + } } diff --git a/SabreTools.Library/Reports/SeparatedValue.cs b/SabreTools.Library/Reports/SeparatedValue.cs index 945d3b0c..ef1e74f7 100644 --- a/SabreTools.Library/Reports/SeparatedValue.cs +++ b/SabreTools.Library/Reports/SeparatedValue.cs @@ -12,107 +12,107 @@ using Stream = System.IO.Stream; namespace SabreTools.Library.Reports { - /// - /// Separated-Value report format - /// - internal class SeparatedValue : BaseReport - { - private char _separator; + /// + /// Separated-Value report format + /// + internal class SeparatedValue : BaseReport + { + private char _separator; - /// - /// Create a new report from the input DatFile and the filename - /// - /// DatFile to write out statistics for - /// Name of the file to write out to - /// Separator character to use in output - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - public SeparatedValue(DatFile datfile, string filename, char separator, bool baddumpCol = false, bool nodumpCol = false) - : base(datfile, filename, baddumpCol, nodumpCol) - { - _separator = separator; - } + /// + /// Create a new report from the input DatFile and the filename + /// + /// DatFile to write out statistics for + /// Name of the file to write out to + /// Separator character to use in output + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + public SeparatedValue(DatFile datfile, string filename, char separator, bool baddumpCol = false, bool nodumpCol = false) + : base(datfile, filename, baddumpCol, nodumpCol) + { + _separator = separator; + } - /// - /// Create a new report from the input DatFile and the stream - /// - /// DatFile to write out statistics for - /// Output stream to write to - /// Separator character to use in output - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - public SeparatedValue(DatFile datfile, Stream stream, char separator, bool baddumpCol = false, bool nodumpCol = false) - : base(datfile, stream, baddumpCol, nodumpCol) - { - _separator = separator; - } + /// + /// Create a new report from the input DatFile and the stream + /// + /// DatFile to write out statistics for + /// Output stream to write to + /// Separator character to use in output + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + public SeparatedValue(DatFile datfile, Stream stream, char separator, bool baddumpCol = false, bool nodumpCol = false) + : base(datfile, stream, baddumpCol, nodumpCol) + { + _separator = separator; + } - /// - /// Write the report to file - /// - /// Number of games to use, -1 means use the number of keys - public override void Write(long game = -1) - { - string line = string.Format("\"" + _datFile.FileName + "\"{0}" - + "\"" + _datFile.TotalSize + "\"{0}" - + "\"" + (game == -1 ? _datFile.Keys.Count() : game) + "\"{0}" - + "\"" + _datFile.RomCount + "\"{0}" - + "\"" + _datFile.DiskCount + "\"{0}" - + "\"" + _datFile.CRCCount + "\"{0}" - + "\"" + _datFile.MD5Count + "\"{0}" - + "\"" + _datFile.SHA1Count + "\"{0}" - + "\"" + _datFile.SHA256Count + "\"{0}" - + "\"" + _datFile.SHA384Count + "\"{0}" - + "\"" + _datFile.SHA512Count + "\"" - + (_baddumpCol ? "{0}\"" + _datFile.BaddumpCount + "\"" : "") - + (_nodumpCol ? "{0}\"" + _datFile.BaddumpCount + "\"" : "") - + "\n", _separator); - - _writer.Write(line); - _writer.Flush(); - } + /// + /// Write the report to file + /// + /// Number of games to use, -1 means use the number of keys + public override void Write(long game = -1) + { + string line = string.Format("\"" + _datFile.FileName + "\"{0}" + + "\"" + _datFile.TotalSize + "\"{0}" + + "\"" + (game == -1 ? _datFile.Keys.Count() : game) + "\"{0}" + + "\"" + _datFile.RomCount + "\"{0}" + + "\"" + _datFile.DiskCount + "\"{0}" + + "\"" + _datFile.CRCCount + "\"{0}" + + "\"" + _datFile.MD5Count + "\"{0}" + + "\"" + _datFile.SHA1Count + "\"{0}" + + "\"" + _datFile.SHA256Count + "\"{0}" + + "\"" + _datFile.SHA384Count + "\"{0}" + + "\"" + _datFile.SHA512Count + "\"" + + (_baddumpCol ? "{0}\"" + _datFile.BaddumpCount + "\"" : "") + + (_nodumpCol ? "{0}\"" + _datFile.BaddumpCount + "\"" : "") + + "\n", _separator); + + _writer.Write(line); + _writer.Flush(); + } - /// - /// Write out the header to the stream, if any exists - /// - public override void WriteHeader() - { - _writer.Write(string.Format("\"File Name\"{0}\"Total Size\"{0}\"Games\"{0}\"Roms\"{0}\"Disks\"{0}\"# with CRC\"{0}\"# with MD5\"{0}\"# with SHA-1\"{0}\"# with SHA-256\"" - + (_baddumpCol ? "{0}\"BadDumps\"" : "") + (_nodumpCol ? "{0}\"Nodumps\"" : "") + "\n", _separator)); - _writer.Flush(); - } + /// + /// Write out the header to the stream, if any exists + /// + public override void WriteHeader() + { + _writer.Write(string.Format("\"File Name\"{0}\"Total Size\"{0}\"Games\"{0}\"Roms\"{0}\"Disks\"{0}\"# with CRC\"{0}\"# with MD5\"{0}\"# with SHA-1\"{0}\"# with SHA-256\"" + + (_baddumpCol ? "{0}\"BadDumps\"" : "") + (_nodumpCol ? "{0}\"Nodumps\"" : "") + "\n", _separator)); + _writer.Flush(); + } - /// - /// Write out the mid-header to the stream, if any exists - /// - public override void WriteMidHeader() - { - // This call is a no-op for separated value formats - } + /// + /// Write out the mid-header to the stream, if any exists + /// + public override void WriteMidHeader() + { + // This call is a no-op for separated value formats + } - /// - /// Write out the separator to the stream, if any exists - /// - public override void WriteMidSeparator() - { - // This call is a no-op for separated value formats - } + /// + /// Write out the separator to the stream, if any exists + /// + public override void WriteMidSeparator() + { + // This call is a no-op for separated value formats + } - /// - /// Write out the footer-separator to the stream, if any exists - /// - public override void WriteFooterSeparator() - { - _writer.Write("\n"); - _writer.Flush(); - } + /// + /// Write out the footer-separator to the stream, if any exists + /// + public override void WriteFooterSeparator() + { + _writer.Write("\n"); + _writer.Flush(); + } - /// - /// Write out the footer to the stream, if any exists - /// - public override void WriteFooter() - { - // This call is a no-op for separated value formats - } - } + /// + /// Write out the footer to the stream, if any exists + /// + public override void WriteFooter() + { + // This call is a no-op for separated value formats + } + } } diff --git a/SabreTools.Library/Reports/Textfile.cs b/SabreTools.Library/Reports/Textfile.cs index f2b0d8cb..3992ebb4 100644 --- a/SabreTools.Library/Reports/Textfile.cs +++ b/SabreTools.Library/Reports/Textfile.cs @@ -13,42 +13,42 @@ using Stream = System.IO.Stream; namespace SabreTools.Library.Reports { - /// - /// Textfile report format - /// - internal class Textfile : BaseReport - { - /// - /// Create a new report from the input DatFile and the filename - /// - /// DatFile to write out statistics for - /// Name of the file to write out to - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - public Textfile(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false) - : base(datfile, filename, baddumpCol, nodumpCol) - { - } + /// + /// Textfile report format + /// + internal class Textfile : BaseReport + { + /// + /// Create a new report from the input DatFile and the filename + /// + /// DatFile to write out statistics for + /// Name of the file to write out to + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + public Textfile(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false) + : base(datfile, filename, baddumpCol, nodumpCol) + { + } - /// - /// Create a new report from the input DatFile and the stream - /// - /// DatFile to write out statistics for - /// Output stream to write to - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - public Textfile(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false) - : base(datfile, stream, baddumpCol, nodumpCol) - { - } + /// + /// Create a new report from the input DatFile and the stream + /// + /// DatFile to write out statistics for + /// Output stream to write to + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + public Textfile(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false) + : base(datfile, stream, baddumpCol, nodumpCol) + { + } - /// - /// Write the report to file - /// - /// Number of games to use, -1 means use the number of keys - public override void Write(long game = -1) - { - string line = @"'" + _datFile.FileName + @"': + /// + /// Write the report to file + /// + /// Number of games to use, -1 means use the number of keys + public override void Write(long game = -1) + { + string line = @"'" + _datFile.FileName + @"': -------------------------------------------------- Uncompressed size: " + Utilities.GetBytesReadable(_datFile.TotalSize) + @" Games found: " + (game == -1 ? _datFile.Keys.Count() : game) + @" @@ -61,61 +61,61 @@ namespace SabreTools.Library.Reports Roms with SHA-384: " + _datFile.SHA384Count + @" Roms with SHA-512: " + _datFile.SHA512Count + "\n"; - if (_baddumpCol) - { - line += " Roms with BadDump status: " + _datFile.BaddumpCount + "\n"; - } - if (_nodumpCol) - { - line += " Roms with Nodump status: " + _datFile.NodumpCount + "\n"; - } + if (_baddumpCol) + { + line += " Roms with BadDump status: " + _datFile.BaddumpCount + "\n"; + } + if (_nodumpCol) + { + line += " Roms with Nodump status: " + _datFile.NodumpCount + "\n"; + } - // For spacing between DATs - line += "\n\n"; + // For spacing between DATs + line += "\n\n"; - _writer.Write(line); - _writer.Flush(); - } + _writer.Write(line); + _writer.Flush(); + } - /// - /// Write out the header to the stream, if any exists - /// - public override void WriteHeader() - { - // This call is a no-op for textfile output - } + /// + /// Write out the header to the stream, if any exists + /// + public override void WriteHeader() + { + // This call is a no-op for textfile output + } - /// - /// Write out the mid-header to the stream, if any exists - /// - public override void WriteMidHeader() - { - // This call is a no-op for textfile output - } + /// + /// Write out the mid-header to the stream, if any exists + /// + public override void WriteMidHeader() + { + // This call is a no-op for textfile output + } - /// - /// Write out the separator to the stream, if any exists - /// - public override void WriteMidSeparator() - { - // This call is a no-op for textfile output - } + /// + /// Write out the separator to the stream, if any exists + /// + public override void WriteMidSeparator() + { + // This call is a no-op for textfile output + } - /// - /// Write out the footer-separator to the stream, if any exists - /// - public override void WriteFooterSeparator() - { - _writer.Write("\n"); - _writer.Flush(); - } + /// + /// Write out the footer-separator to the stream, if any exists + /// + public override void WriteFooterSeparator() + { + _writer.Write("\n"); + _writer.Flush(); + } - /// - /// Write out the footer to the stream, if any exists - /// - public override void WriteFooter() - { - // This call is a no-op for textfile output - } - } + /// + /// Write out the footer to the stream, if any exists + /// + public override void WriteFooter() + { + // This call is a no-op for textfile output + } + } }