EPCIS Event Modules¶
Core EPCIS Event Classes¶
The events module contains the base python implementations of the fundamental EPCIS event classes. The intent of these classes is to implement the EPCIS events along with their business rules and no other type of implementation features. The idea here is that the classes in this module will be inherited and extended by other classes (such as those in this package’s template_events module).
In addition to the base classes defined there are some enumerations and classes that cover common sections and valued shared across the primary EPCIS event types.
-
class
EPCPyYes.core.v1_2.events.
Action
(value)[source]¶ Bases:
enum.Enum
The Action type says how an event relates to the lifecycle of the entity being described. See section 7.3.2 of the EPCIS 1.2 standard.
-
add
= 'ADD'¶ The entity in question has been created or added to.
-
delete
= 'DELETE'¶ The entity in question has been removed from or destroyed altogether.
-
observe
= 'OBSERVE'¶ The entity in question has not been changed: it has neither been created, added to, destroyed, or removed from.
-
-
class
EPCPyYes.core.v1_2.events.
AggregationEvent
(event_time: datetime.datetime, event_timezone_offset: str, record_time: datetime.datetime, action: str = 'ADD', parent_id: Optional[str] = None, child_epcs: Optional[list] = None, child_quantity_list: Optional[list] = None, biz_step: Optional[str] = None, disposition: Optional[str] = None, read_point: Optional[str] = None, biz_location: Optional[str] = None, event_id: Optional[str] = None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, source_list=None, destination_list=None, business_transaction_list=None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.EPCISBusinessEvent
The event type AggregationEvent describes events that apply to objects that have been aggregated to one another. In such an event, there is a set of “contained” objects that have been aggregated within a “containing” entity that’s meant to identify the aggregation itself.
Creates a new python AggregationEvent instance.
- Parameters
event_time – Inherited from
EPCISEvent
event_timezone_offset – Inherited from
EPCISEvent
record_time – Inherited from
EPCISEvent
action – Inherited from
EPCISBusinessEvent
parent_id – The identifier of the parent of the association.
child_epcs – An unordered list of the EPCs of contained objects identified by instance-level identifiers.
child_quantity_list – An unordered list of one or more QuantityElements identifying (at the class level) contained objects.
biz_step – Inherited from
EPCISBusinessEvent
disposition – Inherited from
EPCISBusinessEvent
read_point – Inherited from
EPCISBusinessEvent
biz_location – Inherited from
EPCISBusinessEvent
event_id – Inherited from
EPCISEvent
error_declaration – Inherited from
EPCISEvent
source_list – Inherited from
EPCISBusinessEvent
destination_list – Inherited from
EPCISBusinessEvent
business_transaction_list – Inherited from
EPCISBusinessEvent
-
property
child_epcs
¶ Gets or sets an unordered list of the EPCs of contained objects identified by instance-level identifiers.
-
property
child_quantity_list
¶ Gets or sets the unordered list of one or more QuantityElements identifying contained objects
-
clean
()[source]¶ Implement this function to Validate an event based on rules defined in the EPCIS protocol or custom business rules if neccessary. :return: None or a EPCPyYes.core.errors.ValidationError
-
property
parent_id
¶ Gets or sets identifier of the parent of the association.
-
class
EPCPyYes.core.v1_2.events.
BusinessTransaction
(biz_transaction, type=None)[source]¶ Bases:
object
A BusinessTransaction identifies a particular business transaction. An example of a business transaction is a specific purchase order. Business Transaction information may be included in EPCIS events to record an event’s participation in particular business transactions. As defined in section 7.3.5.3 of the protocol.
- Parameters
biz_transaction – An identifier that denotes a specific business transaction.
type – (Optional) An identifier that indicates what kind of business transaction this BusinessTransaction denotes.
-
class
EPCPyYes.core.v1_2.events.
Destination
(destination_type: str, destination: str)[source]¶ Bases:
EPCPyYes.core.v1_2.events.SourceDest
A Source or Destination is used to provide additional business context when an EPCIS event is part of a business transfer; that is, a process in which there is a transfer of ownership, responsibility, and/or custody of physical or digital objects.
See the EPCPyYes.core.v1_2.CBV.source_destination module for standard source types.
- Parameters
source_type – An identifier that indicates what kind of source or destination this Source or Destination (respectively) denotes.
source – An identifier that denotes a specific source or destination.
-
class
EPCPyYes.core.v1_2.events.
EPCISBusinessEvent
(event_time: datetime.datetime, event_timezone_offset: str, record_time: Optional[datetime.datetime] = None, action: str = 'ADD', biz_step: Optional[str] = None, disposition: Optional[str] = None, read_point: Optional[str] = None, biz_location: Optional[str] = None, event_id: Optional[str] = None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, source_list=None, destination_list=None, business_transaction_list=None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.EPCISEvent
For super-classes with an Action, biz step, biz location, etc…basically every main EPCIS class except the TransformationEvent class.
- Parameters
event_time – Inherited from
EPCISEvent
event_timezone_offset – Inherited from
EPCISEvent
record_time – Inherited from
EPCISEvent
action – How this event relates to the lifecycle of the EPCs named in this event.
biz_step – The business step of which this event was a part.
disposition – The business condition of the objects associated with the EPCs, presumed to hold true until contradicted by a subsequent event.
read_point – The read point at which the event took place.
biz_location – The business location where the objects associated with the EPCs may be found, until contradicted by a subsequent event.
event_id – Inherited from
EPCISEvent
error_declaration – Inherited from
EPCISEvent
source_list – An unordered list of Source elements that provide context about the originating endpoint of a business transfer of which this event is a part.
destination_list – An unordered list of Destination elements that provide context about the terminating endpoint of a business transfer of which this event is a part. Class
EPCPyYes.core.v1_2.CBV.source_destination.SourceDestinationTypes
can be used to generate the appropriate XML values for this.business_transaction_list – An unordered list of business transactions that define the context of this event.
-
clean
()¶ Implement this function to Validate an event based on rules defined in the EPCIS protocol or custom business rules if neccessary. :return: None or a EPCPyYes.core.errors.ValidationError
-
class
EPCPyYes.core.v1_2.events.
EPCISDocument
(header: Optional[EPCPyYes.core.SBDH.sbdh.StandardBusinessDocumentHeader] = None, object_events: Optional[list] = None, aggregation_events: Optional[list] = None, transaction_events: Optional[list] = None, transformation_events: Optional[list] = None, render_xml_declaration: bool = True, created_date: Optional[str] = None)[source]¶ Bases:
object
Represents the higher-level container for an aggregation of EPCIS events.
Initializes the EPCIS Document with the constituent object, aggregation, transaction and transformation events.
- Parameters
object_events – A list of ObjectEvent instances.
aggregation_events – A list of AggregationEvent instances
transaction_events – A list of TransactionEvent instances
transformation_events – A list of TransformationEvent instances.
-
class
EPCPyYes.core.v1_2.events.
EPCISEvent
(event_time: str, event_timezone_offset: str, record_time: Optional[str] = None, event_id: Optional[str] = None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, id=None)[source]¶ Bases:
object
The base EPCIS event as defined by GS1 on page 38 of the EPCIS 1.2 draft.
The base EPCIS event class contains common properties shared across each of the Aggregation, Object, Transaction and Transformation events.
- Parameters
event_time – The date and time at which the EPCIS Capturing Applications asserts the event occurred.
event_timezone_offset – The time zone offset in effect at the time and place the event occurred, expressed as an offset from UTC.
record_time – The date and time at which this event was recorded by an EPCIS Repository.
event_id – An identifier for this event as specified by the capturing application, globally unique across all events other than error declarations.
error_declaration – If present, indicates that this event serves to assert that the assertions made by a prior event are in error.
id – If present is used to store a reference to a database primary key. This will NOT be rendered in the XML EPCIS documents. Use the id parameter and class property according to development needs.
-
class
EPCPyYes.core.v1_2.events.
ErrorDeclaration
(declaration_time: datetime.datetime = '2024-02-25T18:00:10.501744', reason: Optional[str] = None, corrective_event_ids=[])[source]¶ Bases:
object
As defined by the working group?…yikes.
-
class
EPCPyYes.core.v1_2.events.
EventType
(value)[source]¶ Bases:
enum.Enum
A helper Enum for comparing and using event types.
-
class
EPCPyYes.core.v1_2.events.
InstanceLotMasterDataAttribute
(name: str, value: str)[source]¶ Bases:
object
Base class for ILMD nodes.
An ILMD attribute. If you are using the CBV compliant events see the
EPCPyYes.core.v1_2.CBV.instance_lot_master_data. InstanceLotMasterDataAttribute
class.- Parameters
name – The name of the attribute (will be the name of the element in the ILMD section)
value – Will be the element value in the ILMD section.
-
property
name
¶ Gets and sets the name of the ILMD node. This value should be XML safe and is not auto-escaped.
-
property
value
¶ Gets and sets the value of the ILMD node. This value should be XML safe and is not auto-escaped.
-
class
EPCPyYes.core.v1_2.events.
ObjectEvent
(event_time: datetime.datetime, event_timezone_offset: str, record_time: datetime.datetime, action: str = 'ADD', epc_list: Optional[list] = None, biz_step=None, disposition=None, read_point=None, biz_location=None, event_id: Optional[str] = None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, source_list: Optional[list] = None, destination_list: Optional[list] = None, business_transaction_list: Optional[list] = None, ilmd: Optional[str] = None, quantity_list: Optional[list] = None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.EPCISBusinessEvent
A python implementation of the EPCIS Object event as outlined in section 7.4.2 of the standard.
A python representation of an EPCIS ObjectEvent instance.
- Parameters
event_time – Inherited from
EPCISEvent
event_timezone_offset – Inherited from
EPCISEvent
record_time – Inherited from
EPCISEvent
action – Inherited from
EPCISBusinessEvent
epc_list – An unordered list of one or more EPCs naming specific objects to which the event pertained
biz_step – Inherited from
EPCISBusinessEvent
disposition – Inherited from
EPCISBusinessEvent
read_point – Inherited from
EPCISBusinessEvent
biz_location – Inherited from
EPCISBusinessEvent
event_id – Inherited from
EPCISEvent
error_declaration – Inherited from
EPCISEvent
source_list – Inherited from
EPCISBusinessEvent
destination_list – Inherited from
EPCISBusinessEvent
business_transaction_list – Inherited from
EPCISBusinessEvent
ilmd – Instance/Lot master data (Section 7.3.6) that describes the objects created during this event. An ObjectEvent SHALL NOT contain ilmd if action is OBSERVE or DELETE.
quantity_list – An unordered list of one or more QuantityElements identifying (at the class level) objects to which the event pertained.
- Parm enforce_rules
whether or not to enforce EPCIS rules during the initilization of the class. Default is false.
-
class
EPCPyYes.core.v1_2.events.
QuantityElement
(epc_class: str, quantity: Optional[float] = None, uom=None)[source]¶ Bases:
object
The EPCIS QuantityElement as outlined in section 7.3.3.3 of the protocol.
-
class
EPCPyYes.core.v1_2.events.
Source
(source_type: str, source: str)[source]¶ Bases:
EPCPyYes.core.v1_2.events.SourceDest
A Source or Destination is used to provide additional business context when an EPCIS event is part of a business transfer; that is, a process in which there is a transfer of ownership, responsibility, and/or custody of physical or digital objects.
See the EPCPyYes.core.v1_2.CBV.source_destination module for standard source types.
- Parameters
source_type – An identifier that indicates what kind of source or destination this Source or Destination (respectively) denotes.
source – An identifier that denotes a specific source or destination.
-
class
EPCPyYes.core.v1_2.events.
TransactionEvent
(event_time: datetime.datetime, event_timezone_offset: str, record_time: datetime.datetime, action: EPCPyYes.core.v1_2.events.Action = 'ADD', parent_id: Optional[str] = None, epc_list: Optional[list] = None, biz_step: Optional[str] = None, disposition: Optional[str] = None, read_point: Optional[str] = None, biz_location: Optional[str] = None, event_id: Optional[str] = None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, source_list=None, destination_list=None, business_transaction_list=None, quantity_list: Optional[list] = None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.EPCISBusinessEvent
A python implementation of and EPCIS TransactionEvent.
Initializes a new python representation of an EPCIS TransactionEvent.
- Parameters
event_time – Inherited from
EPCISEvent
event_timezone_offset – Inherited from
EPCISEvent
record_time – Inherited from
EPCISEvent
action – Inherited from
EPCISBusinessEvent
parent_id – The identifier of the parent of the association.
epc_list – An unordered list of one or more EPCs naming specific objects to which the event pertained
biz_step – Inherited from
EPCISBusinessEvent
disposition – Inherited from
EPCISBusinessEvent
read_point – Inherited from
EPCISBusinessEvent
biz_location – Inherited from
EPCISBusinessEvent
event_id – Inherited from
EPCISEvent
error_declaration – Inherited from
EPCISEvent
source_list – Inherited from
EPCISBusinessEvent
destination_list – Inherited from
EPCISBusinessEvent
business_transaction_list – Inherited from
EPCISBusinessEvent
quantity_list – Inherited from
EPCISBusinessEvent
-
clean
()¶ Implement this function to Validate an event based on rules defined in the EPCIS protocol or custom business rules if neccessary. :return: None or a EPCPyYes.core.errors.ValidationError
-
class
EPCPyYes.core.v1_2.events.
TransformationEvent
(event_time: datetime.datetime, event_timezone_offset: str, record_time: datetime.datetime, event_id: Optional[str] = None, input_epc_list=None, input_quantity_list=None, output_epc_list=None, output_quantity_list=None, transformation_id=None, biz_step: Optional[str] = None, disposition: Optional[str] = None, read_point: Optional[str] = None, biz_location: Optional[str] = None, business_transaction_list=None, source_list=None, destination_list=None, ilmd=None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.EPCISEvent
A python implementation for the EPCIS TransformationEvent from section 7.4.6 of the GS1 standard.
- Parameters
event_time – Inherited from
EPCISEvent
event_timezone_offset – Inherited from
EPCISEvent
record_time – Inherited from
EPCISEvent
event_id – Inherited from
EPCISEvent
input_epc_list – An unordered list of one or more EPCs identifying (at the instance level) objects that were inputs to the transformation.
input_quantity_list – An unordered list of one or more QuantityElements identifying (at the class level) objects that were inputs to the transformation.
output_epc_list – An unordered list of one or more EPCs naming (at the instance level) objects that were outputs from the transformation.
output_quantity_list – An unordered list of one or more QuantityElements identifying (at the class level) objects that were outputs from the transformation
transformation_id – A unique identifier that links this event to other TransformationEvents having an identical value of transformationID.
biz_step – The business step of which this event was a part.
disposition – The business condition of the objects associated with the EPCs, presumed to hold true until contradicted by a subsequent event.
read_point – The read point at which the event took place.
biz_location – The business location where the objects associated with the EPCs may be found, until contradicted by a subsequent event.
business_transaction_list – An unordered list of business transactions that define the context of this event.
source_list – An unordered list of Source elements that provide context about the originating endpoint of a business transfer of which this event is a part.
destination_list – An unordered list of Destination elements that provide context about the terminating endpoint of a business transfer of which this event is a part. Class
EPCPyYes.core.v1_2.CBV.source_destination.SourceDestinationTypes
can be used to generate the appropriate XML values for this.ilmd – Instance/Lot master data (Section 7.3.6) that describes the output objects created during this event.
error_declaration – Inherited from
EPCISEvent
-
clean
()¶ Implement this function to Validate an event based on rules defined in the EPCIS protocol or custom business rules if neccessary. :return: None or a EPCPyYes.core.errors.ValidationError
EPCIS Template Classes¶
The templates package contains classes derived from the core EPCIS classes along with Jinja2 templates for generating EPCIS event XML. By calling any classes’ render function, you can obtain the output of the Jinja2 template associated with the current class. There are examples of this in the Usage section of this documentation.
-
class
EPCPyYes.core.v1_2.template_events.
AggregationEvent
(event_time: datetime.datetime = '2024-02-25T18:00:11.146804', event_timezone_offset: str = '+00:00', record_time: Optional[datetime.datetime] = None, action: str = 'ADD', parent_id: Optional[str] = None, child_epcs: Optional[list] = None, child_quantity_list: Optional[list] = None, biz_step: Optional[str] = None, disposition: Optional[str] = None, read_point: Optional[str] = None, biz_location: Optional[str] = None, event_id: Optional[str] = None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, source_list=None, destination_list=None, business_transaction_list=None, env: Optional[jinja2.environment.Environment] = None, template: Optional[str] = None, render_xml_declaration=None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.AggregationEvent
,EPCPyYes.core.v1_2.template_events.TemplateMixin
Generates an EPCIS Aggregation Event.
Creates a new EPCIS AggregationEvent instance.
- Parameters
event_time – The date and time at which the EPCIS Capturing Applications asserts the event occurred.
event_timezone_offset – The time zone offset in effect at the time and place the event occurred, expressed as an offset from UTC.
action – How this event relates to the lifecycle of the aggregation named in this event.
parent_id – (Optional when action is OBSERVE, required otherwise) The identifier of the parent of the association
child_epcs – An unordered list of the EPCs of contained objects identified by instance-level identifiers.
child_quantity_list – An unordered list of one or more QuantityElements identifying (at the class level) contained objects
biz_step – The business step of which this event was a part.
disposition – The business condition of the objects associated with the EPCs, presumed to hold true until contradicted by a subsequent event.
read_point – The read point at which the event took place.
biz_location – The business location where the objects associated with the containing and contained EPCs may be found, until contradicted by a subsequent event.
event_id – (Optional) An identifier for this event as specified by the capturing application, globally unique across all events other than error declarations.
error_declaration – If present, indicates that this event serves to assert that the assertions made by a prior event are in error. See Section 7.4.1.2.
source_list – An unordered list of Source elements (Section 7.3.5.4) that provide context about the originating endpoint of a business transfer of which this event is a part.
destination_list – An unordered list of Destination elements (Section 7.3.5.4) that provide context about the terminating endpoint of a business transfer of which this event is a part
business_transaction_list – An unordered list of business transactions that define the context of this event.
-
property
child_epcs
¶ Gets or sets an unordered list of the EPCs of contained objects identified by instance-level identifiers.
-
property
child_quantity_list
¶ Gets or sets the unordered list of one or more QuantityElements identifying contained objects
-
clean
()[source]¶ Implement this function to Validate an event based on rules defined in the EPCIS protocol or custom business rules if neccessary. :return: None or a EPCPyYes.core.errors.ValidationError
-
property
namespaces
¶ Override to provide a list of XML namespace declarations for inclusion in the EPCIS body root node.
- Returns
An empty list.
-
property
parent_id
¶ Gets or sets identifier of the parent of the association.
-
render
()¶ Renders the Class template using the _context dictionary for the template context.
- Param
render_namespaces: A boolean value passed into the
template as a context variable. Used by the default templates to determine whether or not to declare the XML namespaces in the root element.
-
render_dict
()¶ Will return the python dictionary rendered by the JSON encoder. :return: A dictionary.
-
render_json
()¶ Will strip all white space from the template output. :return: A JSON string with no whitespace.
-
render_pretty_json
(indent=4, sort_keys=False)¶ Pretty prints the JSON output. :param indent: Default of 4. :param sort_keys: Default of False. :return: A formatted JSON string indented and (potentially) sorted.
-
property
template
¶ - Returns
Returns a Jinja2 Template instance.
-
class
EPCPyYes.core.v1_2.template_events.
EPCISDocument
(header: Optional[EPCPyYes.core.SBDH.sbdh.StandardBusinessDocumentHeader] = None, object_events: list = [], aggregation_events: list = [], transaction_events: list = [], transformation_events: list = [], render_xml_declaration: bool = False, created_date: Optional[str] = None, template: str = 'epcis/epcis_document.xml')[source]¶ Bases:
EPCPyYes.core.v1_2.events.EPCISDocument
,EPCPyYes.core.v1_2.template_events.TemplateMixin
Initializes the EPCIS Document with the constituent object, aggregation, transaction and transformation events.
- Parameters
object_events – A list of ObjectEvent instances.
aggregation_events – A list of AggregationEvent instances
transaction_events – A list of TransactionEvent instances
transformation_events – A list of TransformationEvent instances.
-
property
namespaces
¶ Override to provide a list of XML namespace declarations for inclusion in the EPCIS body root node.
- Returns
An empty list.
-
render
(render_namespaces=False, render_xml_declaration=False)[source]¶ Renders the Class template using the _context dictionary for the template context.
- Param
render_namespaces: A boolean value passed into the
template as a context variable. Used by the default templates to determine whether or not to declare the XML namespaces in the root element.
-
render_dict
()¶ Will return the python dictionary rendered by the JSON encoder. :return: A dictionary.
-
render_json
()¶ Will strip all white space from the template output. :return: A JSON string with no whitespace.
-
render_pretty_json
(indent=4, sort_keys=False)¶ Pretty prints the JSON output. :param indent: Default of 4. :param sort_keys: Default of False. :return: A formatted JSON string indented and (potentially) sorted.
-
property
template
¶ - Returns
Returns a Jinja2 Template instance.
-
class
EPCPyYes.core.v1_2.template_events.
EPCISEventListDocument
(template_events: List[EPCPyYes.core.v1_2.template_events.TemplateMixin], header: Optional[EPCPyYes.core.SBDH.sbdh.StandardBusinessDocumentHeader] = None, render_xml_declaration: bool = True, created_date: Optional[str] = None, render_namespaces=False, template='epcis/epcis_events_document.xml', additional_context: Optional[dict] = None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.EPCISDocument
,EPCPyYes.core.v1_2.template_events.TemplateMixin
This template event of the EPCISDocument type allows you to specify a generic list of EPCPyYes events of any type in any order- as opposed to the EPCISDocument template class in this same module which has separate lists for each event type.
The EPCISEventListDocument has a single list called template_events which can be supplied in the constructor or can be accessed via the property of the same name. The class must be initialized, however, with at least one event in the template_events parameter.
Initializes the class with at least one event in the template_events paramter. :param template_events: A list of EPCPyYes.core.v1_2.template_event.TemplateMixin objects. :param header: An EPCPyYes SBDH object. :param render_xml_declaration: :param created_date: Created date or the current UTC now. :param render_namespaces: Whether or not to render namespaces in the header. Default = False :param template: The Jinja2 template path. Default is epcis/epcis_events_document.xml
-
property
namespaces
¶ Override to provide a list of XML namespace declarations for inclusion in the EPCIS body root node.
- Returns
An empty list.
-
render
()[source]¶ Renders the Class template using the _context dictionary for the template context.
- Param
render_namespaces: A boolean value passed into the
template as a context variable. Used by the default templates to determine whether or not to declare the XML namespaces in the root element.
-
render_dict
()¶ Will return the python dictionary rendered by the JSON encoder. :return: A dictionary.
-
render_json
()¶ Will strip all white space from the template output. :return: A JSON string with no whitespace.
-
render_pretty_json
(indent=4, sort_keys=False)¶ Pretty prints the JSON output. :param indent: Default of 4. :param sort_keys: Default of False. :return: A formatted JSON string indented and (potentially) sorted.
-
property
template
¶ - Returns
Returns a Jinja2 Template instance.
-
property
-
class
EPCPyYes.core.v1_2.template_events.
ObjectEvent
(event_time: datetime.datetime = '2024-02-25T18:00:11.146762', event_timezone_offset: str = '+00:00', record_time: Optional[datetime.datetime] = None, action: str = 'ADD', epc_list: Optional[list] = None, biz_step=None, disposition=None, read_point=None, biz_location=None, event_id: Optional[str] = None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, source_list: Optional[list] = None, destination_list: Optional[list] = None, business_transaction_list: Optional[list] = None, ilmd: Optional[list] = None, quantity_list: Optional[list] = None, env: Optional[jinja2.environment.Environment] = None, template: Optional[str] = None, render_xml_declaration=None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.ObjectEvent
,EPCPyYes.core.v1_2.template_events.TemplateMixin
Used to render an ObjectEvent using the Jinja2 environment and template associated with the class. The default environment utilizes the templates directory in the root folder of the package.
A python representation of an EPCIS ObjectEvent instance.
- Parameters
event_time – Inherited from
EPCISEvent
event_timezone_offset – Inherited from
EPCISEvent
record_time – Inherited from
EPCISEvent
action – Inherited from
EPCISBusinessEvent
epc_list – An unordered list of one or more EPCs naming specific objects to which the event pertained
biz_step – Inherited from
EPCISBusinessEvent
disposition – Inherited from
EPCISBusinessEvent
read_point – Inherited from
EPCISBusinessEvent
biz_location – Inherited from
EPCISBusinessEvent
event_id – Inherited from
EPCISEvent
error_declaration – Inherited from
EPCISEvent
source_list – Inherited from
EPCISBusinessEvent
destination_list – Inherited from
EPCISBusinessEvent
business_transaction_list – Inherited from
EPCISBusinessEvent
ilmd – Instance/Lot master data (Section 7.3.6) that describes the objects created during this event. An ObjectEvent SHALL NOT contain ilmd if action is OBSERVE or DELETE.
quantity_list – An unordered list of one or more QuantityElements identifying (at the class level) objects to which the event pertained.
- Parm enforce_rules
whether or not to enforce EPCIS rules during the initilization of the class. Default is false.
-
property
namespaces
¶ If there are any CBV ILMD attributes, we’ll need to expose the namespace for any XML generation. Override to provide custom XML namespaces if needed. :return: A full string of the namespace declaration for use in an XML root node.
-
render
()¶ Renders the Class template using the _context dictionary for the template context.
- Param
render_namespaces: A boolean value passed into the
template as a context variable. Used by the default templates to determine whether or not to declare the XML namespaces in the root element.
-
render_dict
()¶ Will return the python dictionary rendered by the JSON encoder. :return: A dictionary.
-
render_json
()¶ Will strip all white space from the template output. :return: A JSON string with no whitespace.
-
render_pretty_json
(indent=4, sort_keys=False)¶ Pretty prints the JSON output. :param indent: Default of 4. :param sort_keys: Default of False. :return: A formatted JSON string indented and (potentially) sorted.
-
property
template
¶ - Returns
Returns a Jinja2 Template instance.
-
class
EPCPyYes.core.v1_2.template_events.
TemplateMixin
(*args, **kwargs)[source]¶ Bases:
EPCPyYes.core.v1_2.json_encoders.JSONFormatMixin
Mixin class to add template support for serializing EPCIS classes to text using jinja templates.
Will render an object event using the default ‘object_event.xml’ template or you can pass in a Jinja2 template along with a new Jinja2 enviornment as well if you wish.
- Parameters
args –
kwargs – env = a jinja2 Environment, template = a string representing the template in either the default or passed in Jinja2 environment and render_xml_declaration which is a bool value used to determine whether or not to render an xml declaration during template rendering. It is populated as a jinja context variable.
-
property
namespaces
¶ Override to provide a list of XML namespace declarations for inclusion in the EPCIS body root node.
- Returns
An empty list.
-
render
()[source]¶ Renders the Class template using the _context dictionary for the template context.
- Param
render_namespaces: A boolean value passed into the
template as a context variable. Used by the default templates to determine whether or not to declare the XML namespaces in the root element.
-
render_dict
()¶ Will return the python dictionary rendered by the JSON encoder. :return: A dictionary.
-
render_json
()¶ Will strip all white space from the template output. :return: A JSON string with no whitespace.
-
render_pretty_json
(indent=4, sort_keys=False)¶ Pretty prints the JSON output. :param indent: Default of 4. :param sort_keys: Default of False. :return: A formatted JSON string indented and (potentially) sorted.
-
property
template
¶ - Returns
Returns a Jinja2 Template instance.
-
class
EPCPyYes.core.v1_2.template_events.
TransactionEvent
(event_time: datetime.datetime = '2024-02-25T18:00:11.146827', event_timezone_offset: str = '+00:00', record_time: Optional[datetime.datetime] = None, action: str = 'ADD', parent_id: Optional[str] = None, epc_list: Optional[list] = None, biz_step: Optional[str] = None, disposition: Optional[str] = None, read_point: Optional[str] = None, biz_location: Optional[str] = None, event_id: Optional[str] = None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, source_list=None, destination_list=None, business_transaction_list=None, quantity_list: Optional[list] = None, env: Optional[jinja2.environment.Environment] = None, template: Optional[str] = None, render_xml_declaration=None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.TransactionEvent
,EPCPyYes.core.v1_2.template_events.TemplateMixin
Initializes a new python representation of an EPCIS TransactionEvent.
- Parameters
event_time – Inherited from
EPCISEvent
event_timezone_offset – Inherited from
EPCISEvent
record_time – Inherited from
EPCISEvent
action – Inherited from
EPCISBusinessEvent
parent_id – The identifier of the parent of the association.
epc_list – An unordered list of one or more EPCs naming specific objects to which the event pertained
biz_step – Inherited from
EPCISBusinessEvent
disposition – Inherited from
EPCISBusinessEvent
read_point – Inherited from
EPCISBusinessEvent
biz_location – Inherited from
EPCISBusinessEvent
event_id – Inherited from
EPCISEvent
error_declaration – Inherited from
EPCISEvent
source_list – Inherited from
EPCISBusinessEvent
destination_list – Inherited from
EPCISBusinessEvent
business_transaction_list – Inherited from
EPCISBusinessEvent
quantity_list – Inherited from
EPCISBusinessEvent
-
clean
()¶ Implement this function to Validate an event based on rules defined in the EPCIS protocol or custom business rules if neccessary. :return: None or a EPCPyYes.core.errors.ValidationError
-
property
namespaces
¶ Override to provide a list of XML namespace declarations for inclusion in the EPCIS body root node.
- Returns
An empty list.
-
render
()¶ Renders the Class template using the _context dictionary for the template context.
- Param
render_namespaces: A boolean value passed into the
template as a context variable. Used by the default templates to determine whether or not to declare the XML namespaces in the root element.
-
render_dict
()¶ Will return the python dictionary rendered by the JSON encoder. :return: A dictionary.
-
render_json
()¶ Will strip all white space from the template output. :return: A JSON string with no whitespace.
-
render_pretty_json
(indent=4, sort_keys=False)¶ Pretty prints the JSON output. :param indent: Default of 4. :param sort_keys: Default of False. :return: A formatted JSON string indented and (potentially) sorted.
-
property
template
¶ - Returns
Returns a Jinja2 Template instance.
-
class
EPCPyYes.core.v1_2.template_events.
TransformationEvent
(event_time: datetime.datetime = '2024-02-25T18:00:11.146849', event_timezone_offset: str = '+00:00', record_time: Optional[datetime.datetime] = None, event_id: Optional[str] = None, input_epc_list=None, input_quantity_list=None, output_epc_list=None, output_quantity_list=None, transformation_id=None, biz_step: Optional[str] = None, disposition: Optional[str] = None, read_point: Optional[str] = None, biz_location: Optional[str] = None, business_transaction_list=None, source_list=None, destination_list=None, ilmd=None, error_declaration: Optional[EPCPyYes.core.v1_2.events.ErrorDeclaration] = None, env: Optional[jinja2.environment.Environment] = None, template: Optional[str] = None, render_xml_declaration=None)[source]¶ Bases:
EPCPyYes.core.v1_2.events.TransformationEvent
,EPCPyYes.core.v1_2.template_events.TemplateMixin
- Parameters
event_time – Inherited from
EPCISEvent
event_timezone_offset – Inherited from
EPCISEvent
record_time – Inherited from
EPCISEvent
event_id – Inherited from
EPCISEvent
input_epc_list – An unordered list of one or more EPCs identifying (at the instance level) objects that were inputs to the transformation.
input_quantity_list – An unordered list of one or more QuantityElements identifying (at the class level) objects that were inputs to the transformation.
output_epc_list – An unordered list of one or more EPCs naming (at the instance level) objects that were outputs from the transformation.
output_quantity_list – An unordered list of one or more QuantityElements identifying (at the class level) objects that were outputs from the transformation
transformation_id – A unique identifier that links this event to other TransformationEvents having an identical value of transformationID.
biz_step – The business step of which this event was a part.
disposition – The business condition of the objects associated with the EPCs, presumed to hold true until contradicted by a subsequent event.
read_point – The read point at which the event took place.
biz_location – The business location where the objects associated with the EPCs may be found, until contradicted by a subsequent event.
business_transaction_list – An unordered list of business transactions that define the context of this event.
source_list – An unordered list of Source elements that provide context about the originating endpoint of a business transfer of which this event is a part.
destination_list – An unordered list of Destination elements that provide context about the terminating endpoint of a business transfer of which this event is a part. Class
EPCPyYes.core.v1_2.CBV.source_destination.SourceDestinationTypes
can be used to generate the appropriate XML values for this.ilmd – Instance/Lot master data (Section 7.3.6) that describes the output objects created during this event.
error_declaration – Inherited from
EPCISEvent
-
clean
()¶ Implement this function to Validate an event based on rules defined in the EPCIS protocol or custom business rules if neccessary. :return: None or a EPCPyYes.core.errors.ValidationError
-
property
namespaces
¶ Override to provide a list of XML namespace declarations for inclusion in the EPCIS body root node.
- Returns
An empty list.
-
render
()¶ Renders the Class template using the _context dictionary for the template context.
- Param
render_namespaces: A boolean value passed into the
template as a context variable. Used by the default templates to determine whether or not to declare the XML namespaces in the root element.
-
render_dict
()¶ Will return the python dictionary rendered by the JSON encoder. :return: A dictionary.
-
render_json
()¶ Will strip all white space from the template output. :return: A JSON string with no whitespace.
-
render_pretty_json
(indent=4, sort_keys=False)¶ Pretty prints the JSON output. :param indent: Default of 4. :param sort_keys: Default of False. :return: A formatted JSON string indented and (potentially) sorted.
-
property
template
¶ - Returns
Returns a Jinja2 Template instance.
EPCIS Helper Functions¶
-
EPCPyYes.core.v1_2.helpers.
get_current_utc_time_and_offset
()[source]¶ Based on the inbound datetime value, it will reuturn the ISO string and the ISO timezone offset value. Helps when creating EPCIS events on the fly.
- Parameters
datetime – The datetime instance you want to convert to a string.
- Returns
A two-tuple with the datetime ISO string and the ISO timezone offset.
-
EPCPyYes.core.v1_2.helpers.
get_iso_8601_regex
()[source]¶ Returns a compiled ISO 8601 regex for use in validation of date strings. :return: A compiled regex.
-
EPCPyYes.core.v1_2.helpers.
gln13_data_to_sgln_urn
(company_prefix, location_reference, extension='0')[source]¶ Takes the three parameters and outputs a compliant EPCGlobal urn. The company prefix and location reference must be a total of 12 digits- do not send in the check digit as part of the location reference.
- Parameters
company_prefix – The company prefix
location_reference – The location reference
extension – The id of the sub-site for the GLN
- Returns
An TDS 1.9 compliant SGLN URN value.
-
EPCPyYes.core.v1_2.helpers.
gtin_to_urn
(company_prefix, indicator, item_reference, serial_number: str)[source]¶ A python generator that creates SGTIN URNs for the list of serial numbers passed in.
- Parameters
company_prefix – The company prefix (GS1).
indicator – The GS1 indicator digit for the GTIN
item_reference – The item reference number for the GTIN
serial_number – A serial number.
- Returns
Generates a sgtin URN string for each serial number provided.
-
EPCPyYes.core.v1_2.helpers.
gtin_urn_generator
(company_prefix, indicator, item_reference, serial_numbers: list)[source]¶ A python generator that creates SGTIN URNs for the list of serial numbers passed in.
- Parameters
company_prefix – The company prefix (GS1).
indicator – The GS1 indicator digit for the GTIN
item_reference – The item reference number for the GTIN
serial_numbers – A list of serial numbers in string or integer format.
- Returns
Generates a sgtin URN string for each serial number provided.
-
EPCPyYes.core.v1_2.helpers.
sscc_urn_generator
(company_prefix, extension, serial_numbers: list)[source]¶ A python generator that creates SSCC URNs for the list of serial numbers passed in.
- Parameters
company_prefix – The company prefix (GS1).
extension – The extension digit.
serial_numbers – The serial reference numbers for the SSCC
- Returns
Generates a SSCC URN string for each serial reference provided.