def extract_wp_db_defs(self):
        db_names = []

        try:
            with open(self.config_file_location, 'r') as wp_config:
                file_contents = wp_config.read()
            wp_config.close()

            # DB's are defined as define('DB_NAME', 'wp_default');
            repatt = '(?:\/\/)?(define\(\'DB_NAME\'.*)'
            dbs = re.findall(repatt, file_contents)

            # For each database def we've found, pull out the name
            # and optional comment to show a nice list to the user
            for db in dbs:
                dbrepat = "define\('DB_NAME\',\s+'([^']*)'\);\s*(\/\/(.*))?"
                match = re.search(dbrepat, db)

                if match.group(3) is not None:
                    db_names.append("%s - %s" %
                                   (match.group(1), match.group(3)))
                else:
                    db_names.append(match.group(1))
        except __HOLE__:  # Couldn't open config file, alert user
            #Open the settings file
            db_names.append("wp-config file doesn't exist, " +
                            'check your settings')
            sublime.status_message("wp-config file doesn't exist, " +
                                   'check your settings')

        return db_names
dataset/ETHPy150Open huntlyc/Sublime-Wordpress-Dev-Plugin/wordpress_dev.py/WordpressDbSwitcherCommand.extract_wp_db_defs