Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sqlparse/tokens.py: 95%
37 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1#
2# Copyright (C) 2009-2020 the sqlparse authors and contributors
3# <see AUTHORS file>
4#
5# This module is part of python-sqlparse and is released under
6# the BSD License: https://opensource.org/licenses/BSD-3-Clause
7#
8# The Token implementation is based on pygment's token system written
9# by Georg Brandl.
10# http://pygments.org/
12"""Tokens"""
15class _TokenType(tuple):
16 parent = None
18 def __contains__(self, item):
19 return item is not None and (self is item or item[:len(self)] == self)
21 def __getattr__(self, name):
22 new = _TokenType(self + (name,))
23 setattr(self, name, new)
24 new.parent = self
25 return new
27 def __repr__(self):
28 # self can be False only if its the `root` i.e. Token itself
29 return 'Token' + ('.' if self else '') + '.'.join(self)
32Token = _TokenType()
34# Special token types
35Text = Token.Text
36Whitespace = Text.Whitespace
37Newline = Whitespace.Newline
38Error = Token.Error
39# Text that doesn't belong to this lexer (e.g. HTML in PHP)
40Other = Token.Other
42# Common token types for source code
43Keyword = Token.Keyword
44Name = Token.Name
45Literal = Token.Literal
46String = Literal.String
47Number = Literal.Number
48Punctuation = Token.Punctuation
49Operator = Token.Operator
50Comparison = Operator.Comparison
51Wildcard = Token.Wildcard
52Comment = Token.Comment
53Assignment = Token.Assignment
55# Generic types for non-source code
56Generic = Token.Generic
57Command = Generic.Command
59# String and some others are not direct children of Token.
60# alias them:
61Token.Token = Token
62Token.String = String
63Token.Number = Number
65# SQL specific tokens
66DML = Keyword.DML
67DDL = Keyword.DDL
68CTE = Keyword.CTE