
import json
import os
from plantcv.plantcv import outputs


def print_results(filename):
    """Print result table

    Inputs:
    filename = filename

    :param filename: str
    :return:
    """

    if os.path.isfile(filename):
        with open(filename, 'r') as f:
            hierarchical_data = json.load(f)
            hierarchical_data["observations"] = outputs.observations
    else:
        hierarchical_data = {"metadata": {}, "observations": outputs.observations}

    with open(filename, mode='w') as f:
        json.dump(hierarchical_data, f)


from plantcv.plantcv import outputs


def print_results(filename):
    """Print result table

    Inputs:
    filename = filename

    :param filename: str
    :return:
    """
    print("""Deprecation warning: plantcv.print_results will be removed in a future version.
             Please use plantcv.outputs.save_results instead.
          """)
    outputs.save_results(filename=filename, outformat="json")

Add deprecation warning and use new method
Add deprecation warning and use new method

  
- import json
- import os
  from plantcv.plantcv import outputs
  
  
  def print_results(filename):
      """Print result table
  
      Inputs:
      filename = filename
  
      :param filename: str
      :return:
      """
+     print("""Deprecation warning: plantcv.print_results will be removed in a future version.
+              Please use plantcv.outputs.save_results instead.
+           """)
+     outputs.save_results(filename=filename, outformat="json")
  
-     if os.path.isfile(filename):
-         with open(filename, 'r') as f:
-             hierarchical_data = json.load(f)
-             hierarchical_data["observations"] = outputs.observations
-     else:
-         hierarchical_data = {"metadata": {}, "observations": outputs.observations}
- 
-     with open(filename, mode='w') as f:
-         json.dump(hierarchical_data, f)
- 
Add deprecation warning and use new method
## Code Before:

import json
import os
from plantcv.plantcv import outputs


def print_results(filename):
    """Print result table

    Inputs:
    filename = filename

    :param filename: str
    :return:
    """

    if os.path.isfile(filename):
        with open(filename, 'r') as f:
            hierarchical_data = json.load(f)
            hierarchical_data["observations"] = outputs.observations
    else:
        hierarchical_data = {"metadata": {}, "observations": outputs.observations}

    with open(filename, mode='w') as f:
        json.dump(hierarchical_data, f)

## Instruction:
Add deprecation warning and use new method
## Code After:

from plantcv.plantcv import outputs


def print_results(filename):
    """Print result table

    Inputs:
    filename = filename

    :param filename: str
    :return:
    """
    print("""Deprecation warning: plantcv.print_results will be removed in a future version.
             Please use plantcv.outputs.save_results instead.
          """)
    outputs.save_results(filename=filename, outformat="json")
