errmsg.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright 2017 Digital
  2. #
  3. # This file is part of DigiLib.
  4. #
  5. # DigiLib is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # DigiLib is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with DigiLib. If not, see <http://www.gnu.org/licenses/>.
  17. """
  18. Error messages
  19. --------------
  20. Some error messages often used in gpio. They should be used with ``.format()``.
  21. """
  22. def args(command=None,amount=None,optional=None,syntax=None):
  23. retmsg = ""
  24. if command:
  25. retmsg += "'{}' ".format(command)
  26. retmsg += "takes "
  27. if amount:
  28. retmsg += "{} ".format(amount)
  29. if optional:
  30. retmsg += "{} ".format(optional)
  31. retmsg += "argument(s): "
  32. if syntax:
  33. retmsg += "{} ".format(syntax)
  34. return retmsg
  35. ERROR_TAKES_ARGUMENTS = "{} takes {} {} argument(s): {}"
  36. if __name__ == "__main__":
  37. print(args("cmd","one","optional","<state>"))
  38. #