Skip to content

Company ID List

This part of the project documentation focuses on an information-oriented approach. Use it as a reference for the technical implementation of the pact_methodology project code.

CompanyIdList

A list of CompanyId objects.

Attributes:

Name Type Description
company_ids list

A list of CompanyId objects.

Raises:

Type Description
ValueError

If company_ids is not a list of CompanyId objects.

ValueError

If there are duplicate CompanyId objects in the list.

Source code in pact_methodology/product_footprint/company_id_list.py
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
class CompanyIdList:
    """
    A list of CompanyId objects.

    Attributes:
        company_ids (list): A list of CompanyId objects.

    Raises:
        ValueError: If company_ids is not a list of CompanyId objects.
        ValueError: If there are duplicate CompanyId objects in the list.
    """

    def __init__(self, company_ids):
        """
        Initializes a CompanyIdList object.

        Args:
            company_ids (list): A list of CompanyId objects.

        Raises:
            ValueError: If company_ids is not a list of CompanyId objects.
            ValueError: If there are duplicate CompanyId objects in the list.
        """
        if not isinstance(company_ids, list) or not all(
            isinstance(company_id, CompanyId) for company_id in company_ids
        ):
            raise ValueError("company_ids must be a list of CompanyId")
        if len(set(company_ids)) != len(company_ids):
            raise DuplicateIdError("Duplicate company_ids are not allowed")
        self.company_ids = company_ids

    def __iter__(self):
        """
        Returns an iterator over the CompanyId objects in the list.

        Returns:
            iterator: An iterator over the CompanyId objects in the list.
        """
        return iter(self.company_ids)

    def __len__(self):
        """
        Returns the number of CompanyId objects in the list.

        Returns:
            int: The number of CompanyId objects in the list.
        """
        return len(self.company_ids)

    def __getitem__(self, index):
        """
        Returns the CompanyId object at the specified index.

        Args:
            index (int): The index of the CompanyId object to return.

        Returns:
            CompanyId: The CompanyId object at the specified index.
        """
        return self.company_ids[index]

    def __setitem__(self, index, value):
        """
        Sets the CompanyId object at the specified index.

        Args:
            index (int): The index of the CompanyId object to set.
            value (CompanyId): The CompanyId object to set.

        Raises:
            ValueError: If value is not a CompanyId object.
        """
        if not isinstance(value, CompanyId):
            raise ValueError("company_id must be an instance of CompanyId")
        self.company_ids[index] = value

    def __delitem__(self, index):
        """
        Deletes the CompanyId object at the specified index.

        Args:
            index (int): The index of the CompanyId object to delete.
        """
        del self.company_ids[index]

    def append(self, company_id):
        """
        Appends a CompanyId object to the list.

        Args:
            company_id (CompanyId): The CompanyId object to append.

        Raises:
            ValueError: If company_id is not a CompanyId object.
            ValueError: If company_id is already in the list.
        """
        if not isinstance(company_id, CompanyId):
            raise ValueError("company_id must be an instance of CompanyId")
        if company_id in self.company_ids:
            raise DuplicateIdError("Duplicate company_ids are not allowed")
        self.company_ids.append(company_id)

    def insert(self, index, company_id):
        """
        Inserts a CompanyId object at the specified index.

        Args:
            index (int): The index at which to insert the CompanyId object.
            company_id (CompanyId): The CompanyId object to insert.

        Raises:
            ValueError: If company_id is not a CompanyId object.
            ValueError: If company_id is already in the list.
        """
        if not isinstance(company_id, CompanyId):
            raise ValueError("company_id must be an instance of CompanyId")
        if company_id in self.company_ids:
            raise DuplicateIdError("Duplicate company_ids are not allowed")
        self.company_ids.insert(index, company_id)

    def remove(self, company_id):
        """
        Removes a CompanyId object from the list.

        Args:
            company_id (CompanyId): The CompanyId object to remove.

        Raises:
            ValueError: If company_id is not in the list.
        """
        if company_id not in self.company_ids:
            raise ValueError("company_id is not in the list")
        self.company_ids.remove(company_id)

__delitem__(index)

Deletes the CompanyId object at the specified index.

Parameters:

Name Type Description Default
index int

The index of the CompanyId object to delete.

required
Source code in pact_methodology/product_footprint/company_id_list.py
81
82
83
84
85
86
87
88
def __delitem__(self, index):
    """
    Deletes the CompanyId object at the specified index.

    Args:
        index (int): The index of the CompanyId object to delete.
    """
    del self.company_ids[index]

__getitem__(index)

Returns the CompanyId object at the specified index.

Parameters:

Name Type Description Default
index int

The index of the CompanyId object to return.

required

Returns:

Name Type Description
CompanyId

The CompanyId object at the specified index.

Source code in pact_methodology/product_footprint/company_id_list.py
54
55
56
57
58
59
60
61
62
63
64
def __getitem__(self, index):
    """
    Returns the CompanyId object at the specified index.

    Args:
        index (int): The index of the CompanyId object to return.

    Returns:
        CompanyId: The CompanyId object at the specified index.
    """
    return self.company_ids[index]

