Changeset 7992:8b0865f47063 in orange


Ignore:
Timestamp:
06/09/11 12:39:23 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
11d4cf284ec4c468b6582fd913b8f572ab19906e
Message:

Added some documentation to Orange.misc.environ.
Disable deprecated member/keyword mapping if orange_no_deprecated_members is true.

Location:
orange/Orange/misc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/misc/__init__.py

    r7918 r7992  
    106106.. automodule:: Orange.misc.serverfiles 
    107107 
     108========= 
     109`environ` 
     110========= 
     111 
     112.. index:: environment 
     113 
     114.. automodule:: Orange.misc.environ 
     115 
    108116""" 
    109  
     117import environ 
    110118import counters 
    111119import selection 
    112120import render 
    113121import serverfiles 
     122 
    114123# addons is intentionally not imported; if it were, add-ons' directories would 
    115124# be added to the python path. If that sounds OK, this can be changed ... 
     
    231240        cache = {} 
    232241         
    233         functools.wraps(func) 
     242        @functools.wraps(func) 
    234243        def wrapped(*args, **kwargs): 
    235244            key = args + tuple(sorted(kwargs.items())) 
     
    250259         
    251260        wrapped.clear = clear 
     261        wrapped._cache = cache 
    252262         
    253263        return wrapped 
    254264    return decorating_function 
     265 
     266 
     267class recursion_limit(object): 
     268    """ A context manager that sets a new recursion limit.  
     269     
     270    """ 
     271    def __init__(self, limit=1000): 
     272        self.limit = limit 
     273         
     274    def __enter__(self): 
     275        self.old_limit = sys.getrecursionlimit() 
     276        sys.setrecursionlimit(self.limit) 
     277     
     278    def __exit__(self, exc_type, exc_val, exc_tb): 
     279        sys.setrecursionlimit(self.old_limit) 
    255280 
    256281 
     
    336361        __main__:1: DeprecationWarning: 'setFooBar' is deprecated. Use 'set_foo_bar' instead! 
    337362         
    338     """ 
     363    .. note:: This decorator does nothing if 
     364        :obj:`Orange.misc.environ.orange_no_deprecated_members` environment 
     365        variable is set to `True`. 
     366         
     367    """ 
     368    if environ.orange_no_deprecated_members: 
     369        return lambda cls: cls 
     370     
    339371    def is_wrapped(method): 
    340372        """ Is member method already wrapped. 
     
    390422        Arg 
    391423         
    392     """ 
     424    .. note:: This decorator does nothing if 
     425        :obj:`Orange.misc.environ.orange_no_deprecated_members` environment 
     426        variable is set to `True`. 
     427         
     428    """ 
     429    if environ.orange_no_deprecated_members: 
     430        return lambda func: func 
     431     
    393432    def decorator(func): 
    394433        @wraps(func) 
     
    421460        123 
    422461         
    423     """ 
     462    .. note:: This decorator does nothing and returns None if 
     463        :obj:`Orange.misc.environ.orange_no_deprecated_members` environment 
     464        variable is set to `True`. 
     465         
     466    """ 
     467    if environ.orange_no_deprecated_members: 
     468        return None 
     469     
    424470    def fget(self): 
    425471        deprecation_warning(old_name, new_name, stacklevel=3) 
     
    436482    prop = property(fget, fset, fdel, 
    437483                    doc="A deprecated member '%s'. Use '%s' instead." % (old_name, new_name)) 
    438     return prop 
    439  
     484    return prop  
    440485 
    441486""" 
     
    480525    """  
    481526    return type(self), (), dict(self.__dict__) 
    482      
     527 
     528 
     529     
  • orange/Orange/misc/environ.py

    r7989 r7992  
    1 """ 
     1"""\ 
     2================================ 
    23Orange environment configuration 
    34================================ 
    45 
     6This module contains some basic customization options for Orange 
     7(for now mostly changing directories where orange settings are saved). 
     8 
     9How it works 
     10------------ 
     11 
     12When this module is imported it will first load and parse a global  
     13configuration `orangerc.cfg` (located in the root directory off the orange 
     14installation). Further, it will look for and try to load a user specific 
     15configuration file located in $(HOME)/.orangerc.cfg or  
     16`application_dir`/.orangerc.cfg where `application_dir` is a variable defined 
     17in the global configuration file. 
     18 
     19.. note:: in the configuration files all OS defined environment variables 
     20    (e.g $HOME, $USER, ...) are available. 
     21 
     22After all the parsing has taken place the select variables defined in the 
     23configuration will be made available as top level module variables. 
     24 
     25Example  
     26------- 
     27 
     28To change the location where settings are saved for Orange Canvas 
     29on Windows edit the global `orangerc.cfg` file and in the 
     30`[directories win32]` section change the `application_dir` variable: 
     31     
     32    [directories win32] 
     33     
     34    application_dir = D:/SharedAppData/orange/ 
     35     
     36In this way we can hard code the path instead of using the system default 
     37(defined in the the %APPDATA variable) 
     38 
     39Variables 
     40--------- 
     41 
     42The following variables are exposed as top level module members  
     43 
     44`install_dir`:  
     45    Directory where Orange is installed. 
     46     
     47`canvas_install_dir`: 
     48    Directory where Orange Canvas is installed. 
     49 
     50`widget_install_dir`: 
     51    Directory where Orange Widgets are installed. 
     52 
     53`icons_install_dir`: 
     54    Directory where icons for widgets are installed. 
     55 
     56`doc_install_dir`: 
     57    Directory where Orange documentation 
     58     
     59`add_ons_dir`: 
     60    Directory where system-wide add-ons are installed  
     61     
     62`add_ons_dir_user`: 
     63    Directory where user add-ons are installed 
     64     
     65`application_dir`: 
     66    Directory where applications can save their data. 
     67      
     68`output_dir`: 
     69    Directory where Orange saves settings/data. 
     70     
     71`default_reports_dir`: 
     72    Directory where Orange Canvas saves the reports. 
     73     
     74`orange_settings_dir`: 
     75    Directory where Orange settings are saved. 
     76     
     77`canvas_settings_dir`: 
     78    Directory where Orange Canvas settings are saved. 
     79     
     80`widget_settings_dir`: 
     81    Directory where Orange Widgets settings are saved. 
     82     
     83`buffer_dir`: 
     84    Directory where :obj:`Orange.misc.serverfiles` downloads are stored.   
     85 
     86`orange_no_deprecated_members`: 
     87    If True all deprecated members in Orange 2.5 will not be available. 
     88       
    589""" 
    690 
Note: See TracChangeset for help on using the changeset viewer.