<s> from mixbox . cache import Cached <EOL> import stix <EOL> from stix . common import InformationSource <EOL> import stix . bindings . data_marking as stix_data_marking_binding <EOL> class Marking ( stix . Entity ) : <EOL> _binding = stix_data_marking_binding <EOL> _binding_class = stix_data_marking_binding . MarkingType <EOL> _namespace = '<STR_LIT>' <EOL> def __init__ ( self , markings = None ) : <EOL> self . markings = _MarkingSpecifications ( markings ) <EOL> @ property <EOL> def markings ( self ) : <EOL> return self . _markings <EOL> @ markings . setter <EOL> def markings ( self , value ) : <EOL> self . _markings = _MarkingSpecifications ( value ) <EOL> def add_marking ( self , value ) : <EOL> self . _markings . append ( value ) <EOL> def to_obj ( self , return_obj = None , ns_info = None ) : <EOL> super ( Marking , self ) . to_obj ( <EOL> return_obj = return_obj , <EOL> ns_info = ns_info <EOL> ) <EOL> obj = self . _binding_class ( ) <EOL> if self . markings : <EOL> obj . Marking = self . markings . to_obj ( ns_info = ns_info ) <EOL> return obj <EOL> def to_list ( self ) : <EOL> return self . markings . to_list ( ) if self . markings else [ ] <EOL> @ classmethod <EOL> def from_obj ( cls , obj , return_obj = None ) : <EOL> if not obj : <EOL> return None <EOL> if not return_obj : <EOL> return_obj = cls ( ) <EOL> return_obj . markings = _MarkingSpecifications . from_obj ( obj . Marking ) <EOL> return return_obj <EOL> @ classmethod <EOL> def from_list ( cls , markings_list , return_obj = None ) : <EOL> if not markings_list : <EOL> return None <EOL> if not return_obj : <EOL> return_obj = cls ( ) <EOL> mlist = _MarkingSpecifications . from_list ( markings_list ) <EOL> return_obj . markings = mlist <EOL> return return_obj <EOL> to_dict = to_list <EOL> from_dict = from_list <EOL> class MarkingSpecification ( Cached , stix . Entity ) : <EOL> _binding = stix_data_marking_binding <EOL> _binding_class = stix_data_marking_binding . MarkingSpecificationType <EOL> _namespace = '<STR_LIT>' <EOL> def __init__ ( self , controlled_structure = None , marking_structures = None ) : <EOL> super ( MarkingSpecification , self ) . __init__ ( ) <EOL> self . id_ = None <EOL> self . idref = None <EOL> self . version = None <EOL> self . controlled_structure = controlled_structure <EOL> self . marking_structures = _MarkingStructures ( marking_structures ) <EOL> self . information_source = None <EOL> @ property <EOL> def information_source ( self ) : <EOL> return self . _information_source <EOL> @ information_source . setter <EOL> def information_source ( self , value ) : <EOL> self . _set_var ( InformationSource , try_cast = False , information_source = value ) <EOL> @ property <EOL> def marking_structures ( self ) : <EOL> return self . _marking_structures <EOL> @ marking_structures . setter <EOL> def marking_structures ( self , value ) : <EOL> self . _marking_structures = _MarkingStructures ( value ) <EOL> def to_obj ( self , return_obj = None , ns_info = None ) : <EOL> super ( MarkingSpecification , self ) . to_obj ( <EOL> return_obj = return_obj , <EOL> ns_info = ns_info <EOL> ) <EOL> obj = self . _binding_class ( ) <EOL> obj . id = self . id_ <EOL> obj . idref = self . idref <EOL> obj . version = self . version <EOL> obj . Controlled_Structure = self . controlled_structure <EOL> obj . Marking_Structure = self . marking_structures . to_obj ( ns_info = ns_info ) <EOL> if self . information_source : <EOL> obj . Information_Source = self . information_source . to_obj ( ns_info = ns_info ) <EOL> return obj <EOL> def to_dict ( self ) : <EOL> return super ( MarkingSpecification , self ) . to_dict ( ) <EOL> @ classmethod <EOL> def from_obj ( cls , obj , return_obj = None ) : <EOL> if not obj : <EOL> return None <EOL> if not return_obj : <EOL> return_obj = cls ( ) <EOL> return_obj . id_ = obj . id <EOL> return_obj . idref = obj . idref <EOL> return_obj . version = obj . version <EOL> return_obj . controlled_structure = obj . Controlled_Structure <EOL> return_obj . marking_structures = _MarkingStructures . from_obj ( obj . Marking_Structure ) <EOL> return_obj . information_source = InformationSource . from_obj ( obj . Information_Source ) <EOL> return return_obj <EOL> @ classmethod <EOL> def from_dict ( cls , d , return_obj = None ) : <EOL> if not d : <EOL> return None <EOL> if not return_obj : <EOL> return_obj = cls ( ) <EOL> get = d . get <EOL> return_obj . id_ = get ( '<STR_LIT:id>' ) <EOL> return_obj . idref = get ( '<STR_LIT>' ) <EOL> return_obj . version = get ( '<STR_LIT:version>' ) <EOL> return_obj . controlled_structure = get ( '<STR_LIT>' ) <EOL> return_obj . marking_structures = _MarkingStructures . from_dict ( <EOL> get ( '<STR_LIT>' ) <EOL> ) <EOL> return_obj . information_source = InformationSource . from_dict ( <EOL> get ( '<STR_LIT>' ) <EOL> ) <EOL> return return_obj <EOL> class MarkingStructure ( Cached , stix . Entity ) : <EOL> _binding = stix_data_marking_binding <EOL> _binding_class = stix_data_marking_binding . MarkingStructureType <EOL> _namespace = '<STR_LIT>' <EOL> _XSI_TYPE = None <EOL> def __init__ ( self ) : <EOL> self . id_ = None <EOL> self . idref = None <EOL> self . marking_model_name = None <EOL> self . marking_model_ref = None <EOL> def to_obj ( self , return_obj = None , ns_info = None ) : <EOL> super ( MarkingStructure , self ) . to_obj ( <EOL> return_obj = return_obj , <EOL> ns_info = ns_info <EOL> ) <EOL> if not return_obj : <EOL> return_obj = self . _binding_class ( ) <EOL> return_obj . id = self . id_ <EOL> return_obj . idref = self . idref <EOL> return_obj . marking_model_name = self . marking_model_name <EOL> return_obj . marking_model_ref = self . marking_model_ref <EOL> return return_obj <EOL> def to_dict ( self ) : <EOL> d = { } <EOL> if self . _XSI_TYPE : <EOL> d [ '<STR_LIT>' ] = self . _XSI_TYPE <EOL> if self . id_ : <EOL> d [ '<STR_LIT:id>' ] = self . id_ <EOL> if self . idref : <EOL> d [ '<STR_LIT>' ] = self . idref <EOL> if self . marking_model_name : <EOL> d [ '<STR_LIT>' ] = self . marking_model_name <EOL> if self . marking_model_ref : <EOL> d [ '<STR_LIT>' ] = self . marking_model_ref <EOL> return d <EOL> @ staticmethod <EOL> def lookup_class ( xsi_type ) : <EOL> if not xsi_type : <EOL> return MarkingStructure <EOL> return stix . lookup_extension ( xsi_type ) <EOL> @ classmethod <EOL> def from_obj ( cls , obj , return_obj = None ) : <EOL> import stix . extensions . marking . tlp <EOL> import stix . extensions . marking . simple_marking <EOL> import stix . extensions . marking . terms_of_use_marking <EOL> if not obj : <EOL> return None <EOL> if return_obj : <EOL> m = return_obj <EOL> m . id_ = obj . id <EOL> m . idref = obj . idref <EOL> m . marking_model_name = obj . marking_model_name <EOL> m . marking_model_ref = obj . marking_model_ref <EOL> else : <EOL> klass = stix . lookup_extension ( obj , default = cls ) <EOL> m = klass . from_obj ( obj , return_obj = klass ( ) ) <EOL> return m <EOL> @ classmethod <EOL> def from_dict ( cls , d , return_obj = None ) : <EOL> import stix . extensions . marking . tlp <EOL> import stix . extensions . marking . simple_marking <EOL> import stix . extensions . marking . terms_of_use_marking <EOL> if not d : <EOL> return None <EOL> get = d . get <EOL> if return_obj is not None : <EOL> m = return_obj <EOL> m . id_ = get ( '<STR_LIT:id>' ) <EOL> m . idref = get ( '<STR_LIT>' ) <EOL> m . marking_model_name = get ( '<STR_LIT>' ) <EOL> m . marking_model_ref = get ( '<STR_LIT>' ) <EOL> else : <EOL> klass = stix . lookup_extension ( get ( '<STR_LIT>' ) , default = cls ) <EOL> m = klass . from_dict ( d , return_obj = klass ( ) ) <EOL> return m <EOL> class _MarkingSpecifications ( stix . TypedList ) : <EOL> _contained_type = MarkingSpecification <EOL> class _MarkingStructures ( stix . TypedList ) : <EOL> _contained_type = MarkingStructure <EOL> add_extension = stix . add_extension </s>
