Gentoo Archives: gentoo-commits

From: "Tiziano Müller" <dev-zero@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] dev/dev-zero:master commit in: dev-python/pygments/, dev-python/pygments/files/
Date: Tue, 02 Jul 2013 13:48:48
Message-Id: 1372772916.7b6200badeea7d354ee82cf1360a5d544d4b8fd1.dev-zero@gentoo
1 commit: 7b6200badeea7d354ee82cf1360a5d544d4b8fd1
2 Author: Tiziano Müller <tm <AT> dev-zero <DOT> ch>
3 AuthorDate: Tue Jul 2 13:48:36 2013 +0000
4 Commit: Tiziano Müller <dev-zero <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 2 13:48:36 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=dev/dev-zero.git;a=commit;h=7b6200ba
7
8 Add pygments with a patch to include additional lexer (especially TOML), provided by pygments.rb and required by github-linguist.
9
10 ---
11 dev-python/pygments/Manifest | 3 +
12 .../files/pygments.rb-0.5.1-github-lexer.py | 401 +++++++++++++++++++++
13 dev-python/pygments/pygments-1.6.ebuild | 61 ++++
14 3 files changed, 465 insertions(+)
15
16 diff --git a/dev-python/pygments/Manifest b/dev-python/pygments/Manifest
17 new file mode 100644
18 index 0000000..30d867b
19 --- /dev/null
20 +++ b/dev-python/pygments/Manifest
21 @@ -0,0 +1,3 @@
22 +AUX pygments.rb-0.5.1-github-lexer.py 12971 SHA256 597d44483dd10d2f83dbe59d3c6b07bd8cc8b5f445612e8f20e8222c3dd02a0b SHA512 addf94f5d416b4f7613754dcfe01cbddf618dad778c6439edef9d0e465e37b5981d150dec9ed0efc07aae426328ebe30551d101b7ca67fa159b65ed58a20f759 WHIRLPOOL 2aa03d1f583d7e60b3545e41e33d0df8780179122711fa93463651b738ca922b9d53a0cefa319bb19b1b0a7219712169abc8a96c61516b40107a50d5b92e206c
23 +DIST Pygments-1.6.tar.gz 1423161 SHA256 799ed4caf77516e54440806d8d9cd82a7607dfdf4e4fb643815171a4b5c921c0 SHA512 552d0c2a1296773a5482122bd5cbec0ce91a497cd86ee105e1c5ddf2bfa9c206fcc7de504c6da480344c6e1bee30d7b26012fd061dcb2091d8b2b21bcd163bf0 WHIRLPOOL babf6e638529a902fab37c17fb1215aca3c04c3e2a00d00bdff7e8049ca6a46c238282c088e79816f7c6879fc9b13e3de9824ae93d3f184f4d9aae58af0c9c8d
24 +EBUILD pygments-1.6.ebuild 1877 SHA256 915a54b6e59ba4f8d752b633bcee1957a8b22e8415ab5e8f9789d3efbb679511 SHA512 402a6c9ba81f6c37b98eebfcb227eb5d0d6aae29e638da14dc287da9afec5de235575bac98627a96b6bb422a1d6dc233f4179b3033f38f265182c18f5cf692f3 WHIRLPOOL dab73487b80682836d7286022b690bc015b5441e4f256e778d94ca4b24e0c99391797349fda894d04d5f4d3964cd5d3afce3a7d77404af80b9f78e412b416541
25
26 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
27 new file mode 100644
28 index 0000000..cbbed94
29 --- /dev/null
30 +++ b/dev-python/pygments/files/pygments.rb-0.5.1-github-lexer.py
31 @@ -0,0 +1,401 @@
32 +# -*- coding: utf-8 -*-
33 +"""
34 + pygments.lexers.github
35 + ~~~~~~~~~~~~~~~~~~~
36 +
37 + Custom lexers for GitHub.com
38 +
39 + :copyright: Copyright 2012 by GitHub, Inc
40 + :license: BSD, see LICENSE for details.
41 +"""
42 +import re
43 +
44 +from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer
45 +from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
46 + Other, Keyword, Operator, Literal
47 +
48 +__all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer', "TOMLLexer"]
49 +
50 +class Dasm16Lexer(RegexLexer):
51 + """
52 + Simple lexer for DCPU-16 Assembly
53 +
54 + Check http://0x10c.com/doc/dcpu-16.txt
55 + """
56 + name = 'dasm16'
57 + aliases = ['DASM16']
58 + filenames = ['*.dasm16', '*.dasm']
59 + mimetypes = ['text/x-dasm16']
60 +
61 + INSTRUCTIONS = [
62 + 'SET',
63 + 'ADD', 'SUB',
64 + 'MUL', 'MLI',
65 + 'DIV', 'DVI',
66 + 'MOD', 'MDI',
67 + 'AND', 'BOR', 'XOR',
68 + 'SHR', 'ASR', 'SHL',
69 + 'IFB', 'IFC', 'IFE', 'IFN', 'IFG', 'IFA', 'IFL', 'IFU',
70 + 'ADX', 'SBX',
71 + 'STI', 'STD',
72 + 'JSR',
73 + 'INT', 'IAG', 'IAS', 'RFI', 'IAQ', 'HWN', 'HWQ', 'HWI',
74 + ]
75 +
76 + REGISTERS = [
77 + 'A', 'B', 'C',
78 + 'X', 'Y', 'Z',
79 + 'I', 'J',
80 + 'SP', 'PC', 'EX',
81 + 'POP', 'PEEK', 'PUSH'
82 + ]
83 +
84 + # Regexes yo
85 + char = r'[a-zA-Z$._0-9@]'
86 + identifier = r'(?:[a-zA-Z$_]' + char + '*|\.' + char + '+)'
87 + number = r'[+-]?(?:0[xX][a-zA-Z0-9]+|\d+)'
88 + binary_number = r'0b[01_]+'
89 + instruction = r'(?i)(' + '|'.join(INSTRUCTIONS) + ')'
90 + single_char = r"'\\?" + char + "'"
91 + string = r'"(\\"|[^"])*"'
92 +
93 + def guess_identifier(lexer, match):
94 + ident = match.group(0)
95 + klass = Name.Variable if ident.upper() in lexer.REGISTERS else Name.Label
96 + yield match.start(), klass, ident
97 +
98 + tokens = {
99 + 'root': [
100 + include('whitespace'),
101 + (':' + identifier, Name.Label),
102 + (identifier + ':', Name.Label),
103 + (instruction, Name.Function, 'instruction-args'),
104 + (r'\.' + identifier, Name.Function, 'data-args'),
105 + (r'[\r\n]+', Text)
106 + ],
107 +
108 + 'numeric' : [
109 + (binary_number, Number.Integer),
110 + (number, Number.Integer),
111 + (single_char, String),
112 + ],
113 +
114 + 'arg' : [
115 + (identifier, guess_identifier),
116 + include('numeric')
117 + ],
118 +
119 + 'deref' : [
120 + (r'\+', Punctuation),
121 + (r'\]', Punctuation, '#pop'),
122 + include('arg'),
123 + include('whitespace')
124 + ],
125 +
126 + 'instruction-line' : [
127 + (r'[\r\n]+', Text, '#pop'),
128 + (r';.*?$', Comment, '#pop'),
129 + include('whitespace')
130 + ],
131 +
132 + 'instruction-args': [
133 + (r',', Punctuation),
134 + (r'\[', Punctuation, 'deref'),
135 + include('arg'),
136 + include('instruction-line')
137 + ],
138 +
139 + 'data-args' : [
140 + (r',', Punctuation),
141 + include('numeric'),
142 + (string, String),
143 + include('instruction-line')
144 + ],
145 +
146 + 'whitespace': [
147 + (r'\n', Text),
148 + (r'\s+', Text),
149 + (r';.*?\n', Comment)
150 + ],
151 + }
152 +
153 +class PuppetLexer(RegexLexer):
154 + name = 'Puppet'
155 + aliases = ['puppet']
156 + filenames = ['*.pp']
157 +
158 + tokens = {
159 + 'root': [
160 + include('puppet'),
161 + ],
162 + 'puppet': [
163 + include('comments'),
164 + (r'(class)(\s*)(\{)', bygroups(Name.Class, Text, Punctuation), ('type', 'namevar')),
165 + (r'(class|define)', Keyword.Declaration, ('block','class_name')),
166 + (r'node', Keyword.Declaration, ('block', 'node_name')),
167 + (r'elsif', Keyword.Reserved, ('block', 'conditional')),
168 + (r'if', Keyword.Reserved, ('block', 'conditional')),
169 + (r'unless', Keyword.Reserved, ('block', 'conditional')),
170 + (r'(else)(\s*)(\{)', bygroups(Keyword.Reserved, Text, Punctuation), 'block'),
171 + (r'case', Keyword.Reserved, ('case', 'conditional')),
172 + (r'(::)?([A-Z][\w:]+)+(\s*)(<{1,2}\|)', bygroups(Name.Class, Name.Class, Text, Punctuation), 'spaceinvader'),
173 + (r'(::)?([A-Z][\w:]+)+(\s*)(\{)', bygroups(Name.Class, Name.Class, Text, Punctuation), 'type'),
174 + (r'(::)?([A-Z][\w:]+)+(\s*)(\[)', bygroups(Name.Class, Name.Class, Text, Punctuation), ('type', 'override_name')),
175 + (r'(@{0,2}[\w:]+)(\s*)(\{)(\s*)', bygroups(Name.Class, Text, Punctuation, Text), ('type', 'namevar')),
176 + (r'\$(::)?(\w+::)*\w+', Name.Variable, 'var_assign'),
177 + (r'(include|require)', Keyword.Namespace, 'include'),
178 + (r'import', Keyword.Namespace, 'import'),
179 + (r'(\w+)(\()', bygroups(Name.Function, Punctuation), 'function'),
180 + (r'\s', Text),
181 + ],
182 + 'block': [
183 + include('puppet'),
184 + (r'\}', Text, '#pop'),
185 + ],
186 + 'override_name': [
187 + include('strings'),
188 + include('variables'),
189 + (r'\]', Punctuation),
190 + (r'\s', Text),
191 + (r'\{', Punctuation, '#pop'),
192 + ],
193 + 'node_name': [
194 + (r'inherits', Keyword.Declaration),
195 + (r'[\w\.]+', String),
196 + include('strings'),
197 + include('variables'),
198 + (r',', Punctuation),
199 + (r'\s', Text),
200 + (r'\{', Punctuation, '#pop'),
201 + ],
202 + 'class_name': [
203 + (r'inherits', Keyword.Declaration),
204 + (r'[\w:]+', Name.Class),
205 + (r'\s', Text),
206 + (r'\{', Punctuation, '#pop'),
207 + (r'\(', Punctuation, 'paramlist'),
208 + ],
209 + 'include': [
210 + (r'\n', Text, '#pop'),
211 + (r'[\w:-]+', Name.Class),
212 + include('value'),
213 + (r'\s', Text),
214 + ],
215 + 'import': [
216 + (r'\n', Text, '#pop'),
217 + (r'[\/\w\.]+', String),
218 + include('value'),
219 + (r'\s', Text),
220 + ],
221 + 'case': [
222 + (r'(default)(:)(\s*)(\{)', bygroups(Keyword.Reserved, Punctuation, Text, Punctuation), 'block'),
223 + include('case_values'),
224 + (r'(:)(\s*)(\{)', bygroups(Punctuation, Text, Punctuation), 'block'),
225 + (r'\s', Text),
226 + (r'\}', Punctuation, '#pop'),
227 + ],
228 + 'case_values': [
229 + include('value'),
230 + (r',', Punctuation),
231 + ],
232 + 'comments': [
233 + (r'\s*#.*\n', Comment.Singleline),
234 + ],
235 + 'strings': [
236 + (r"'.*?'", String.Single),
237 + (r'\w+', String.Symbol),
238 + (r'"', String.Double, 'dblstring'),
239 + (r'\/.+?\/', String.Regex),
240 + ],
241 + 'dblstring': [
242 + (r'\$\{.+?\}', String.Interpol),
243 + (r'(?:\\(?:[bdefnrstv\'"\$\\/]|[0-7][0-7]?[0-7]?|\^[a-zA-Z]))', String.Escape),
244 + (r'[^"\\\$]+', String.Double),
245 + (r'\$', String.Double),
246 + (r'"', String.Double, '#pop'),
247 + ],
248 + 'variables': [
249 + (r'\$(::)?(\w+::)*\w+', Name.Variable),
250 + ],
251 + 'var_assign': [
252 + (r'\[', Punctuation, ('#pop', 'array')),
253 + (r'\{', Punctuation, ('#pop', 'hash')),
254 + (r'(\s*)(=)(\s*)', bygroups(Text, Operator, Text)),
255 + (r'(\(|\))', Punctuation),
256 + include('operators'),
257 + include('value'),
258 + (r'\s', Text, '#pop'),
259 + ],
260 + 'booleans': [
261 + (r'(true|false)', Literal),
262 + ],
263 + 'operators': [
264 + (r'(\s*)(==|=~|\*|-|\+|<<|>>|!=|!~|!|>=|<=|<|>|and|or|in)(\s*)', bygroups(Text, Operator, Text)),
265 + ],
266 + 'conditional': [
267 + include('operators'),
268 + include('strings'),
269 + include('variables'),
270 + (r'\[', Punctuation, 'array'),
271 + (r'\(', Punctuation, 'conditional'),
272 + (r'\{', Punctuation, '#pop'),
273 + (r'\)', Punctuation, '#pop'),
274 + (r'\s', Text),
275 + ],
276 + 'spaceinvader': [
277 + include('operators'),
278 + include('strings'),
279 + include('variables'),
280 + (r'\[', Punctuation, 'array'),
281 + (r'\(', Punctuation, 'conditional'),
282 + (r'\s', Text),
283 + (r'\|>{1,2}', Punctuation, '#pop'),
284 + ],
285 + 'namevar': [
286 + include('value'),
287 + (r'\[', Punctuation, 'array'),
288 + (r'\s', Text),
289 + (r':', Punctuation, '#pop'),
290 + (r'\}', Punctuation, '#pop'),
291 + ],
292 + 'function': [
293 + (r'\[', Punctuation, 'array'),
294 + include('value'),
295 + (r',', Punctuation),
296 + (r'\s', Text),
297 + (r'\)', Punctuation, '#pop'),
298 + ],
299 + 'paramlist': [
300 + include('value'),
301 + (r'=', Punctuation),
302 + (r',', Punctuation),
303 + (r'\s', Text),
304 + (r'\[', Punctuation, 'array'),
305 + (r'\)', Punctuation, '#pop'),
306 + ],
307 + 'type': [
308 + (r'(\w+)(\s*)(=>)(\s*)', bygroups(Name.Tag, Text, Punctuation, Text), 'param_value'),
309 + (r'\}', Punctuation, '#pop'),
310 + (r'\s', Text),
311 + include('comments'),
312 + (r'', Text, 'namevar'),
313 + ],
314 + 'value': [
315 + (r'[\d\.]', Number),
316 + (r'([A-Z][\w:]+)+(\[)', bygroups(Name.Class, Punctuation), 'array'),
317 + (r'(\w+)(\()', bygroups(Name.Function, Punctuation), 'function'),
318 + include('strings'),
319 + include('variables'),
320 + include('comments'),
321 + include('booleans'),
322 + (r'(\s*)(\?)(\s*)(\{)', bygroups(Text, Punctuation, Text, Punctuation), 'selector'),
323 + (r'\{', Punctuation, 'hash'),
324 + ],
325 + 'selector': [
326 + (r'default', Keyword.Reserved),
327 + include('value'),
328 + (r'=>', Punctuation),
329 + (r',', Punctuation),
330 + (r'\s', Text),
331 + (r'\}', Punctuation, '#pop'),
332 + ],
333 + 'param_value': [
334 + include('value'),
335 + (r'\[', Punctuation, 'array'),
336 + (r',', Punctuation, '#pop'),
337 + (r';', Punctuation, '#pop'),
338 + (r'\s', Text, '#pop'),
339 + (r'', Text, '#pop'),
340 + ],
341 + 'array': [
342 + include('value'),
343 + (r'\[', Punctuation, 'array'),
344 + (r',', Punctuation),
345 + (r'\s', Text),
346 + (r'\]', Punctuation, '#pop'),
347 + ],
348 + 'hash': [
349 + include('value'),
350 + (r'\s', Text),
351 + (r'=>', Punctuation),
352 + (r',', Punctuation),
353 + (r'\}', Punctuation, '#pop'),
354 + ],
355 + }
356 +
357 +class AugeasLexer(RegexLexer):
358 + name = 'Augeas'
359 + aliases = ['augeas']
360 + filenames = ['*.aug']
361 +
362 + tokens = {
363 + 'root': [
364 + (r'(module)(\s*)([^\s=]+)', bygroups(Keyword.Namespace, Text, Name.Namespace)),
365 + (r'(let)(\s*)([^\s=]+)', bygroups(Keyword.Declaration, Text, Name.Variable)),
366 + (r'(del|store|value|counter|seq|key|label|autoload|incl|excl|transform|test|get|put)(\s+)', bygroups(Name.Builtin, Text)),
367 + (r'(\()([^\:]+)(\:)(unit|string|regexp|lens|tree|filter)(\))', bygroups(Punctuation, Name.Variable, Punctuation, Keyword.Type, Punctuation)),
368 + (r'\(\*', Comment.Multiline, 'comment'),
369 + (r'[\+=\|\.\*\;\?-]', Operator),
370 + (r'[\[\]\(\)\{\}]', Operator),
371 + (r'"', String.Double, 'string'),
372 + (r'\/', String.Regex, 'regex'),
373 + (r'([A-Z]\w*)(\.)(\w+)', bygroups(Name.Namespace, Punctuation, Name.Variable)),
374 + (r'.', Name.Variable),
375 + (r'\s', Text),
376 + ],
377 + 'string': [
378 + (r'\\.', String.Escape),
379 + (r'[^"]', String.Double),
380 + (r'"', String.Double, '#pop'),
381 + ],
382 + 'regex': [
383 + (r'\\.', String.Escape),
384 + (r'[^\/]', String.Regex),
385 + (r'\/', String.Regex, '#pop'),
386 + ],
387 + 'comment': [
388 + (r'[^*\)]', Comment.Multiline),
389 + (r'\(\*', Comment.Multiline, '#push'),
390 + (r'\*\)', Comment.Multiline, '#pop'),
391 + (r'[\*\)]', Comment.Multiline)
392 + ],
393 + }
394 +
395 +class TOMLLexer(RegexLexer):
396 + """
397 + Lexer for TOML, a simple language for config files
398 + """
399 +
400 + name = 'TOML'
401 + aliases = ['toml']
402 + filenames = ['*.toml']
403 +
404 + tokens = {
405 + 'root': [
406 +
407 + # Basics, comments, strings
408 + (r'\s+', Text),
409 + (r'#.*?$', Comment.Single),
410 + (r'"(\\\\|\\"|[^"])*"', String),
411 + (r'(true|false)$', Keyword.Constant),
412 + ('[a-zA-Z_][a-zA-Z0-9_\-]*', Name),
413 +
414 + # Datetime
415 + (r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z', Number.Integer),
416 +
417 + # Numbers
418 + (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
419 + (r'\d+[eE][+-]?[0-9]+j?', Number.Float),
420 + (r'\-?\d+', Number.Integer),
421 +
422 + # Punctuation
423 + (r'[]{}:(),;[]', Punctuation),
424 + (r'\.', Punctuation),
425 +
426 + # Operators
427 + (r'=', Operator)
428 +
429 + ]
430 + }
431 +
432 +
433
434 diff --git a/dev-python/pygments/pygments-1.6.ebuild b/dev-python/pygments/pygments-1.6.ebuild
435 new file mode 100644
436 index 0000000..913deb3
437 --- /dev/null
438 +++ b/dev-python/pygments/pygments-1.6.ebuild
439 @@ -0,0 +1,61 @@
440 +# Copyright 1999-2013 Gentoo Foundation
441 +# Distributed under the terms of the GNU General Public License v2
442 +# $Header: /var/cvsroot/gentoo-x86/dev-python/pygments/pygments-1.6.ebuild,v 1.13 2013/06/02 08:44:10 ago Exp $
443 +
444 +EAPI=5
445 +PYTHON_COMPAT=( python{2_5,2_6,2_7,3_1,3_2,3_3} pypy{1_9,2_0} )
446 +
447 +inherit distutils-r1
448 +
449 +MY_PN="Pygments"
450 +MY_P="${MY_PN}-${PV}"
451 +
452 +DESCRIPTION="Pygments is a syntax highlighting package written in Python."
453 +HOMEPAGE="http://pygments.org/ http://pypi.python.org/pypi/Pygments"
454 +SRC_URI="mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_P}.tar.gz"
455 +
456 +LICENSE="BSD"
457 +SLOT="0"
458 +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"
459 +IUSE="doc github test"
460 +
461 +RDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
462 +DEPEND="${RDEPEND}
463 + test? (
464 + dev-python/nose[${PYTHON_USEDEP}]
465 + virtual/ttf-fonts
466 + dev-texlive/texlive-latexrecommended
467 + )"
468 +
469 +S="${WORKDIR}/${MY_P}"
470 +
471 +python_prepare_all() {
472 + if use github ; then
473 + # we may have to ask upstream to include it since it also features
474 + # and improved puppet lexer but that one gets overriden by the
475 + # pygments original
476 + cp "${FILESDIR}/pygments.rb-0.5.1-github-lexer.py" pygments/lexers/github.py || die
477 + cd pygments/lexers
478 + # not py-3 compatible
479 + python2 _mapping.py || die "regenerating mapping failed"
480 + fi
481 +}
482 +
483 +python_test() {
484 + cp -r -l tests "${BUILD_DIR}"/ || die
485 +
486 + if [[ ${EPYTHON} == python3.* ]]; then
487 + # Notes:
488 + # -W is not supported by python3.1
489 + # -n causes Python to write into hardlinked files
490 + 2to3 --no-diffs -w "${BUILD_DIR}"/tests/*.py || die
491 + fi
492 +
493 + nosetests -w "${BUILD_DIR}"/tests || die "Tests fail with ${EPYTHON}"
494 +}
495 +
496 +python_install_all() {
497 + use doc && local HTML_DOCS=( docs/build/. )
498 +
499 + distutils-r1_python_install_all
500 +}