srcinfo.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. """
  2. pygments.lexers.srcinfo
  3. ~~~~~~~~~~~~~~~~~~~~~~~
  4. Lexers for .SRCINFO files used by Arch Linux Packages.
  5. The description of the format can be found in the wiki:
  6. https://wiki.archlinux.org/title/.SRCINFO
  7. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
  8. :license: BSD, see LICENSE for details.
  9. """
  10. from pygments.lexer import RegexLexer, words
  11. from pygments.token import Text, Comment, Keyword, Name, Operator, Whitespace
  12. __all__ = ['SrcinfoLexer']
  13. keywords = (
  14. 'pkgbase', 'pkgname',
  15. 'pkgver', 'pkgrel', 'epoch',
  16. 'pkgdesc', 'url', 'install', 'changelog',
  17. 'arch', 'groups', 'license', 'noextract', 'options', 'backup',
  18. 'validpgpkeys',
  19. )
  20. architecture_dependent_keywords = (
  21. 'source', 'depends', 'checkdepends', 'makedepends', 'optdepends',
  22. 'provides', 'conflicts', 'replaces',
  23. 'md5sums', 'sha1sums', 'sha224sums', 'sha256sums', 'sha384sums',
  24. 'sha512sums',
  25. )
  26. class SrcinfoLexer(RegexLexer):
  27. """Lexer for .SRCINFO files used by Arch Linux Packages.
  28. """
  29. name = 'Srcinfo'
  30. aliases = ['srcinfo']
  31. filenames = ['.SRCINFO']
  32. url = 'https://wiki.archlinux.org/title/.SRCINFO'
  33. version_added = '2.11'
  34. tokens = {
  35. 'root': [
  36. (r'\s+', Whitespace),
  37. (r'#.*', Comment.Single),
  38. (words(keywords), Keyword, 'assignment'),
  39. (words(architecture_dependent_keywords, suffix=r'_\w+'),
  40. Keyword, 'assignment'),
  41. (r'\w+', Name.Variable, 'assignment'),
  42. ],
  43. 'assignment': [
  44. (r' +', Whitespace),
  45. (r'=', Operator, 'value'),
  46. ],
  47. 'value': [
  48. (r' +', Whitespace),
  49. (r'.*', Text, '#pop:2'),
  50. ],
  51. }