diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2009-05-06 07:25:12 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2009-05-06 07:25:12 +0200 |
| commit | bb6e0fa8e774641b6d68a2cbd31f78c60c785d88 (patch) | |
| tree | f6c2f92c7601ec854913a7fb29165b9633839ba0 /sqlparse/dialects.py | |
| parent | 423b839b8c12bc6215ee15683abbd18b4e7162e3 (diff) | |
| download | sqlparse-bb6e0fa8e774641b6d68a2cbd31f78c60c785d88.tar.gz | |
Removed obsolete dialects module.
Diffstat (limited to 'sqlparse/dialects.py')
| -rw-r--r-- | sqlparse/dialects.py | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/sqlparse/dialects.py b/sqlparse/dialects.py deleted file mode 100644 index cabe503..0000000 --- a/sqlparse/dialects.py +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright (C) 2008 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. - -"""This module contains classes that represent SQL dialects.""" - -from tokens import * - - -class Dialect(object): - """Base class for SQL dialect implementations.""" - - def handle_token(self, tokentype, text): - """Handle a token. - - Arguments: - tokentype: A token type. - text: Text representation of the token. - - Returns: - A tuple of three items: tokentype, text, splitlevel. - splitlevel is either -1, 0 or 1 and describes an identation level. - """ - raise NotImplementedError - - def reset(self): - """Reset Dialect state.""" - pass - - -class DefaultDialect(Dialect): - - def __init__(self): - self._in_declare = False - self._stmt_type = None - - def get_statement_type(self): - return self._stmt_type - - def set_statement_type(self, type_): - self._stmt_type = type_ - - def handle_token(self, tokentype, text): - if not tokentype == Keyword: - return tokentype, text, 0 - unified = text.upper() - if unified == 'DECLARE': - self._in_declare = True - return tokentype, text, 1 - if unified == 'BEGIN': - if self._in_declare: - return tokentype, text, 0 - return tokentype, text, 0 - if unified == 'END': - return tokentype, text, -1 - # TODO: Use a constant here - if unified in ('IF', 'FOR') and self._stmt_type == 6: - return tokentype, text, 1 - return tokentype, text, 0 - - def reset(self): - self._in_declare = False - - -class PSQLDialect(DefaultDialect): - - def __init__(self): - super(PSQLDialect, self).__init__() - self._in_dbldollar = False - - def handle_token(self, tokentype, text): - if (tokentype == Name.Builtin - and text.startswith('$') and text.endswith('$')): - if self._in_dbldollar: - self._in_dbldollar = False - return tokentype, text, -1 - else: - self._in_dbldollar = True - return tokentype, text, 1 - elif self._in_dbldollar: - return tokentype, text, 0 - else: - return super(PSQLDialect, self).handle_token(tokentype, text) - - def reset(self): - self._dollar_started = False - self._in_dbldollar = False |
