* [gentoo-commits] dev/dev-zero:master commit in: dev-python/pygments/, dev-python/pygments/files/
@ 2013-07-02 13:48 Tiziano Müller
0 siblings, 0 replies; only message in thread
From: Tiziano Müller @ 2013-07-02 13:48 UTC (permalink / raw
To: gentoo-commits
commit: 7b6200badeea7d354ee82cf1360a5d544d4b8fd1
Author: Tiziano Müller <tm <AT> dev-zero <DOT> ch>
AuthorDate: Tue Jul 2 13:48:36 2013 +0000
Commit: Tiziano Müller <dev-zero <AT> gentoo <DOT> org>
CommitDate: Tue Jul 2 13:48:36 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/dev-zero.git;a=commit;h=7b6200ba
Add pygments with a patch to include additional lexer (especially TOML), provided by pygments.rb and required by github-linguist.
---
dev-python/pygments/Manifest | 3 +
.../files/pygments.rb-0.5.1-github-lexer.py | 401 +++++++++++++++++++++
dev-python/pygments/pygments-1.6.ebuild | 61 ++++
3 files changed, 465 insertions(+)
diff --git a/dev-python/pygments/Manifest b/dev-python/pygments/Manifest
new file mode 100644
index 0000000..30d867b
--- /dev/null
+++ b/dev-python/pygments/Manifest
@@ -0,0 +1,3 @@
+AUX pygments.rb-0.5.1-github-lexer.py 12971 SHA256 597d44483dd10d2f83dbe59d3c6b07bd8cc8b5f445612e8f20e8222c3dd02a0b SHA512 addf94f5d416b4f7613754dcfe01cbddf618dad778c6439edef9d0e465e37b5981d150dec9ed0efc07aae426328ebe30551d101b7ca67fa159b65ed58a20f759 WHIRLPOOL 2aa03d1f583d7e60b3545e41e33d0df8780179122711fa93463651b738ca922b9d53a0cefa319bb19b1b0a7219712169abc8a96c61516b40107a50d5b92e206c
+DIST Pygments-1.6.tar.gz 1423161 SHA256 799ed4caf77516e54440806d8d9cd82a7607dfdf4e4fb643815171a4b5c921c0 SHA512 552d0c2a1296773a5482122bd5cbec0ce91a497cd86ee105e1c5ddf2bfa9c206fcc7de504c6da480344c6e1bee30d7b26012fd061dcb2091d8b2b21bcd163bf0 WHIRLPOOL babf6e638529a902fab37c17fb1215aca3c04c3e2a00d00bdff7e8049ca6a46c238282c088e79816f7c6879fc9b13e3de9824ae93d3f184f4d9aae58af0c9c8d
+EBUILD pygments-1.6.ebuild 1877 SHA256 915a54b6e59ba4f8d752b633bcee1957a8b22e8415ab5e8f9789d3efbb679511 SHA512 402a6c9ba81f6c37b98eebfcb227eb5d0d6aae29e638da14dc287da9afec5de235575bac98627a96b6bb422a1d6dc233f4179b3033f38f265182c18f5cf692f3 WHIRLPOOL dab73487b80682836d7286022b690bc015b5441e4f256e778d94ca4b24e0c99391797349fda894d04d5f4d3964cd5d3afce3a7d77404af80b9f78e412b416541
diff --git a/dev-python/pygments/files/pygments.rb-0.5.1-github-lexer.py b/dev-python/pygments/files/pygments.rb-0.5.1-github-lexer.py
new file mode 100644
index 0000000..cbbed94
--- /dev/null
+++ b/dev-python/pygments/files/pygments.rb-0.5.1-github-lexer.py
@@ -0,0 +1,401 @@
+# -*- coding: utf-8 -*-
+"""
+ pygments.lexers.github
+ ~~~~~~~~~~~~~~~~~~~
+
+ Custom lexers for GitHub.com
+
+ :copyright: Copyright 2012 by GitHub, Inc
+ :license: BSD, see LICENSE for details.
+"""
+import re
+
+from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer
+from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
+ Other, Keyword, Operator, Literal
+
+__all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer', "TOMLLexer"]
+
+class Dasm16Lexer(RegexLexer):
+ """
+ Simple lexer for DCPU-16 Assembly
+
+ Check http://0x10c.com/doc/dcpu-16.txt
+ """
+ name = 'dasm16'
+ aliases = ['DASM16']
+ filenames = ['*.dasm16', '*.dasm']
+ mimetypes = ['text/x-dasm16']
+
+ INSTRUCTIONS = [
+ 'SET',
+ 'ADD', 'SUB',
+ 'MUL', 'MLI',
+ 'DIV', 'DVI',
+ 'MOD', 'MDI',
+ 'AND', 'BOR', 'XOR',
+ 'SHR', 'ASR', 'SHL',
+ 'IFB', 'IFC', 'IFE', 'IFN', 'IFG', 'IFA', 'IFL', 'IFU',
+ 'ADX', 'SBX',
+ 'STI', 'STD',
+ 'JSR',
+ 'INT', 'IAG', 'IAS', 'RFI', 'IAQ', 'HWN', 'HWQ', 'HWI',
+ ]
+
+ REGISTERS = [
+ 'A', 'B', 'C',
+ 'X', 'Y', 'Z',
+ 'I', 'J',
+ 'SP', 'PC', 'EX',
+ 'POP', 'PEEK', 'PUSH'
+ ]
+
+ # Regexes yo
+ char = r'[a-zA-Z$._0-9@]'
+ identifier = r'(?:[a-zA-Z$_]' + char + '*|\.' + char + '+)'
+ number = r'[+-]?(?:0[xX][a-zA-Z0-9]+|\d+)'
+ binary_number = r'0b[01_]+'
+ instruction = r'(?i)(' + '|'.join(INSTRUCTIONS) + ')'
+ single_char = r"'\\?" + char + "'"
+ string = r'"(\\"|[^"])*"'
+
+ def guess_identifier(lexer, match):
+ ident = match.group(0)
+ klass = Name.Variable if ident.upper() in lexer.REGISTERS else Name.Label
+ yield match.start(), klass, ident
+
+ tokens = {
+ 'root': [
+ include('whitespace'),
+ (':' + identifier, Name.Label),
+ (identifier + ':', Name.Label),
+ (instruction, Name.Function, 'instruction-args'),
+ (r'\.' + identifier, Name.Function, 'data-args'),
+ (r'[\r\n]+', Text)
+ ],
+
+ 'numeric' : [
+ (binary_number, Number.Integer),
+ (number, Number.Integer),
+ (single_char, String),
+ ],
+
+ 'arg' : [
+ (identifier, guess_identifier),
+ include('numeric')
+ ],
+
+ 'deref' : [
+ (r'\+', Punctuation),
+ (r'\]', Punctuation, '#pop'),
+ include('arg'),
+ include('whitespace')
+ ],
+
+ 'instruction-line' : [
+ (r'[\r\n]+', Text, '#pop'),
+ (r';.*?$', Comment, '#pop'),
+ include('whitespace')
+ ],
+
+ 'instruction-args': [
+ (r',', Punctuation),
+ (r'\[', Punctuation, 'deref'),
+ include('arg'),
+ include('instruction-line')
+ ],
+
+ 'data-args' : [
+ (r',', Punctuation),
+ include('numeric'),
+ (string, String),
+ include('instruction-line')
+ ],
+
+ 'whitespace': [
+ (r'\n', Text),
+ (r'\s+', Text),
+ (r';.*?\n', Comment)
+ ],
+ }
+
+class PuppetLexer(RegexLexer):
+ name = 'Puppet'
+ aliases = ['puppet']
+ filenames = ['*.pp']
+
+ tokens = {
+ 'root': [
+ include('puppet'),
+ ],
+ 'puppet': [
+ include('comments'),
+ (r'(class)(\s*)(\{)', bygroups(Name.Class, Text, Punctuation), ('type', 'namevar')),
+ (r'(class|define)', Keyword.Declaration, ('block','class_name')),
+ (r'node', Keyword.Declaration, ('block', 'node_name')),
+ (r'elsif', Keyword.Reserved, ('block', 'conditional')),
+ (r'if', Keyword.Reserved, ('block', 'conditional')),
+ (r'unless', Keyword.Reserved, ('block', 'conditional')),
+ (r'(else)(\s*)(\{)', bygroups(Keyword.Reserved, Text, Punctuation), 'block'),
+ (r'case', Keyword.Reserved, ('case', 'conditional')),
+ (r'(::)?([A-Z][\w:]+)+(\s*)(<{1,2}\|)', bygroups(Name.Class, Name.Class, Text, Punctuation), 'spaceinvader'),
+ (r'(::)?([A-Z][\w:]+)+(\s*)(\{)', bygroups(Name.Class, Name.Class, Text, Punctuation), 'type'),
+ (r'(::)?([A-Z][\w:]+)+(\s*)(\[)', bygroups(Name.Class, Name.Class, Text, Punctuation), ('type', 'override_name')),
+ (r'(@{0,2}[\w:]+)(\s*)(\{)(\s*)', bygroups(Name.Class, Text, Punctuation, Text), ('type', 'namevar')),
+ (r'\$(::)?(\w+::)*\w+', Name.Variable, 'var_assign'),
+ (r'(include|require)', Keyword.Namespace, 'include'),
+ (r'import', Keyword.Namespace, 'import'),
+ (r'(\w+)(\()', bygroups(Name.Function, Punctuation), 'function'),
+ (r'\s', Text),
+ ],
+ 'block': [
+ include('puppet'),
+ (r'\}', Text, '#pop'),
+ ],
+ 'override_name': [
+ include('strings'),
+ include('variables'),
+ (r'\]', Punctuation),
+ (r'\s', Text),
+ (r'\{', Punctuation, '#pop'),
+ ],
+ 'node_name': [
+ (r'inherits', Keyword.Declaration),
+ (r'[\w\.]+', String),
+ include('strings'),
+ include('variables'),
+ (r',', Punctuation),
+ (r'\s', Text),
+ (r'\{', Punctuation, '#pop'),
+ ],
+ 'class_name': [
+ (r'inherits', Keyword.Declaration),
+ (r'[\w:]+', Name.Class),
+ (r'\s', Text),
+ (r'\{', Punctuation, '#pop'),
+ (r'\(', Punctuation, 'paramlist'),
+ ],
+ 'include': [
+ (r'\n', Text, '#pop'),
+ (r'[\w:-]+', Name.Class),
+ include('value'),
+ (r'\s', Text),
+ ],
+ 'import': [
+ (r'\n', Text, '#pop'),
+ (r'[\/\w\.]+', String),
+ include('value'),
+ (r'\s', Text),
+ ],
+ 'case': [
+ (r'(default)(:)(\s*)(\{)', bygroups(Keyword.Reserved, Punctuation, Text, Punctuation), 'block'),
+ include('case_values'),
+ (r'(:)(\s*)(\{)', bygroups(Punctuation, Text, Punctuation), 'block'),
+ (r'\s', Text),
+ (r'\}', Punctuation, '#pop'),
+ ],
+ 'case_values': [
+ include('value'),
+ (r',', Punctuation),
+ ],
+ 'comments': [
+ (r'\s*#.*\n', Comment.Singleline),
+ ],
+ 'strings': [
+ (r"'.*?'", String.Single),
+ (r'\w+', String.Symbol),
+ (r'"', String.Double, 'dblstring'),
+ (r'\/.+?\/', String.Regex),
+ ],
+ 'dblstring': [
+ (r'\$\{.+?\}', String.Interpol),
+ (r'(?:\\(?:[bdefnrstv\'"\$\\/]|[0-7][0-7]?[0-7]?|\^[a-zA-Z]))', String.Escape),
+ (r'[^"\\\$]+', String.Double),
+ (r'\$', String.Double),
+ (r'"', String.Double, '#pop'),
+ ],
+ 'variables': [
+ (r'\$(::)?(\w+::)*\w+', Name.Variable),
+ ],
+ 'var_assign': [
+ (r'\[', Punctuation, ('#pop', 'array')),
+ (r'\{', Punctuation, ('#pop', 'hash')),
+ (r'(\s*)(=)(\s*)', bygroups(Text, Operator, Text)),
+ (r'(\(|\))', Punctuation),
+ include('operators'),
+ include('value'),
+ (r'\s', Text, '#pop'),
+ ],
+ 'booleans': [
+ (r'(true|false)', Literal),
+ ],
+ 'operators': [
+ (r'(\s*)(==|=~|\*|-|\+|<<|>>|!=|!~|!|>=|<=|<|>|and|or|in)(\s*)', bygroups(Text, Operator, Text)),
+ ],
+ 'conditional': [
+ include('operators'),
+ include('strings'),
+ include('variables'),
+ (r'\[', Punctuation, 'array'),
+ (r'\(', Punctuation, 'conditional'),
+ (r'\{', Punctuation, '#pop'),
+ (r'\)', Punctuation, '#pop'),
+ (r'\s', Text),
+ ],
+ 'spaceinvader': [
+ include('operators'),
+ include('strings'),
+ include('variables'),
+ (r'\[', Punctuation, 'array'),
+ (r'\(', Punctuation, 'conditional'),
+ (r'\s', Text),
+ (r'\|>{1,2}', Punctuation, '#pop'),
+ ],
+ 'namevar': [
+ include('value'),
+ (r'\[', Punctuation, 'array'),
+ (r'\s', Text),
+ (r':', Punctuation, '#pop'),
+ (r'\}', Punctuation, '#pop'),
+ ],
+ 'function': [
+ (r'\[', Punctuation, 'array'),
+ include('value'),
+ (r',', Punctuation),
+ (r'\s', Text),
+ (r'\)', Punctuation, '#pop'),
+ ],
+ 'paramlist': [
+ include('value'),
+ (r'=', Punctuation),
+ (r',', Punctuation),
+ (r'\s', Text),
+ (r'\[', Punctuation, 'array'),
+ (r'\)', Punctuation, '#pop'),
+ ],
+ 'type': [
+ (r'(\w+)(\s*)(=>)(\s*)', bygroups(Name.Tag, Text, Punctuation, Text), 'param_value'),
+ (r'\}', Punctuation, '#pop'),
+ (r'\s', Text),
+ include('comments'),
+ (r'', Text, 'namevar'),
+ ],
+ 'value': [
+ (r'[\d\.]', Number),
+ (r'([A-Z][\w:]+)+(\[)', bygroups(Name.Class, Punctuation), 'array'),
+ (r'(\w+)(\()', bygroups(Name.Function, Punctuation), 'function'),
+ include('strings'),
+ include('variables'),
+ include('comments'),
+ include('booleans'),
+ (r'(\s*)(\?)(\s*)(\{)', bygroups(Text, Punctuation, Text, Punctuation), 'selector'),
+ (r'\{', Punctuation, 'hash'),
+ ],
+ 'selector': [
+ (r'default', Keyword.Reserved),
+ include('value'),
+ (r'=>', Punctuation),
+ (r',', Punctuation),
+ (r'\s', Text),
+ (r'\}', Punctuation, '#pop'),
+ ],
+ 'param_value': [
+ include('value'),
+ (r'\[', Punctuation, 'array'),
+ (r',', Punctuation, '#pop'),
+ (r';', Punctuation, '#pop'),
+ (r'\s', Text, '#pop'),
+ (r'', Text, '#pop'),
+ ],
+ 'array': [
+ include('value'),
+ (r'\[', Punctuation, 'array'),
+ (r',', Punctuation),
+ (r'\s', Text),
+ (r'\]', Punctuation, '#pop'),
+ ],
+ 'hash': [
+ include('value'),
+ (r'\s', Text),
+ (r'=>', Punctuation),
+ (r',', Punctuation),
+ (r'\}', Punctuation, '#pop'),
+ ],
+ }
+
+class AugeasLexer(RegexLexer):
+ name = 'Augeas'
+ aliases = ['augeas']
+ filenames = ['*.aug']
+
+ tokens = {
+ 'root': [
+ (r'(module)(\s*)([^\s=]+)', bygroups(Keyword.Namespace, Text, Name.Namespace)),
+ (r'(let)(\s*)([^\s=]+)', bygroups(Keyword.Declaration, Text, Name.Variable)),
+ (r'(del|store|value|counter|seq|key|label|autoload|incl|excl|transform|test|get|put)(\s+)', bygroups(Name.Builtin, Text)),
+ (r'(\()([^\:]+)(\:)(unit|string|regexp|lens|tree|filter)(\))', bygroups(Punctuation, Name.Variable, Punctuation, Keyword.Type, Punctuation)),
+ (r'\(\*', Comment.Multiline, 'comment'),
+ (r'[\+=\|\.\*\;\?-]', Operator),
+ (r'[\[\]\(\)\{\}]', Operator),
+ (r'"', String.Double, 'string'),
+ (r'\/', String.Regex, 'regex'),
+ (r'([A-Z]\w*)(\.)(\w+)', bygroups(Name.Namespace, Punctuation, Name.Variable)),
+ (r'.', Name.Variable),
+ (r'\s', Text),
+ ],
+ 'string': [
+ (r'\\.', String.Escape),
+ (r'[^"]', String.Double),
+ (r'"', String.Double, '#pop'),
+ ],
+ 'regex': [
+ (r'\\.', String.Escape),
+ (r'[^\/]', String.Regex),
+ (r'\/', String.Regex, '#pop'),
+ ],
+ 'comment': [
+ (r'[^*\)]', Comment.Multiline),
+ (r'\(\*', Comment.Multiline, '#push'),
+ (r'\*\)', Comment.Multiline, '#pop'),
+ (r'[\*\)]', Comment.Multiline)
+ ],
+ }
+
+class TOMLLexer(RegexLexer):
+ """
+ Lexer for TOML, a simple language for config files
+ """
+
+ name = 'TOML'
+ aliases = ['toml']
+ filenames = ['*.toml']
+
+ tokens = {
+ 'root': [
+
+ # Basics, comments, strings
+ (r'\s+', Text),
+ (r'#.*?$', Comment.Single),
+ (r'"(\\\\|\\"|[^"])*"', String),
+ (r'(true|false)$', Keyword.Constant),
+ ('[a-zA-Z_][a-zA-Z0-9_\-]*', Name),
+
+ # Datetime
+ (r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z', Number.Integer),
+
+ # Numbers
+ (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
+ (r'\d+[eE][+-]?[0-9]+j?', Number.Float),
+ (r'\-?\d+', Number.Integer),
+
+ # Punctuation
+ (r'[]{}:(),;[]', Punctuation),
+ (r'\.', Punctuation),
+
+ # Operators
+ (r'=', Operator)
+
+ ]
+ }
+
+
diff --git a/dev-python/pygments/pygments-1.6.ebuild b/dev-python/pygments/pygments-1.6.ebuild
new file mode 100644
index 0000000..913deb3
--- /dev/null
+++ b/dev-python/pygments/pygments-1.6.ebuild
@@ -0,0 +1,61 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-python/pygments/pygments-1.6.ebuild,v 1.13 2013/06/02 08:44:10 ago Exp $
+
+EAPI=5
+PYTHON_COMPAT=( python{2_5,2_6,2_7,3_1,3_2,3_3} pypy{1_9,2_0} )
+
+inherit distutils-r1
+
+MY_PN="Pygments"
+MY_P="${MY_PN}-${PV}"
+
+DESCRIPTION="Pygments is a syntax highlighting package written in Python."
+HOMEPAGE="http://pygments.org/ http://pypi.python.org/pypi/Pygments"
+SRC_URI="mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="doc github test"
+
+RDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
+DEPEND="${RDEPEND}
+ test? (
+ dev-python/nose[${PYTHON_USEDEP}]
+ virtual/ttf-fonts
+ dev-texlive/texlive-latexrecommended
+ )"
+
+S="${WORKDIR}/${MY_P}"
+
+python_prepare_all() {
+ if use github ; then
+ # we may have to ask upstream to include it since it also features
+ # and improved puppet lexer but that one gets overriden by the
+ # pygments original
+ cp "${FILESDIR}/pygments.rb-0.5.1-github-lexer.py" pygments/lexers/github.py || die
+ cd pygments/lexers
+ # not py-3 compatible
+ python2 _mapping.py || die "regenerating mapping failed"
+ fi
+}
+
+python_test() {
+ cp -r -l tests "${BUILD_DIR}"/ || die
+
+ if [[ ${EPYTHON} == python3.* ]]; then
+ # Notes:
+ # -W is not supported by python3.1
+ # -n causes Python to write into hardlinked files
+ 2to3 --no-diffs -w "${BUILD_DIR}"/tests/*.py || die
+ fi
+
+ nosetests -w "${BUILD_DIR}"/tests || die "Tests fail with ${EPYTHON}"
+}
+
+python_install_all() {
+ use doc && local HTML_DOCS=( docs/build/. )
+
+ distutils-r1_python_install_all
+}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-07-02 13:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-02 13:48 [gentoo-commits] dev/dev-zero:master commit in: dev-python/pygments/, dev-python/pygments/files/ Tiziano Müller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox