Changeset 5061:e6cbb15915d9 in orange


Ignore:
Timestamp:
08/04/08 12:21:54 (6 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
0fdf108b0cf435ed029a8061c29397243eadd924
Message:
  • ExampleTable_new(filename) now also looks for files specified in the environment variable ORANGE_DATA_PATH
File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/lib_kernel.cpp

    r4985 r5061  
    18821882char *obsoleteFlags[] = {"dontCheckStored", "dontStore", "use", "useMetas", "domain", 0 }; 
    18831883 
    1884 PyObject *loadDataFromFile(PyTypeObject *type, char *filename, PyObject *argstuple, PyObject *keywords, bool generatorOnly = false) 
     1884 
     1885PyObject *loadDataFromFileNoSearch(PyTypeObject *type, char *filename, PyObject *argstuple, PyObject *keywords, bool generatorOnly = false) 
    18851886{ 
    18861887  PyObject *res; 
     
    19571958} 
    19581959 
     1960PyObject *loadDataFromFile(PyTypeObject *type, char *filename, PyObject *argstuple, PyObject *keywords, bool generatorOnly = false) 
     1961{ 
     1962  PyObject *ptype, *pvalue, *ptraceback; 
     1963 
     1964  PyObject *res = loadDataFromFileNoSearch(type, filename, argstuple, keywords, generatorOnly); 
     1965  PyErr_Fetch(&ptype, &pvalue, &ptraceback); 
     1966  if (!ptype) { 
     1967    return res; 
     1968  } 
     1969   
     1970  #if defined _WIN32 
     1971  const char sep = ';'; 
     1972  const char pathsep = '\\'; 
     1973  #else 
     1974  const char sep = ':'; 
     1975  const char pathsep = '/'; 
     1976  #endif 
     1977  const int flen = strlen(filename); 
     1978 
     1979  char *path = getenv("ORANGE_DATA_PATH"); 
     1980  if (path) { 
     1981    for(char *pi = path, *pe=pi; *pi; pi = pe+1) { 
     1982      for(pe = pi; *pe && *pe != sep; pe++); 
     1983      const int plen = pe-pi; 
     1984      char *npath = strncpy(new char[plen+flen+2], pi, pe-pi); 
     1985      if (!plen || (pe[plen] != pathsep)) { 
     1986        npath[plen] = pathsep; 
     1987        strcpy(npath+plen+1, filename); 
     1988      } 
     1989      else { 
     1990        strcpy(npath+plen, filename); 
     1991      } 
     1992      PyErr_Clear(); 
     1993      res = loadDataFromFileNoSearch(type, npath, argstuple, keywords, generatorOnly); 
     1994      if (res) { 
     1995        Py_XDECREF(ptype); 
     1996        Py_XDECREF(pvalue); 
     1997        Py_XDECREF(ptraceback); 
     1998        return res; 
     1999      } 
     2000      if (!*pe) 
     2001        break; 
     2002    } 
     2003  } 
     2004   
     2005  PyErr_Restore(ptype, pvalue, ptraceback); 
     2006  return PYNULL;  
     2007} 
     2008   
    19592009 
    19602010int pt_ExampleGenerator(PyObject *args, void *egen) 
Note: See TracChangeset for help on using the changeset viewer.