Changeset 9345:a63cf0303eba in orange


Ignore:
Timestamp:
12/13/11 13:05:24 (2 years ago)
Author:
mitar
Branch:
default
Convert:
0b4c39badd01ad14742ee5a000864ce20c693383
Message:

Fixed inspect.getmembers to work with Python 2.6.

Location:
orange/doc/Orange/rst
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/doc/Orange/rst/conf.py

    r9334 r9345  
    1818import myinspect 
    1919import sphinx.ext.autodoc 
     20import numpydoc 
    2021sphinx.ext.autodoc.inspect = myinspect 
     22numpydoc.docscrape.inspect = myinspect 
    2123 
    2224#disable deprecation decorators for the documentation 
     
    3739# Numpydoc generates autosummary directives for all undocumented members. Orange documentation only includes documented 
    3840# member, so _str_member_list is modified to return [] where a list of undocumented members is originally returned. 
    39 import numpydoc 
    4041numpydoc.docscrape_sphinx.SphinxDocString._str_member_list # if numpydoc changes, this line will cause an error 
    4142numpydoc.docscrape_sphinx.SphinxDocString._str_member_list = lambda x, y : [] 
  • orange/doc/Orange/rst/myinspect.py

    r8068 r9345  
    2929formatargspec = nfas 
    3030 
     31# inspect.getmembers from Python 2.7 
     32# In Python 2.6 there is try/except missing and function fails on C++-based classes if they define attributes 
     33# Example: AttributeError: 'Plot' object attribute 'animate_points' is an instance attribute 
     34def getmembers27(object, predicate=None): 
     35    """Return all members of an object as (name, value) pairs sorted by name. 
     36    Optionally, only return members that satisfy a given predicate.""" 
     37    results = [] 
     38    for key in dir(object): 
     39        try: 
     40            value = getattr(object, key) 
     41        except AttributeError: 
     42            continue 
     43        if not predicate or predicate(value): 
     44            results.append((key, value)) 
     45    results.sort() 
     46    return results 
     47 
     48getmembers = getmembers27 
     49 
    3150if __name__ == "__main__": 
    3251    for a in [ "0", "0.", "-1.3", "1.30000000001" ]: 
Note: See TracChangeset for help on using the changeset viewer.