# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Andi Albrecht, albrecht.andi@gmail.com
#
# This module is part of python-sqlparse and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
#
# The Token implementation is based on pygment's token system written
# by Georg Brandl.
# http://pygments.org/

"""Tokens"""


class _TokenType(tuple):
    parent = None

    def __contains__(self, item):
        return item is not None and (self is item or item[:len(self)] == self)

    def __getattr__(self, name):
        new = _TokenType(self + (name,))
        setattr(self, name, new)
        new.parent = self
        return new

    def __repr__(self):
        # self can be False only if its the `root` ie. Token itself
        return 'Token' + ('.' if self else '') + '.'.join(self)

    def __call__(self, *args, **kwargs):
        # FIXME: couldn't import otherwise
        Token = __import__("sqlparse.sql.Token")
        return Token(self, *args, **kwargs)

Token = _TokenType()

# Special token types
Text = Token.Text
Whitespace = Text.Whitespace
Newline = Whitespace.Newline
Error = Token.Error
# Text that doesn't belong to this lexer (e.g. HTML in PHP)
Other = Token.Other

# Common token types for source code
Keyword = Token.Keyword
Name = Token.Name
Alias = Token.Name.Alias
Literal = Token.Literal
String = Literal.String
Number = Literal.Number
Punctuation = Token.Punctuation
Operator = Token.Operator
Comparison = Operator.Comparison
Wildcard = Token.Wildcard
Comment = Token.Comment
Assignment = Token.Assignment

# Generic types for non-source code
Generic = Token.Generic

# String and some others are not direct childs of Token.
# alias them:
Token.Token = Token
Token.String = String
Token.Number = Number

# SQL specific tokens
DML = Keyword.DML
DDL = Keyword.DDL
CTE = Keyword.CTE
Command = Keyword.Command

@@ -343,16 +343,37 @@
 ens%22%22%22%0A%0A
+import sqlparse.sql%0A%0A
 %0Aclass _
@@ -886,107 +886,28 @@
     
-# FIXME: couldn't import otherwise%0A        Token = __import__(%22sqlparse.sql.Token%22)%0A        return 
+return sqlparse.sql.
 Toke
@@ -932,16 +932,17 @@
 wargs)%0A%0A
+%0A
 Token = 

fix callable import