<s> from __future__ import absolute_import <EOL> import codecs <EOL> from . lib import print_red <EOL> from . lib . mysql_reader import MysqlReader <EOL> from . lib . postgres_file_writer import PostgresFileWriter <EOL> from . lib . postgres_db_writer import PostgresDbWriter <EOL> from . lib . converter import Converter <EOL> from . lib . config import Config <EOL> from . lib . errors import ConfigurationFileInitialized <EOL> class Mysql2Pgsql ( object ) : <EOL> def __init__ ( self , options ) : <EOL> self . run_options = options <EOL> try : <EOL> self . file_options = Config ( options . file , True ) . options <EOL> except ConfigurationFileInitialized , e : <EOL> print_red ( e . message ) <EOL> raise e <EOL> def convert ( self ) : <EOL> reader = MysqlReader ( self . file_options [ '<STR_LIT>' ] ) <EOL> if self . file_options [ '<STR_LIT>' ] [ '<STR_LIT:file>' ] : <EOL> writer = PostgresFileWriter ( self . _get_file ( self . file_options [ '<STR_LIT>' ] [ '<STR_LIT:file>' ] ) , <EOL> self . run_options . verbose , <EOL> tz = self . file_options . get ( '<STR_LIT>' , False ) , <EOL> index_prefix = self . file_options . get ( "<STR_LIT>" , '<STR_LIT>' ) ) <EOL> else : <EOL> writer = PostgresDbWriter ( self . file_options [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> self . run_options . verbose , <EOL> tz = self . file_options . get ( '<STR_LIT>' , False ) , <EOL> index_prefix = self . file_options . get ( "<STR_LIT>" , '<STR_LIT>' ) ) <EOL> Converter ( reader , writer , self . file_options , self . run_options . verbose ) . convert ( ) <EOL> def _get_file ( self , file_path ) : <EOL> return codecs . open ( file_path , '<STR_LIT:wb>' , '<STR_LIT:utf-8>' ) </s>
