def install(self, instance):
        cfg = self.config
        if self.database == self.master_database:
            template = 'template1'
        else:
            # TODO: follow base if pull request
            template = self.master_database
        config_opt_map = dict(
            host='host',
            user='username',
            password='password',
            encoding='encoding',
            lc_collate='lc-collate',
            lc_ctype='lc-ctype',
            tablespace='tablespace'
        )
        options = ['--' + opt + '=' + str(cfg[cfg_name])
                   for cfg_name, opt in config_opt_map.iteritems()
                   if cfg in cfg_name]
        fail = instance.do(['createdb', '--template', template] + options +
                           [self.database])
        if fail:
            # Workaround for:
            # ERROR:  source database "..." is being accessed by other users
            instance.do([
                'pg_dump', '-h', str(cfg['host']), '-U', str(cfg['user']),
                '-E', str(cfg['encoding']), '-f', '/tmp/' + template + '.sql',
                template
            ])
            instance.do(['createdb', '--template', 'template1'] + options +
                        [self.database])
            instance.do([
                'psql', '-h', str(cfg['host']), '-U', str(cfg['user']),
                '-f', '/tmp/' + template + '.sql', self.database
            ])
        info = self.connection_info
        info['database'] = self.database
        return info
dataset/ETHPy150Open crosspop/asuka/asuka/services/pgsql.py/PostgreSQLService.install/swapped operands of `in`