Python pygments.token.Operator() Examples

The following are 30 code examples of pygments.token.Operator(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pygments.token , or try the search function .
Example #1
Source File: test_lexer.py    From http-prompt with MIT License 6 votes vote down vote up
def test_unquoted_bodystring(self):
        self.assertEqual(self.get_tokens('`echo name`=john'), [
            (Text, '`'),
            (Name.Builtin, 'echo'),
            (Text, 'name'),
            (Text, '`'),
            (Operator, '='),
            (String, 'john')
        ])
        self.assertEqual(self.get_tokens('name=`echo john`'), [
            (Name, 'name'),
            (Operator, '='),
            (Text, '`'),
            (Name.Builtin, 'echo'),
            (Text, 'john'),
            (Text, '`')
        ]) 
Example #2
Source File: test_lexer.py    From http-prompt with MIT License 6 votes vote down vote up
def test_unquoted_querystring(self):
        self.assertEqual(self.get_tokens('`echo name`==john'), [
            (Text, '`'),
            (Name.Builtin, 'echo'),
            (Text, 'name'),
            (Text, '`'),
            (Operator, '=='),
            (String, 'john')
        ])
        self.assertEqual(self.get_tokens('name==`echo john`'), [
            (Name, 'name'),
            (Operator, '=='),
            (Text, '`'),
            (Name.Builtin, 'echo'),
            (Text, 'john'),
            (Text, '`')
        ]) 
Example #3
Source File: test_ezhil.py    From pygments with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def test_gcd_expr(lexer):
    fragment = u'1^3+(5-5)*gcd(a,b)\n'
    tokens = [
        (Token.Number.Integer, u'1'),
        (Token.Operator, u'^'),
        (Token.Literal.Number.Integer, u'3'),
        (Token.Operator, u'+'),
        (Token.Punctuation, u'('),
        (Token.Literal.Number.Integer, u'5'),
        (Token.Operator, u'-'),
        (Token.Literal.Number.Integer, u'5'),
        (Token.Punctuation, u')'),
        (Token.Operator, u'*'),
        (Token.Name, u'gcd'),
        (Token.Punctuation, u'('),
        (Token.Name, u'a'),
        (Token.Operator, u','),
        (Token.Name, u'b'),
        (Token.Punctuation, u')'),
        (Token.Text, u'\n')
    ]
    assert list(lexer.get_tokens(fragment)) == tokens 
Example #4
Source File: test_ruby.py    From pygments with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def test_escaped_bracestring(lexer):
    fragment = u'str.gsub(%r{\\\\\\\\}, "/")\n'
    tokens = [
        (Token.Name, u'str'),
        (Token.Operator, u'.'),
        (Token.Name, u'gsub'),
        (Token.Punctuation, u'('),
        (Token.Literal.String.Regex, u'%r{'),
        (Token.Literal.String.Regex, u'\\\\'),
        (Token.Literal.String.Regex, u'\\\\'),
        (Token.Literal.String.Regex, u'}'),
        (Token.Punctuation, u','),
        (Token.Text, u' '),
        (Token.Literal.String.Double, u'"'),
        (Token.Literal.String.Double, u'/'),
        (Token.Literal.String.Double, u'"'),
        (Token.Punctuation, u')'),
        (Token.Text, u'\n'),
    ]
    assert list(lexer.get_tokens(fragment)) == tokens 
Example #5
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_curl_append_without_spaces(self):
        self.assertEqual(self.get_tokens('curl>>file.txt'), [
            (Keyword, 'curl'),
            (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #6
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_curl_append_with_many_params(self):
        command = ("curl post --auth user:pass --verify=no  "
                   "name='john doe'  page==2 >> file.txt")
        self.assertEqual(self.get_tokens(command), [
            (Keyword, 'curl'), (Keyword, 'post'),
            (Name, '--auth'), (String, 'user:pass'),
            (Name, '--verify'), (Operator, '='), (String, 'no'),
            (Name, 'name'), (Operator, '='),
            (Text, "'"), (String, 'john doe'), (Text, "'"),
            (Name, 'page'), (Operator, '=='), (String, '2'),
            (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #7
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_get_write(self):
        self.assertEqual(self.get_tokens('get > file.txt'), [
            (Keyword, 'get'), (Operator, '>'), (String, 'file.txt')
        ]) 
Example #8
Source File: mime.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def get_content_type_subtokens(self, match):
        yield match.start(1), Text, match.group(1)
        yield match.start(2), Text.Whitespace, match.group(2)
        yield match.start(3), Name.Attribute, match.group(3)
        yield match.start(4), Operator, match.group(4)
        yield match.start(5), String, match.group(5)

        if match.group(3).lower() == "boundary":
            boundary = match.group(5).strip()
            if boundary[0] == '"' and boundary[-1] == '"':
                boundary = boundary[1:-1]
            self.boundary = boundary 
Example #9
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_post_append_with_spaces_and_body_params(self):
        command = ' post    name="john doe"  username=john  >> /tmp/file.txt  '
        self.assertEqual(self.get_tokens(command), [
            (Keyword, 'post'), (Name, 'name'), (Operator, '='),
            (Text, '"'), (String, 'john doe'), (Text, '"'),
            (Name, 'username'), (Operator, '='), (String, 'john'),
            (Operator, '>>'), (String, '/tmp/file.txt')
        ]) 
Example #10
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_post_write_escaped_filename_with_body_params(self):
        command = r'post name="john doe" username=john > /tmp/my\ file.txt'
        self.assertEqual(self.get_tokens(command), [
            (Keyword, 'post'), (Name, 'name'), (Operator, '='),
            (Text, '"'), (String, 'john doe'), (Text, '"'),
            (Name, 'username'), (Operator, '='), (String, 'john'),
            (Operator, '>'), (String, r'/tmp/my\ file.txt')
        ]) 
Example #11
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_get_append_with_querystring_params(self):
        command = 'get page==10 id==200 >> /tmp/file.txt'
        self.assertEqual(self.get_tokens(command), [
            (Keyword, 'get'),
            (Name, 'page'), (Operator, '=='), (String, '10'),
            (Name, 'id'), (Operator, '=='), (String, '200'),
            (Operator, '>>'), (String, '/tmp/file.txt')
        ]) 
Example #12
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_post_append_with_spaces(self):
        self.assertEqual(self.get_tokens('   post  >>   file.txt'), [
            (Keyword, 'post'), (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #13
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_get_append_escaped_filename(self):
        self.assertEqual(self.get_tokens(r'get >> /tmp/my\ file.txt'), [
            (Keyword, 'get'), (Operator, '>>'),
            (String, r'/tmp/my\ file.txt')
        ]) 
Example #14
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_get_append(self):
        self.assertEqual(self.get_tokens('get >> file.txt'), [
            (Keyword, 'get'), (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #15
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_get_write_quoted_filename(self):
        self.assertEqual(self.get_tokens('get > "/tmp/my file.txt"'), [
            (Keyword, 'get'), (Operator, '>'),
            (Text, '"'), (String, '/tmp/my file.txt'), (Text, '"')
        ]) 
Example #16
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_curl_write_quoted_filename(self):
        self.assertEqual(self.get_tokens("curl > 'my file.txt'"), [
            (Keyword, 'curl'), (Operator, '>'),
            (Text, "'"), (String, 'my file.txt'), (Text, "'")
        ]) 
Example #17
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_curl_append_with_post_param(self):
        self.assertEqual(self.get_tokens('curl post name=doe >> file.txt'), [
            (Keyword, 'curl'), (Keyword, 'post'),
            (Name, 'name'), (Operator, '='), (String, 'doe'),
            (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #18
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_curl_append(self):
        self.assertEqual(self.get_tokens('curl >> file.txt'), [
            (Keyword, 'curl'),
            (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #19
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_curl_write(self):
        self.assertEqual(self.get_tokens('curl > file.txt'), [
            (Keyword, 'curl'),
            (Operator, '>'), (String, 'file.txt')
        ]) 
Example #20
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_append_with_many_params(self):
        command = ("httpie post --auth user:pass --verify=no  "
                   "name='john doe'  page==2 >> file.txt")
        self.assertEqual(self.get_tokens(command), [
            (Keyword, 'httpie'), (Keyword, 'post'),
            (Name, '--auth'), (String, 'user:pass'),
            (Name, '--verify'), (Operator, '='), (String, 'no'),
            (Name, 'name'), (Operator, '='),
            (Text, "'"), (String, 'john doe'), (Text, "'"),
            (Name, 'page'), (Operator, '=='), (String, '2'),
            (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #21
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_append_quoted_filename(self):
        self.assertEqual(self.get_tokens('httpie >> "my file.txt"'), [
            (Keyword, 'httpie'), (Operator, '>>'),
            (Text, '"'), (String, 'my file.txt'), (Text, '"')
        ]) 
Example #22
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_write_quoted_filename(self):
        self.assertEqual(self.get_tokens("httpie > 'my file.txt'"), [
            (Keyword, 'httpie'), (Operator, '>'),
            (Text, "'"), (String, 'my file.txt'), (Text, "'")
        ]) 
Example #23
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_append_with_post_param(self):
        self.assertEqual(self.get_tokens('httpie post name=doe >> file.txt'), [
            (Keyword, 'httpie'), (Keyword, 'post'),
            (Name, 'name'), (Operator, '='), (String, 'doe'),
            (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #24
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_append_without_spaces(self):
        self.assertEqual(self.get_tokens('httpie>>file.txt'), [
            (Keyword, 'httpie'),
            (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #25
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_append(self):
        self.assertEqual(self.get_tokens('httpie >> file.txt'), [
            (Keyword, 'httpie'),
            (Operator, '>>'), (String, 'file.txt')
        ]) 
Example #26
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_write_without_spaces(self):
        self.assertEqual(self.get_tokens('httpie>file.txt'), [
            (Keyword, 'httpie'),
            (Operator, '>'), (String, 'file.txt')
        ]) 
Example #27
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_write(self):
        self.assertEqual(self.get_tokens('httpie > file.txt'), [
            (Keyword, 'httpie'),
            (Operator, '>'), (String, 'file.txt')
        ]) 
Example #28
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_post_pipe(self):
        self.assertEqual(self.get_tokens('post | tee "/tmp/test"'), [
            (Keyword, 'post'),
            (Operator, '|'),
            (Text, 'tee'),
            (String.Double, '"/tmp/test"'),
        ]) 
Example #29
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_httpie_body_param(self):
        self.assertEqual(self.get_tokens('httpie post name=`echo john`'), [
            (Keyword, 'httpie'),
            (Keyword, 'post'),
            (Name, 'name'),
            (Operator, '='),
            (Text, '`'),
            (Name.Builtin, 'echo'),
            (Text, 'john'),
            (Text, '`'),
        ]) 
Example #30
Source File: test_lexer.py    From http-prompt with MIT License 5 votes vote down vote up
def test_header_option_value(self):
        self.assertEqual(self.get_tokens('Accept:`echo "application/json"`'), [
            (Name, 'Accept'),
            (Operator, ':'),
            (Text, '`'),
            (Name.Builtin, 'echo'),
            (String.Double, '"application/json"'),
            (Text, '`'),
        ])