def generate_table_alias(src_table_alias, joined_tables=[]):
 alias = src_table_alias
 if (not joined_tables):
  return (('%s' % alias), ('%s' % _quote(alias)))
 for link in joined_tables:
  alias += ('__' + link[1])
 if (len(alias) >= 64):
  alias_hash = hex(crc32(alias))[2:]
  ALIAS_PREFIX_LENGTH = ((63 - len(alias_hash)) - 1)
  alias = ('%s_%s' % (alias[:ALIAS_PREFIX_LENGTH], alias_hash))
 return (('%s' % alias), ('%s as %s' % (_quote(joined_tables[(-1)][0]), _quote(alias))))

def generate_table_alias ( src_table_alias , joined_tables = [ ] ) : alias = src_table_alias if ( not joined_tables ) : return ( ( '%s' % alias ) , ( '%s' % _quote ( alias ) ) ) for link in joined_tables : alias += ( '__' + link [ 1 ] ) if ( len ( alias ) >= 64 ) : alias_hash = hex ( crc32 ( alias ) ) [ 2 : ] ALIAS_PREFIX_LENGTH = ( ( 63 - len ( alias_hash ) ) - 1 ) alias = ( '%s_%s' % ( alias [ : ALIAS_PREFIX_LENGTH ] , alias_hash ) ) return ( ( '%s' % alias ) , ( '%s as %s' % ( _quote ( joined_tables [ ( - 1 ) ] [ 0 ] ) , _quote ( alias ) ) ) )
generate a standard table alias name .