#  Copyright 2020 Modelling, Simulation and Design Lab (MSDL) at
#  McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

"""This file is a simple helperfile to allow a valid binding of files and folders.

It has a set of functions that will always point towards the correct directory.
This was created because the linking for the dependencies folder was not as
straightforward as required.
"""

import os

def pypdevsbbl(*paths):
    """Gets the absolute path of the ``pypdevsbbl`` directory.

    Args:
        *paths:   Unpacked list of paths to join.

    Returns:
        The absolute path of the code directory followed by the paths.
    """
    dname = os.path.dirname(os.path.abspath(__file__))
    return os.path.abspath(os.path.join(os.path.join(dname, ".."), *paths))

def src(*paths):
    """Gets the absolute path of the code source directory.

    Args:
        *paths:   Unpacked list of paths to join.

    Returns:
        The absolute path of the code directory followed by the paths.
    """
    return os.path.abspath(os.path.join(os.path.join(pypdevsbbl(), ".."), *paths))

def dependencies(*paths):
    """Gets the absolute path of the ``dependencies`` directory.

    Args:
        *paths:   Unpacked list of paths to join.

    Returns:
        The absolute path of the dependencies directory followed by the paths.
    """
    return src("dependencies", *paths)

def test(*paths):
    """Gets the absolute path of the ``test`` directory.

    Args:
        *paths:   Unpacked list of paths to join.

    Returns:
        The absolute path of the test directory followed by the paths.
    """
    return src("test", *paths)
