1# BAREOS - Backup Archiving REcovery Open Sourced 2# 3# Copyright (C) 2019-2020 Bareos GmbH & Co. KG 4# 5# This program is Free Software; you can redistribute it and/or 6# modify it under the terms of version three of the GNU Affero General Public 7# License as published by the Free Software Foundation and included 8# in the file LICENSE. 9# 10# This program is distributed in the hope that it will be useful, but 11# WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13# Affero General Public License for more details. 14# 15# You should have received a copy of the GNU Affero General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18# 02110-1301, USA. 19 20from pygments.lexer import RegexLexer, inherit, bygroups 21from pygments.lexers.shell import BashLexer 22from pygments.token import * 23 24# 25# http://pygments.org/docs/lexerdevelopment/ 26# http://pygments.org/docs/tokens/ 27# 28 29# Test: 30# cat consolidate.cfg | pygmentize -l extensions/bareos_lexers.py:BareosConfigLexer -x 31# 32 33 34class BareosBaseLexer(BashLexer): 35 name = "BareosBase" 36 37 tokens = { 38 "root": [ 39 # (r'(<input>)(.*)(</input>)', bygroups(None, Generic.Emph, None)), 40 # (r'(<input>)(.*)(</input>)', bygroups(None, Generic.Strong, None)), 41 (r"(<input>)(.*)(</input>)", bygroups(None, Generic.Heading, None)), 42 (r"(<strong>)(.*)(</strong>)", bygroups(None, Generic.Strong, None)), 43 inherit, 44 ] 45 } 46 47 48class BareosConfigLexer(BareosBaseLexer): 49 name = "BareosConfig" 50 aliases = ["bareosconfig", "bconfig"] 51 filenames = ["*.cfg"] 52 53 tokens = {"root": [inherit]} 54 55 56class BareosConsoleLexer(BareosBaseLexer): 57 name = "BareosConsole" 58 aliases = ["bareosconsole", "bconsole"] 59 # filenames = ['*.cfg'] 60 61 tokens = {"root": [inherit]} 62 63 64class BareosLogLexer(BareosBaseLexer): 65 name = "BareosLog" 66 aliases = ["bareoslog"] 67 filenames = ["*.log"] 68 69 tokens = {"root": [inherit]} 70 71 72class BareosMessageLexer(BareosBaseLexer): 73 name = "BareosMessage" 74 aliases = ["bareosmessage", "bmessage"] 75 # filenames = ['*.log'] 76 77 tokens = {"root": [inherit]} 78