r_drain.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """
  2. ***************************************************************************
  3. r_drain.py
  4. ----------
  5. Date : February 2016
  6. Copyright : (C) 2016 by Médéric Ribreux
  7. Email : medspx at medspx dot fr
  8. ***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************
  16. """
  17. __author__ = 'Médéric Ribreux'
  18. __date__ = 'February 2016'
  19. __copyright__ = '(C) 2016, Médéric Ribreux'
  20. def checkParameterValuesBeforeExecuting(alg, parameters, context):
  21. """ Verify if we have the right parameters """
  22. # start_coordinates and start_points are mutually exclusives
  23. if (alg.parameterAsString(parameters, 'start_coordinates', context)
  24. and alg.parameterAsVectorLayer(parameters, 'start_points', context)):
  25. return False, alg.tr("You need to set either start coordinates OR a start points vector layer!")
  26. # You need to set at least one parameter
  27. if (not alg.parameterAsString(parameters, 'start_coordinates', context)
  28. and not alg.parameterAsVectorLayer(parameters, 'start_points', context)):
  29. return False, alg.tr("You need to set either start coordinates OR a start points vector layer!")
  30. paramscore = [f for f in ['-c', '-a', '-n']
  31. if alg.parameterAsBoolean(parameters, f, context)]
  32. if len(paramscore) > 1:
  33. return False, alg.tr("-c, -a, -n parameters are mutually exclusive!")
  34. return True, None