Changeset 9492:edd4db64b7b6 in orange


Ignore:
Timestamp:
08/24/11 08:37:50 (3 years ago)
Author:
matija <matija.polajnar@…>
Branch:
default
Convert:
7530a8c2634daad351b58b2a9947c83c18040367
Message:

OWFile: Skip the whole warnings-generating loop if we don't have attribute load status.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Data/OWFile.py

    r9490 r9492  
    286286        warnings = "" 
    287287        metas = data.domain.getmetas() 
    288         for status, messageUsed, messageNotUsed in [ 
    289                                 (orange.Variable.MakeStatus.Incompatible, 
    290                                  "", 
    291                                  "The following attributes already existed but had a different order of values, so new attributes needed to be created"), 
    292                                 (orange.Variable.MakeStatus.NoRecognizedValues, 
    293                                  "The following attributes were reused although they share no common values with the existing attribute of the same names", 
    294                                  "The following attributes were not reused since they share no common values with the existing attribute of the same names"), 
    295                                 (orange.Variable.MakeStatus.MissingValues, 
    296                                  "The following attribute(s) were reused although some values needed to be added", 
    297                                  "The following attribute(s) were not reused since they miss some values") 
    298                                 ]: 
    299             if self.createNewOn > status: 
    300                 message = messageUsed 
    301             else: 
    302                 message = messageNotUsed 
    303             if not message: 
    304                 continue 
    305             attrs = [] 
    306             if hasattr(data, "attribute_load_status"): 
     288        if hasattr(data, "attribute_load_status"):  # For some file formats, this is not populated 
     289            for status, messageUsed, messageNotUsed in [ 
     290                                    (orange.Variable.MakeStatus.Incompatible, 
     291                                     "", 
     292                                     "The following attributes already existed but had a different order of values, so new attributes needed to be created"), 
     293                                    (orange.Variable.MakeStatus.NoRecognizedValues, 
     294                                     "The following attributes were reused although they share no common values with the existing attribute of the same names", 
     295                                     "The following attributes were not reused since they share no common values with the existing attribute of the same names"), 
     296                                    (orange.Variable.MakeStatus.MissingValues, 
     297                                     "The following attribute(s) were reused although some values needed to be added", 
     298                                     "The following attribute(s) were not reused since they miss some values") 
     299                                    ]: 
     300                if self.createNewOn > status: 
     301                    message = messageUsed 
     302                else: 
     303                    message = messageNotUsed 
     304                if not message: 
     305                    continue 
     306                attrs = [] 
    307307                attrs = [attr.name for attr, stat in zip(data.domain, data.attributeLoadStatus) if stat == status] \ 
    308308                      + [attr.name for id, attr in metas.items() if data.metaAttributeLoadStatus.get(id, -99) == status] 
    309             if attrs: 
    310                 jattrs = ", ".join(attrs) 
    311                 if len(jattrs) > 80: 
    312                     jattrs = jattrs[:80] + "..." 
    313                 if len(jattrs) > 30:  
    314                     warnings += "<li>%s:<br/> %s</li>" % (message, jattrs) 
    315                 else: 
    316                     warnings += "<li>%s: %s</li>" % (message, jattrs) 
     309                if attrs: 
     310                    jattrs = ", ".join(attrs) 
     311                    if len(jattrs) > 80: 
     312                        jattrs = jattrs[:80] + "..." 
     313                    if len(jattrs) > 30:  
     314                        warnings += "<li>%s:<br/> %s</li>" % (message, jattrs) 
     315                    else: 
     316                        warnings += "<li>%s: %s</li>" % (message, jattrs) 
    317317 
    318318        self.warnings.setText(warnings) 
Note: See TracChangeset for help on using the changeset viewer.