<s> from mixbox . cache import Cached <EOL> import stix <EOL> import stix . utils as utils <EOL> from stix . common import vocabs <EOL> from stix . common import StructuredTextList , VocabString <EOL> import stix . bindings . ttp as ttp_binding <EOL> class MalwareInstance ( Cached , stix . Entity ) : <EOL> _binding = ttp_binding <EOL> _binding_class = _binding . MalwareInstanceType <EOL> _namespace = "<STR_LIT>" <EOL> def __init__ ( self , id_ = None , idref = None , title = None , description = None , short_description = None ) : <EOL> self . id_ = id_ <EOL> self . idref = idref <EOL> self . title = title <EOL> self . description = description <EOL> self . short_description = short_description <EOL> self . names = None <EOL> self . types = None <EOL> @ property <EOL> def id_ ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _id <EOL> @ id_ . setter <EOL> def id_ ( self , value ) : <EOL> if not value : <EOL> self . _id = None <EOL> else : <EOL> self . _id = value <EOL> self . idref = None <EOL> @ property <EOL> def idref ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _idref <EOL> @ idref . setter <EOL> def idref ( self , value ) : <EOL> if not value : <EOL> self . _idref = None <EOL> else : <EOL> self . _idref = value <EOL> self . id_ = None <EOL> @ property <EOL> def title ( self ) : <EOL> return self . _title <EOL> @ title . setter <EOL> def title ( self , value ) : <EOL> self . _title = value <EOL> @ property <EOL> def description ( self ) : <EOL> """<STR_LIT>""" <EOL> return next ( iter ( self . descriptions ) , None ) <EOL> @ description . setter <EOL> def description ( self , value ) : <EOL> self . descriptions = value <EOL> @ property <EOL> def descriptions ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _description <EOL> @ descriptions . setter <EOL> def descriptions ( self , value ) : <EOL> self . _description = StructuredTextList ( value ) <EOL> def add_description ( self , description ) : <EOL> """<STR_LIT>""" <EOL> self . descriptions . add ( description ) <EOL> @ property <EOL> def short_description ( self ) : <EOL> """<STR_LIT>""" <EOL> return next ( iter ( self . short_descriptions ) , None ) <EOL> @ short_description . setter <EOL> def short_description ( self , value ) : <EOL> self . short_descriptions = value <EOL> @ property <EOL> def short_descriptions ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _short_description <EOL> @ short_descriptions . setter <EOL> def short_descriptions ( self , value ) : <EOL> self . _short_description = StructuredTextList ( value ) <EOL> def add_short_description ( self , description ) : <EOL> """<STR_LIT>""" <EOL> self . short_descriptions . add ( description ) <EOL> @ property <EOL> def names ( self ) : <EOL> return self . _names <EOL> @ names . setter <EOL> def names ( self , value ) : <EOL> self . _names = MalwareNames ( value ) <EOL> def add_name ( self , name ) : <EOL> self . _names . append ( name ) <EOL> @ property <EOL> def types ( self ) : <EOL> return self . _types <EOL> @ types . setter <EOL> def types ( self , value ) : <EOL> self . _types = MalwareTypes ( value ) <EOL> def add_type ( self , type_ ) : <EOL> self . _types . append ( type_ ) <EOL> @ staticmethod <EOL> def lookup_class ( xsi_type ) : <EOL> if not xsi_type : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> return stix . lookup_extension ( xsi_type ) <EOL> def to_obj ( self , return_obj = None , ns_info = None ) : <EOL> super ( MalwareInstance , self ) . to_obj ( return_obj = return_obj , ns_info = ns_info ) <EOL> if not return_obj : <EOL> return_obj = self . _binding_class ( ) <EOL> return_obj . id = self . id_ <EOL> return_obj . Title = self . title <EOL> if self . descriptions : <EOL> return_obj . Description = self . descriptions . to_obj ( ns_info = ns_info ) <EOL> if self . short_descriptions : <EOL> return_obj . Short_Description = self . short_descriptions . to_obj ( ns_info = ns_info ) <EOL> if self . names : <EOL> return_obj . Name = self . names . to_obj ( ns_info = ns_info ) <EOL> if self . types : <EOL> return_obj . Type = self . types . to_obj ( ns_info = ns_info ) <EOL> return return_obj <EOL> @ classmethod <EOL> def from_obj ( cls , obj , return_obj = None ) : <EOL> import stix . extensions . malware . maec_4_1_malware <EOL> if not obj : <EOL> return None <EOL> if not return_obj : <EOL> klass = stix . lookup_extension ( obj , default = cls ) <EOL> return_obj = klass . from_obj ( obj , klass ( ) ) <EOL> else : <EOL> return_obj . id_ = obj . id <EOL> return_obj . title = obj . Title <EOL> return_obj . descriptions = StructuredTextList . from_obj ( obj . Description ) <EOL> return_obj . short_descriptions = StructuredTextList . from_obj ( obj . Short_Description ) <EOL> return_obj . names = MalwareNames . from_obj ( obj . Name ) <EOL> return_obj . types = MalwareTypes . from_obj ( obj . Type ) <EOL> return return_obj <EOL> def to_dict ( self ) : <EOL> d = utils . to_dict ( self ) <EOL> if getattr ( self , '<STR_LIT>' , None ) : <EOL> d [ '<STR_LIT>' ] = self . _XSI_TYPE <EOL> return d <EOL> @ classmethod <EOL> def from_dict ( cls , dict_repr , return_obj = None ) : <EOL> from stix . extensions . malware import maec_4_1_malware <EOL> if not dict_repr : <EOL> return None <EOL> get = dict_repr . get <EOL> if not return_obj : <EOL> klass = stix . lookup_extension ( get ( '<STR_LIT>' ) , cls ) <EOL> return_obj = klass . from_dict ( dict_repr , klass ( ) ) <EOL> else : <EOL> return_obj . id_ = get ( '<STR_LIT:id>' ) <EOL> return_obj . title = get ( '<STR_LIT:title>' ) <EOL> return_obj . descriptions = StructuredTextList . from_dict ( get ( '<STR_LIT:description>' ) ) <EOL> return_obj . short_descriptions = StructuredTextList . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . names = MalwareNames . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . types = MalwareTypes . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return return_obj <EOL> class MalwareNames ( stix . TypedList ) : <EOL> _contained_type = VocabString <EOL> class MalwareTypes ( stix . TypedList ) : <EOL> _contained_type = VocabString <EOL> def _fix_value ( self , value ) : <EOL> return vocabs . MalwareType ( value ) <EOL> add_extension = stix . add_extension </s>