__init__(company_ids)

Initializes a CompanyIdList object.

Parameters:

Name Type Description Default
company_ids list

A list of CompanyId objects.

required

Raises:

Type Description
ValueError

If company_ids is not a list of CompanyId objects.

ValueError

If there are duplicate CompanyId objects in the list.

Source code in pact_methodology/product_footprint/company_id_list.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def __init__(self, company_ids):
    """
    Initializes a CompanyIdList object.

    Args:
        company_ids (list): A list of CompanyId objects.

    Raises:
        ValueError: If company_ids is not a list of CompanyId objects.
        ValueError: If there are duplicate CompanyId objects in the list.
    """
    if not isinstance(company_ids, list) or not all(
        isinstance(company_id, CompanyId) for company_id in company_ids
    ):
        raise ValueError("company_ids must be a list of CompanyId")
    if len(set(company_ids)) != len(company_ids):
        raise DuplicateIdError("Duplicate company_ids are not allowed")
    self.company_ids = company_ids

__iter__()

Returns an iterator over the CompanyId objects in the list.

Returns:

Name Type Description
iterator

An iterator over the CompanyId objects in the list.

Source code in pact_methodology/product_footprint/company_id_list.py
36
37
38
39
40
41
42
43
def __iter__(self):
    """
    Returns an iterator over the CompanyId objects in the list.

    Returns:
        iterator: An iterator over the CompanyId objects in the list.
    """
    return iter(self.company_ids)

__len__()

Returns the number of CompanyId objects in the list.

Returns:

Name Type Description
int

The number of CompanyId objects in the list.

Source code in pact_methodology/product_footprint/company_id_list.py
45
46
47
48
49
50
51
52
def __len__(self):
    """
    Returns the number of CompanyId objects in the list.

    Returns:
        int: The number of CompanyId objects in the list.
    """
    return len(self.company_ids)

__setitem__(index, value)

Sets the CompanyId object at the specified index.

Parameters:

Name Type Description Default
index int

The index of the CompanyId object to set.

required
value CompanyId

The CompanyId object to set.

required

Raises:

Type Description
ValueError

If value is not a CompanyId object.

Source code in pact_methodology/product_footprint/company_id_list.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def __setitem__(self, index, value):
    """
    Sets the CompanyId object at the specified index.

    Args:
        index (int): The index of the CompanyId object to set.
        value (CompanyId): The CompanyId object to set.

    Raises:
        ValueError: If value is not a CompanyId object.
    """
    if not isinstance(value, CompanyId):
        raise ValueError("company_id must be an instance of CompanyId")
    self.company_ids[index] = value

append(company_id)

Appends a CompanyId object to the list.

Parameters:

Name Type Description Default
company_id CompanyId

The CompanyId object to append.

required

Raises:

Type Description
ValueError

If company_id is not a CompanyId object.

ValueError

If company_id is already in the list.

Source code in pact_methodology/product_footprint/company_id_list.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
def append(self, company_id):
    """
    Appends a CompanyId object to the list.

    Args:
        company_id (CompanyId): The CompanyId object to append.

    Raises:
        ValueError: If company_id is not a CompanyId object.
        ValueError: If company_id is already in the list.
    """
    if not isinstance(company_id, CompanyId):
        raise ValueError("company_id must be an instance of CompanyId")
    if company_id in self.company_ids:
        raise DuplicateIdError("Duplicate company_ids are not allowed")
    self.company_ids.append(company_id)

insert(index, company_id)

Inserts a CompanyId object at the specified index.

Parameters:

Name Type Description Default
index int

The index at which to insert the CompanyId object.

required
company_id CompanyId

The CompanyId object to insert.

required

Raises:

Type Description
ValueError

If company_id is not a CompanyId object.

ValueError

If company_id is already in the list.

Source code in pact_methodology/product_footprint/company_id_list.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
def insert(self, index, company_id):
    """
    Inserts a CompanyId object at the specified index.

    Args:
        index (int): The index at which to insert the CompanyId object.
        company_id (CompanyId): The CompanyId object to insert.

    Raises:
        ValueError: If company_id is not a CompanyId object.
        ValueError: If company_id is already in the list.
    """
    if not isinstance(company_id, CompanyId):
        raise ValueError("company_id must be an instance of CompanyId")
    if company_id in self.company_ids:
        raise DuplicateIdError("Duplicate company_ids are not allowed")
    self.company_ids.insert(index, company_id)

remove(company_id)

Removes a CompanyId object from the list.

Parameters:

Name Type Description Default
company_id CompanyId

The CompanyId object to remove.

required

Raises:

Type Description
ValueError

If company_id is not in the list.

Source code in pact_methodology/product_footprint/company_id_list.py
125
126
127
128
129
130
131
132
133
134
135
136
137
def remove(self, company_id):
    """
    Removes a CompanyId object from the list.

    Args:
        company_id (CompanyId): The CompanyId object to remove.

    Raises:
        ValueError: If company_id is not in the list.
    """
    if company_id not in self.company_ids:
        raise ValueError("company_id is not in the list")
    self.company_ids.remove(company_id)