Exemple #1
0
def setup_custom():
    """Expose custom configuration onto os.environ"""
    config = pyblish.Config()
    os.environ[config['configuration_environment_variable']] = CONFIGPATH

    # Re-read from environment
    config.reset()
Exemple #2
0
def setup():
    """Disable default plugins and only use test plugins"""
    config = pyblish.Config()
    config['paths'] = []

    pyblish.plugin.deregister_all()
    pyblish.plugin.register_plugin_path(PLUGINPATH)
Exemple #3
0
def test_custom_cascading_configuration():
    """The last-added configuration has last say"""
    config = pyblish.Config()

    # The last-entered path sets this variable to False
    print config['custom_variable']
    assert config['custom_variable'] is False
Exemple #4
0
def setup_custom_file():
    """Expose custom configuration by direct reference to file"""
    config = pyblish.Config()
    path = os.path.join(CONFIGPATH, 'additional_configuration', 'config.yaml')
    os.environ[config['configuration_environment_variable']] = path

    # Re-read from environment
    config.reset()
Exemple #5
0
def setup_wildcard():
    pyblish.plugin.deregister_all()

    config = pyblish.Config()
    config['paths'] = []

    wildcard_path = os.path.join(PLUGINPATH, 'wildcards')
    pyblish.plugin.register_plugin_path(wildcard_path)
Exemple #6
0
def setup_echo():
    """Plugins that output information"""
    pyblish.plugin.deregister_all()

    config = pyblish.Config()
    config['paths'] = []

    path = os.path.join(PLUGINPATH, 'echo')
    pyblish.plugin.register_plugin_path(path)
Exemple #7
0
def test_modifying_config_at_run_time():
    """Altering config at run-time works"""
    config = pyblish.Config()

    path = '/invalid/path'
    config['paths'].append(path)

    assert path in config['paths']
    config.reset()
    assert path not in config['paths']
Exemple #8
0
def setup_duplicate():
    """Expose duplicate plugins to discovery mechanism"""
    pyblish.plugin.deregister_all()

    config = pyblish.Config()
    config['paths'] = []

    for copy in ('copy1', 'copy2'):
        path = os.path.join(PLUGINPATH, 'duplicate', copy)
        pyblish.plugin.register_plugin_path(path)
Exemple #9
0
def test_config_init():
    """Config is reading from configuration"""
    config = pyblish.Config()

    config_path = pyblish.lib.main_package_path()
    config_path = os.path.join(config_path, 'config.yaml')

    with open(config_path) as f:
        manual_config = yaml.load(f)

    for key in manual_config:
        assert key in config
Exemple #10
0
def test_custom_file():
    """Passing file on config path is ok

    E.g. PYBLISHCONFIGPATH=c:\config.yaml

    """

    config = pyblish.Config()

    # The last-entered path sets this variable to False
    print config['custom_variable']
    assert config['custom_variable'] is False
Exemple #11
0
def setup_custom_cascade():
    """Expose custom configuration onto os.environ"""
    config = pyblish.Config()

    path1 = CONFIGPATH
    path2 = os.path.join(path1, 'additional_configuration')

    sep = ";" if os.name == "nt" else ":"
    path = path1 + sep + path2

    os.environ[config['configuration_environment_variable']] = path

    # Re-read from environment
    config.reset()
Exemple #12
0
def test_user_overrides_custom():
    """User configuration overrides Custom configuration"""
    config = pyblish.Config()

    user_config_path = config['USERCONFIGPATH']
    os.environ[config['configuration_environment_variable']] = CONFIGPATH

    with open(user_config_path, 'w') as f:
        yaml.dump({'custom_variable': 'user value'}, f)

    config.reset()

    # Even though our custom configuration defines
    # this the user-configuration will override it.
    print config['custom_variable']
    assert config['custom_variable'] == 'user value'
Exemple #13
0
def test_user_config():
    """User config augments default config"""
    config = pyblish.Config()

    user_config_path = config['USERCONFIGPATH']

    with open(user_config_path, 'w') as f:
        yaml.dump({'test_variable': 'test_value'}, f)

    config.reset()

    with open(user_config_path, 'r') as f:
        user_config = yaml.load(f)

    assert user_config
    for key in user_config:
        assert key in config
Exemple #14
0
def test_config_is_singleton():
    """Config is singleton"""
    config = pyblish.Config()

    assert config is pyblish.Config()
Exemple #15
0
def test_custom_config():
    """Custom configuration augments defaults"""
    config = pyblish.Config()
    assert config['custom_variable'] is True
Exemple #16
0
import os
import re
import sys
import shutil
import logging
import inspect
import traceback

# Local library
import pyblish
import pyblish.lib
import pyblish.error

from pyblish.vendor import iscompatible

config = pyblish.Config()

__all__ = [
    'Plugin', 'Selector', 'Validator', 'Extractor', 'Conformer', 'Context',
    'Instance', 'discover', 'plugin_paths', 'registered_paths',
    'environment_paths', 'configured_paths', 'register_plugin_path',
    'deregister_plugin_path', 'deregister_all'
]

patterns = {
    'validators': config['validators_regex'],
    'extractors': config['extractors_regex'],
    'selectors': config['selectors_regex'],
    'conformers': config['conformers_regex']
}