# Path: tacl/constants.py
# CATALOGUE_WORK_RELABELLED_ERROR = 'Catalogue file labels "{}" more than once.'
# 
# Path: tacl/exceptions.py
# class MalformedCatalogueError(TACLError):
# 
#     pass


import copy
import csv
import os
from .constants import CATALOGUE_WORK_RELABELLED_ERROR
from .exceptions import MalformedCatalogueError
        """
        return self._ordered_labels or self.labels

    @property
    def labels(self):
        """Returns the distinct labels defined in the catalogue.

        :rtype: `list`

        """
        return sorted(set(self.values()))

    def load(self, path):
        """Loads the data from `path` into the catalogue.

        :param path: path to catalogue file
        :type path: `str`

        """
        fieldnames = ['work', 'label']
        with open(path, 'r', encoding='utf-8', newline='') as fh:
            reader = csv.DictReader(fh, delimiter=' ', fieldnames=fieldnames,
                                    skipinitialspace=True)
            for row in reader:
                work, label = row['work'], row['label']
                if label:
                    if label not in self._ordered_labels:
                        self._ordered_labels.append(label)
                    if work in self:
                        raise MalformedCatalogueError(

# Path: tacl/constants.py
# CATALOGUE_WORK_RELABELLED_ERROR = 'Catalogue file labels "{}" more than once.'
# 
# Path: tacl/exceptions.py
# class MalformedCatalogueError(TACLError):
# 
#     pass


# Path: tacl/catalogue.py
import copy
import csv
import os
from .constants import CATALOGUE_WORK_RELABELLED_ERROR
from .exceptions import MalformedCatalogueError

        """
        return self._ordered_labels or self.labels

    @property
    def labels(self):
        """Returns the distinct labels defined in the catalogue.

        :rtype: `list`

        """
        return sorted(set(self.values()))

    def load(self, path):
        """Loads the data from `path` into the catalogue.

        :param path: path to catalogue file
        :type path: `str`

        """
        fieldnames = ['work', 'label']
        with open(path, 'r', encoding='utf-8', newline='') as fh:
            reader = csv.DictReader(fh, delimiter=' ', fieldnames=fieldnames,
                                    skipinitialspace=True)
            for row in reader:
                work, label = row['work'], row['label']
                if label:
                    if label not in self._ordered_labels:
                        self._ordered_labels.append(label)
                    if work in self:
                        raise MalformedCatalogueError(

                            CATALOGUE_WORK_RELABELLED_ERROR.format(work))