Exemplo n.º 1
0
def remove_output_path(path: str) -> str:
    if not path:
        path = paths.clean(os.getcwd())
    else:
        path = paths.clean(path)

    if path in _logging_paths:
        _logging_paths.remove(path)

    return path
Exemplo n.º 2
0
def add_output_path(path: str) -> str:
    if not path:
        path = paths.clean(os.getcwd())
    else:
        path = paths.clean(path)

    if path not in _logging_paths:
        _logging_paths.append(path)

    return path
Exemplo n.º 3
0
    def write_file(write_path: str):
        mode = 'a' if append_to_file else 'w'
        try:
            with open(paths.clean(write_path), mode) as f:
                f.write('{}\n'.format(message))
        except FileNotFoundError:
            return write_path

        return None
Exemplo n.º 4
0
    def make_path(self, *args, override_key: str = None):

        override_root_path = None
        if override_key is not None:
            override_root_path = self.fetch(override_key)

        if override_root_path:
            return paths.clean(os.path.join(override_root_path, *args))

        return paths.package(*args)
Exemplo n.º 5
0
def remove_output_path(path: str = None) -> str:
    """
    Removes the specified path from the output logging paths if it is
    in the listed paths.

    :param path:
        The path to remove from the logging output paths. If the path is empty
        or no path is given, the current working directory will be used
        instead.
    """
    cleaned = paths.clean(path or os.getcwd())
    if cleaned in _logging_paths:
        _logging_paths.remove(path)
    return cleaned
Exemplo n.º 6
0
def add_output_path(path: str = None) -> str:
    """
    Adds the specified path to the output logging paths if it is not
    already in the listed paths.

    :param path:
        The path to add to the logging output paths. If the path is empty
        or no path is given, the current working directory will be used
        instead.
    """
    cleaned = paths.clean(path or os.getcwd())
    if cleaned not in _logging_paths:
        _logging_paths.append(cleaned)
    return cleaned
Exemplo n.º 7
0
def remove_output_path(path: str = None) -> str:
    """
    Removes the specified path from the output logging paths if it is
    in the listed paths.

    :param path:
        The path to remove from the logging output paths. If the path is empty
        or no path is given, the current working directory will be used
        instead.
    """
    cleaned = paths.clean(path or os.getcwd())
    if cleaned in _logging_paths:
        _logging_paths.remove(path)
    return cleaned
Exemplo n.º 8
0
def add_output_path(path: str = None) -> str:
    """
    Adds the specified path to the output logging paths if it is not
    already in the listed paths.

    :param path:
        The path to add to the logging output paths. If the path is empty
        or no path is given, the current working directory will be used
        instead.
    """
    cleaned = paths.clean(path or os.getcwd())
    if cleaned not in _logging_paths:
        _logging_paths.append(cleaned)
    return cleaned
Exemplo n.º 9
0
    def test_clean_current_directory(self):
        """ should clean path to be current directory """

        directory = os.path.realpath(os.path.abspath(os.curdir))
        self.assertEqual(paths.clean(None), directory)
        self.assertEqual(paths.clean('.'), directory)
Exemplo n.º 10
0
 def write_file(write_path: str):
     mode = 'a' if append_to_file and os.path.exists(write_path) else 'w'
     with open(paths.clean(write_path), mode) as f:
         f.write('{}\n'.format(message))
Exemplo n.º 11
0
 def write_file(write_path: str):
     mode = 'a' if append_to_file and os.path.exists(write_path) else 'w'
     with open(paths.clean(write_path), mode) as f:
         f.write('{}\n'.format(message))
Exemplo n.º 12
0
    def test_clean_current_directory(self):
        """ should clean path to be current directory """

        directory = os.path.realpath(os.path.abspath(os.curdir))
        self.assertEqual(paths.clean(None), directory)
        self.assertEqual(paths.clean('.'), directory)