edit.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Recipe creation tool - edit plugin
  2. #
  3. # This sub-command edits the recipe and appends for the specified target
  4. #
  5. # Example: recipetool edit busybox
  6. #
  7. # Copyright (C) 2018 Mentor Graphics Corporation
  8. #
  9. # SPDX-License-Identifier: GPL-2.0-only
  10. #
  11. import argparse
  12. import errno
  13. import logging
  14. import os
  15. import re
  16. import subprocess
  17. import sys
  18. import scriptutils
  19. logger = logging.getLogger('recipetool')
  20. tinfoil = None
  21. def tinfoil_init(instance):
  22. global tinfoil
  23. tinfoil = instance
  24. def edit(args):
  25. import oe.recipeutils
  26. recipe_path = tinfoil.get_recipe_file(args.target)
  27. appends = tinfoil.get_file_appends(recipe_path)
  28. return scriptutils.run_editor([recipe_path] + list(appends), logger)
  29. def register_commands(subparsers):
  30. parser = subparsers.add_parser('edit',
  31. help='Edit the recipe and appends for the specified target. This obeys $VISUAL if set, otherwise $EDITOR, otherwise vi.')
  32. parser.add_argument('target', help='Target recipe/provide to edit')
  33. parser.set_defaults(func=edit, parserecipes=True)