Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor pf product ids attr with product id list class #65

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/reference/product_id_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.

::: pact_methodology.product_footprint.product_id_list
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ nav:
- Data Quality Rating: "reference/data_quality_rating.md"
- URN: "reference/urn.md"
- CPC: "reference/cpc.md"
- Product ID List: "reference/product_id_list.md"
18 changes: 10 additions & 8 deletions pact_methodology/product_footprint/product_footprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from pact_methodology.product_footprint.version import Version
from pact_methodology.product_footprint.validity_period import ValidityPeriod
from pact_methodology.urn import CompanyId, ProductId
from pact_methodology.product_footprint.product_id_list import ProductIdList


class ProductFootprint:
"""
Expand All @@ -27,7 +29,7 @@ class ProductFootprint:
company_name (str): The name of the company that owns the ProductFootprint.
company_ids (list[CompanyId]): A list of CompanyIds for the company that owns the ProductFootprint.
product_description (str): A description of the product.
product_ids (list[ProductId]): A list of ProductIds for the product.
product_ids (ProductIdList): A list of ProductIds for the product.
product_category_cpc (CPC): The category of the product according to the CPC (Central Product Classification) system.
product_name_company (str): The name of the product as used by the company.
comment (str): A comment about the ProductFootprint.
Expand Down Expand Up @@ -67,7 +69,7 @@ def __init__(
company_name: str,
company_ids: list[CompanyId],
product_description: str,
product_ids: list[ProductId],
product_ids: ProductIdList,
product_category_cpc: CPC,
product_name_company: str,
comment: str,
Expand Down Expand Up @@ -360,21 +362,21 @@ def product_description(self, value):

@property
def product_ids(self):
"""Gets the list of ProductIds for the product."""
"""Gets the ProductIdList for the product."""
return self._product_ids

@product_ids.setter
def product_ids(self, value):
"""Sets the list of ProductIds for the product.
"""Sets the ProductIdList for the product.

Args:
value (list[ProductId]): The list of product IDs to set.
value (ProductIdList): The ProductIdList to set.

Raises:
ValueError: If value is not a list of ProductId instances.
ValueError: If value is not an instance of ProductIdList.
"""
if not isinstance(value, list) or not all(isinstance(product_id, ProductId) for product_id in value):
raise ValueError("product_ids must be a list of ProductId")
if not isinstance(value, ProductIdList):
raise ValueError("product_ids must be an instance of ProductIdList")
self._product_ids = value

@property
Expand Down
Loading
Loading