Exemplo n.º 1
0
def get_mixin_path():
    """
    Get the path where mixin is stored.

    :rtype: Path
    """
    return get_config_path() / 'mixin'
Exemplo n.º 2
0
def get_metadata_path():
    """
    Get the path where metadata is stored.

    :rtype: Path
    """
    return get_config_path() / 'metadata'
Exemplo n.º 3
0
def get_mixin_path():
    """
    Get the path where mixins are stored in the COLCON_HOME configuration.

    :rtype: Path
    """
    return get_config_path() / 'mixin'
Exemplo n.º 4
0
 def __init__(self, parser):  # noqa: D107
     # avoid setting members directly, the base class overrides __setattr__
     # pass them as keyword arguments instead
     super().__init__(
         parser,
         _config_path=Path(
             os.environ.get(DEFAULTS_FILE_ENVIRONMENT_VARIABLE.name,
                            get_config_path() / 'defaults.yaml')),
         _parsers={},
     )
Exemplo n.º 5
0
def test_config_path():
    # use config path
    config_path = '/some/path'.replace('/', os.sep)
    with patch('colcon_core.location.logger.info') as info:
        set_default_config_path(path=config_path)
        info.assert_called_once_with(
            "Using config path '{config_path}'".format_map(locals()))

    # use config path if environment variable is not set
    config_path_env_var = 'TEST_COLCON_CONFIG_PATH'
    with patch('colcon_core.location.logger.info') as info:
        set_default_config_path(path=config_path, env_var=config_path_env_var)
        info.assert_called_once_with(
            "Using config path '{config_path}'".format_map(locals()))

    # use environment variable when set
    config_path = '/other/path'.replace('/', os.sep)
    with EnvironmentContext(**{config_path_env_var: config_path}):
        assert isinstance(get_config_path(), Path)
        assert str(get_config_path()) == config_path
Exemplo n.º 6
0
import os
import socket
import time
from urllib.error import HTTPError
from urllib.error import URLError
from urllib.request import urlopen

from colcon_core.location import get_config_path
from colcon_core.logging import colcon_logger
from colcon_mixin.mixin import get_mixin_files
from colcon_mixin.mixin import get_mixin_path
import yaml

logger = colcon_logger.getChild(__name__)
"""The path of the yaml file describing the mixin repositories."""
mixin_repositories_file = get_config_path() / 'mixin_repositories.yaml'


def get_repositories():
    """
    Get the registered repositories.

    :rtype: dict
    """
    global mixin_repositories_file
    if not mixin_repositories_file.exists():
        return {}
    if mixin_repositories_file.is_dir():
        raise IsADirectoryError()
    content = mixin_repositories_file.read_text()
    data = yaml.load(content)
Exemplo n.º 7
0
import socket
import time
from urllib.error import HTTPError
from urllib.error import URLError
from urllib.request import urlopen

from colcon_core.location import get_config_path
from colcon_core.logging import colcon_logger
from colcon_metadata.metadata import get_metadata_files
from colcon_metadata.metadata import get_metadata_path
import yaml

logger = colcon_logger.getChild(__name__)

"""The path of the yaml file describing the metadata repositories."""
metadata_repositories_file = get_config_path() / 'metadata_repositories.yaml'


def get_repositories():
    """
    Get the registered repositories.

    :rtype: dict
    """
    global metadata_repositories_file
    if not metadata_repositories_file.exists():
        return {}
    if metadata_repositories_file.is_dir():
        raise IsADirectoryError()
    content = metadata_repositories_file.read_text()
    data = yaml.safe_load(content)