Commit 9d825529 authored by Christopher Combs's avatar Christopher Combs
Browse files

Added option to ignore file paths to pvldiff

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@7794 41f8697f-d340-4b68-9986-7bafba869bb8
parent 90caf39d
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#include "PvlContainer.h"
#include "Pvl.h"
#include "IException.h"
#include "QRegularExpression"


using namespace std;
@@ -15,6 +16,7 @@ bool filesMatch;
QString differenceReason;
PvlGroup tolerances;
PvlGroup ignorekeys;
PvlGroup ignorefilepaths;

void CompareKeywords(const PvlKeyword &pvl1, const PvlKeyword &pvl2);
void CompareObjects(const PvlObject &pvl1, const PvlObject &pvl2);
@@ -25,6 +27,7 @@ void IsisMain() {

  tolerances = PvlGroup();
  ignorekeys = PvlGroup();
  ignorefilepaths = PvlGroup();
  differenceReason = "";
  filesMatch = true;

@@ -41,6 +44,10 @@ void IsisMain() {
    if(diffFile.hasGroup("IgnoreKeys")) {
      ignorekeys = diffFile.findGroup("IgnoreKeys");
    }

    if(diffFile.hasGroup("IgnoreFilePaths")) {
      ignorefilepaths = diffFile.findGroup("IgnoreFilePaths");
    }
  }

  CompareObjects(file1, file2);
@@ -77,6 +84,8 @@ void CompareKeywords(const PvlKeyword &pvl1, const PvlKeyword &pvl2) {
    return;
  }

  // Make sure that  Tolerances, IgnoreKeys and IgnoreFilePaths each have either one argument that
  // applies to all values in the keyword OR a one-to-one relationship between the two
  if(tolerances.hasKeyword(pvl1.name()) &&
      tolerances[pvl1.name()].size() > 1 &&
      pvl1.size() != tolerances[pvl1.name()].size()) {
@@ -93,9 +102,18 @@ void CompareKeywords(const PvlKeyword &pvl1, const PvlKeyword &pvl2) {
    throw IException(IException::User, msg, _FILEINFO_);
  }

  if (ignorefilepaths.hasKeyword(pvl1.name()) &&
      ignorefilepaths[pvl1.name()].size() > 1 &&
      pvl1.size() != ignorefilepaths[pvl1.name()].size()) {
    QString msg = "Size of keyword '" + pvl1.name() + "' does not match with ";
    msg += "its number of filepath ignores in the DIFF file.";
    throw IException(IException::User, msg, _FILEINFO_);
  }

  for(int i = 0; i < pvl1.size() && filesMatch; i++) {
    QString val1 = pvl1[i];
    QString val2 = pvl2[i];

    QString unit1 = pvl1.unit(i);
    QString unit2 = pvl2.unit(i);

@@ -104,6 +122,16 @@ void CompareKeywords(const PvlKeyword &pvl1, const PvlKeyword &pvl2) {
      ignoreIndex = i;
    }

    // If we only have one value for the keyword, use it for all paths in the keyword's array,
    // otherwise use the corresponding IgnoreFilePaths value
    if (ignorefilepaths.hasKeyword(pvl1.name()) &&
      (((ignorefilepaths[pvl1.name()].size() > 1 && ignorefilepaths[pvl1.name()][i] == "true") ||
        (ignorefilepaths[pvl1.name()].size() == 1 && ignorefilepaths[pvl1.name()][0] == "true")))) {
          val1 =  val1.replace(QRegularExpression("(\\/[\\w\\-\\. ]*)+\\/"), "");
          val2 =  val2.replace(QRegularExpression("(\\/[\\w\\-\\. ]*)+\\/"), "");
    }


    try {
      if(!ignorekeys.hasKeyword(pvl1.name()) ||
          ignorekeys[pvl1.name()][ignoreIndex] == "false") {
+7 −4
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@
      Added capabilities for unique tolerances and ignore keys for individual
      array elements within keywords
    </change>
    <change name="Christopher Combs" date="2017-06-16">
      Added capability to ignore file paths for elements of PvlKeywords
    </change>
  </history>

  <category>