def post_validation(self, config, key_name): theme_config = config[key_name] # TODO: Remove when theme_dir is fully deprecated. if config['theme_dir'] is not None: if 'custom_dir' not in theme_config: # Only pass in 'theme_dir' if it is set and 'custom_dir' is not set. theme_config['custom_dir'] = config['theme_dir'] if not any(['theme' in c for c in config.user_configs]): # If the user did not define a theme, but did define theme_dir, then remove default set in validate. theme_config['name'] = None if not theme_config['name'] and 'custom_dir' not in theme_config: raise ValidationError( "At least one of 'theme.name' or 'theme.custom_dir' must be defined." ) # Ensure custom_dir is an absolute path if 'custom_dir' in theme_config and not os.path.isabs( theme_config['custom_dir']): config_dir = os.path.dirname(config.config_file_path) theme_config['custom_dir'] = os.path.join( config_dir, theme_config['custom_dir']) if 'custom_dir' in theme_config and not os.path.isdir( theme_config['custom_dir']): raise ValidationError( "The path set in {name}.custom_dir ('{path}') does not exist.". format(path=theme_config['custom_dir'], name=self.name)) config[key_name] = theme.Theme(**theme_config)
def post_validation(self, config, key_name): theme_config = config[key_name] if not theme_config['name'] and 'custom_dir' not in theme_config: raise ValidationError( "At least one of 'theme.name' or 'theme.custom_dir' must be defined." ) # Ensure custom_dir is an absolute path if 'custom_dir' in theme_config and not os.path.isabs( theme_config['custom_dir']): config_dir = os.path.dirname(config.config_file_path) theme_config['custom_dir'] = os.path.join( config_dir, theme_config['custom_dir']) if 'custom_dir' in theme_config and not os.path.isdir( theme_config['custom_dir']): raise ValidationError( "The path set in {name}.custom_dir ('{path}') does not exist.". format(path=theme_config['custom_dir'], name=key_name)) if 'locale' in theme_config and not isinstance(theme_config['locale'], str): raise ValidationError("'{name}.locale' must be a string.".format( name=theme_config['name'])) config[key_name] = theme.Theme(**theme_config)
def post_validation(self, config, key_name): theme_config = config[key_name] # TODO: Remove when theme_dir is fully deprecated. if config['theme_dir'] is not None: if 'custom_dir' not in theme_config: # Only pass in 'theme_dir' if it is set and 'custom_dir' is not set. theme_config['custom_dir'] = config['theme_dir'] if not any(['theme' in c for c in config.user_configs]): # If the user did not define a theme, but did define theme_dir, then remove default set in validate. theme_config['name'] = None if not theme_config['name'] and 'custom_dir' not in theme_config: raise ValidationError( "At least one of 'theme.name' or 'theme.custom_dir' must be defined." ) # Ensure custom_dir is an absolute path if 'custom_dir' in theme_config and not os.path.isabs( theme_config['custom_dir']): theme_config['custom_dir'] = os.path.abspath( theme_config['custom_dir']) config[key_name] = theme.Theme(**theme_config)