Changeset 10899:43a6df7713f1 in orange for Orange/data/io.py


Ignore:
Timestamp:
06/04/12 14:43:35 (23 months ago)
Author:
mitar
Branch:
default
Message:

Be more robust in handling search paths hook.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/data/io.py

    r10894 r10899  
    916916            call = entry_point.load() 
    917917            paths = call() 
     918            for path in paths: 
     919                if isinstance(path, tuple) and len(path) == 2 and \ 
     920                        all(isinstance(p, basestring) for p in path): 
     921                    search_paths.append(path) 
     922                elif isinstance(path, basestring): 
     923                    search_paths.append(("", path)) 
     924                else: 
     925                    warnings.warn("Invalid search path %r. Expected tuple or " 
     926                                  "string, got %r" % (entry_point, type(path))) 
    918927        except pkg_resources.DistributionNotFound, ex: 
    919928            warnings.warn("Missing dependency for %r: %r" % (entry_point, ex), 
    920929                         UserWarning) 
    921             paths = [] 
    922930        except Exception, ex: 
    923931            warnings.warn("Error calling %r: %r" % (entry_point, ex), 
    924932                         UserWarning) 
    925             paths = [] 
    926  
    927         for path in paths: 
    928             if isinstance(path, tuple) and len(path) == 2 and \ 
    929                     all(isinstance(p, basestring) for p in path): 
    930                 search_paths.append(path) 
    931             elif isinstance(path, basestring): 
    932                 search_paths.append(("", path)) 
    933             else: 
    934                 warnings.warn("Invalid search path %r. Expected tuple or " 
    935                               "string, got %r" % (entry_point, type(path))) 
    936933    return search_paths 
    937934 
Note: See TracChangeset for help on using the changeset viewer.