Commit d1339c5b authored by acpaquette's avatar acpaquette Committed by Jesse Mapel
Browse files

Exposed the verbose and indent fields in the ale load methods

parent 4d78973d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ namespace ale {
   *
   * @returns A string containing a JSON formatted ISD for the image.
   */
  std::string loads(std::string filename, std::string props="", std::string formatter="usgscsm", bool verbose=true);
  std::string loads(std::string filename, std::string props="", std::string formatter="usgscsm", int indent = 2, bool verbose=true);

  /**
   * Load all of the metadata for an image into a JSON ISD.
+97 −83
Original line number Diff line number Diff line
@@ -59,8 +59,9 @@ namespace ale {
    return "";
  }

 std::string loads(std::string filename, std::string props, std::string formatter, bool verbose) {
  std::string loads(std::string filename, std::string props, std::string formatter, int indent, bool verbose) {
    static bool first_run = true;

    if(first_run) {
       // Initialize the Python interpreter but only once.
       first_run = !first_run;
@@ -87,7 +88,7 @@ namespace ale {


    // Create a Python tuple to hold the arguments to the method.
     PyObject *pArgs = PyTuple_New(3);
    PyObject *pArgs = PyTuple_New(5);
    if(!pArgs) {
      throw runtime_error(getPyTraceback());
    }
@@ -105,6 +106,17 @@ namespace ale {
    PyTuple_SetItem(pArgs, 2, pStringFormatter);
    Py_INCREF(pStringFormatter); // take ownership of reference

    PyObject *pIntIndent = PyLong_FromLong((long) indent);
    PyTuple_SetItem(pArgs, 3, pIntIndent);
    Py_INCREF(pIntIndent); // take ownership of reference

    PyObject *pBoolVerbose = Py_False;
    if (!verbose) {
      pBoolVerbose = Py_True;
    }
    PyTuple_SetItem(pArgs, 4, pBoolVerbose);
    Py_INCREF(pBoolVerbose); // take ownership of reference


    // Call the function with the arguments.
    PyObject* pResult = PyObject_CallObject(pFunc, pArgs);
@@ -129,6 +141,8 @@ namespace ale {
    Py_DECREF(pStringFileName);
    Py_DECREF(pStringProps);
    Py_DECREF(pStringFormatter);
    Py_DECREF(pIntIndent);
    Py_DECREF(pBoolVerbose);

    Py_DECREF(pArgs);