class_docstr: Base class for Postgres-related lexers.
  
  This is implemented as a mixin to avoid the Lexer metaclass kicking in.
  this way the different lexer don't have a common Lexer ancestor. If they
  had, _tokens could be created on this ancestor and not updated for the
  other classes, resulting e.g. in PL/pgSQL parsed as SQL. This shortcoming
  seem to suggest that regexp lexers are not really subclassable.
class_docstr_tok: ["Base","class","for","Postgres-related","lexers",".","This","is","implemented","as","a","mixin","to","avoid","the","Lexer","metaclass","kicking","in",".","this","way","the","different","lexer","do","n't","have","a","common","Lexer","ancestor",".","If","they","had",",","_tokens","could","be","created","on","this","ancestor","and","not","updated","for","the","other","classes",",","resulting","e.g",".","in","PL\/pgSQL","parsed","as","SQL",".","This","shortcoming","seem","to","suggest","that","regexp","lexers","are","not","really","subclassable","."]
code: def _get_lexer(self, lang):
      if lang.lower() == "sql":
          return get_lexer_by_name("postgresql", **self.options)
  
      tries = [lang]
      if lang.startswith("pl"):
          tries.append(lang[2:])
      if lang.endswith("u"):
          tries.append(lang[:-1])
      if lang.startswith("pl") and lang.endswith("u"):
          tries.append(lang[2:-1])
  
      for l in tries:
          try:
              return get_lexer_by_name(l, **self.options)
          except ClassNotFound:
              pass
      else:
          # TODO: better logging
          # print >>sys.stderr, "language not found:", lang
          return None
  
imports: import re
  from pygments.lexer import Lexer, RegexLexer, do_insertions, bygroups, words
  from pygments.token import Punctuation, Whitespace, Error, Text, Comment, Operator, Keyword, Name, String, Number, Generic
  from pygments.lexers import get_lexer_by_name, ClassNotFound
  from pygments.util import iteritems
  from pygments.lexers._postgres_builtins import KEYWORDS, DATATYPES, PSEUDO_TYPES, PLPGSQL_KEYWORDS
  from pygments.lexers import _tsql_builtins
label_desc: Use image node_id 2 for calling the PostgresBase obj's underlying member method code with example usage: obj._get_lexer(lang) and returns: get_lexer_by_name, None, get_lexer_by_name