code: def ocrd_tool_tool_parse_params(ctx, parameters, json):
      
      if parameters is None or parameters == "":
          parameters = {}
      else:
          with open(parameters, 'r') as f:
              parameters = loads(f.read())
      parameterValidator = ParameterValidator(ctx.json['tools'][ctx.tool_name])
      report = parameterValidator.validate(parameters)
      if not report.is_valid:
          print(report.to_xml())
          sys.exit(1)
      if json:
          print(dumps(parameters))
      else:
          for k in parameters:
              print('params["%s"]="%s"' % (k, parameters[k]))
docs: Parse parameters with fallback to defaults and output as shell-eval'able assignments to params var.