MCPcopy Create free account
hub / github.com/STIXProject/python-stix / set_producer_identity

Method set_producer_identity

stix/indicator/indicator.py:557–601  ·  view source on GitHub ↗

Sets the name of the producer of this indicator. This is the same as calling ``indicator.producer.identity.name = identity``. If the ``producer`` property is ``None``, it will be initialized to an instance of :class:`stix.common.information_source.Informatio

(self, identity)

Source from the content-addressed store, hash-verified

555 self.related_packages.append(value)
556
557 def set_producer_identity(self, identity):
558 """Sets the name of the producer of this indicator.
559
560 This is the same as calling
561 ``indicator.producer.identity.name = identity``.
562
563 If the ``producer`` property is ``None``, it will be initialized to
564 an instance of
565 :class:`stix.common.information_source.InformationSource`.
566
567 If the ``identity`` property of the ``producer`` instance is ``None``,
568 it will be initialized to an instance of
569 :class:`stix.common.identity.Identity`.
570
571 Note:
572 if the `identity` parameter is not an instance
573 :class:`stix.common.identity.Identity` an attempt will be made
574 to convert it to one.
575
576 Args:
577 identity: An instance of ``str`` or
578 ``stix.common.identity.Identity``.
579
580 """
581 def unset_producer_identity():
582 try:
583 self.producer.identity.name = None
584 except AttributeError:
585 pass
586
587 if not identity:
588 unset_producer_identity()
589 return
590
591 if not self.producer:
592 self.producer = InformationSource()
593
594 if isinstance(identity, Identity):
595 self.producer.identity = identity
596 return
597
598 if not self.producer.identity:
599 self.producer.identity = Identity()
600
601 self.producer.identity.name = str(identity)
602
603 def set_produced_time(self, produced_time):
604 """Sets the ``produced_time`` property of the ``producer`` property

Callers 2

mainFunction · 0.95
mainFunction · 0.95

Calls 2

InformationSourceClass · 0.90
IdentityClass · 0.90

Tested by

no test coverage detected