<commit_before>import os
import settings
import shutil
from io import BytesIO
from zipfile import ZipFile
from urllib.request import urlopen

from .config import WPConfig


class WPThemeConfig(WPConfig):
    """ Relies on WPConfig to get wp_site and run wp-cli.
        Overrides is_installed to check for the theme only
    """

    THEMES_PATH = os.path.join('wp-content', 'themes')

    def __init__(self, wp_site, theme_name=settings.DEFAULT_THEME_NAME, theme_faculty=None):
        """
        Class constructor

        Argument keywords:
        wp_site -- Instance of class WPSite
        theme_name -- (optional) Theme name, converted trough a mapping
        theme_faculty -- (optional) Theme faculty. Used for theme color.
        """
        super(WPThemeConfig, self).__init__(wp_site)

        # convert theme name
        if theme_name == 'epfl':
            self.name = 'wp-theme-2018'
        elif theme_name == 'epfl-light':
            self.name = 'wp-theme-light'

        self.faculty = theme_faculty
        self.base_path = os.path.sep.join([self.wp_site.path, self.THEMES_PATH])
        self.path = os.path.sep.join([self.base_path, self.name])

    def __repr__(self):
        installed_string = '[ok]' if self.is_installed else '[ko]'
        return "theme {0} at {1}".format(installed_string, self.path)

    @property
    def is_installed(self):
        """
        Tells if theme is installed or not

        Return
        True, False
        """
        command = "theme list --field=name --format=json"
        command_output = self.run_wp_cli(command)
        return False if command_output is True else self.name in command_output

    def activate(self):
        """
        Set theme as active theme in WordPress<commit_msg>Fix missing declaration of theme name<commit_after>import os
import settings
import shutil
from io import BytesIO
from zipfile import ZipFile
from urllib.request import urlopen

from .config import WPConfig


class WPThemeConfig(WPConfig):
    """ Relies on WPConfig to get wp_site and run wp-cli.
        Overrides is_installed to check for the theme only
    """

    THEMES_PATH = os.path.join('wp-content', 'themes')

    def __init__(self, wp_site, theme_name=settings.DEFAULT_THEME_NAME, theme_faculty=None):
        """
        Class constructor

        Argument keywords:
        wp_site -- Instance of class WPSite
        theme_name -- (optional) Theme name, converted trough a mapping
        theme_faculty -- (optional) Theme faculty. Used for theme color.
        """
        super(WPThemeConfig, self).__init__(wp_site)

        # convert theme name
        self.name = ''
        if theme_name == 'epfl':
            self.name = 'wp-theme-2018'
        elif theme_name == 'epfl-light':
            self.name = 'wp-theme-light'

        self.faculty = theme_faculty
        self.base_path = os.path.sep.join([self.wp_site.path, self.THEMES_PATH])
        self.path = os.path.sep.join([self.base_path, self.name])

    def __repr__(self):
        installed_string = '[ok]' if self.is_installed else '[ko]'
        return "theme {0} at {1}".format(installed_string, self.path)

    @property
    def is_installed(self):
        """
        Tells if theme is installed or not

        Return
        True, False
        """
        command = "theme list --field=name --format=json"
        command_output = self.run_wp_cli(command)
        return False if command_output is True else self.name in command_output

    def activate(self):
        """
        Set theme as active theme in WordPress
{'fraction_non_alphanumeric': 0.09531819456125595, 'fraction_numerical': 0.00336417157275021, 'mean_word_length': 2.49119373776908, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2097185', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1026, 'n_words': 305}