# Path: arbalest/s3.py
# def normalize_path(path):
#     return posixpath.normpath(path)
# 
# Path: arbalest/sql.py
# class Database(object):
#     cursor = None
# 
#     def __init__(self, connection):
#         self.connection = connection
# 
#     def open(self):
#         if self.cursor is None:
#             self.cursor = self.connection.cursor()
# 
#     def execute(self, sql, params=None):
#         try:
#             return self.cursor.execute(sql, params)
#         except ValueError, e:
#             if params is None:
#                 return self.cursor.execute(sql, '')
#             else:
#                 raise ValueError(e)
# 
#     def fetchall(self):
#         for row in self.cursor:
#             yield row
# 
#     def commit(self):
#         return self.connection.commit()
# 
#     def rollback(self):
#         return self.connection.rollback()
# 
#     def close(self):
#         return self.connection.close()


import json
from arbalest.s3 import normalize_path
from arbalest.sql import Database
                ]
            },
            'updated_journal': updated_journal
        }

    def save(self):
        manifest = self.get()
        self.bucket.save(self.manifest_key, json.dumps(manifest['manifest']))
        return manifest['updated_journal']

    def commit(self, saved_keys):
        self.bucket.save(self.journal_key, json.dumps(saved_keys))

    def exists(self):
        return self.bucket.get(self.manifest_key).exists()

    def journal_exists(self):
        return self.bucket.get(self.journal_key).exists()


class SqlManifest(object):
    def __init__(self, metadata, source, schema, bucket, db_connection):
        self.metadata = metadata
        self.source = source
        self.schema = schema
        self.bucket = bucket

        if isinstance(db_connection, Database):
            self.database = db_connection
        else:

# Path: arbalest/s3.py
# def normalize_path(path):
#     return posixpath.normpath(path)
# 
# Path: arbalest/sql.py
# class Database(object):
#     cursor = None
# 
#     def __init__(self, connection):
#         self.connection = connection
# 
#     def open(self):
#         if self.cursor is None:
#             self.cursor = self.connection.cursor()
# 
#     def execute(self, sql, params=None):
#         try:
#             return self.cursor.execute(sql, params)
#         except ValueError, e:
#             if params is None:
#                 return self.cursor.execute(sql, '')
#             else:
#                 raise ValueError(e)
# 
#     def fetchall(self):
#         for row in self.cursor:
#             yield row
# 
#     def commit(self):
#         return self.connection.commit()
# 
#     def rollback(self):
#         return self.connection.rollback()
# 
#     def close(self):
#         return self.connection.close()


# Path: arbalest/redshift/manifest.py
import json
from arbalest.s3 import normalize_path
from arbalest.sql import Database

                ]
            },
            'updated_journal': updated_journal
        }

    def save(self):
        manifest = self.get()
        self.bucket.save(self.manifest_key, json.dumps(manifest['manifest']))
        return manifest['updated_journal']

    def commit(self, saved_keys):
        self.bucket.save(self.journal_key, json.dumps(saved_keys))

    def exists(self):
        return self.bucket.get(self.manifest_key).exists()

    def journal_exists(self):
        return self.bucket.get(self.journal_key).exists()


class SqlManifest(object):
    def __init__(self, metadata, source, schema, bucket, db_connection):
        self.metadata = metadata
        self.source = source
        self.schema = schema
        self.bucket = bucket

        if isinstance(db_connection, Database):
            self.database = db_connection
        else:

            self.database = Database(db_connection)