private void UpdateParagraphFromAcknowledgement(DebianParagraph para, Acknowledgements.AcknowledgementAttribute ack) { string person; string year; ExtractCopyrightInformation(ack.Copyright, out person, out year); if (year == "????") { return; // we don't know if this information is newer or not } var copyrightField = para.FindField("Copyright"); if (copyrightField != null) { string prevYear; string prevPerson; ExtractCopyrightInformation(copyrightField.Value, out prevYear, out prevPerson); if (prevYear == "????" || prevYear.CompareTo(year) < 0) { copyrightField.Value = year + " " + person; } else { return; // our current information is as new or newer. } } string shortLicense; List <string> longLicense; ExtractLicenseInformation(ack.LicenseUrl, out shortLicense, out longLicense); if (shortLicense != "????") { var licenseField = para.FindField("License"); if (licenseField != null) { licenseField.Value = shortLicense; } if (longLicense.Count > 0) { AddLicenseParagraphIfNeeded(shortLicense, longLicense); } } if (!string.IsNullOrEmpty(ack.Url)) { var commentField = para.FindField("Comment"); if (commentField == null) { para.Fields.Add(new DebianField("Comment", "URL = " + ack.Url)); } else { commentField.Value = "URL = " + ack.Url; } } }
internal void AddOrUpdateParagraphFromAcknowledgement(Acknowledgements.AcknowledgementAttribute ack, string prefix) { string fileSpec = null; if (!string.IsNullOrEmpty(ack.Location)) { fileSpec = ack.Location; if (!fileSpec.StartsWith("/")) { fileSpec = Path.GetFileName(fileSpec); } } else { fileSpec = ack.Key; } if (!String.IsNullOrEmpty(prefix)) { fileSpec = Path.Combine(prefix, fileSpec); } if (IsWindowsSpecific(Path.GetFileName(fileSpec))) { return; } foreach (var p in Paragraphs) { if (p.Fields.Count >= 3 && p.Fields[0].Tag == "Files") { if (p.Fields[0].Value == fileSpec || Path.GetFileName(p.Fields[0].Value) == fileSpec || Path.GetFileName(fileSpec) == p.Fields[0].Value) { UpdateParagraphFromAcknowledgement(p, ack); return; } } } var para = new DebianParagraph(); Paragraphs.Add(para); para.Fields.Add(new DebianField("Files", fileSpec)); string person; string year; ExtractCopyrightInformation(ack.Copyright, out person, out year); var copyright = year + " " + person; para.Fields.Add(new DebianField("Copyright", copyright)); string shortLicense; List <string> longLicense; ExtractLicenseInformation(ack.LicenseUrl, out shortLicense, out longLicense); para.Fields.Add(new DebianField("License", shortLicense)); if (!string.IsNullOrEmpty(ack.Url)) { para.Fields.Add(new DebianField("Comment", "URL = " + ack.Url)); } if (shortLicense != "????" && longLicense.Count > 0) { AddLicenseParagraphIfNeeded(shortLicense, longLicense); } }