<s> import csv <EOL> import os <EOL> import sys <EOL> import pdb <EOL> import traceback <EOL> sys . path . extend ( [ '<STR_LIT:..>' , '<STR_LIT:.>' , '<STR_LIT>' ] ) <EOL> from geopy import geocoders <EOL> from collections import defaultdict <EOL> from load_data import * <EOL> from dbtruck . exporters . db import * <EOL> import dbtruck . settings as settings <EOL> def create_hidden_table ( db , table ) : <EOL> loctable = '<STR_LIT>' % table <EOL> try : <EOL> db . execute ( '<STR_LIT>' % loctable ) . fetchone ( ) [ <NUM_LIT:0> ] <EOL> return loctable <EOL> except : <EOL> try : <EOL> q = """<STR_LIT>""" % ( loctable , table ) <EOL> db . execute ( q , bexit = False ) <EOL> q = '<STR_LIT>' % ( loctable , loctable ) <EOL> db . execute ( q , bexit = False ) <EOL> return loctable <EOL> except : <EOL> traceback . print_exc ( ) <EOL> return None <EOL> def get_table_cols ( db , table ) : <EOL> cols = db . execute ( """<STR_LIT>""" % table ) . fetchall ( ) <EOL> return [ c [ <NUM_LIT:0> ] for c in cols ] <EOL> def get_all_table_names ( db ) : <EOL> try : <EOL> tables = db . execute ( """<STR_LIT>""" ) . fetchall ( ) <EOL> return [ row [ <NUM_LIT:0> ] for row in tables ] <EOL> except : <EOL> return [ ] <EOL> def get_hidden_table_names ( db ) : <EOL> for regtable , loctable in get_table_name_pairs ( db ) : <EOL> if regtable and loctable : <EOL> yield loctable <EOL> def get_regular_table_names ( db ) : <EOL> for regtable , loctable in get_table_name_pairs ( db ) : <EOL> yield regtable <EOL> def get_table_name_pairs ( db ) : <EOL> tables = get_all_table_names ( db ) <EOL> loctables , regtables = [ ] , [ ] <EOL> for table in tables : <EOL> if table . startswith ( '<STR_LIT:_>' ) and table . endswith ( '<STR_LIT>' ) : <EOL> loctables . append ( table ) <EOL> else : <EOL> regtables . append ( table ) <EOL> pairs = [ ] <EOL> for regtable in regtables : <EOL> if ( '<STR_LIT>' % regtable ) in loctables : <EOL> pairs . append ( ( regtable , '<STR_LIT>' % regtable ) ) <EOL> else : <EOL> pairs . append ( ( regtable , None ) ) <EOL> return pairs <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from sqlalchemy import * <EOL> from sqlalchemy . orm import scoped_session , sessionmaker <EOL> from sqlalchemy . ext . declarative import declarative_base <EOL> db = create_engine ( '<STR_LIT>' ) <EOL> for pair in get_table_name_pairs ( db ) : <EOL> print pair </s>
